Marching Cube Voxel Terrain
Hi Everybody,
This week end, i'll try to make a terrain generator based on voxel (looking minecraft) with perlin noise,
and change the cube into slop by a little marching cube algorithm.
And After drive like crazy on this terrain with the buggy.
Perlin noise snippet there:
http://www.gamestart3d.com/content/code-snippet-perlin-noise
A preview of what I've done this evening:

* Next Step:
- Optimize the check for the neighbors (will be fun).
- Instead of duplicate a cube, i'll make a little marching cube using the nGeometryTemplate to have lot less memory use. And to have slopes everywhere !!!
;) good night
Scorpheus
P.S.: The function SceneDeleteItem doesn't seems to work, the item is still there.
Do I need to delete the geometry too ? I tested only on a duplicate item from SceneDuplicateItem.
Mr.Admin
Sat, 09/17/2011 - 00:50
Permalink
Interesting :)
SceneDeleteItem seems to be working here on every project in the test suite.
Can you check that the item count indeed stays the same after a call to SceneDeleteItem using the profiler (alt+f5).
I am afraid to ask but, how many cubes in this screenshot and what frame rate do you get?
Thomas Simonnet
Sat, 09/17/2011 - 20:00
Permalink
Project Update:
- The geometry is optimized, it's generated quite fast.
- Begining the simple marching cube.
But 2 problems:
- The pushUV crash the application.
- And I can generate and show the geometry, but can't assign this mesh as staticmesh for the physics.
If you can help me for the physics MrAdmin, it will be nice to drive on it ;)
See you all
Mr.Admin
Sat, 09/17/2011 - 20:19
Permalink
Sure can do, any chance you can share the project? I'd also like to take a look at why pushing the UV on the template is crashing the engine.
Thanks!
Thomas Simonnet
Sat, 09/17/2011 - 20:45
Permalink
The project is here:
http://dl.free.fr/l6mh2CjGw
The pushUV crash and I don't find a way to turn this mesh into static physic mesh.
:) this way the voxelterrain has a lot more fps than duplicate cube like the first screenshot
For the moment I try to make slopes, I didn't finish yet, so there is hole.
Mr.Admin
Sat, 09/17/2011 - 21:04
Permalink
Haha :D Crazy stuff!
That makes me think that you may have some use for a way to access a terrain heightmap from script?
I don't think we'd have enough processing power to update a whole terrain at runtime from script (even more so since updating the terrain height map will force all cached terrain pages to be flushed).
But still for this kind of setup or for localized runtime updates this is definitively a very interesting option.
Back on topic, thanks for the project. I am going to investigate these issues asap.
Thomas Simonnet
Sat, 09/17/2011 - 21:13
Permalink
It was to try voxel tree in squirrel, and marching cube :p
And after it will be possible "maybe" to create convex terrain, and add detail localy by increase the resolution of the grid.
it's for the fun of research for optimization and to have a fast scripted terrain :p
I have some impossible idea for after (animation of the cubes "a la" Portal2)(absolutely no idea how to do that fast)
Mr.Admin
Sat, 09/17/2011 - 21:38
Permalink
Whatever it is you do, if it sounds impossible GO FOR IT! ;)
Thomas Simonnet
Mon, 09/19/2011 - 23:33
Permalink
Update:
the terrain generate when you progress on it, faster but not enough.
Not cube anymore, but nGeometryTemplate. so It's lighter in poly and I can make any polygon I want.
Now, I need to find a way to make a physic mesh from the nGeometryTemplate :) (Yes I am talking to you Mr Admin MOUAHAHAHA !!)
.... and optimize more and more !!
and make a nice shader and a skybox !!!
I will try to save and load the already generated meshes
Have a good night !!
Scorpheus
Mr.Admin
Mon, 09/19/2011 - 23:54
Permalink
Looking good! A few holes to go :D!
I fixed the UV issue and investigated the physic problem and... it turns out it is going to be a little more involved than we may think. Basically the physic system uses a separate cache for geometries than the renderer one. So it will load geometries from disk when it needs to. And there lies the problem, your geometry isn't on the disk but generated from script.
I'm investigating possible solutions for this, and I'll find one.
PS: I wonder what kind of car can drive on this landscape!
Thomas Simonnet
Tue, 09/20/2011 - 00:07
Permalink
In fact I probably didn't add a good lighting, because it's not holes but black shadow !!
With uv it's nicer ;)
Maybe for the physic, I can save the geometry on the disk and reload to make the physic, like if I was loading them in streaming and using them.
And for the car, a big buggy with big wheel :p, but I will make the terrain more flat or/and canyon. Just need to play with the perlin noise :p
Pages