# What are these TForm functions?

ðŸ‘‰ BlitzCoder will be building a new platform and other plans to preserve and continue the Blitz legacy.

To be able to achieve this goal, we need your support by becoming a Patreon Paid Member ðŸ‘ˆ

Tweet

hello im tryin to understand how does TFormNormal and TFormVector work.

you must have a good understanding of 3d space to understand these functions.

blitz3d 3d world has a 3d global space with x axis (left - right), y axis (down - up), z axis (backward - forward) depending on the world origin.

each 3d entity has a global space position and orientation, but also a local space position and orientation (depending on its origin).

why are Tformpoint() and Tformvector() are useful ?

Tformpoint() allows you to determine the position of a point in the global space, from a point in the local space of the entity, considering its orientation.
an example of use is if you want to find a point (coordinates) behind your entity, considering its orientation.
Tformpoint( 0, 0, -1, entity, 0)
px# = tformedx() : py# = tformedy() : pz# = tformedz()

Tformvector() allows you to determine a vector in the global space, from a vector in the local space of the entity, considering its orientation.
an example of use is if you want to throw a linepick (which requires a vector properties) in front of an entity.
Tformvector( 0, 0, +10, entity, 0)
vecx# = tformedx() : vecy# = tformedy() : vecz# = tformedz()

clear ?

and when doing this wth tformpoint,

c=createcube()
moveentity c,10,-10,10
d=createcube()
rotateentity d,0,180,0
moveentity d,10,10,10
Tformpoint( 0, 0, -1, d, c)
px# = tformedx() : py# = tformedy() : pz# = tformedz()
print px+" "+py+" "+pz

I get -20 20 -19. how does it get to that?

Tformnormal() is similar to tformvector(), except you will get a normalized vector ( its attributes vecx, vecy, vecz, will not exceed 1.0 in total ), this is useful to have a vector as a direction, ( without length / speed ), for example if you want to have a spaceship or bullet or physicbody with a direction and a variable translation speed.

after rereading each command description, my explanations were not totally correct, to be more precise these tform commands are useful to determine a point or vector or normal from the 3d local space of an entity, to the 3d local space of another entity, or to the 3d global space (if you give the value 0).

use 3d markers to understand what is going on, with some testing, you will understand...

keep in mind that the 3d point / 3d vector / 3d normal, is calculated from the origin of the local space of the entity, or from the origin of the global space of the world...