TGC Codebase Backup



Object Positioning Relative to a Camera by Kira Vakaan

19th Jan 2009 20:20
Summary

Use this function to position and rotate an object relative to a camera's position and rotation.



Description

Syntax:
OrbitCamera(Camera,Object,XDist#,YDist#,ZDist#,XAng#,YAng#,ZAng#,ZDepthFlag)

Camera - The number of the camera to reposition the object around
Object - The number of the object to reposition
XDist#, YDist#, ZDist# - The new X, Y, and Z positions of the object relative to the camera's position and rotation
XAng#, YAng#, ZAng# - The new X, Y, and Z angles of the object relative to the camera's rotation



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    function OrbitCamera(Camera,Object,XDist#,YDist#,ZDist#,XAng#,YAng#,ZAng#,ZDepthFlag)
   position object Object,camera position x(Camera),camera position y(Camera),camera position z(Camera)
   rotate object Object,camera angle x(Camera),camera angle y(Camera),camera angle z(Camera)
   move object right Object,XDist#
   move object up Object,YDist#
   move object Object,ZDist#
   pitch object down Object,XAng#
   turn object right Object,YAng#
   roll object left Object,ZAng#
   if not ZDepthFlag then disable object zdepth Object
endfunction