# Level/Scene Rendering Question

## Recommended Posts

yuppies    116
I plan to render my scene using a big mesh (directX .X mesh) but i got a problem on getting the height on my floor mesh(terrain) whats the tecnique in getting the right height value for my scene? any idea?

##### Share on other sites
soconne    105
If you're using a .X file, you're going to have to organize the geometry into a quadtree or octree, or some other structure. Then you figure out what polygons are close enough to you such that you might be intersecting them. Then you have to perform collision detection.

Try these sites, they have good tutorials on the subject.

http://nehe.gamedev.net
http://www.gametutorials.com
http://www.codesampler.com

##### Share on other sites
Guest Anonymous Poster
you mean like getting the height at a specific cordinate?
i did it like this: i sent a ray straight from above and measured how far it reached, the code is the following (for direct3d):

D3DXVECTOR3 orig, dir;
orig.x = x;
orig.y = y;
orig.z = 100.0f;
dir.x = 0.0f;
dir.y = 0.0f;
dir.z = -1.0f;
BOOL hit; DWORD dwIndex; float u,v; float dist;
D3DXIntersect(m_d3dmesh, &orig, &dir, &hit, &dwIndex, &u, &v, &dist, NULL, NULL);

hit tells you (tada) weather the ray hit or not, dist tells you how far away from its origin it hit. to calculate the xyz of the spot you do this:
D3DXVECTOR3 xyz = orig + dir * dist;

##### Share on other sites
dxdotnet1    106

SO the result of this;

D3DXVECTOR3 xyz = orig + dir * dist;

gaves me my intersection point right? and i can use this as my hieght?