This command makes a 3D object look towards another object or location.





x, y, z

The location where you want the object to look.


The number of seconds the move will take (if omitted, the movement is immediate)


This command is different from the LookAt command. The LookAt command makes your object constantly look at another object or location. The TurnTo command makes your object look toward the other object or position, but it makes no further attempts after any motion is made.

Sample Code

In the following code, you will be able to move a sphere with the arrow keys. Two other spheres will be created, one using the LookAt command, another using the TurnTo command.

 oworld = New World(); ocamera = New Camera(oworld); sphere = oworld.CreateSphere(50,50,50,25,25); sphere2 = oworld.CreateSphere(50,50,50,25,25); sphere3 = oworld.CreateSphere(50,50,50,25,25); sphere2.SetPosition(-100,-100,0); sphere3.SetPosition(100,-100,0); Sphere3.LookAt(sphere); Sphere2.TurnTo(sphere,5); ocamera.MoveBack(1200); sphere.Walk(); //loop While(TRUE); 

Elementary Game Programming and Simulators Using Jamagic
Elementary Game Programming & Simulations Using Jamagic (Charles River Media Game Development)
ISBN: 1584502614
EAN: 2147483647
Year: 2002
Pages: 105
Authors: Sergio Perez

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net