[Gambas-user] gb3: OpenGL Rotate and Translate logic
Kevin Fishburne
kevinfishburne at ...1887...
Sun May 27 10:02:53 CEST 2012
On 05/27/2012 03:29 AM, tommyline at ...2340... wrote:
> Simply speaking, "near" and "far" clipping planes is something like two vertical planes in front of your eyes, and the view is rendered between them. Like hologram generator. Both of the planes must be in front of you, so "near" must be greater than 0,
> the"far" depends on how far you want to see your world. Let's say you set "far" as 20 and see the rectangle which is 100 units deep, you will see only 20 units of it (but in the view direction - if not rotated, in Z direction). In your case "near" is always in front of your eyes, so set it as 0.1, "far" should be big enough to see quite a lot of the world if it rotates plus elevation over it, I'd say 5000 should be enough, but you have to check it to be sure.
> As for missing parts of the world, the best trick to hide it is to use fog on very low settings, so it makes nice blurr, but doesn't affect close range picture.
>
> Tomek
Ah. Now it makes sense. I kept thinking the near plane had to be behind
the camera to "make sure" close objects were rendered.
I just figured out how to freely switch between ortho and projection
modes so I can draw pixel-presice OSD's as well as the 3D scene:
Public Sub Mode_Ortho()
' Set OpenGL matrices to orthogonal mode.
Gl.MatrixMode(Gl.PROJECTION)
Gl.LoadIdentity()
Glu.Ortho2D(0, sWidth, 0, sHeight)
Gl.Scalef(1, -1, 1)
End
Public Sub Mode_Perspective()
' Set OpenGL matrices to perspective mode.
Gl.MatrixMode(Gl.PROJECTION)
Gl.LoadIdentity()
Glu.Perspective(45, sWidth / sHeight, -1, 1)
Gl.Scalef(1, -1, 1)
End
Lovely. I'm reworking the code now to migrate existing features to the
new hybrid ortho/perspective setup. Should look much improved in a few
days, "2.5D" as they say.
--
Kevin Fishburne
Eight Virtues
www: http://sales.eightvirtues.com
e-mail: sales at ...1887...
phone: (770) 853-6271
More information about the User
mailing list