Encapsulates the retrieval, data access and storage of Alias Wire Files.
#include <AlUniverse.h>
class AlUniverse : public AlMessage
enum AlFileType {
kUnknown, // File type is unknown and will be ignored by ::retrieve().
kWire, // Autodesk Wire File
kIges, // Initial Graphics Exchange Standard
kVdais, // Verband Der Automobilindustrie IGES Subset
kC4x, // EDS/GM format.
kJamais, // Japan Automobile Manufacturers Association IGES Subset.
kVdafs, // Verband Der Automobilindustrie Freeform Surface Interface.
kDxf, // Drawing Exchange Format
// The file types below are available only in OpenAlias.
kDes, // EDS/GM Data Exchange Standard
kTri, // Autodesk Object Separated Triangle Format
kQuad, // Autodesk Object Separated Quad Format
kProRender, // Pro/Engineer Render File Format.
kInventor, // OpenInventor Metafile Subset V1.0
kStl, // 3D Systems SLA Format
kObj, // Autodesk TAV format.
kEpsf, // Adobe Encapsulated Postscript v2.x
kIllustrator, // Illustrator Format.
kSlc // 3D Systems Slice Format.
};
// Project subdirectory types.
// These indicate the subdirectories where different types of files are
// located.
enum AlDirectoryType {
kAnimData, // Animation data (Save Anim / Retrieve Anim)
kCanvasData, // Paint canvas files
kDepthData, // Depth files
kEnvironmentData, // Environment files (saved/retrieved via
// multi-lister)
kLightData, // Light files (saved/retrieved via multi-lister)
kMaskData, // Mask files
kMiscData, // Miscellaneous data files: color, window and so on.
kOptionData, // UI option files
kPixData, // Image files for file textures, image planes and so on.
kPlotData, // Plot files
kRibData, // Pixar RIB files
kSlaData, // Stereo Lithography files (.stl, .slc, .tri)
kSdlData, // Scene Description Files
kShaderData, // Shader files (saved/retrieved via multi-lister)
kStageData, // Wire files representing stages.
kTextureData, // Texture files (saved/retrieved via multi-lister)
kWireData // Wire files an CAD files (for example, IGES, DXF, and so on.)
};
enum AlApplicationMode
{
kOpenModel,
kOpenAlias
};
enum AlLayerSortMode{
kLayerNumber,
kLayerName
};
static statusCode initialize( AlCoordinateSystem = kZUp,
boolean initProjectEnv = FALSE );
static boolean isInitialized();
static AlCoordinateSystem coordinateSystem ();
static statusCode expandFileName( char[], const char *,
AlDirectoryType directoryType );
static boolean isWireFile( const char *, char * );
static boolean AlUniverse::isOldWireFile( const char *fileName );
static statusCode wireFileWindowSize( int &sizeX, int &sizeY );
static statusCode setWireFileWindowSize( int sizeX, int sizeY );
static AlFileType fileType( const char * );
static statusCode retrieveOptions( AlRetrieveOptions& );
static statusCode setRetrieveOptions( const AlRetrieveOptions& );
static statusCode retrieve( const char * );
static statusCode retrieve( const char *, void(*)(int) );
static const char* lastWireFileRetrieved();
static const char* lastFileSaved();
static statusCode store( const char *, AlDagNode* = NULL );
static statusCode storeActive( const char * );
static AlDagNode* firstDagNode();
static AlSet* firstSet();
static AlCluster* firstCluster();
static const char* currentStage( void );
static statusCode setCurrentStage( const char* );
static statusCode mergeStage( const char* );
static statusCode mergeAllStages( void );
static statusCode deleteStage( const char* );
static statusCode deleteAllStages( void );
static statusCode stageVisibility( const char *, boolean& );
static statusCode setStageVisibility( const char *, boolean );
static const char* stageWindowSource( void );
static statusCode setStageWindowSource( const char * );
static const char* stageBackgroundSource( void );
static statusCode setStageBackgroundSource( const char * );
static statusCode renameStage( const char *, const char * );
static AlList* stageNames( void );
static statusCode createNewStage( const char *, char*& );
static statusCode retrieveStageSet( const char *,boolean );
static statusCode saveStageSet( const char *);
static statusCode setStageWireFileName( const char *, const char * );
static const char* stageWireFileName( const char * );
static AlWindow* firstWindow();
static AlWindow* currentWindow();
static AlWindow* sbdWindow();
static AlImagePlane* firstImagePlane();
static statusCode blindData( int, long&, const char*& );
static statusCode blindData( int, int, long&, const char*& );
static statusCode setBlindData( int, long, const char* );
static statusCode removeBlindData( int );
static statusCode removeBlindData( int, int );
static AlChannel* firstChannel();
static AlChannel* nextChannel(AlChannel *);
static statusCode nextChannelD( AlChannel *);
static AlAction* firstAction();
static AlAction* nextAction(AlAction *);
static AlShader* firstShader();
static AlShader* nextShader( AlShader* );
static statusCode nextShaderD( AlShader* );
static AlEnvironment* firstEnvironment();
static AlLayer* firstLayer();
static AlLayer* nextLayer( AlLayer* );
static statusCode nextLayerD( AlLayer* );
static AlLayer* layerByNumber(int);
static AlLayer* creationLayer();
static statusCode setCreationLayer(AlLayer *);
static boolean layersEnabled();
static statusCode setLayersEnabled( boolean );
static statusCode sortLayersInLayersBar(AlLayerSortMode);
static AlPerspectiveCamera* firstCamera();
static AlPerspectiveCamera* nextCamera( AlPerspectiveCamera* );
static statusCode nextCameraD( AlPerspectiveCamera* );
static AlLocator* firstLocator();
static AlLocator* nextLocator(AlLocator *);
static statusCode deleteAll();
static statusCode deleteAllLocators();
static AlConstructionEntity* firstConstructionEntity();
static AlConstructionEntity* nextConstructionEntity(AlConstructionEntity *);
static statusCode nextConstructionEntityD(AlConstructionEntity *);
static statusCode deleteAllConstructionEntities();
static statusCode importCloudFile( const char *, int );
static AlCloud *firstCloud();
static int numberOfClouds();
static AlBlendCurve* firstBlendCurve();
static int numberOfBlendCurves();
static statusCode redrawScreen( unsigned int flags = kRedrawInactive | kRedrawActive );
static statusCode applyIteratorToImagePlanes( AlIterator*, int& );
static statusCode applyIteratorToWindows( AlIterator *, int& );
static statusCode applyIteratorToDagNodes( AlIterator *, int& );
static statusCode applyIteratorToActions( AlIterator *, int& );
static statusCode applyIteratorToChannels( AlIterator *, int& );
static statusCode applyIteratorToSets( AlIterator *, int& );
static statusCode applyIteratorToClusters( AlIterator *, int& );
static statusCode applyIteratorToShaders( AlIterator *, int& );
static statusCode applyIteratorToLocators(AlIterator *, int &);
static statusCode applyIteratorToLayers(AlIterator *, int &);
static statusCode applyIteratorToClouds(AlIterator *, int &);
static statusCode applyIteratorToBlendCurves(AlIterator *, int &);
static statusCode writeSDLNoAnimation( const char *, boolean );
static statusCode writeSDL( const char *, boolean, double, double, double );
static statusCode frameRange(AlFrameRangeType, double&, double&, double&);
static double currentTime();
static statusCode doUpdates( boolean = TRUE );
static boolean updatesOn()
static AlApplicationMode applicationMode();
static statusCode userPrefColor( int, int&, int&, int& );
static statusCode setUserPrefColor( int, int, int, int );
static boolean constructionPlaneInEffect();
static statusCode constructionPlaneTransform( AlTM& );
static AlCategory *firstCategory();
static AlCategory *nextCategory(AlCategory *);
This is a static class in that all of its member functions are static. It provides the foundation on which to interface with Alias Wire Files (OpenModel) or with Alias directly (via OpenAlias).
In Alias, there is the concept of a ’stage’, an independent entity that encapsulates all the top-level information about a modeling environment. The stage effectively represents the running version of an individual Wire file. In the interactive package, stages can be controlled through the Stage Editor. The identical control also exists in the AlUniverse class, via the Stage functions. These let you switch between stages, create and destroy stages, merge stages, and alter their features.
OpenAlias and OpenModel use object data that defines, among other things, transformations, curve and surface geometry, cameras, and lights. Transformations are kept in objects called "DAG nodes". DAG nodes can be connected to other DAG nodes to form a list of DAG nodes. There are particular types of DAG nodes which refer specifically to geometry, cameras, lights, or refer to another list of DAG nodes to form a hierarchical structure. Together, these different types of DAG nodes can be used to build a list of hierarchical structures which is collectively called a directed acyclic graph or "DAG".
The AlUniverse class gives access to the first DAG node in the DAG, and from that DAG node, the list of all DAG nodes in the universe can be traversed.
The object data may also contain animation information on various animatable items, such as a DAG node or a piece of geometry. The animation information can be accessed through the item that is animated. The AlUniverse class also gives access to animation data through global lists.
Geometry also contains shading information. Each surface or face (a particular kind of curve) contains a list of shaders. The AlUniverse class also gives access to a global list of all shaders in the universe, as well as the single environment class.
The AlUniverse class also gives access to the list of sets in the universe via the firstSet() method. Similarly, the firstCluster() method gives access to all the clusters in the universe. However, clusters are also accessible through methods in the classes that can belong to clusters (that is, AlDagNode, AlCurveCV and AlSurfaceCV). A cluster is an object in the DAG that has a collection of DAG nodes and/or CVs. The transformations in the DAG nodes above the cluster are applied to the CVs in the cluster after the latter’s own transformations have been applied.
AlUniverse provides base access to the ImagePlane list and the Window list through firstImagePlane(), firstWindow() and related functions.
Whenever a new Alias object of any kind is created, it is added to the appropriate place in the universe. For example, if a DAG node is created, it is traversable through the AlUniverse::firstDagNode() method. If a new animation action is created, it is accessible by walking the list of actions via AlUniverse::firstAction()/nextAction().
However, there are a few exceptions. The AlCurve, AlFace, AlSurface and AlKeyframe classes can all be created and will not be part of the universe initially. They will become part of the universe when they are added to other objects. For example, an AlCurve becomes part of the universe when its AlCurveNode is created. An AlKeyframe becomes part of the universe when its AlParamAction is created. If a class is not part of the universe, this means that if AlUniverse::store() is called, that class will not be stored. If an OpenAlias plug-in exits without making an object part of the universe, then the data will be lost and wasted memory will result.
The initialize method must be called before any other AlUniverse method is called. A Alias AlObject cannot be created until the initialize method is called.
statusCode AlUniverse::doUpdates( boolean newState )
Notifies the system that you are finished performing. If this flag is TRUE, then it is equivalent to sending out a ’geometry modified’ message to the rest of the system. When the system receives the update message, then operations such as construction history, and so on are done. If the previous state of the flag was FALSE and the new state is TRUE, then an update will be done now and on each subsequent DAG modification.
statusCode AlUniverse::initialize( AlCoordinateSystem up, boolean initProjectEnv )
Initializes the OpenAlias/OpenModel environment so that Alias object data can be retrieved, created, and/or stored. The world space coordinate system of the Universe can be oriented so that either the positive Y-axis or positive Z-axis is considered the "up" direction. This method will do nothing if called more than once. By default OpenModel applications are not aware of the Alias project environment (for example, user_data/demo/wire etc). By passing TRUE as the second argument, the OpenModel application will become aware of the Alias project environment, expect such an environment to exist, and will use it for locating files. The .Alias* setup files will be read and processed. However, unlike Alias, when the OpenModel application starts, if the project environment does not exist, it will not be created, and the application will proceed in the default manner. Note that the arguments have no effect when initialization occurs under OpenAlias. That is, the world space coordinate system and the project environment are determined by the running Alias application.
< up - indicates whether the y-axis (kYUp) or z-axis (kZUp) should be the up direction. If no argument is specified, the default is kZUp. This parameter has no effect when using OpenAlias.
< initProjectEnv - indicates whether the OpenModel application is to be aware of the Alias project environment or not. The default if FALSE.
statusCode AlUniverse::expandFileName( char expandedName[], const char *fileName, AlDirectoryType directoryType )
Given a filename, expands to an absolute pathname based on the file’s type and Alias project environment.
> expandedName - location to return expanded filename.
< fileName - name of the file to locate within the project environment. Must not contain leading slashes or dots.
< directoryType - the type of project subdirectory where the file is located. (See AlUniverse.h for possible values.
sSuccess - the fully expanded name was successfully constructed and the file exists
sInvalidArguments - the passed filename is already absolute (contains leading ’/’), or is relative (contains
leading ’..’), or the directory type is invalid
sNoProjectEnvironment - the returned path does not exist. This may be because the Alias project environment does not exist in whole or in part.
SFailure - either or both passed names were NULL
statusCode AlUniverse::wireFileWindowSize( int &sizeX, int &sizeY )
statusCode AlUniverse::setWireFileWindowSize( int sizeX, int sizeY )
boolean AlUniverse::isWireFile( const char *fileName, char * vbuf )
Determines if a file is an Alias wire file and finds the version number.
Note: vbuf must be allocated and at least 8 characters.
AlUniverse::AlFileType AlUniverse::fileType( const char *fileName )
kUnknown - file type is unknown and will be ignored by ::retrieve().
The file types listed below are available for import in both OpenModel and OpenAlias.
kWire |
Autodesk Wire File |
kIges |
Initial Graphics Exchange Standard |
kVdais |
Verband Der Automobilindustrie IGES Subset |
kC4x |
EDS/GM format |
kJamais |
Japan Automobile Manufacturers Association IGES Subset |
kVdafs |
Verband Der Automobilindustrie Freeform Surface Interface |
kDxf |
Drawing Exchange Format |
kStl |
3D Systems SLA Format |
The file types listed below are available for import only in OpenAlias.
kDes |
EDS/GM Data Exchange Standard |
kTri |
Autodesk Object Separated Triangle Format |
kQuad |
Autodesk Object Separated Quad Format |
kProRender |
Pro/Engineer Render File Format |
kInventor |
OpenInventor Metafile Subset V1.0 |
kObj |
Autodesk TAV format |
kEpsf |
Adobe Encapsulated Postscript |
kIllustrator : |
Illustrator Format |
kSlc |
3D Systems Slice Format |
statusCode AlUniverse::retrieve( const char *fileName )
Retrieves an Alias Wire file and adds the objects stored in the file to the list of Alias AlDagNode objects. If fileName is NULL the file is read from stdin.
Note that if sInvalidWireFile is returned you are likely trying to retrieve a newer wire file than your application recognizes. In this case you should link your application with the OpenModel library distributed with the newer Alias.
statusCode AlUniverse::retrieve( const char *fileName,void(*progressCallback)(int) )
This method is a variation of the AlUniverse::retrieve(const char *) method with the addition that it allows a retrieve progress callbackto be set.
NOTES:
1. The function progressCallback() should be in the C name space within an extern "C" block.
2. The ’int’ number passed to the progress callback is expressed as a percentage value between 0 and 100. This number is a close approximation of the retrieval progress and will not be exact due to compression usedin the Alias wire file format.
statusCode AlUniverse::store( const char * fileName, AlDagNode* dagNode )
If the AlDagNode argument is absent or NULL then this method stores all the AlObjects in the universe to a file as an Alias Wire file. If the AlDagNode argument is not NULL then only the model below the AlDagNode is stored. If the AlDagNode is in the middle of a hierarchy, the AlDagNodes above the argument will also be stored so as to preserve transformations on the model.
statusCode AlUniverse::stageVisibility( const char *name, boolean& on_or_off )
statusCode AlUniverse::setStageWindowSource( const char *name )
statusCode AlUniverse::setStageBackgroundSource( const char *name )
statusCode AlUniverse::renameStage( const char* oldName, const char *newName )
statusCode AlUniverse::createNewStage( const char* name, char*& stagename )
Creates a new stage and sets the current stage to the new stage. The name assigned to the stage is returned in stagename. Access to stagename is important when stage names are reused and a new unique name is selected. Note that stagename will be assigned to something that can change through calls in the API. So caution must be taken when using stagename in future calls.
In addition, what stagename points to must not be modified since it is internal Alias data.
statusCode AlUniverse::retrieveStageSet( const char *stageSet, boolean deleteStages )
statusCode AlUniverse::setStageWireFileName( const char *stageName, const char *wireFileName )
const char* AlUniverse::stageWireFileName( const char *stageName )
statusCode AlUniverse::applyIteratorToWindows( AlIterator *iter, int& rc )
statusCode AlUniverse::applyIteratorToImagePlanes( AlIterator* iter, int& rc )
statusCode AlUniverse::blindData( int type, long& size, const char*& ptr )
Retrieves the blind data for the universe. If there is no data, the size will be 0 and the pointer will be NULL.
statusCode AlUniverse::blindData( int type, int index, long& size, const char*& ptr )
Retrieves the blind data for the universe. If there is no data, the size will be 0 and the pointer will be NULL
NOTE: If universes are merged then the resulting universe will have blind data for both universes. If there are two or more blind data packets with the same "type", the parameter 'index' can be used to access them.
statusCode AlUniverse::setBlindData( int type, long size, const char* ptr )
Associates a block of data with the object. If a block of data is already associated with this object and this user_type, the old block is replaced by a reference to the new block. The old block of data is not deleted.
AlPerspectiveCamera* AlUniverse::nextCamera( AlPerspectiveCamera* curCamera )
statusCode AlUniverse::nextCameraD( AlPerspectiveCamera* curCamera )
AlConstructionEntity* AlUniverse::nextConstructionEntity(AlConstructionEntity *curConstructionEntity)
statusCode AlUniverse::nextConstructionEntityD(AlConstructionEntity *ce)
statusCode AlUniverse::sortLayersInLayersBar(AlLayerSortMode sortMode)
statusCode AlUniverse::importCloudFile( const char *fileName, int samplingFactor)
statusCode AlUniverse::redrawScreen( unsigned int flags )
Redraws the modeling windows. Use it after you have completed an operation to see the results. Different parts of the display can be selectively updated by performing a bitwise OR of the following flags:
To redraw everything use the following flag:
This routine succeeds in OpenAlias and fails in OpenModel.
statusCode AlUniverse::applyIteratorToDagNodes( AlIterator* iter, int& rc )
statusCode AlUniverse::applyIteratorToActions( AlIterator* iter, int& rc )
statusCode AlUniverse::applyIteratorToChannels( AlIterator* iter, int& rc )
statusCode AlUniverse::applyIteratorToSets( AlIterator* iter, int& rc )
statusCode AlUniverse::applyIteratorToClusters( AlIterator* iter, int& rc )
statusCode AlUniverse::applyIteratorToShaders( AlIterator* iter, int& rc )
statusCode AlUniverse::applyIteratorToLocators(AlIterator *iter, int &rc)
statusCode AlUniverse::applyIteratorToLayers( AlIterator* iter, int& rc )
statusCode AlUniverse::applyIteratorToClouds( AlIterator* iter, int& rc )
statusCode AlUniverse::applyIteratorToBlendCurves( AlIterator* iter, int& rc )
statusCode AlUniverse::writeSDLNoAnimation( const char *filename, boolean store_active )
This method outputs an SDL file for the entire universe if store_active is FALSE. If it is TRUE, then only the active objects in the current universe will be output to a file. In either case no animation will be output; the scene is evaluated at the current view frame which can be set using the AlViewFrame class methods.
statusCode AlUniverse::writeSDL( const char *filename, boolean store_active, double start, double end, double by )
This method outputs an SDL file for the entire universe if store_active is FALSE. If it is TRUE, then only the active objects in the current universe will be output to a file. Animation will be written to the SDL file for the frame range given. If 'by' is zero then only a single frame will be output.
statusCode AlUniverse::frameRange(AlFrameRangeType rangeType, double &start, double &end, double &by)
Determines the frame range for the current universe. The range type can be one of kFromPreviewWindow (gets the value from the Preview window, either kMinMax or kGlobal; based on the choice in the preview window - this is undefined for OpenModel), kMinMax (gets the actual start and end as defined by the animaiton on the objects), and kGlobal (gets the values entered by the user - again, undefined for OpenModel).
statusCode AlUniverse::userPrefColor( int colorField, int &r, int &g, int &b)
statusCode AlUniverse::setUserPrefColor( int colorField, int r, int g, int b)
statusCode AlUniverse::constructionPlaneTransform( AlTM &tm )
AlCategory* AlUniverse::nextCategory(AlCategory *curCategory)