Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

[SlimDX] Ray.Intersects help

Started by LotusExigeS1 Aug 13, 2011 at 10:58 AM 0 replies 1.5k views
Original Post
LotusExigeS1
LotusExigeS1
[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 !
LotusExigeS1
LotusExigeS1
Sorry guys, please ignore me ... this was me being a tool. passed in the wrong xpos and ypos.

Ta.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.