# [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.

## 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 on other sites
Sorry guys, please ignore me ... this was me being a tool. passed in the wrong xpos and ypos.

Ta.

1. 1
2. 2
Rutin
22
3. 3
JoeJ
18
4. 4
5. 5

• 15
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631724
• Total Posts
3001903
×