If you want to transform between local and global coordinates, that is when you use it.
So if you want, for instance, to know where in the 'world' a point is that is say 1 unit to the left of an entity, relative to the entity's orientation, then you would use the tformed commands. In the example given you would do this:
TformPoint -1,0,0,My3DModelWhichCouldBeFacingAnyDirection,0
Xpos#=TformedX() ;the x coordinate in the world of a point which lies 1 unit to the left of the 3d model listed above
YPos#=Tformedy() ;the y coordinate in the world of a point which lies 1 unit to the left of the 3d model listed above
zPos#=TformedZ() ;the z coordinate in the world of a point which lies 1 unit to the left of the 3d model listed above
perhaps a few more examples could be given such as:
Let us say you wanted to know if a particular entity "EntityA" is in front of another entity "EntityB" then to do this you would simply do this:
XPositionOfEntityARelativeToEntityB#=EntityX(EntityA,true)-EntityX(EntityB,true)
YPositionOfEntityARelativeToEntityB#=EntityY(EntityA,true)-EntityY(EntityB,true)
ZPositionOfEntityARelativeToEntityB#=EntityZ(EntityA,true)-EntityZ(EntityB,true)
;then we use tformvector or tformnormal to transform this vector from 'world space' to 'local space' of EntityB
TformNormal XPositionOfEntityARelativeToEntityB#,YPositionOfEntityARelativeToEntityB#,ZPositionOfEntityARelativeToEntityB#,0,EntityB
If TFormedZ()>0.0 then
;Entity A must be in front of Entity B
endif
If TFormedZ()<0.0 then
;EntityA must be behind Entity B
endif
If TFormedX()<0.0 then
;Entity A must be to the left of Entity B
endif
If TFormedX()>0.0 then
;Entity A must be to the right of Entity B
endif
;Same logic applies to TFormedY() ie if TFormedY()>0.0 then Entity A must be above Entity B, although the actual value of TFormedX,Y,Z() will tell you just how much to the front/left/up/down/right/back the entity is.
|