Game Development Reference
In-Depth Information
// Get current theta
// returns 0-PI radians
float Theta = (float)Math.acos(ForwardVecProj.DotProduct(Bill2CameraVecProj));
float DegreeTheta = Theta * 180.0f/Physics.PI;
// 6. Cross Product to form rotation axis
Vector3 RotAxis = Vector3.CrossProduct(ForwardVecProj, Bill2CameraVecProj);
// 7. Rotate BillBoard Toward Camera
// cos in radians
if ((Math.cos(Theta) < 0.9999) && (Math.cos(Theta) > -0.9999))
{
m_Orientation.SetRotationAxis(RotAxis);
m_Orientation.AddRotation(DegreeTheta);
}
else
{
//Log.e( "BILLBOARD", "No Cylindrical Rotation!! , Theta = " + Theta);
}
}
Finally, the UpdateObject3d() function is called continuously to update the orientation of the billboard
object by calling the SetBillBoardTowardCamera() function discussed in Listing 6-13.
Listing 6-13. Updating the Billboard
void UpdateObject3d(Camera Cam)
{
super.UpdateObject3d();
SetBillBoardTowardCamera(Cam);
}
Creating the BillBoardFont Class
The BillBoardFont class is used to associate a specific character with the billboard texture image.
The BillBoardFont class is derived from the BillBoard class.
public class BillBoardFont extends BillBoard
The variable m_Character is used to hold the alphanumeric value that represents the billboard texture
for this class.
private char m_Character;
The BillBoardFont() constructor is shown in Listing 6-14. First, the constructor of the superclass is
called, which would be the constructor for the BillBoard class. Then, the character that this billboard
represents is set in the variable m_Character .
 
Search WWH ::




Custom Search