Hi Gideros maintainers,
This is something that may have been discussed before, and yes I know that Gideros in mainly a 2D engine, but there are a few situations where minimalistic 3D support would have been handy (Star wars like effect for which a posted a solution was one of them).
I may not be very well documented on OpenGL (I coded a 3D engine with OpenGL ten years ago, but didn't touched OpenGL beside that), but it seems to me that implementing 3D would just be a matter of using:
glVertexPointer(<strong>3</strong>, GL_FLOAT, 0, &vertices_[0]); |
instead of:
glVertexPointer(2, GL_FLOAT, 0, &vertices_[0]); |
in gideros/gmesh.cpp, thus allowing a Z coordinate in Mesh object, and of course configuring a perspective transform matrix during init and clearing the depth buffer on every frame rendering...
It doesn't look like a huge modification at first, and while I am figuring out how to compile gideros from sources myself to try this, I would like to know your opinions about this.
What do you think ?
Comments
Therefore I guess it is more complicated than change a simple C++ class to support 3D in Gideros.
http://giderosmobile.com/forum/discussion/2100/raycasting-engine-3d-object-engine-release-by-biorhythmgames/p1
Whatever, I will try myself and see wether it is actually complicated or not
https://deluxepixel.com
I'd say to wait for @john26 and @marcelojunior to achieve their (our) big goal first and then add more cross-platform native features
Maybe could be worth to have a community "suggested features" system, where we all could post and vote for future developments - and willing people could pick them up to start other kickstarter projects..
With my modification, Mesh now accept a boolean in the constructor to specify wether coordinates are to be handled as 3D or 2D, and the Z coordinate can be passed in vertices manipulation functions from lua.
This is not full blown 3D support: no shadows, no lighting, no depth test (yet...), no 3D transforms (yet!), but I already can think of a few effects that become possible thanks to this even in 2D games:
- flipping a card with real perpsective effect
- spinning dice
- the start wars effect becomes straight forward
While I am at it, it will still go on working on this to add at least depth buffer checking and if possible 3d transforms.
BTW, I came accross an way to implement clipping/masking using stencil buffers quite easily. I will have a try at this also..
Likes: john26
Are you going to somehow push your changes to the liberton version of gideros that is being worked on?
Is there any speed change with normal 2D - does it go slower or is there no difference?
https://deluxepixel.com
I did not see any performance degradation, and currently it has only been tested with gideros player.
I am currently setting up my own gideros repository, a fork of the main (not Liberton) gideros repo. I don't want to interfere with @john26 and @marcelojunior work for now.
Of course at some point in the future my changes could be merged in the main repository if appropriate.
Likes: SinisterSoft, techdojo
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: SinisterSoft
https://github.com/gideros/gideros
https://www.youtube.com/c/JohnBlackburn1975
Likes: SinisterSoft, john26, pie, talis
So I decided to switch OpenGL 1 support for OpenGL ES 2. It is been a complex work but I believe all is working again like it should. I've tested my changes on a few games of mine using GiderodPlayer for Windows and all seems ok. I've not yet tested with android, but at least now the code compiles without complaining for OpenGL missing functions.
For those who can compile gideros and are interested in testing, my repo is https://github.com/hgy29/gideros/tree/hgy29 (branch hgy29).
Current features are:
- Support 3D meshes (boolean value added to Mesh constructor specifying wether its 3D or not)
- Support for 3D transforms (setZ, scaleZ, rotationX,rotationY and so on added to Sprite API), works on all sprites not only meshes
- Support for enabling perspective projection in the scene by application:setFieldOfView(angle), angle=0 to keep ortho projection.
- Default vertex shader and fragment shader to mimic previous implementation
- Depth buffer enabled on 3D meshes only
To come:
- Clipping/Masking thanks to stencil buffer ops
Likes: SinisterSoft, pie, talis
https://deluxepixel.com
Likes: SinisterSoft, talis
These changes introduce basic 3D support in meshes and frustum setting.
This worked imposed some heavy changes in core Gideros graphics:
Switch to OpenGL ES 2.0 programmable pipeline instead of OpenGL 1.1 fixed pipeline. Right now shaders are set up to mimic fixed pipeline behavior as used by gideros
Implements 3D matrix transforms (i.e. 4x4 matrices), and add related API calls in Sprite class
Add frustum setting API in Application class to enable perspective projection
Add depth buffer setting and checking, and setup stencil buffers for future masking (or shading) option.
Add a 3D parameter on mesh objetcs, merely specifying if vertex take two or three coordinates
Note: I've currently tested the changes againts Windows gideros player, two different android devices, an iPhone 6. I am fairly confident that everything should work smoothly on all iOS devices starting from iPhone 3GS (won't work for earlier phones), and they should work on most recent android devices (theoretically starting from Froyo). I couldn't compile gideros player for macos yet, but since it is based on Qt things should be ok, however testing is really needed.
Likes: pie, SinisterSoft
Model grabbed here: http://tf3dm.com/3d-model/horse-39028.html, file is .obj and is parsed completely in lua. Loading takes a fraction of second and animation is smooth.
Likes: SinisterSoft, jdbc, pie
https://deluxepixel.com
indeed just placing 2d objects into 3d space and moving the camera on them gives a lot of new opportunities already.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
I don't think that camera will be positionnable, because it will break pure 2D stuff, but the 3D scene could be moved around to achieve the same result.
Also, in order to avoid breaking 2D, depth testing (i.e., not rendering shapes behind already drawn ones), is only activated for 3D meshes.
Another point to be aware of is that Sprite:hitTest and alike functions won't work if Sprite Z coordinate is not 0 (because of perspective frustum, X & Y coordinates on screen depends on the Z coordinate also). This could be sorted out, but I'd rather wait that community validate current changes before going on.
Also, I found that now the GLES 2.0 stuff is done, advanced 3D rendering becomes possible: adding normal array, bump map, and lighting is quite an easy task.
Likes: talis, SinisterSoft, pie
This new functionality will surely bring a whole new dimension to Gideros . Literally and practically
Really great job =D>
Likes: MoKaLux
https://deluxepixel.com