#include <AlDagNode.h>
class AlDagNode : public AlObject , public AlClusterable , public AlAnimatable , public
AlSettable , public AlPickable
virtual ~AlDagNode();
virtual statusCode deleteObject();
virtual AlObject* copyWrapper() const;
AlDagNode* copyObject( AlCopyOptions* = NULL );
virtual AlAnimatable* asAnimatablePtr();
virtual AlSettable* asSettablePtr();
virtual AlClusterable* asClusterablePtr();
virtual AlPickable* asPickablePtr();
virtual AlObjectType type() const;
virtual AlDagNode* asDagNodePtr();
virtual const char* name() const;
virtual statusCode setName( const char* );
AlGroupNode* parentNode() const;
AlDagNode* nextNode() const;
AlDagNode* prevNode() const;
virtual boolean isInstanceable();
statusCode addSiblingNode( AlDagNode* );
statusCode comment( long&, const char*& );
statusCode setComment( long, const char* );
statusCode removeComment( void );
statusCode blindData( int, long&, const char*& );
statusCode setBlindData( int, long, const char* );
statusCode removeBlindData( int );
statusCode persistentID( int, AlPersistentID*& );
statusCode hasPersistentID( int );
statusCode localTransformationMatrix( double[4][4] ) const;
statusCode globalTransformationMatrix( double[4][4] ) const;
statusCode inverseGlobalTransformationMatrix( double[4][4] ) const;
statusCode affectedTransformationMatrix( const AlTM&, double[4][4] )
const;
statusCode localTransformationMatrix( AlTM& ) const;
statusCode globalTransformationMatrix( AlTM& ) const;
statusCode inverseGlobalTransformationMatrix( AlTM& ) const;
statusCode affectedTransformationMatrix( const AlTM&, AlTM& ) const;
statusCode translation( double&, double&, double& ) const;
statusCode rotation( double&, double&, double& ) const;
statusCode scale( double&, double&, double& ) const;
statusCode rotatePivot( double&, double&, double& ) const;
statusCode scalePivot( double&, double&, double& ) const;
statusCode rotatePivotIn( double &x, double &y, double &z ) const;
statusCode rotatePivotOut( double &x, double &y, double &z ) const;
statusCode scalePivotIn( double &x, double &y, double &z ) const;
statusCode scalePivotOut( double &x, double &y, double &z ) const;
statusCode setTranslation( double, double, double );
statusCode setWorldTranslation( double, double, double );
statusCode setRotation( double, double, double );
statusCode setScale( double, double, double );
statusCode setRotatePivot( double, double, double );
statusCode setScalePivot( double, double, double );
statusCode localRotationAxes( double[3], double[3], double[3] ) const;
statusCode setLocalRotationAxes(double[3], double[3], double[3]);
statusCode localRotationAngles( double&, double&, double& ) const;
statusCode setLocalRotationAngles( double, double, double );
statusCode localRotateBy(double , double ,double );
statusCode localTranslateBy(double , double ,double );
statusCode boundingBox( double[8][4] ) const;
boolean isDisplayModeSet( AlDisplayModeType ) const;
statusCode setDisplayMode( AlDisplayModeType, boolean );
AlJoint* joint() const;
statusCode addJoint();
statusCode removeJoint();
AlDagNode* searchBelow( const char * ) const;
AlDagNode* searchAcross( const char * ) const;
statusCode updateDrawInfo( void ) const;
statusCode sendGeometryModifiedMessage();
statusCode doUpdates( boolean newState = TRUE );
AlConstraint* firstConstraint( void ) const;
class AlCopyOptions
{
friend class AlDagNode;
AlCopyOptions();
virtual ~AlCopyOptions();
boolean groupCopy() const;
statusCode setGroupCopy( boolean );
boolean instanceCopy() const;
statusCode setInstanceCopy( boolean );
boolean copyAnimation() const;
statusCode setCopyAnimation( boolean );
boolean copyClusters() const;
statusCode setCopyClusters( boolean );
int numCopies() const;
statusCode setNumCopies( int );
AlParamControlType parameterControl() const;
statusCode setParameterControl( AlParamControlType );
AlHierarchyType hierarchy() const;
statusCode setHierarchy( AlHierarchyType );
double timeOffset() const;
statusCode setTimeOffset( double );
statusCode translation( double&, double&, double& ) const;
statusCode setTranslation( double, double, double );
statusCode rotation( double&, double&, double& ) const;
statusCode setRotation( double, double, double );
statusCode scale( double&, double&, double& ) const;
statusCode setScale( double, double, double );
Each dag node can be mutually attached to a previous and next dag node to form a list of dag nodes. This list can belong to a group (or parent) dag node. This list of dag nodes that belong to a group node are called "children" of the group node.
The purpose of a dag node is to contain information which defines particular affine transformations such as scale, rotation and translation. There is a specific fixed order in which the transformations are combined. There are methods for accessing each particular transformation and a method exists for obtaining the local tranformation matrix built from these transformations. For more information, see the description for the method localTransormationMatrix().
Classes derived from this class will refer to a particular type of object. For example, the AlCameraNode class is derived from AlDagNode and refers to AlCamera objects only. The shape, position and/or orientation of the object referred to is defined by combining the transformations for the dag node with all the transformations inherited from the dag nodes above it in the dag. There is a method for obtaining the global tranformation matrix, which is built from the local transformations and all inherited transformations. For example, if dag node A is a parent of dag node B which is a parent of dag node C, then the global transformation of C is the matrix product [C]*[B]*[A], where [C], [B], and [A] are local transformations of each dag node.
A dag node can have some user-defined text associated with it and so there are methods for getting and setting the text.
Users cannot instantiate an AlDagNode directly. A derived class of an AlDagNode must be instantiated and then if required the create() method of the class must be called. This will automatically insert the dag node into the dag as a parent-less node. A dag node can be moved so that it is a sibling of any dag node in the dag. Deleting a dag node removes the node from its list of siblings. For derived classes, deletion of a dag node will cause the deletion of the object that it refers to.
Since an AlDagNode simply contains transformations but does not refer to any transformable object, this class is of little practical use on its own. It is primarily an abstract base class from which other dag node classes are derived. NOTE that NULL dag nodes created in the Alias Interactive package are retrieved by this library as group nodes without children.
What does a transformation matrix mean? This matrix is the product of matrices for scale, rotate and translate. One useful piece of information from this matrix is the POSITION of an object. The first three values in the bottom row of the matrix (indices (3,0), (3,1), and (3,2)) represent the translation of the origin (0,0,0) in the x, y, and z directions. For instance, if you placed a sphere at (20, 30, 16) in the Alias interactive package, then moved it to (-30, 16, 28), you would notice that its global transformation matrix would have (-30, 16, 28) in the bottom row.
Additionally, AlDagNode includes AlCopyOptions as a nested class. This class allows for the querying and setting of options for AlDagNode::copyObject(). When first instantiated, an instance of AlCopyOptions will have its values set according to the values in Edit->Duplicate Object option box. It is not possible to set the values in this option box through this class.
NOTE:
Plug-ins or OpenModel applications may have compile errors with the AlDagNode.h header file under IRIX 5.3.
You may experience a compile problem with the nested class 'AlCopyOptions'. The nested class problem has been fixed in patch 894 for the IRIX 5.3 C++ compiler available from SGI. This problem does not occur under IRIX 6.2.
sInsufficientMemory - if not enough memory available
sFailure - could not complete request.
sFailure - the dag node could not be deleted
sInvalidObject - the dag node was not valid
sInvalidArgument - newName was NULL
sFailure - the request could not be completed.
sInvalidObject - the dag node was invalid
sNameChangedToUniqueOne - name was changed to be a unique version of the given name
sInvalidArgument - 'sibling' was invalid or NULL
sFailure - the AlDagNode could not be made a sibling of this object
sInvalidObject - the dag node was invalid
boolean AlDagNode::isInstanceable()
Note that the comment is NOT a null terminated string.
> data - address of the block of text
sInvalidObject - the given object is not valid
> size - number of characters in the block of text
> data - address of the block of text
sInvalidObject - the given object is not valid
> id - a copy of the AlPersistentID
sInvalidObject - the given object is not valid
sFailure - node does not have a persistent ID.
sInvalidObject - the given object is not valid
< data - address of the block of text
sInsufficientMemory - not enough memory sInvalidObject - the given object is not valid
< size - number of characters in the block of text
< data - address of the block of text
sInsufficientMemory - not enough memory sInvalidObject - the given object is not valid
sFailure - there was no comment to remove sInvalidObject - the given object is not valid
sFailure - no such blind data existed sInvalidObject - the given object is not valid
sInvalidArgument - matrix was NULL.
sFailure - The request could not be completed.
sInvalidObject - the dag node was invalid
local transform = T1 * T2 * T3 * T4 * T5 * T6 * T7 * T8 * T9
- (T1) translation by x,y,z of scalePivotIn vector
- (T2) scale by x,y,z of scale vector
- (T3) translation by x,y,z of scalePivotOut vector
- (T4) translation by x,y,z of rotatePivotIn vector
- (T5) x-axis rotation by x component of rotation vector
- (T6) y-axis rotation by y component of rotation vector
- (T7) z-axis rotation by z component of rotation vector
- (T8) translation by x,y,z of rotatePivotOut vector
- (T9) translation by x,y,z of translation vector
This order reflects the order in which a point would be transformed by each transformation. When setting and querying the rotate pivot and the scale pivot, you only need to worry about setting the pivot in world space. The methods setRotatePivot() and setScalePivot() will calculate the corresponding In and Out transformations (T1,T3,T4,T8).
sInvalidArgument - matrix was NULL.
sFailure - The request could not be completed.
sInvalidObject - the dag node was invalid
sInvalidArgument - matrix was NULL.
sInvalidObject - this DagNode is invalid.
Arguments
> matrix - the matrix to contain the global transformation Return codes
sSuccess - the global transformation matrix was computed statusCode AlDagNode::inverseGlobalTransformationMatrix( AlTM& matrix ) const
Description
Computes the inverse of the global transformation matrix for the object, which is obtained by post-multiplying the local transformation matrix with the global transformation matrix of the parent AlGroupNode. This version of the function takes an AlTM matrix instead of a 4x4 matrix of doubles. You will want to use this method to transform normals. There is a routine in AlTM called AlTM::transNormal, however it may not be numerically stable. Normals are transformed by the equation n' = n * trans(inv(M)). To transform a normal (nx,ny,nz), the following code fragment can be used:AlTM invTM;
dagNode->inverseGlobalTransformMatrix( invTM );
invTM.transpose().transVector( nx, ny, nz );
Arguments
> matrix - the matrix to contain the global transformation Return codes
sSuccess - the global transformation matrix was computed statusCode AlDagNode::inverseGlobalTransformationMatrix( double matrix[4][4] ) const
Description
Computes the inverse of the global transformation matrix for the object, which is obtained by post-multiplying the local transformation matrix with the global transformation matrix of the parent AlGroupNode. For more information, see the AlDagNode class description.
Arguments
> matrix - the matrix to contain the global transformation Return codes
sSuccess - the global transformation matrix was computed statusCode AlDagNode::affectedTransformationMatrix( const AlTM& tm, AlTM& matrix ) const
Description
Computes the transformation matrix for the object, which is obtained by post-multiplying the local transformation matrix with the given AlTM 'tm'. Arguments
< tm - the transformation matrix generated while walking the dag. Return codes
sSuccess - the transformation matrix was computed statusCode AlDagNode::affectedTransformationMatrix( const AlTM& tm, double matrix[4][4] ) const
Description
Computes the transformation matrix for the object, which is obtained by post-multiplying the local transformation matrix with the given AlTM. Arguments
< tm - the transformation matrix generated while walking the dag. Return codes
sSuccess - the transformation matrix was computed statusCode AlDagNode::translation( double &x, double &y, double &z ) const
Description
Get the final local translation vector. Arguments
> x, y, z - components of the translation vector Return codes
sSuccess - the final local translation vector was returned statusCode AlDagNode::rotation( double &x, double &y, double &z ) const
Description
Get the amount of rotation (in degrees ) about the x, y, and z axes. Arguments
> x, y, z - amount of rotation about the x, y, z axis Return codes
sSuccess - the rotation was returned statusCode AlDagNode::scale( double &x, double &y, double &z ) const
Description
Get the amount of scale in the x, y, and z direction. Arguments
> x, y, z - components of the scale transformation Return codes
sSuccess - the scale amount was returned statusCode AlDagNode::rotatePivot( double &x, double &y, double &z ) const
Description
Returns the rotate pivot position in world space. The rotate pivot is the point about which rotations take place. For more information, see the description for the method localTransformationMatrix(). Arguments
> x, y, z - components of the translation vector Return codes
sSuccess - the rotate pivot was returned statusCode AlDagNode::scalePivot( double &x, double &y, double &z ) const
Description
Returns the scale pivot position in world space. The scale pivot is the point about which scaling take place. For more information, see the description for the method localTransformationMatrix(). Arguments
> x, y, z - components of the translation vector Return codes
sSuccess - the scale pivot was returned statusCode AlDagNode::doUpdates( boolean newState )
Description
The doUpdate flag is used to notify the system that you are finished performing. If this flag is true, it is equivalent to sending out a 'geometry modified' message to the rest of the system. When the system receives the update message, operations such as construction history, etc. are performed. This feature is important when using construction history plug-ins. Construction history plug-ins should always set the doUpdate flag to FALSE when performing updates (otherwise an infinite update loop will result, usually ending in a core dump). The update can be explicitly forced using the AlDagNode::sendGeometryModifiedMessage() method. This flag DOES NOT UPDATE THE SCREEN. Use the AlUniverse::redrawScreen to perform the screen refresh. If the previous state of the flag was FALSE and the new state is TRUE, an update will be performed at this point and on each subsequent dag modification. Return codes
sSuccess - the new state was set statusCode AlDagNode::setTranslation( double x, double y, double z )
Description
Set the final local translation vector. The translation transformation will be done after rotations. Arguments
< x, y, z - components of the translation vector Return codes
sSuccess - the final local translation vector was set statusCode AlDagNode::setWorldTranslation( double x, double y, double z )
Description
Set the final world translation vector (by appropriately modifying the local translation). Arguments
< x, y, z - components of the translation vector Return codes
sSuccess - the final local translation vector was set statusCode AlDagNode::sendGeometryModifiedMessage()
Description
Sends out an update message notifying that the geometry of this dagNode has been modified. This function is intended to be used after a series of geometry changes have been performed with the 'doUpdate' parameter set to FALSE. Note that updates should not be performed during construction history plug-ins (an infinite loop will result). Return codes
sSuccess - the message was sent statusCode AlDagNode::setRotation( double x, double y, double z )
Description
Set the amount of rotation (in degrees ) about the x, y, and z axes. The rotations will be done after the scale transformation and before the final local translation. See setTranslation for notes on doUpdate. Arguments
< x, y, z - amount of rotation about the x, y, z axis Return codes
sSuccess - the amount of rotation was set statusCode AlDagNode::setScale( double x, double y, double z )
Description
Set the local scale vector. The scale transformation will be done before the local rotations. There is no restriction on the values of the components of the scale vector. Arguments
< x, y, z - components of the scale transformation Return codes
sSuccess - the local scale vector was set statusCode AlDagNode::setRotatePivot( double x, double y, double z )
Description
Changes the rotate pivot to the world space position given by x, y, and z. The rotate pivot is the point about which rotations take place. Arguments
< x, y, z - components of the translation vector Return codes
sSuccess - the rotate pivot was set statusCode AlDagNode::setScalePivot( double x, double y, double z)
Description
Changes the scale pivot to the world space position given by x, y, and z. The scale pivot is the point about which scaling take place. Arguments
< x, y, z - components of the translation vector Return codes
sSuccess - the scale pivot was set statusCode AlDagNode::localRotationAxes( double x[3], double y[3], double z[3] ) const
Description
Returns vectors representing the local rotation axes for this node. These axes are the three axes vectors in world space co-ordinates. Arguments
> x, y, z - three vectors representing the 3 axes. Return codes
sSuccess - the local rotation axes were returned statusCode AlDagNode::setLocalRotationAxes(double x[3], double y[3], double z[3])
Description
Sets the local rotation axes of this dag node to the given world space vectors. Note that you must ensure that the three vectors x, y and z are orthogonal, otherwise you may get unpredictable results. Also, note that if they are orthogonal, that all three axes are not needed, and in fact this method does not use the z vector. Arguments
> x, y, z - three vectors representing the 3 axes. Return codes
sSuccess - the local rotation axes were returned statusCode AlDagNode::localRotationAngles( double& x, double& y, double& z ) const
Description
These angles allow you to determine how the local rotation axis have been rotated from their initial position. For example the x value indicates how much the y and z axes have been rotated about the x axis. Arguments
> x, y, z - rotation angles about the three axes. Return codes
sSuccess - the local rotation angles were returned statusCode AlDagNode::setLocalRotationAngles( double x, double y, double z )
Description
Setting the local rotation angles is the only means by which the local rotations axes can be modified. Each angle represents how much the other two axes are rotated about itself from their initial position. For example the value for x will determine how much the y and z axes are rotated about the x axis. Arguments
> x, y, z - rotation angles about the three axes. Return codes
sSuccess - the local rotation angles were set statusCode AlDagNode::localRotateBy(double x, double y,double z)
Description:
Perform a dag node rotation based on the setting of the local axes. This function is additive or relative. Rotations are applied against previous rotations. The current rotation in world space is returned by AlDagNode::rotation(). Parameters:
> x,y,z - amount to rotate by Return values
sSuccess - method succeeded statusCode AlDagNode::localTranslateBy(double x, double y,double z)
Description:
Perform a dag node translation based on the setting of the local axes. This function is additive or relative. Translations are applied against previous translations. The current translation in world space is returned by AlDagNode::translation(). Parameters:
> x,y,z - amount to translate by Return values
sSuccess - method succeeded statusCode AlDagNode::boundingBox( double corners[8][4] ) const
Description
Returns the eight corners of the bounding box in world space. These corners are exactly like the bounding boxes drawn in the interactive Alias package. This dag node must be in bounding box mode when this method is called. Arguments
> corners - a matrix to hold the eight corners of the bounding box. Each corner has an x, y, z and homogeneous component. Return codes
sSuccess - the bounding box was returned boolean AlDagNode::isDisplayModeSet( AlDisplayModeType mode ) const
Description
Returns TRUE if the specified display mode is toggled on for the dag node. Returns FALSE otherwise.
The only valid AlDisplayModeTypes for an AlDagNode are
< on_or_off - TRUE means that this dag node will have the display mode set. FALSE means it will be unset.
sInvalidArgument - invalid display type.
sInvalidObject - the dag node was invalid
sFailure - the display mode could not be set
sInvalidObject - this DagNode is invalid.
sInvalidObject - this DagNode is invalid.
sInvalidObject - this DagNode is invalid.
sInvalidObject - this DagNode is invalid.
sInvalidObject - the dag node was invalid
sFailure - if it wasn't possible to to add an AlJoint.
sInvalidObject - the dag node was invalid
sFailure - if it wasn't possible to remove the AlJoint.
sInvalidObject - the dag node was invalid
sFailure - this call is not valid in OpenModel
sInvalidObject - the AlCopyOptions object was not properly created.
sInvalidObject - the AlCopyOptions object was not properly created.
sInvalidObject - the AlCopyOptions object was not properly created.
sInvalidObject - the AlCopyOptions object was not properly created.
sInvalidArgument - control was not one of the three possibilities.
sInvalidObject - the AlCopyOptions object was not properly created.
sInvalidArgument - control was not one of the three possibilities.
sInvalidObject - the AlCopyOptions object was not properly created.
sInvalidObject - the AlCopyOptions object was not properly created.
sInvalidObject - the AlCopyOptions object was not properly created.
sInvalidObject - the AlCopyOptions object was not properly created.
sInvalidObject - the AlCopyOptions object was not properly created.
sInvalidObject - the AlCopyOptions object was not properly created.
sInvalidObject - the AlCopyOptions object was not properly created.
sInvalidObject - the AlCopyOptions object was not properly created.