TFormPoint
Parameters:
| x# - x co-ordinate on which to perform transformation y# - y co-ordinate on which to perform transformaion z# - z co-ordinate on which to perform transformation src_entity - source entity space from which to transform co-ordinates dest_entity - destination entity space to transform co-ordinates |
Description:
| TFormPoint takes the co-ordinates of the source entity and 'transforms' them into co-ordinates relative to the co-ordinates of the destination entity (taking x, y and z as offsets, usually all set to 0 to use the center of the given entities). The resulting co-ordinates can be retrieved by the use of the TFormedX, TFormedY and TFormedZ functions. Passing 0 as either source or destination entity means that the transformation is performed relative to the global space (ie. the 3D world).
In English, this means that if you supply two entities, you can find the individual x, y and z offset distances of the source entity from the destination entity (providing you pass 0, 0, 0 as the x, y and z parameters). Changing the x, y and z parameters to anything other than zero will perform the transformation with this offset taken into account. For example, you can specify a point 5 units to the left of the given entities (x = 5), and the result will be offset by that x value. |
|
Graphics3D 640, 480 cam = CreateCamera () MoveEntity cam, 5, 0, -5 box = CreateCube () MoveEntity box, 5, 0, 0 Repeat If KeyDown (203) TurnEntity cam, 0, 0.5, 0 If KeyDown (205) TurnEntity cam, 0, -0.5, 0 If KeyDown (200) MoveEntity cam, 0, 0, 0.1 If KeyDown (208) MoveEntity cam, 0, 0, -0.1 bx# = EntityX (box) by# = EntityY (box) bz# = EntityZ (box) cx# = EntityX (cam, 1) cy# = EntityY (cam, 1) cz# = EntityZ (cam, 1) TFormPoint 0, 0, 0, cam, box xdist# = TFormedX () ydist# = TFormedY () zdist# = TFormedZ () UpdateWorld RenderWorld Text 0, 20, "Box's global position" Text 20, 40, "x: " + bx Text 20, 60, "y: " + by Text 20, 80, "z: " + bz Text 0, 120, "Camera's global position" Text 20, 140, "x: " + cx Text 20, 160, "y: " + cy Text 20, 180, "z: " + cz Text 0, 220, "Camera position relative to box" Text 20, 240, "x: " + xdist Text 20, 260, "y: " + ydist Text 20, 280, "z: " + zdist Flip Until KeyHit (1) End |