ang_add(ANGLE* angle1, ANGLE* angle2)

ang_rotate(ANGLE* angle1, ANGLE* angle2)

Rotiert einen Euler-Winkel um einen anderen Euler-Winkel zu dem Zweck, ein Objekt oder einen View um seine lokale Achse, anstatt um die X Y Z-Achse des Welt-Koordinatensystems zu drehen.Dies wird meist dazu benutzt, ein Flugzeug oder Raumschiff um beliebige Achsen zu drehen. ang_add rotiert angle1 um angle2, ang_rotate rotiert angle2 um angle1. Das Resultat wird immer im angle1-Parameter gespeichert, welcher sowohl der pan-Winkelvektor einer Entity, als auch der eines Views sein kann.

Parameter:

angle1 - pan/tilt/roll Eulerwinkel, der modifiziert wird.
angle2 - pan/tilt/roll Eulerwinkel, der zur Rotation benutzt wird..

Geschwindigkeit:

Mittel

Bespiele (lite-C):

// An entity rotates about its vertical axis, regardless of its orientation in space
function ent_rotatepan(ENTITY* ent)
{
  while(1) {
    ang_rotate(ent.pan,vector(5*time_step,0,0));
    wait(1);
  }
}

// A camera is hunting a target and turns with it, keeping the target always in the middle of the view.
function chase_camera(ENTITY* target)
{
// calculate the camera view's direction angle to the target
  var cam_dist[3] = {-200,-100,-100}; // xyz distance vector from the camera to the target
  var cam_ang[3] = {0,0,0}; // direction angle of the camera to the target.
  vec_to_angle(cam_ang,cam_dist);

  while (1)
  {
// place the camera at the right position to the target
    vec_diff(camera.x,nullvector,cam_dist);
    vec_rotate(camera.x,target.pan);
    vec_add(camera.x,target.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,target.pan);
    wait(1);
  }
}

Siehe auch:

vec_to_angle, vec_rotate,c_rotate

► Aktuelle Version Online