Graphics Reference
In-Depth Information
void SetParent ( Node ￿ newParent );
void SetChild ( Node ￿ newChild )
{
newChild −> SetParent ( this ); }
// local translation sets
void SetLocalTranslation ( float x , float y , float z ,
bool useLocalRotation = false );
void LocalTranslate ( float x , float y , float z ,
bool useLocalRotation = false );
// global translation sets [...]
// local rotation sets
void SetLocalRotation ( const Quaternion & rotation );
void LocalRotate ( const Quaternion & rotation );
void SetLocalEulerAngles ( float x , float y , float z );
// global rotation sets [...]
// local scale sets
void SetLocalScale ( float x , float y , float z );
// local gets [...]
// global gets
Vector3 GetGlobalTranslation () const ;
Quaternion GetGlobalRotation () const ;
Vector3 GetGlobalEulerAngles () const ;
Vector3 GetGlobalLossyScale () const ;
Vector3 GetGlobalRight () ;
Vector3 GetGlobalUp () ;
Vector3 GetGlobalBackward () ;
Vector3 GetGlobalForward () ;
Matrix GetGlobalMatrix () const ;
Matrix GetGlobalMatrix_TranslationAndRotation () const ;
Matrix GetGlobalMatrixWithoutLocalMatrix () const ;
Listing 3.2. Node class interface.
All of the set functions that alter a node's local TRS call the UpdateLocalMatrix
function, which updates the localMatrix cache matrix. That means that after
calling functions that set local translation, rotation, and scale, UpdateLocalMatrix
gets called more than once without actually being used anywhere. There are two
optimizations available here. One is to use a dirty flag that would defer the call
to UpdateLocalMatrix until any function that needs it is called. Another idea is to
expose a function that sets all parameters (translation, rotation, and scale) one
by one and then calls the update function. However, none of these are present in
the demo application for the sake of simplicity.
Function GetGlobalMatrix returns the global transformation matrix. GetGlobal
Matrix_TranslationAndRotation does this as well but does not involve scale. This
is, in fact, matrix M TR from Section 3.2.4. The last function, GetGlobalMatrix
Search WWH ::




Custom Search