Standing on mesh ???

Started by
1 comment, last by AhmedSaleh 18 years, 9 months ago
if i use mesh from .x file to create my terrain or building, how i can i get the x,y,z value on the mesh surface in the point I get clicked with mouse so i can use my character to walk/stand on it ?
Advertisement
Use an octree, quadtree, bsp tree, or some sort of space partioning system. This will allow you to break your mesh up so you can grab the vertex data easily and perform polygon tests.
Hi,

You Can use the D3DX Function D3DXIntersect(); which returns a boolean value if u hit a mesh or not(ray to plane intersection test) , you can use that too to test for the value of the height below and above you, with some basic math .

float GetTheHeightBelowYou(float XPos, float YPos, float ZPos)
{
BOOL Hit;
float u, v, Dist;
DWORD FaceIndex;

D3DXIntersect(meshprt,
&D3DXVECTOR3(XPos,YPos,ZPos),// ray
&D3DXVECTOR3(0.0f, -1.0f, 0.0f), // ray's direction
&Hit, &FaceIndex, &u, &v, &Dist);
if(Hit == TRUE)
return YPos-Dist;
return YPos;
}
Game Programming is the process of converting dead pictures to live ones .

This topic is closed to new replies.

Advertisement