PDA

View Full Version : TBGL_RotateXYZ and OpenGL



dcromley
05-11-2011, 18:26
Eros,
In your page http://www.thinbasic.com/community/content.php
Please put a link to the Journals -- they are still wonderful:
http://www.thinbasic.com/community/forumdisplay.php?336-ThinBasic-Journal

Petr,
From http://psch.thinbasic.com/
"TBGL originally started as [an] OpenGL wrapper."

I still like working with rotation mathematics. I'm working on a program demo'ing (demonstrating) rotations via Euler angles. I've looked at OpenGL some, looking for the the primitives for TBGL_Rotate and TBGL_RotateXYZ. I see GL_Rotate, GL_Rotatef (single) and GL_Rotated (double), but not GLRotateXYZ. Is this your creation? Are there some OpenGL articles on this?

Regards, Dave

Petr Schreiber
05-11-2011, 18:41
Hi Dave,

yes, TBGL_RotateXYZ is my TBGL specific abbreviation. It is equivalent of:


IF xAngle THEN glRotateF xAngle, 1, 0, 0
IF yAngle THEN glRotateF yAngle, 0, 1, 0
IF zAngle THEN glRotateF zAngle, 0, 0, 1

So just a linearly applied shortcut to save programmer some writing

TBGL_Rotate is version of glRotatef, enhanced with polymorphism. That means, with 4 parameters it works like:


glRotatef angle, xAxis, yAxis, zAxis

but with 1 parameter it works like:


glRotatef angle, 0, 0, 1

making it more easy to use in 2D graphics (where just one axis of turning, perpendicular to screen, makes sense).

I personally do not like the original OpenGL glRotatef behavior, that is why in the entity system I decided to do the transformations completely manually, to make possible rotations in local system of each geometrical object (much easier for manipulating airplane and other cases). So TBGL_EntityTurn operates on the local coordinate system level additively, TBGL_EntitySetRot is then equivalent of TBGL_RotateXYZ.

I think the way it works in entity system is more suitable for euler angles approach.

Thanks for your kind words on the Journal. This effort has been currently replaced by having Articles (http://www.thinbasic.com/community/content.php) section directly on website - it allows keeping the articles always up to date.


Petr

dcromley
05-11-2011, 21:45
Petr,
Thanks so much.
All of TB is a bottomless resource.
I am often surprised at yet another feature.
You'll be hearing from me. Thanks again, Dave

ErosOlmi
06-11-2011, 12:05
Eros,
In your page http://www.thinbasic.com/community/content.php
Please put a link to the Journals -- they are still wonderful:
http://www.thinbasic.com/community/forumdisplay.php?336-ThinBasic-Journal


Good suggestion.
Done for all community forum pages using top forum notices