Jump to content

  • Log In with Google      Sign In   
  • Create Account

OpenTK projection of 3d points....


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 sam1   Members   -  Reputation: 101

Like
0Likes
Like

Posted 22 October 2012 - 02:03 PM

I'm learning OpenTK for some simple 3D work. I'm able to setup a simple scene showing basic shapes. However OpenTK does not have a project() function to allow me to place 2D text into a 3D scene. I'm attempting to use the following project() function but getting odd results.

Private Function Project13(world As Vector3) As Vector3
Dim view(4) As Integer
Dim model(16) As Double
Dim proj(16) As Double
Dim Screen As Vector3
GL.GetInteger(GetPName.Viewport, view)
GL.GetDouble(GetPName.ModelviewMatrix, model)
GL.GetDouble(GetPName.ProjectionMatrix, proj)
OpenTK.Graphics.Glu.Project(world, model, proj, view, Screen)
Screen.Y = GlControl1.Height - Screen.Y
Console.WriteLine(Screen.ToString)
Return Screen
End Function

3D math isn't my strong point, but can anyone suggest what might be amiss?

Sponsor:

#2 Scourage   Members   -  Reputation: 763

Like
0Likes
Like

Posted 22 October 2012 - 04:03 PM

You need to create an orthographic projection. I use:

Matrix4 orth=Matrix4.CreateOrthographicOffCenter(0, myViewport.width, 0, myViewport.height, -100, 100); 

This gives me a projection matrix with the origin in the bottom left corner. You can use pixel values to place objects on the screen. You will need to set the GL.ProjectionMatrix using this matrix and then render your objects/text.

cheers,

Bob

Halfway down the trail to Hell...




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS