Thanks Petr, for the example.
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
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Thanks Petr, for the example.
Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server
Updated the code,
it is possible to clear buffer, matrix stack faster and better
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
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
you can't always get what you want, but if you try sometimes you might find, you get what you need
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
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Bookmarks