Jump to content
  • Advertisement
Sign in to follow this  

Standing on mesh ???

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

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)
float u, v, Dist;
DWORD FaceIndex;

&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

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!