#include <AlPolyset.h>
class AlPolyset : public AlObject
AlPolyset();
virtual ~AlPolyset();
virtual statusCode deleteObject();
virtual AlObject* copyWrapper() const;
statusCode create();
virtual AlObjectType type() const;
virtual AlPolyset* asPolysetPtr();
AlPolysetNode* polysetNode() const;
int newVertex( double, double, double );
int newPolygon();
statusCode deleteVertex( int );
statusCode deletePolygon( int );
statusCode deletePolygons( int, const int[] );
AlPolysetVertex* vertex( int ) const;
statusCode vertexD( int, AlPolysetVertex& ) const;
AlPolygon* polygon( int ) const;
statusCode polygonD( int, AlPolygon& ) const;
int numberOfVertices() const;
int numberOfPolygons() const;
statusCode calcNormals( boolean );
statusCode verticesWorldPosition( double* ) const;
statusCode verticesAffectedPosition( AlTM&, double* ) const;
statusCode verticesUnaffectedPosition( double* ) const;
statusCode setVerticesUnaffectedPosition( double* );
// Modify vertex sharing information
//
statusCode mergeVertices( int flags,
double distanceTolerance,
double normalTolerance,
double textureTolerance );
statusCode splitVertices();
int numberOfShaderLists() const;
// For backwards compatibility, these first routines always deal with
// the first shader list
AlShader* firstShader() const;
AlShader* nextShader( AlShader* ) const;
statusCode nextShaderD( AlShader *) const;
statusCode assignShader( AlShader* );
statusCode layerShader( AlShader* );
// The following routines allow full access to potentially multiple
// shader lists per polyset. The first parameter is the list number.
AlShader* firstShader( int ) const;
AlShader* nextShader( int, AlShader* ) const;
statusCode nextShaderD( int, AlShader *) const;
statusCode assignShader( int, AlShader* );
statusCode renderInfo( AlRenderInfo & ) const;
statusCode setRenderInfo( AlRenderInfo& ) const;
boolean isDisplayModeSet( AlDisplayModeType ) const;
statusCode setDisplayMode( AlDisplayModeType, boolean );
boolean isFrozenNormals() const;
statusCode freezeNormals();
statusCode unFreezeNormals();
statusCode calcSTs();
statusCode blindData( int, long&, const char *& );
statusCode setBlindData( int, long, const char * );
statusCode removeBlindData( int );
statusCode applyIteratorToPolygons( AlIterator*, int& ) const;
statusCode applyIteratorToVertices( AlIterator*, int& ) const;
statusCode doUpdates( boolean newState = TRUE );
For more information on how to create the polyset geometry, see the description for the create() method.
A polyset is a collection of polygons that use a collection of vertices.
There are two ways to delete an AlPolyset.
If the AlPolyset::deleteObject() is called, the attached AlPolysetNode is deleted. If the AlPolysetNode::deleteObject() is called, the attached AlPolyset is deleted.
All AlPolyset objects have render information attached to them. The AlRenderInfo structure can be used to query the polyset's render parameters.
In addition, polysets may contains more than one list of shaders. These shaders are used to specify per-polygon shading.
Polysets are made of polygons and vertices, each of which you traverse as a list by using the polygon() and vertex() methods. The AlPolygon and AlPolysetVertex methods allow you to work with the individual polygons and vertices. You can also pack the polyset information into an array using methods in this class.
sFailure - they could not be deleted
sInvalidObject - the polyset was invalid
Polygons maintain their own arrays of vertices selected from the polyset's vertices.
When a polygon or a vertex is created, its index in the polyset's array is returned. This index is used to get pointers to the polygon or vertex through either of the polygon() or vertex() methods as appropriate.
The AlPolysetNode for this polyset is created by this method as well. It is available through the polysetNode() method. It is impossible to create a polyset without a polyset node.
sFailure - Polyset no longer active.
sInsufficientMemory - Ran out of memory.
sAlreadyCreated - the AlPolyset has already been created
sFailure - the polyset is inactive.
sInvalidObject - the polyset was invalid
Please note that when deleting several polygons, the polygon with the highest index should be deleted first, and the one with the lowest index should be deleted last.
For example, if you had three polygons, indexed 0, 1, and 2, and you were to delete them all starting at the lowest index, only two would actually be deleted. That is, on the first iteration, polygon 0 would be deleted and polygon 2 would be moved to index 0. On the second iteration, polygon 1 would be deleted, leaving one polygon with an index of 0. On the last iteration, an attempt would be made to delete polygon 2, but there would be no such polygon, so nothing would be deleted. In the end, one polygon would remain. However, if the deletion started with the greatest index, on the first iteration polygon 2 would be deleted. On the second iteration, polygon 1 would be deleted. And on the last iteration, polygon 0 would be deleted.
sInvalidArgument - The polygon doesn't belong to this AlPolyset.
sFailure - the polyset is inactive.
sInvalidObject - the polygon was invalid
< indices[] - the array of indices to delete
sInvalidArgument - 'indices' was NULL
sFailure - the polyset is inactive.
sInvalidObject - the polyset was invalid
sInvalidArgument - the vertex index was out of range
sInvalidObject - the polyset was invalid
sInvalidArgument - vertexList was NULL
sFailure - the polyset is inactive.
sInvalidObject - the polyset was invalid
> vertexList - contains all the vertices' unaffected positions upon return
sInvalidArgument - vertexList was NULL
sFailure - the polyset is inactive.
sInvalidObject - the polyset was invalid
sInvalidArgument - vertexList was NULL
sFailure - the polyset is inactive.
sInvalidObject - the polyset was invalid
statusCode AlPolyset::setVerticesUnaffectedPosition( double vertexList[] )
Description
Sets the unaffected positions of this polyset's vertices to the given array. The vertexList array must have the size [numberOfVertices * 3]. Arguments
< vertexList - contains all the vertices' unaffected positions Return code
sSuccess - The deletion succeeded. AlShader* AlPolyset::firstShader( int shaderlist ) const
Description
Returns the first shader that the specified shader list in this polyset references. Note that the index used MUST be defined in the polyset, and MUST be less than AL_MAX_SHADERS_PER_POLYSET (currently 64). Arguments
< shaderlist - Shader list to act on. AlShader* AlPolyset::firstShader() const
Description
Returns the first shader that the first shader list in this polyset references. AlShader* AlPolyset::nextShader( int shaderlist, AlShader* last_shader ) const
Description
Returns the shader after the given shader in the object's specified shader list. Returns NULL if there isn't a next shader. Specifying NULL as parameter will return the first shader in the specified shader list. Note that the index used MUST be defined in the polyset, and MUST be less than AL_MAX_SHADERS_PER_POLYSET (currently 64). Arguments
< shader_list - Shader list we are dealing with. statusCode AlPolyset::nextShaderD( int shaderlist, AlShader* last_shader ) const
Description
Destructively points last_shader to the shader after the given shader in the object's specified shader list. Returns sFailure if there isn't a next shader. Note that the index used MUST be defined in the polyset, and MUST be less than AL_MAX_SHADERS_PER_POLYSET (currently 64). Arguments
< shader_list - Shader list we are dealing with. Return codes
sSuccess - the wrapper last_shader points to the next shader AlShader* AlPolyset::nextShader( AlShader* last_shader ) const
Description
Returns the shader after the given shader in the object's first shader list. Returns NULL if there isn't a next shader. Specifying NULL as parameter will return the first shader in the first shader list. Arguments
< last_shader - Shader from which to walk forward statusCode AlPolyset::nextShaderD( AlShader* last_shader ) const
Description
Returns the shader after the given shader in the object's first shader list. Arguments
< last_shader - Shader from which to walk forward Return codes
sSuccess - the wrapper last_shader points to the next shader statusCode AlPolyset::assignShader( AlShader* shader )
Description
Assigns the given shader to the polyset. If the polyset already has shaders, they will be removed from the polyset. The polyset must have a polyset node for this method to succeed. Arguments
< shader - The shader which will be assigned to the polyset. Return codes
sSuccess - the shader was successfully assigned to the polyset. statusCode AlPolyset::assignShader( int shaderlist, AlShader* shader )
Description
Assigns the given shader to the polyset list. If the polyset list already has shaders they will be removed from the list. Note that the index used MUST be defined in the polyset, and MUST be less or equal to AL_MAX_SHADERS_PER_POLYSET (currently 64). To assign an additional shader to a polyset, specify the list number as one plus the current number of shader lists, as returned by the numberOfShaderLists() method. Note that it is only possible to layer shaders on the first shader list of a polyset. All other shader lists must contain only one shader. Arguments
< shaderlist - List to affect. Return codes
sSuccess - the shader was successfully assigned to the polyset. statusCode AlPolyset::layerShader( AlShader* shader )
Description
Layers the given shader on the polyset. The polyset must have a polyset node for this method to succeed. Note that it is only possible to layer shaders on the first shader list of a polyset. All other shader lists must contain only one shader. Arguments
< shader - The shader which will be layered on the polyset. Return codes
sSuccess - the shader was successfully layered on the polyset. statusCode AlPolyset::renderInfo( AlRenderInfo &renderInfo ) const
Description
Fills in the renderInfo structure with the render info for this polyset. If there wasn't any render information, the renderInfo is unchanged. Arguments
> renderInfo - the structure to fill in. Return code
sSuccess - if getting the render information was successful. statusCode AlPolyset::mergeVertices( int flags,double distanceTolerance,double normalTolerance,double textureTolerance )
Description
This routine processes the entire polyset, and based on the tolerances specified in the flags parameter, merges vertices so that they are shared between polygons. statusCode AlPolyset::splitVertices()
Description
This routine separates out all vertices from being shared into individual non-shared vertices per polygon. int AlPolyset::numberOfShaderLists() const
Description
This routine returns the number of shader lists associated with this polyset. Each shader list contains a list of shaders that may be used for rendering. The shader list used for rendering may be set on a per-polygon level. The default is the first (or list number 0). Additional lists may be created by assigning shaders to the n+1st shader list, where n is the number of shader lists currently in existance, as returned by the numberOfShaderLists() method. This method returns -1 if the polyset is invalid. statusCode AlPolyset::setRenderInfo( AlRenderInfo &renderInfo ) const
Description
Sets the render info for this surface to the contents of the renderInfo structure. Arguments
> renderInfo - the structure to take the render information from. Return code
sSuccess - if setting the render information was successful. boolean AlPolyset::isDisplayModeSet( AlDisplayModeType mode ) const
Description
Returns TRUE if the specified display mode is toggled on for the polyset. Returns FALSE otherwise, or if the object is not valid. Arguments
< mode - display mode of interest. statusCode AlPolyset::setDisplayMode( AlDisplayModeType mode, boolean on_or_off)
Description
For the given display mode, if the flag is TRUE, the display mode for the polyset is set; otherwise, it is unset. Arguments
< mode - display mode of interest. Return values
sSuccess - if this operation was successful. boolean AlPolyset::isFrozenNormals() const
Description
Returns whether the normals of this polyset have been "frozen"; that is, protected from calls to calcNormals. Since normals may be recalculated in the Alias environment at any time, use this call to preserve use-generated normals. Arguments
none Return codes
TRUE - the normals are frozen statusCode AlPolyset::freezeNormals()
Description
Sets a flag on the polyset to indicate that the normals of the polyset should not be recomputed. Note that modifying the polyset after freezing the normals will result in the normals not matching the underlying geometry. Arguments
none Return codes
sSuccess - the normals are frozen statusCode AlPolyset::unFreezeNormals()
Description
Sets a flag on the polyset to indicate that the normals of the polyset should be recomputed as needed. Arguments
none Return codes
sSuccess - the normals are unfrozen statusCode AlPolyset::blindData( int user_type, long& size, const char *& data )
Description
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 between 0 and 11999 are reserved. If you would like to reserve a block of "user_types" please contact us. Arguments
< type - user type of the data desired. Return codes
sSuccess - blind data retrieved statusCode AlPolyset::setBlindData( int user_type, long size, const char * data )
Description
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. Arguments
< user_type - user type of the blind data desired. Return codes
sSuccess - everything is okay. statusCode AlPolyset::removeBlindData( int user_type )
Description
Removes the block of data of the given type from the object. Note that the user is still responsible for the memory associated with this block of data. Arguments
< user_type - user type of the blind desired. Return codes
sSuccess - everthing is okay statusCode AlPolyset::applyIteratorToPolygons( AlIterator* iter, int &rc ) const
Description
Apply the given AlIterator to all polygons in the polyset. The second argument will be set to the return value of the last application of the iterator's function. See the AlIterator class for more information.
Arguments
< iter - the iterator to apply to each polygon Return codes
sSuccess - the application of the iterator terminated normally statusCode AlPolyset::applyIteratorToVertices( AlIterator* iter, int &rc ) const
Description
Apply the given AlIterator to all vertices in the polyset. The second argument will be set to the return value of the last application of the iterator's function. See the AlIterator class for more information.
Arguments
< iter - the iterator to apply to each polygon Return codes
sSuccess - the application of the iterator terminated normally statusCode AlPolyset::calcSTs()
Description
Uses a linear projection algorithm to calculate the default texture coordinates. Return codes
sSuccess - worked