simple3D - 3D Engine for Monkey

Monkey Archive Forums/Monkey Projects/simple3D - 3D Engine for Monkey

bruZard(Posted 2012) [#1]
The "Game" is over, now it is a project and i call it "S3D".

Today it is just a really small update:
added	: ScaleEntity:Void(entity:Entity, x:Float = 1.0, y:Float = 1.0, z:Float = 1.0)
changed	: Entities do not more ignore his scale factor
changed	: cleanup source
changed : source splitted


http://www.sedm.de/monkey/s3d/s3d.zip

the next big thing are real cameras. the whole scene must be transformed if you move or rotate the camera. Then the "ObjLoader" Class has to be extended for more flexibility, more then one texture layer und for so many things that i think this thing will never be ready :)
Animations are a big theme, i've atm no idea about animations with vertex buffer objects ... but i think thats just a hole to jump over that.
once again: excuse me for my bad english ;)


Qcat(Posted 2012) [#2]
Nice!

will give this one a go when i have time.


bruZard(Posted 2012) [#3]
v0.12 is online ... here's the changelog:
added	: Vector.setW:Void(w:Float = 1.0)
added	: Light.setLightType:Void(lightType:Int = 1.0)
added	: Entity.addChild:Void(child:Entity)
added	: Mesh.setCulling:Void(culling:Int = 0)
added	: MeshCulling:Void(mesh:Entity, culling:Int = GL_BACK)
changed	: S3D.createCamera() now has the optional parameter "parent:Entity"
changed : S3D.createLight() now has the optional parameter "lightType:Int = LIGHT_POINT" and "parent:Entity"
changed : S3D.loadMesh() now has the optional parameter "parent:Entity"
changed : S3D.refMesh() now has the optional parameter "parent:Entity"
changed	: CreateCamera() now has the optional parameter "parent:Entity"
changed : CreateLight() now has the optional parameter "lightType:Int = LIGHT_POINT" and "parent:Entity"
changed : LoadMesh() now has the optional parameter "parent:Entity"
changed : CloseMesh() now has the optional parameter "parent:Entity"
changed : you can now use transparent texures
changed : backface culling is now active per default but set to "no culling"
surprise: the Example works on Android, GLFW and iOS




Now the archive contains a folder "modules" and a folder "bananas" so you can extract the full S3D update over your monkey installation.

The example in bananas/s3dExample shows a small island in the sky with a tree and a rock. If you want to compile this you have to build the example (not run), go to the build folder and open the CONFIG.TXT. Add "|*.obj|*.mtl" to the list of textfiles and rebuild the example. I've test it with all available opengl.gles11 targets and it will work.

Important: Ever use "SetUpdateRate" in OnCreate() ;)

http://www.sedm.de/monkey/s3d/s3d.zip

have fun!


DruggedBunny(Posted 2012) [#4]
Nice, and it runs very smoothly on my Android phone. The B3D-style command set is also very welcome!


Hima(Posted 2012) [#5]
Can't wait to try this! Though when you said ever use "SetUpdateRate" in OnCreate(), did you mean "never"? And if so, could you please explain why? :O


slenkar(Posted 2012) [#6]
i get this error with glfw
(ClCompile target) ->
c:\dropbox\monkey\bananas\s3dexample\example.build\glfw\main.cpp(4975): error C2661: '_glNormalPointer' : no overloaded function takes 3 arguments


Jesse(Posted 2012) [#7]
I guess it doesn't work with a macbook pro 5,5 with nvidia graphics.

TRANS FAILED: TRANS Failed to execute 'xcodebuild -configuration Debug', return code=16640


bruZard(Posted 2012) [#8]
@Hima: with "ever" i mean "ever". I've forgot it sometimes and spend hours in debugging ;)

@slenkar: this is a bug in the gles11 module. You must override the normalpointer function with a version with 3 parameters:

open /modules/opengl/native/gles11.glfw.cpp and search for this function:
void _glNormalPointer( int size,int type,int stride,int offset ){
	glNormalPointer( type,stride,(const void*)offset );
}

create a copy of this function and remove the parameter "size":
void _glNormalPointer(int type,int stride,int offset ){
	glNormalPointer( type,stride,(const void*)offset );
}



slenkar(Posted 2012) [#9]
ok it builds now thanks,

this is how my config.txt file looks like

TEXT_FILES=*.txt|*.xml|*.json|*.obj|*.mtl

but the game still cant load the isle.obj file


bruZard(Posted 2012) [#10]
please check the IMAGE_FILE config, should look like this: IMAGE_FILES=*.png|*.jpg

I've uploaded a GLFW binary, can you check whether it will run?

http://www.sedm.de/monkey/s3d/s3dglfw.zip


slenkar(Posted 2012) [#11]
the binary doesnt run
dont know why


bruZard(Posted 2012) [#12]
please tell me your system specs


Volker(Posted 2012) [#13]
I receive an error about system32/ct_oal.dll
Then the binary works and I see the island.


bruZard(Posted 2012) [#14]
@Volker: have you Monkey 052b installed?

[EDIT]
wait, you have to install OpenAL > http://connect.creativelabs.com/openal/Downloads/oalinst.zip
[/EDIT]


slenkar(Posted 2012) [#15]
sys specs
Celeron 2.5ghz processor
OpenGL 1.3
GL_ARB_multitexture GL_ARB_point_parameters GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_dot3 GL_ARB_texture_env_crossbar GL_ARB_transpose_matrix GL_ARB_vertex_buffer_object GL_ARB_vertex_program GL_ARB_window_pos GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_clip_volume_hint GL_EXT_compiled_vertex_array GL_EXT_cull_vertex GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_multi_draw_arrays GL_EXT_packed_pixels GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_specular_color GL_EXT_stencil_wrap GL_EXT_texture_compression_s3tc GL_EXT_texture_env_add GL_EXT_texture_env_combine GL_EXT_texture_filter_anisotropic GL_3DFX_texture_compression_FXT1 GL_IBM_texture_mirrored_repeat GL_NV_blend_square GL_NV_texgen_reflection GL_SGIS_generate_mipmap GL_WIN_swap_hint

Intel Gfx 64MB Gfx RAM
768MB of RAM

When I compiled, the error was:
on line 60 of Mesh.monkey
which reads:glGenBuffers 2,bufs

On the OpenGL website it says:
http://www.opengl.org/sdk/docs/man/xhtml/glGenBuffers.xml
glGenBuffers is available only if the GL version is 1.5 or greater.


bruZard(Posted 2012) [#16]
GLES1.1 based on OpenGL1.5 ... that means: you can not run Monkey GL code on your machine.


benmc(Posted 2012) [#17]
This would, of course, belong in another thread in another forum, but would it be possible to get a walk through of how the models were created/textured/exported for use in Monkey? I'm not a 3D guy, but would like to learn more, and some kind of starter tutorial somewhere would be awesome.


Shinkiro1(Posted 2012) [#18]
I thought you can use a new logo after renaming your project so I through something together:




slenkar(Posted 2012) [#19]
GLES1.1 based on OpenGL1.5 ... that means: you can not run Monkey GL code on your machine.


Me and old betsy are gonna have to go for a walk with a shotgun
BOOM!

(in other words I will purchase a new PC)


bruZard(Posted 2012) [#20]
@Shinkiro1 : thanks for your participation, but as you see ... i've already create a new logo ;)

@slenkar: maybe a driver update will help or just a new graphics card? But you should keep in mind: Your computer is a dinosaur!

@project
v013 takes a while, the camera control is very difficult because i must transform the whole scene. Stay tuned.


bruZard(Posted 2012) [#21]
if anybody want ask for ES2.0 ... still wait for S3DX, it is'nt possible to create a 2.0 module with a fallback to 1.1 .. so i must create two modules.


bruZard(Posted 2012) [#22]
i've splitted the project in three branches:

s3d.S3D11 for OpenGL ES1.1
s3d.S3D20 for OpenGL ES2.0
s3d.S3DDX for a DirectX based version for XNA (very experimental)

a new version will come in the next few days.


Difference(Posted 2012) [#23]
Very interesting, Android + iOS + XNA support sounds great!


MikeHart(Posted 2012) [#24]
On both, GLFW and IOS I get depth buffer sorting problems. What could be the reason?


bruZard(Posted 2012) [#25]
you have to set DEPTH_BUFFER_ENABLED in the CONFIG.TXT. Look at your build folder.


MikeHart(Posted 2012) [#26]
Thanks that did the trick. Still some alpha errors are visible but it is promising. Thanks for the effort you put into this.


Cheese(Posted 2012) [#27]
Hmmmm, I tried running the example with an OBJ exported by Google SketchUp Pro and it dies because the object fails to load.

OBJ file:
http://cheesekeg.com/archlinux.zip

example.monkey:
Import mojo
Import s3d.s3d

Class App3D Extends App
	Field isle:Mesh', cam:Camera, l:Light
	
	Method OnCreate()
		Local cam:= CreateCamera
		Local l:= CreateLight
		isle = LoadMesh("archlinux.obj")
		
		MeshCulling(isle, GL_BACK)
		
		PositionEntity isle, .0, -.7, -2.0
		CameraClsColor cam, 0, 128, 255
		
		SetUpdateRate 60
	End
	
	Method OnUpdate()
		TurnEntity isle, 0.0, 1.0, 0.0
	End
	
	Method OnRender()
		RenderWorld
	End
End

Function Main()
	New App3D
End


Output:
Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:03.04
Load obj file:archlinux.obj
Monkey runtime error: obj error
C:/Dropbox/CheesyStuff/MonkeyPro54/modules/s3d/objLoader.monkey<65>
C:/Dropbox/CheesyStuff/MonkeyPro54/modules/s3d/s3d.monkey<106>
C:/Dropbox/CheesyStuff/MonkeyPro54/modules/s3d/s3d.monkey<153>
C:/Dropbox/CheesyStuff/MonkeyPro54/bananas/s3dExample/example.monkey<10>
C:/Dropbox/CheesyStuff/MonkeyPro54/modules/mojo/app.monkey<53>


Process ended with return code 0 at 2/28/2012 12:01:24 PM


I like where this is going; rapid prototyping FTW!
Do you plan on continuing this project/hosting a repository for it? I'd love to play with it!


JIM(Posted 2012) [#28]
Had no time to check this out in detail, but are you sure you have "*.obj" in CONFIG.TXT file in the build folder?

Make sure the .obj file actually is in the .build/[target name]/data folder.


bruZard(Posted 2012) [#29]
you can also rename your *.obj to *.txt

and yes ... this project will be continued, but at this time i've not enough time. to many projects ;-)


Cheese(Posted 2012) [#30]
Thanks for the responses.

Running the example with the provided "isle.obj" works fine for me, but running it with my "archlinux.obj" results in the failure stated above. My apologies for not clarifying this in my previous message!

Here are the GLWF/Android configurations respectively:
GLFW - CONFIG.TXT
GLFW_WINDOW_TITLE="Monkey Game"
GLFW_WINDOW_WIDTH=640
GLFW_WINDOW_HEIGHT=480
GLFW_WINDOW_RESIZABLE=false
GLFW_WINDOW_FULLSCREEN=false

CPP_INCREMENTAL_GC=1

OPENGL_GLES20_ENABLED=false
OPENGL_DEPTH_BUFFER_ENABLED=false

MOJO_IMAGE_FILTERING_ENABLED=true

TEXT_FILES=*.txt|*.xml|*.json|*.obj|*.mtl
IMAGE_FILES=*.png|*.jpg
SOUND_FILES=*.wav
MUSIC_FILES=*.wav


Android - CONFIG.TXT
MOJO_HICOLOR_TEXTURES=true
MOJO_IMAGE_FILTERING_ENABLED=true

ANDROID_APP_LABEL="Monkey Game"
ANDROID_APP_PACKAGE=com.monkey
ANDROID_SCREEN_ORIENTATION=portrait
OPENGL_GLES20_ENABLED=false
ANDROID_NATIVE_GL_ENABLED=false

TEXT_FILES=*.txt|*.xml|*.json|*.obj|*.mtl
IMAGE_FILES=*.png|*.jpg|*.gif|*.bmp
SOUND_FILES=*.wav|*.ogg|*.mp3|*.m4a
MUSIC_FILES=*.wav|*.ogg|*.mp3|*.m4a


Here's what archlinux.obj + .mtl is supposed to look like:


Does anyone else have a problem running the example using the OBJ I supplied?

I also tried the lovely teapot just now and it failed with the same error and stack trace:
http://groups.csail.mit.edu/graphics/classes/6.837/F03/models/


Thanks in advance!

- Brandon


bruZard(Posted 2012) [#31]
I've no idea what's going wrong in SketchUp, but in Blender i've to check the Exportoptions "Export Normals" and "Triangulate Faces" to create a compatible object file. The S3D Wavefront Importer is very raw and far away from a stable release.


Beaker(Posted 2012) [#32]
Took a quick look. The problem appears to be that the obj loader doesn't know how to handle quad faces, only triangle ones. Shouldn't be that difficult to add.


bruZard(Posted 2012) [#33]
all Quads must be converted to Triangles ... if the Exporter doesnt support that, you have to change the Software ... use Blender instead ;)