• Advertisement
Sign in to follow this  

Level/Scene Rendering Question

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

If you intended to correct an error in the post then please contact us.

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


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement