I have been trying very hard to get this pick ray
working and can' get it done, I have been all over
the internet and here and I'm just stuck and ready
to put my fist through the screen. Days and Weeks at
it.
I need some Code to help me with this.
I have some c++ code but trying to decifer that is a
nightmare at the least.
I have this Quad:
Gl.glBegin(Gl.GL_QUADS)
Gl.glTexCoord2f(tc1, tc2)
Gl.glVertex3f(p1.x, p1.y, p1.z)
Gl.glTexCoord2f(tc3, tc4)
Gl.glVertex3f(p2.x, p2.y, p2.z)
Gl.glTexCoord2f(tc5, tc6)
Gl.glVertex3f(p3.x, p3.y, p3.z)
Gl.glTexCoord2f(tc7, tc8)
Gl.glVertex3f(p4.x, p4.y, p4.z)
Gl.glEnd()
I have this Pick Ray:
Dim viewport As Integer() = New Integer(3) {}
Dim modelviewMatrix As Double() = New Double(15) {}
Dim projectionMatrix As Double() = New Double(15) {}
Dim realY As Integer
Dim realXA As Integer
realXA = Cursor.Position.X
Dim worldX As Double, worldY As Double, worldZ As Double
Gl.glGetIntegerv(Gl.GL_VIEWPORT, viewport)
Gl.glGetDoublev(Gl.GL_MODELVIEW_MATRIX, modelviewMatrix)
Gl.glGetDoublev(Gl.GL_PROJECTION_MATRIX, projectionMatrix)
realY = viewport(3) - CInt(Cursor.Position.Y) - 1
Label1.Text = "Coordinates at cursor X>>" & realXA & "Y>>" & realY
Glu.gluUnProject(CDbl(realXA), CDbl(realY), 0, modelviewMatrix, projectionMatrix, viewport, worldX, worldY, worldZ)
Label2.Text = "World Coords at Z = 0.0 Are>>X>" & worldX & "Y>>" & worldY & "Z>>" & worldZ
clickRayA = New Vector(CSng(worldX), CSng(worldY), CSng(worldZ))
Glu.gluUnProject(CDbl(realXA), CDbl(realY), 1.0, modelviewMatrix, projectionMatrix, viewport, worldX, worldY, worldZ)
Label3.Text = "World Coords at Z = 0.0 Are>>X>" & worldX & "Y>>" & worldY & "Z>>" & worldZ
clickRayB = New Vector(CSng(worldX), CSng(worldY), CSng(worldZ))
clickSlope = Vector.op_Subtraction(clickRayB, clickRayA)
clickSlope.Normalize()
I do also have the ray visible, so it is there.
I just can't get past the end of this code.
I know I need something like:
Select = clickRayA,clickSlope,closestHit
I can't figure it out.
I need some code to help, C# would do.
Thanks If You Can Help!
Steve