D3DXIntersect, converting to world coords

Started by
7 comments, last by shakazed 20 years, 2 months ago
Can I convert the intersection point returned by D3DXIntersect into world space coordinates anyhow? EDIT: Want to use the function to calculate the y coord for any given point on my terrain (which is a .x file). [edited by - shakazed on January 25, 2004 11:10:39 AM]
Advertisement
Ok, so I thought when passing D3DXIntersect pDist it would give me the distance along the ray where the collision took place, and then use this as my new y coord (add constant) for my mesh. But it doesn´t give me any values I can use in that manner. Any ideas?
Did you try the point RayPos + RayDir * Dist?
Hmm?
VolkerG: Didn´t work, too bad :/

How to get intersection point returned by D3DXIntersect into world space coordinates ?

Step 1: WorldSpace ==>ModelSpace
you might have passed your RayStartPos in Model_Space coordonates.
like MyRayStart=MeshWorldMatrix*RayStart

Step 2: Intersection Test
passe your ray parametters in MeshWorldMatrix format to D3DXIntersect function.

Step 3 ModelSpace ===>WorldSpace
world space Intersection Point=Intersection Point * Mesh_InverseWorldMatrix.


Good Luck
Round, one , fight!!!
Hmm, will have to try when I get home. Thanks for the advice!
Gaaah! Aren´t there any tutorials on how to do this? I´ve looked all over (atleast it feels like that). I just can´t get it working. Since I´m so stupid I really need a step by step tutorial that explains everything I guess there are other ways to do terrain following with .x files. I could really use some pointers.

[edited by - shakazed on January 26, 2004 9:33:31 AM]
translate your y vector by the same amout you''ve transformed your mesh.

This topic is closed to new replies.

Advertisement