• Advertisement
Sign in to follow this  

Standing on mesh ???

This topic is 4680 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

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 ?

Share this post


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

Share this post


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

  • Advertisement