I'd like to deform terrain in real-time(e.g. by impact of rockets or sth. like that).
Are there any existing solutions for this problem ?
I know that there's a lib (libMini for irrlicht) for terrain generating, but i could'nt find out if it has the ability to do changes to the terrain in real-time?
Another question: Is it possible to generate terrains randomly?. (Create a random heightmap during runtime and then build/generate a terrain out of the heightmap)
hello,
yes it's possible. If you rely on Irrlicht's CTerrainSceneNode, it won't be that easy because it doesn't expose the vertice array (it's a MeshBuffer, a SMeshBufferLightMap to be more precise) that contains the vertice position. But this require to change it in every patch (sub-resolution precalculated meshes), so it won't be that easy if you're not familiar with the LOD terrain generation.
So i advise either three things, you choose depending on your skills and features you need :
- either you make you own terrain, without paches and LOD : you just make a addHillPlaneMesh and change the vertice position in Y
- either you use Irrlicht's terrain engine : you simply change the vertice position in every patch. You'll need to change the CTerrainSceneNode source code to make the meshBuffer public or add a fonction to manipulate the vertices
- either you make your own terrain class
to make random relief, i advise either
- fractal cloud
- perlin noise
i've done some source code for that, it's big, maybe i can release it if can help...
"Depending on my skills" i would prefer the first option
At the moment i'm not able to test it, but if the results of addHillPlaneMesh() look good enough ( irrlicht doc says:"It is uses mostly for quick tests of the engine only.") it should be sufficient.
For all that im interested in your source (if there are some comments )
Maybe i can learn something.
Apropos: Do you know where i can find infos bout LOD terrain generation ??
the question was, as i understood, how do you dynamically modify the altitude of terrain vertices.
Of course you can rewrite the heightmap and re-prerender() but it may not fit some performance requierments if it's in real time.
I'll make a page for my terrain project. give me the week end for that...
I'm not sure it's simpler than irrlicht's built in one because it's more evolved (infinite terrain, dynamic tesselation, dynamic texturing, ...)
I can't look at the exact code for Irr 0.11 for the terrainNode, I have it heavily modified with a lot of changes, but if I recall, there have been posts about this before, and it's not hard to do at all. Changing Y values of vertex positions, slightly, isn't a problem, the thing is, when Y values are changed, bounding boxes aren't recreated, so culling may be off a little bit.
All you have to do, is get the MeshBuffer and modify the vertex data, very simple process actually.
The function call GetMesh() will return you the mesh of the node, which has the SMeshBufferLightMap meshBuffer with all the vertex data.
If you modify that, you will need to add a function to the TerrainNode that copies those vertices to the RenderBuffer vertices. Only a slight modification, if you can't figure it out, I'll post up some code changes to make it possible. I'm changing the way the terrainNode works slightly, and hopefully Niko will take the changes. The new way will use the Mesh as static mesh data, and the RenderBuffer will by scaled, position, rotated, whatever dynamic Mesh data. This will be necessary for geoMorphing calculations.
The function call GetMesh() will return you the mesh of the node, which has the SMeshBufferLightMap meshBuffer with all the vertex data.
If you modify that, you will need to add a function to the TerrainNode that copies those vertices to the RenderBuffer vertices. Only a slight modification, if you can't figure it out, I'll post up some code changes to make it possible. I'm changing the way the terrainNode works slightly, and hopefully Niko will take the changes. The new way will use the Mesh as static mesh data, and the RenderBuffer will by scaled, position, rotated, whatever dynamic Mesh data. This will be necessary for geoMorphing calculations.
not to sound igorant [intended] or anything but......what exactly is to be modified..I am just starting out game dev [ ok barely starting but who's counting ] and could use some advise on that PLUS:
is it possible to change texture at point of deform and if so how ?