[Gambas-user] gb3: OpenGL Rotate and Translate logic

tommyline at ...2340... tommyline at ...2340...
Sun May 27 08:40:15 CEST 2012


Ok,

first - you've got perspective range as

Glu.Perspective(45, sWidth / sHeight, -1, 1) <- should be positve and bigger ie. Glu.Perspective(45, sWidth / sHeight, 0.1, 500) or even more if the world is big.

second - you're too low over the ground, thus  the world is kind of "flipped", increase eyez in glu.LookAt().

See it it works, then we can sort out the rest.

Tomek

----- Original Message -----
From: "Kevin Fishburne" <kevinfishburne at ...1887...>
To: gambas-user at lists.sourceforge.net
Sent: Sunday, 27 May, 2012 7:14:31 AM
Subject: Re: [Gambas-user] gb3: OpenGL Rotate and Translate logic

On 05/26/2012 01:17 PM, tommyline at ...2340... wrote:
> Oooooops!
>
> I just realized, you use Gl.Ortho mode. That means Glu.LookAt is not for you, I spent few hours trying to figure out how to make it work in ortho, but I can't. It behaves like mad, no matter what origin you set up. Sorry, that's one of the reasons I use perspective mode. I suppose the rotation in 2D is made by rotating world's vertexes, rather than camera, but I can be wrong.
> Sorry for misunderstending you.
>
> Tomek
>

That's it man, now I'm finding out where you live and leaving a bag of 
rotten shrimp in your mailbox. ;)

Alright, I'm done with ortho for now and have switched to perspective. 
Amazingly it worked nearly perfectly on the first attempt but one weird 
thing is happening:

   UpVec1 = Sin(Rad(Camera.Orientation))
   UpVec2 = Cos(Rad(Camera.Orientation))
   UpVec3 = 0

   Gl.MatrixMode(Gl.PROJECTION)
   Gl.LoadIdentity()
   Glu.Perspective(45, sWidth / sHeight, -1, 1)

   Gl.MatrixMode(Gl.MODELVIEW)
   Gl.LoadIdentity()

   Glu.LookAt(Camera.WorldX, Camera.WorldY, 10, Camera.WorldX, 
Camera.WorldY, 0, UpVec1, UpVec2, UpVec3)

It appears as though the scene is being rendered vertically inverted, 
like taking a screenshot and flipping it vertically in GIMP. Moving 
left/right works but moving up/down is backward. I tried experimenting 
with the up vector and eye/center Z parameters for Glu.LookAt with no 
success. I'll continue researching and experimenting but throw me a bone 
if you've seen this before.

-- 
Kevin Fishburne
Eight Virtues
www: http://sales.eightvirtues.com
e-mail: sales at ...1887...
phone: (770) 853-6271


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Gambas-user mailing list
Gambas-user at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user




More information about the User mailing list