#### Archived

This topic is now archived and is closed to further replies.

# D3DXIntersect, converting to world coords

This topic is 5431 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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]

##### Share on other sites
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?

##### Share on other sites
Did you try the point RayPos + RayDir * Dist?

Hmm?

##### Share on other sites
VolkerG: Didn´t work, too bad :/

##### Share on other sites

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

##### Share on other sites
Hmm, will have to try when I get home. Thanks for the advice!

##### Share on other sites
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]

##### Share on other sites
translate your y vector by the same amout you''ve transformed your mesh.

1. 1
2. 2
3. 3
Rutin
25
4. 4
5. 5
khawk
14

• 11
• 11
• 23
• 10
• 9
• ### Forum Statistics

• Total Topics
633650
• Total Posts
3013119
×