billboard derived from ygNode Example Source Header

Description: a transform that orients to face the viewer about a point or axis

notes:
Category: Transformation
Author: Alex Hill
Revision: 11/01/01

    Messages
mode (point | axis), three floats set the mode and optional axis
    Comments

constructor billboard

method reset

1 set the rotation mode to axial with Z axis (0,0,1)

method message

1 set the mode and optional axis

method app

1 find viewer in the world
2 if a viewer is found
2.1 get viewer position vector relative to this node
2.2 get the cross product of the viewer vector and the rotation axis
2.3 establish the object front as the positive Y-axis
2.4 get the cross product of the front axis and the rotation axis
2.5 get a normal towards the viewer by crossing this cross with the rotation axis
2.6 get the rotation to the viewer vector
2.7 create a matrix with this rotation
2.8 if the mode if point then
2.8.1 get the rotation about the viewer cross product
2.8.2 set the final matrix to this rotation
2.8.3 add this rotation matrix to the existing rotation matrix
2.9 set the dcs matrix