Hello! I’m trying to create my procedural planet based on splitting an icosahedron a few times and applying the improvedPerlinNoise to each vertex to obtain some cool hills and valleys,I already got something working.
Screenshots here http://i61.tinypic.com/30lpj85.jpg and http://i61.tinypic.com/2h67syg.jpg (the sea is just a blue sphere)
Now I want to implement some sort of LOD (level of detail) so that the 5/6 faces nearest to camera position tesselates a few more times, in order to obtain a more fine detail only where it’s needed (e.g. landing on the planet).
I need to iterate myPlanet.getVertexes() to get the closest one, and then iterate myPlanet.getFaces() to see what faces contain this very closest vertex. These are the faces that should be tessellated as soon as I manage how to dinamically add or remove these verts on my planet.
My problem is that this iteration function is very slow. Every time I try to implement something new that needs to put in comparison every vertex of the planet (90% of the things, sadly) I need to cycle trough the full vertex list and performance drops miserably.
I feel that this is not the way it’s meant to be done. Are there any GL methods to traverse a mesh geometry more fluently than a cpu-based for-each cycle? Or, even better, is there some jme3 built in method to accomplish this kind of iteration?
OpenGL data structures are not designed for fast spatial lookup of vertexes. They don’t really need to be as the GPU just wants to chomp them sequentially as fast as possible.
If you need to look things up like this then you will have to build your own data structure to support it. Maybe figure out how you want to split the planet up into some kind of grid and put things into bins or something.
you mean I’ve got to work out that BSP tree thingy or sort of? My J2EE brain is bleeding
What’s the more suitable design pattern in mycase on your opinion? I won’t need huge googleEarth-like planets, My goal is to obtain simple toony planets similar to this http://img2.wikia.nocookie.net/__cb20100326140022/dragonball/images/6/6e/KingKaisPlanetFS.png
with a few hills and some sea. No complex canyons or pixel-sharp cliffs. But nevetheless I want to be able to land on the surface, enable the gravity and do stuff around.
Given that I’m persuaded that the classic tutorials (cubes, triangles, basic texturing…) work mostly in CPU. Is there any documentation about what instructions/functions/things that can be passed (and how) to the GPU with jme3? I don’t want to do the mistake to use openGL as if I’m using Papervision3D, you know.
I wouldn’t even use anything tree based as it’s not necessary. Find some function that takes planet x,y and turns it into grid x, y… then just put things in grid ‘bins’. For what you want to do it will be the fastest way. Constant time lookups versus log time lookups.