PDA

View Full Version : Demonstration of matrix operations



Petr Schreiber
28-03-2009, 15:40
TBGL offers 3 basic transformations - translating, rotating and scaling.

When creating geometry on the fly, we can use TBGL_Translate, TBGL_Rotate and TBGL_Rotate to transform primitives.
In some situations, we would prefer to work with one triangle mesh, which would have all the transformations baked in.

Attached script shows multiple techniques:
- how the matrix magic works under the surface
- how to bake transformation to data structure
- how to use hi performance vertex arrays

Program allows you to cast transformations on triangle, as well as it shows complete dynamic matrix stack listing, so you can observe which parts of matrix represent what.

( first 3 columns are orientation of X, Y, Z axes, diagonal reflects scaling, last column translation )


I hope this will reveal at least part of mysteries related to matrices used in transforms,
Petr

UPDATED 29.03.2009
+ Added clearing the buffer
! Cleaned up matrix stack code

kryton9
29-03-2009, 05:06
Thanks Petr, for the example.

Petr Schreiber
29-03-2009, 14:47
Updated the code,

it is possible to clear buffer, matrix stack faster and better :)


Petr

Lionheart008
30-03-2009, 13:44
hi petr, hi kent:)

I like the script, very very nice one... and so everyone can see what translation/rotation/scaling of a vertex/triangle are good for you can see after changing the values... good exercise ! :)

perhaps you can add a new button (I have done a dummy example for you) for realisation the triangle at the new position after changing the values... (moveObjectToNewPosition button) only an idea... :)

have all a nice day, it wasn`t so great for me this monday morning, my car no more hasn`t fun to start... electronic problems with lighmachine and cockpit... uff...

ciao, lionheart

Petr Schreiber
30-03-2009, 16:24
Hi Frank,

interesting idea, but I want to keep this example as simple as possible... of course I will not limit any efforts to enhance it :)


Petr