ang_add(ANGLE* angle1, ANGLE* angle2)
ang_rotate(ANGLE* angle1, ANGLE* angle2)
Rotates an Euler angle by another Euler angle, in order to rotate an object or
view
about its local axes, rather than the X Y Z axis of the world coordinate system. This is mostly used for rotating aircraft or spaceship about arbitrary axes.
ang_add rotates angle1 by angle2,
ang_rotate rotates angle2 by angle1. The result is always
stored in angle1, which can also be an entity or view pan angle.
Parameters:
angle1 - pan/tilt/roll Euler angle to be modified
angle2 - pan/tilt/roll Euler angle used for rotation.
Speed:
mediumExample:
// A camera is hunting a target and turns with it, keeping the target always in the middle of the view.
var cam_dist[3] = -500,100,100; // xyz distance vector from camera towards the target
function chase_camera(target)
{
my = target; // The target Entity
// calculate the camera view's direction angle to the target
var cam_ang[3]; // direction angle of the camera to the target.
vec_diff(temp,nullvector,cam_dist);
vec_to_angle(cam_ang,temp);
cam_ang.roll = 0; // roll didn't change vec_to_angle
// permanent updating of the camera's position and angle
while (1)
{
// place the camera at the right position to the target
vec_set(camera.x,cam_dist);
vec_rotate(camera.x,my.pan);
vec_add(camera.x,my.x);
// Set the camera angles to the camera view direction
vec_set(camera.pan,cam_ang);
// and rotate it about the target angle
ang_add(camera.pan,my.pan);
wait(1);
}
}
See also:
vec_to_angle,
vec_rotate,
c_rotate
► latest
version online