Jump to content
  • Advertisement
Sign in to follow this  
LotusExigeS1

[SlimDX] Ray.Intersects help

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

[color="#2a2a2a"]Can someone please help with the below. I only get a positive 'hit' when I am in the bounding box. Thanks for any help.

[color="#2a2a2a"]Public Function RayBBIntersects(ByVal bb As BoundingBox, ByVal xPos As Single, ByVal yPos As Single) As Boolean
Dim near As New Vector3(xPos, yPos, 0.0F)
Dim far As New Vector3(xPos, yPos, 1.0F)
Dim n As Vector3 = Vector3.Unproject(near, 0, 0, cClientArea.Width, cClientArea.Height, -1000, 1000, cViewMatrix * cProjectionMatrix)
Dim f As Vector3 = Vector3.Unproject(far, 0, 0, cClientArea.Width, cClientArea.Height, -1000, 1000, cViewMatrix * cProjectionMatrix)

Dim direction As Vector3 = f - n
direction.Normalize()

Dim r As New Ray(n, direction)
Dim distance As Single = 0
Return Ray.Intersects(r, bb, distance)
End Function



[color="#2a2a2a"]Thanks guys !

Share this post


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