Sign in to follow this  

Standing on mesh ???

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

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