Thunder2002


Hi,

at the moment i am wondering how to deal correctly with a terrain in XNA. For now i just have a static terrain model loaded from file. So i have an object (a buggy for example) and want to get some physics on it, therefore i need to check for collision with the underlying terrain. The collision with the buggy could be done with a boundingbox, but the terrain needs to be checked per face (3 vertices triangle) i think. But i cant find a way to check this. I think iteration throught all faces of the terrain would take to long for all objects in the world. How do other developers solve this problem

So if I do it this way i will always need to calculate every object in the world each frame, no mather if its visible or not, is this the correct way I really get crazy about this whole scenario and don't know what ways are right and wrong

Also i am confused about slicing of the terrain, a big game world with hundret-thousands of vertices needs a slicing algorithm, but do i automaticly need a dynamic terrain based on a vertex array in XNA How else to slice an existing model

Hopefully someone can help me out here

Cu Thunder2002



Re: Terrain & Terrain-Physics (intersection, dynamic slicing)

Darkside


Been doing a lot on this recently from a beginner perspective.

Main problem you need to counter, is not to do per-vertex collision detection between your model and the terrain, the easiest sollution to this is to use a heightmap or even better, a tree stucture (like Quadtrees or Octtrees) to hold and control the height data for your terrain.

Examples for these can be found on www.codeplex.com.

For more detail on how to use them and the respective arguments on this visit http://gpwiki.org and of course http://wikipedia.com , http://gamedev.net also has some good articles and forum comments.

Have fun

Darkside






Re: Terrain & Terrain-Physics (intersection, dynamic slicing)

ClydeCoulter

Thunder, take a look at my quadtree project. It has a sample game that shows how to find the height at the terrain location an object is at.

http://www.codeplex.com/quadtreeload

It has pretty good commenting and .txt files for explanations of key assignments, creating a heightmap and texture for the heightmap, etc......

It's a start, from there you can modify it how you like.







Re: Terrain & Terrain-Physics (intersection, dynamic slicing)

Thunder2002

Thanks very much, over the last days i build out my own version based on your, it boosts dramaticly up the rendering, i can render huge terrain course of the great vertex cache and also render small parts at very high frame rate, brilliant work
While reading & writing i found some very small things that could be fixed up:

->Quadtree
--->Create()
Can never be reached, was just assigned above to the same value, so it can't be larger.

if (height > heightData.GetLength(0))
m_valid = false;
if (width > heightData.GetLength(1))
m_valid = false;

->Quadtreenode
--->Buildout()
Both situations can't be reached, if the first is valid the second is impossible.

if (data > m_maxHeight)
m_maxHeight = data;
if (data < m_minHeight)
m_minHeight = data;

->Quadtree
--->Create()
Unused variable.

SurfaceFormat fmt = heightMap.Format;

Just wanted to mention when i already spend so much time on it