Sign in to follow this  

Level/Scene Rendering Question

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this