Basic Interface to Alias DAG node objects.
#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 );
AlDagNode* copyObject( AlCopyOptions*, int, int * );
virtual AlObjectType type() const;
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( AlPersistentID *&, int );
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;
AlLayer* layer() const;
statusCode setLayer( const AlLayer * );
boolean isAConstructionPlane();
AlList* clusterPreTransformationMatrices() const;
statusCode createSymmetricGeometry();
statusCode createSymmetricGeometry( AlDagNode *& );
unsigned int version( void ) const;
class AlCopyOptions
AlCopyOptions();
virtual ~AlCopyOptions();
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 );
This class encapsulates the basic functionality for creating, manipulating and deleting a DAG node. A DAG node is part of a tree-like hierarchical structure known as a directed acyclic graph or DAG. All DAG nodes belong to a single DAG which is contained in the current universe. The head of the DAG is accessible by calling the AlUniverse::firstDagNode() static method.
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.
A DAG node contains information that 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 transformation 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 transformation 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 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.
statusCode AlDagNode::deleteObject()
Destructor for AlDagNode. The entire DAG branch rooted at this node will be deleted. For each delete DAG node its animation will be deleted and the DAG node will be removed from all clusters or sets it is in. Some DAG nodes cannot be deleted (for example, AlTextureNodes), in which case this method will return sFailure.
AlDagNode *AlDagNode::copyObject( AlCopyOptions* options )
Copies this AlDagNode returning a pointer to the new copy. If "options" is not NULL then the given copy options will be used in making copies, otherwise the options as they exist in the Duplicate object option box will be used. If multiple copies are made, a reference to the last copy will be returned. AlUniverse::redrawScreen() must be called once the copy is complete to see the results.
statusCode AlDagNode::addSiblingNode( AlDagNode *sibling )
Inserts an AlDagNode as the next sibling of this AlDagNode object. If the AlDagNode is already a sibling of this object, then nothing is done and the AlDagNode is left where it is in the list of siblings. Otherwise, the AlDagNode is removed from the list of siblings it belongs to and added to the list of siblings for this object. If the AlDagNode is an AlGroupNode and it has siblings which are instanced AlGroupNodes, those instanced siblings are also made siblings of this object.
statusCode AlDagNode::comment( long &size, const char* &data )
statusCode AlDagNode::blindData( int user_type, long &size, const char* &data )
Obtains the size and address of a block of data associated with the object. If there is no data, then the size will be zero and the address of the data is NULL. User_types must be reserved. If you would like to reserve a block of "user_types" please contact us. User_types less than zero indicate that the blind data is not persistent. As such, when the model is stored, blind data with a negative user_type will not be stored.
statusCode AlDagNode::persistentID( AlPersistentID *&id, int userType )
statusCode AlDagNode::setPersistentID( AlPersistentID &id, int userType )
Sets the values of the AlPersistentID associated with this node. This method only allows you to create persistent IDs with user types other than 1. If the persistent ID does not exist, it will be created.
User types between 0 and 9999 are reserved. If you would like to reserve a block of user types please contact us.
statusCode AlDagNode::setComment( long size, const char* data )
Associates a block of textual data with the object. If a block of text is already associated with the object, the reference to the old block of text is replaced by a reference to the new block of text. The old block of text is not deleted. It is up to the user to manage the deletion of the old block of text.
statusCode AlDagNode::setBlindData( int user_type, long size, const char* data )
Associates a block of data with the object. If a block of data is already associated with the object, the reference to the old block of data is replaced by a reference to the new block of data. The old block of data is not deleted. It is up to the user to manage the deletion of the old block of data. The user_type may be user defined to add more than one blind data block to any one object (see blindData() above for additional information).
statusCode AlDagNode::localTransformationMatrix( AlTM& matrix ) const
statusCode AlDagNode::localTransformationMatrix( double matrix[4][4] ) const
Computes the local transformation matrix for the object. The matrix is oriented such that to transform a point, the point must be pre-multiplied by the matrix. The local transformation matrix is defined by seven triples which specify components for scale, rotation, and translation transformations. It is computed by doing the following transformations:
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).
statusCode AlDagNode::globalTransformationMatrix( AlTM& matrix ) const
statusCode AlDagNode::globalTransformationMatrix( double matrix[4][4] ) const
Computes 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.
statusCode AlDagNode::inverseGlobalTransformationMatrix( AlTM& matrix ) const
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 );
statusCode AlDagNode::inverseGlobalTransformationMatrix( double matrix[4][4] ) const
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.
statusCode AlDagNode::affectedTransformationMatrix( const AlTM& tm, AlTM& matrix ) const
Computes the transformation matrix for the object, which is obtained by post-multiplying the local transformation matrix with the given AlTM ’tm’.
statusCode AlDagNode::affectedTransformationMatrix( const AlTM& tm, double matrix[4][4] ) const
Computes the transformation matrix for the object, which is obtained by post-multiplying the local transformation matrix with the given AlTM.
statusCode AlDagNode::rotatePivot( double &x, double &y, double &z ) const
statusCode AlDagNode::scalePivot( double &x, double &y, double &z ) const
statusCode AlDagNode::doUpdates( boolean newState )
Notifies 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, and so on, are done. This feature is important when using construction history plug-ins. Construction history plug-ins should always set the doUpdate flag to FALSE when doing 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 do the screen refresh. If the previous state of the flag was FALSE and the new state is TRUE, an update will be done at this point and on each subsequent DAG modification.
statusCode AlDagNode::setTranslation( double x, double y, double z )
Sets the final local translation vector. The translation transformation is done after rotations.
This method takes advantage of the doUpdate mechanism to control whether updates happen immediately or are batched until the end of an operation.
NOTE: If this DAG node is a surface made from construction history, then the construction history will be broken. To find out if this surface is created by construction history, cast this DAG node to a surface. If it is a surface, call the method AlSurface::isConstructionHistoryResultingSurface().
statusCode AlDagNode::setWorldTranslation( double x, double y, double z )
statusCode AlDagNode::sendGeometryModifiedMessage()
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 done with the ’doUpdate’ parameter set to FALSE. Note that updates should not be done during construction history plug-ins (an infinite loop will result).
statusCode AlDagNode::setRotation( double x, double y, double z )
statusCode AlDagNode::setScale( double x, double y, double z )
statusCode AlDagNode::setRotatePivot( double x, double y, double z )
statusCode AlDagNode::setScalePivot( double x, double y, double z)
statusCode AlDagNode::localRotationAxes( double x[3], double y[3], double z[3] ) const
statusCode AlDagNode::setLocalRotationAxes(double x[3], double y[3], double z[3])
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.
statusCode AlDagNode::localRotationAngles( double& x, double& y, double& z ) const
statusCode AlDagNode::setLocalRotationAngles( double x, double y, double z )
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.
statusCode AlDagNode::localRotateBy(double x, double y,double z)
statusCode AlDagNode::localTranslateBy(double x, double y,double z)
statusCode AlDagNode::boundingBox( double corners[8][4] ) const
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 before this method is called.
boolean AlDagNode::isDisplayModeSet( AlDisplayModeType mode ) const
statusCode AlDagNode::setDisplayMode( AlDisplayModeType mode, boolean on_or_off)
For the given display mode, if the flag is TRUE then the display mode for the DAG node is set; otherwise it is unset.
The only valid AlDisplayModeTypes for an AlDagNode are
AlDagNode * AlDagNode::searchBelow( const char * name ) const
AlDagNode * AlDagNode::searchAcross( const char * name ) const
AlList* AlDagNode::clusterPreTransformationMatrices() const
Returns a list of AlClusterPreTMItem, which contains the transformation matrices of the geometry DAG node for clusters.
NULL is returned for non_leaf or null DAG nodes, or if a DAG node does not involve with any cluster.
Note: you must delete the AlList object.
AlDagNode *AlDagNode::copyObject( AlCopyOptions* options, int numOfBlindDataIDsToCopy, int *blindDataIDsToCopy )
This method is similar to the ::copyObject() method above. In addition, blind data IDs to be copied are specified with this method.
< - numOfBlindDataIDsToCopy contains the number of elements of array blindDataIDsToCopy[]
< - blindDataIDsToCopy is an array of IDs to copy
NULL will be returned if numOfBlindDataIDsToCopy < 1 or blindDataIDsToCopy is NULL.
Warning: we suggest only copying blind data IDs that are managed by your code. Copying blind data IDs out of your range may lead to program errors.
AlDagNode::AlCopyOptions::AlCopyOptions()
This constructor initializes the instance to the current Duplicate options, or in OpenModel to the defaults for the Duplicate operation.
By default, copies will be grouped with the original AlDagNode.
statusCode AlDagNode::AlCopyOptions::setInstanceCopy( boolean instance )
statusCode AlDagNode::AlCopyOptions::setCopyClusters( boolean clusters )
statusCode AlDagNode::AlCopyOptions::setParameterControl( AlParamControlType control )
statusCode AlDagNode::AlCopyOptions::setHierarchy( AlHierarchyType hier )