# Level/Scene Rendering Question

This topic is 4867 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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
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
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

SO the result of this;

D3DXVECTOR3 xyz = orig + dir * dist;

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

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631428
• Total Posts
3000027
×