Bookshelf Contents Previous Next Glossary Index Search

AlPolygon

Interface to Alias polyset polygons.

Synopsis

#include <AlPolygon.h>
class AlPolygon : public AlObject
AlPolygon();
virtual ~AlPolygon();
virtual AlObject* copyWrapper() const;
virtual AlObjectType type() const;
int numberOfVertices() const;
AlPolysetVertex* vertex( int ) const;
statusCode vertexD( int, AlPolysetVertex& ) const;
statusCode addVertex( int );
statusCode removeVertex( int );
statusCode verticesWorldPosition( double[] )const;
statusCode verticesAffectedPosition( const AlTM&, double[] )const;
statusCode verticesUnaffectedPosition( double[] )const;
statusCode addVertices( int, int[] );
statusCode removeVertices( int, int[] );
statusCode normal( double&, double&, double& ) const;
statusCode setNormal( double, double, double );
statusCode calcNormal();
int index();
AlPolyset* polyset() const;
int findVertexIndex( AlPolysetVertex* );
int vertexPolysetIndex( int vertexIndex );
int shaderIndex();
statusCode setShaderIndex( int );
statusCode setSt( int vertex, double, double );
statusCode st( int vertex, double &, double & );
statusCode st( int vertex, float &, float & ); // Obsolete
statusCode normal( int vertex, double &, double &, double & );
statusCode normal( int vertex, float&, float&, float& ); // Obsolete
statusCode setNormal( int vertex, double, double, double );
boolean queryPerPolyTextures() const;
statusCode setPerPolyTextures( boolean state );
statusCode queryPerPolyTextureOther1( unsigned short &index ) const;
statusCode setPerPolyTextureOther1( unsigned short index );
statusCode queryPerPolyTextureOther2( unsigned short &index ) const;
statusCode setPerPolyTextureOther2( unsigned short index );
statusCode queryPerPolyTextureIndex( unsigned short &index ) const;
statusCode setPerPolyTextureIndex( unsigned short index );
statusCode queryPerPolyTextureRotation( int &flag ) const;
statusCode setPerPolyTextureRotation( int flag );
statusCode queryPerPolyTextureFlip( int &flag ) const;
statusCode setPerPolyTextureFlip( int flag );
statusCode blindData( int, long&, const char *& );
statusCode setBlindData( int, long, const char * );
statusCode removeBlindData( int );
statusCode applyIteratorToVertices( AlIterator*, int& ) const;
statusCode doUpdates( boolean newState = TRUE );

Description

AlPolygon is the interface to the polygon data of Alias' polyset objects. To create a polygon, first instantiate and create an AlPolyset and then use the AlPolyset::newPolygon() method to create a new polygon. It is not possible to create a polygon without a polyset.

A polygon is a collection of vertices from a particular polyset.

The only way to delete a polygon is with the AlPolyset::deletePolygon() method.

Polygons are made of lists of vertices which you traverse using an index through the vertex() method. You can also pack the vertex information into an array using methods in this class.

Summary

AlPolygon::AlPolygon()

Description

Constructs an AlPolygon wrapper object.

AlPolygon::~AlPolygon()

Description

Deletes an AlPolygon wrapper object.

AlObject* AlPolygon::copyWrapper() const

Description

Makes an exact copy of the AlPolygon wrapper.

AlObjectType AlPolygon::type() const

Description

Returns the class identifier kPolygonType.

int AlPolygon::numberOfVertices() const

Description

Returns a count of the number of vertices in this polygon. If the polygon is not valid, -1 is returned.

AlPolysetVertex* AlPolygon::vertex( int index ) const

Description

Finds a vertex in the polygon's array of vertices given the vertex's index. Returns the pointer to the vertex if the vertex is found and NULL otherwise.

Arguments

< int index - the index of the vertex to find

int AlPolygon::findVertexIndex( AlPolysetVertex* polyvertex)

Description

Calculates the index of a vertex in the polygon (in terms of polygon vertex indices). -1 is returned if the vertex is not present in the polygon.

statusCode AlPolygon::vertexD( int index, AlPolysetVertex& vtex ) const

Description

Finds a vertex in the polygon's array of vertices given the vertex's index. If found, destructively set the given AlPolysetVertex to refer to that vertex. Otherwise, fail.

Arguments

< int index - the index of the vertex to find

<> AlPolysetVertex& vtex - the found vertex

Return Codes

sSuccess - vertex has been found

sInvalidObject - the polygon was invalid

sFailure - vertex could not be found

statusCode AlPolygon::doUpdates( boolean newState )

Description

See AlDagNode for information

statusCode AlPolygon::addVertex( int index )

Description

Adds a new vertex to the polygon's array of vertices. The argument is the vertex's index in the polyset's array of vertices.

Arguments

< int index - the index of the vertex to add

Return Codes

sSuccess - vertex is added

sInvalidArgument - index is not in the polyset's vertex range

sFailure - vertex could not be added

sInvalidObject - the polygon was invalid

statusCode AlPolygon::removeVertex( int index )

Description

Removes a vertex from the polygon's array of vertices given the vertex's index. The index is the vertex's index in the polygon, and not the polyset.

The vertex will remain in other polygons using it. To delete a vertex from all polygons in a polyset, use AlPolyset::deleteVertex().

Arguments

< int index - the index of the vertex to remove

Return code

sSuccess - the removal succeeded

sInvalidArgument - the vertex doesn't belong to this AlPolygon

sFailure - the polygon is inactive

sInvalidObject - the polygon was invalid

int AlPolygon::vertexPolysetIndex( int vertexIndex )

Description

Converts the vertex index from a polygon to its index in the polyset.

Arguments

< int vertexIndex - the index of the vertex in the polygon

Return value

The index of the vertex in the polyset or -1 on error.

statusCode AlPolygon::verticesWorldPosition( double vertexList[] ) const

Description

Returns the world position of this polygon's vertices in the given array. The vertex array must have the size [numberOfVertices * 3].

Arguments

> vertexList - contains all the vertices' world positions upon return

Return code

sSuccess - the method succeeded

sInvalidArgument - vertexList was NULL

sFailure - the polygon is inactive

sInvalidObject - the polygon was invalid

statusCode AlPolygon::verticesUnaffectedPosition( double vertexList[] ) const

Description

Returns the unaffected position of this polygon's vertices in the given array. The vertex array must have the size [numberOfVertices * 3].

Note that there is no way to set the unaffected position of a polygon's vertices. You must use the AlPolyset method.

Arguments

> vertexList - contains all the vertices' unaffected positions upon return

Return code

sSuccess - the method succeeded

sInvalidArgument - vertexList was NULL

sFailure - the polygon is inactive

sInvalidObject - the polygon was invalid

statusCode AlPolygon::verticesAffectedPosition( const AlTM& tm, double vertexList[] ) const

Description

Returns the position of this polygon's vertices in the given array modified by the AlTM. The vertex array must have the size [numberOfVertices * 3].

Note that there is no way to set the unaffected position of a polygon's vertices. You must use the AlPolyset method.

Arguments

> vertexList - contains all the vertices' affected positions upon return

< tm - the transformation matrix that is accumulated using the DAG

Return code

sSuccess - the method succeeded

sInvalidArgument - vertexList was NULL

sFailure - the polygon is inactive

sInvalidObject - the polygon was invalid

statusCode AlPolygon::setSt( int vertex, double s, double t )

Description

Sets the ST coordinates for the vertex.

Arguments

s,t - the coordinates

vertex - the vertex index

Return code

sSuccess - the coordinates were set

sInvalidArgument - the vertex was out of range

sInvalidObject - the polygon was invalid

statusCode AlPolygon::setNormal( int vertex, double x, double y, double z )

Description

Sets the normal of the vertex.

Arguments

x,y,z - the normal of of the vertex

vertex - the index of the vertex to set

Return code

sSuccess - the normal was set

sInvalidArgument - the vertex was out of range

sInvalidObject - the polygon was invalid

sFailure - the normal was frozen

statusCode AlPolygon::st( int vertex, double &s, double &t )

Description

Retrieves the ST coordinates of the vertex.

Arguments

s,t - returned coordinates

vertex - the vertex to examine

Return code

sSuccess - the coordinates were returned

sFailure - the coordinates were invalid and not returned

sInvalidArgument - the index was out of range

sInvalidObject - the polygon was invalid

statusCode AlPolygon::normal( int vertex, double &x, double &y, double &z )

Description

Gets the normal of a vertex.

Arguments

x,y,z - the coordinates of the normal

vertex - the vertex index

Return code

sInvalidObject - the object was invalid

sSuccess - the normal was returned

sInvalidArgument - the vertex index was out of range

sFailure - the polygon is inactive

statusCode AlPolygon::addVertices( int numberOfVertices, int indices[] )

Description

Allows the addition of a number of vertices to this polygon.

Arguments

< numberOfVertices - number of vertices in array 'indices'

< indices - array of vertex indices to add

Return Codes

sSuccess - the method succeeded.

sInvalidArgument - the number of vertices to add is less than 1

sFailure - internal failure or could not find a vertex index that was specified in the array

sInvalidObject - the polygon was invalid

statusCode AlPolygon::removeVertices( int numberOfVertices, int indices[] )

Description

Removes a number of vertices from a polygon. Note that this method does not actually delete the vertices. The vertices will still remain in other polygons that contain them.

Note: this method will be more efficient if the indices array is sorted in increasing order.

Arguments

< numberOfVertices - number of vertices in array 'indices'

< indices - array of indices to remove

Return Codes

sSuccess - the method succeeded

sInvalidArgument - the number of vertices is less than 0 or the number of vertices is greater than the number actually contained in this polygon

sFailure - the method failed

sInvalidObject - the polygon was invalid

statusCode AlPolygon::normal( double& x, double& y, double& z ) const

Description

Gets the normal for the polygon.

Arguments

> double &x, &y, &z - retrieved 3D normal

Return code

sSuccess - the normal was retrieved from the polygon

sFailure - the polygon is inactive

sInvalidObject - the polygon is invalid

statusCode AlPolygon::setNormal( double x, double y, double z )

Description

Sets the normal for the polygon. The calcNormal() method will overwrite any values set with this method.

Arguments

< double x, y, z - 3D vector to set the normal of the polygon

Return code

sSuccess - the normal was retrieved from the polygon

sFailure - the polygon is inactive

sInvalidObject - the polygon is invalid

statusCode AlPolygon::calcNormal()

Description

Calculates the normal for this polygon. The setNormal() method can be used to set a specific normal on a polygon.

Return code

sSuccess - the normal was retrieved from the polygon

sFailure - the polygon is inactive

sInvalidObject - the polygon is invalid

statusCode AlPolygon::setPerPolyTextures( boolean state )

Description

Setting the PerPolyTexture flag on a polygon alters the manner in which texture coordinates are mapped in the interactive Alias renderers (Quick Render and Toggle shade). It does not affect the Alias software renderers. Per Poly texturing causes textures to be mapped across a single polygon. All polygons are assumed to be Quads (four sided). The textures are exactly mapped onto these quads. The texture used is a portion of the texture specified in the multilister. The texture image is assumed to be composed of an 8 x 8 grid of smaller textures (a texture palette). The setPerPolyTextureIndex method may be used to control which element of this grid is used. In addition, the setPerPolyTextureFlip and setPerPolyTextureRotation methods may be used to flip or rotate the texture element on the polygon. Note: it is recommended that for new development the per-vertex-per-poly methods of setting texture coordinates directly be used, as opposed the perPolyTexture methods. The perPolyTexture methods are maintained for compatability with previous releases only.

Arguments

Return Codes

sInvalidObject - the polygon is invalid

boolean AlPolygon::queryPerPolyTextures() const

Description

Querys whether perPolyTexturing is enabled on this polygon. Note: it is recommended that for new development the per-vertex-per-poly methods of setting texture coordinates directly be used, as opposed to the perPolyTexture methods. The perPolyTexture methods are maintained for compatability with previous releases only.

statusCode AlPolygon::queryPerPolyTextureOther1( unsigned short &index ) const

Description

Allows you to query a single 8 bit user defined value onto a polygon that is being used in per-poly texturing mode.

Note: it is recommended that for new development the per-vertex-per-poly methods of setting texture coordinates directly be used, as opposed to the perPolyTexture methods. The perPolyTexture methods are maintained for compatability with previous releases only.

Return Codes

sSuccess - method worked

sFailure - method failed

sInvalidObject - the polygon is invalid

statusCode AlPolygon::queryPerPolyTextureOther2( unsigned short &index ) const

Description

Allows you to query a second 8 bit user defined value onto a polygon that is being used in per-poly texturing mode.

Note: it is recommended that for new development the per-vertex-per-poly methods of setting texture coordinates directly be used, as opposed to the perPolyTexture methods. The perPolyTexture methods are maintained for compatability with previous releases only.

Return Codes

sSuccess - method worked

sFailure - method failed

sInvalidObject - the polygon is invalid

statusCode AlPolygon::queryPerPolyTextureIndex( unsigned short &index ) const

Description

Allows you to query which of the texture images in the per-polygon palette is used to map this polygon. The grid is assumed to be an 8x8 grid of texture images, mapped horizontally and then vertically.

Note: it is recommended that for new development the per-vertex-per-poly methods of setting texture coordinates directly be used, as opposed to the perPolyTexture methods. The perPolyTexture methods are maintained for compatability with previous releases only.

Return Codes

ssSuccess - method worked

sFailure - method failed

sInvalidObject - the polygon is invalid

statusCode AlPolygon::queryPerPolyTextureRotation( int &flag ) const

Description

Returns the rotational value assigned to this polygon when used with perPolyTexturing. The value will be one of: kPOLY_ROT_NONE, kPOLY_ROT_90, kPOLY_ROT_180, or kPOLY_ROT_270

Note: it is recommended that for new development the per-vertex-per-poly methods of setting texture coordinates directly be used, as opposed to the perPolyTexture methods. The perPolyTexture methods are maintained for compatability with previous releases only.

Return Codes

sInsSuccess - method worked

sFailure - method failed

validObject - the polygon is invalid

statusCode AlPolygon::queryPerPolyTextureFlip( int &flag ) const

Description

Returns the flip value assigned to this polygon when used with perPolyTexturing. The value will be one of: kPOLY_FLIP_NONE, kPOLY_FLIP_HORIZ, kPOLY_FLIP_VERT, or kPOLY_FLIP_BOTH

Note: it is recommended that for new development the per-vertex-per-poly methods of setting texture coordinates directly be used, as opposed to the perPolyTexture methods. The perPolyTexture methods are maintained for compatability with previous releases only.

Return Codes

sSuccess - method worked

sFailure - method failed

sInvalidObject - the polygon is invalid

statusCode AlPolygon::setPerPolyTextureOther1( unsigned short index )

Description

Allows you to set a single 8 bit user defined value onto a polygon that is being used in per-poly texturing mode.

Note: it is recommended that for new development the per-vertex-per-poly methods of setting texture coordinates directly be used, as opposed to the perPolyTexture methods. The perPolyTexture methods are maintained for compatability with previous releases only.

Return Codes

sSuccess - method worked

sFailure - method failed

sInvalidObject - the polygon is invalid

statusCode AlPolygon::setPerPolyTextureOther2( unsigned short index )

Description

Allows you to set a second 8 bit user defined value onto a polygon that is being used in per-poly texturing mode.

Note: it is recommended that for new development the per-vertex-per-poly methods of setting texture coordinates directly be used, as opposed to the perPolyTexture methods. The perPolyTexture methods are maintained for compatability with previous releases only.

Return Codes

sSuccess - method worked

sFailure - method failed

sInvalidObject - the polygon is invalid

statusCode AlPolygon::setPerPolyTextureIndex( unsigned short index )

Description

Allows you to specify which of the texture images in the per-polygon palette is used to map this polygon. The grid is assumed to be an 8x8 grid of texture images, mapped horizontally and then vertically.

Note: it is recommended that for new development the per-vertex-per-poly methods of setting texture coordinates directly be used, as opposed to the perPolyTexture methods. The perPolyTexture methods are maintained for compatability with previous releases only.

Return Codes

sSuccess - method worked

sFailure - method failed

sInvalidObject - the polygon is invalid

statusCode AlPolygon::setPerPolyTextureRotation( int flag )

Description

Sets the rotational value assigned to this polygon when used with perPolyTexturing. The value will be one of: kPOLY_ROT_NONE, kPOLY_ROT_90, kPOLY_ROT_180, or kPOLY_ROT_270

Note: it is recommended that for new development the per-vertex-per-poly methods of setting texture coordinates directly be used, as opposed to the perPolyTexture methods. The perPolyTexture methods are maintained for compatability with previous releases only.

Return Codes

sSuccess - method worked

sFailure - method failed

sInvalidObject - the polygon is invalid

statusCode AlPolygon::setPerPolyTextureFlip( int flag )

Description

Sets the flip value assigned to this polygon when used with perPolyTexturing. The value will be one of: kPOLY_FLIP_NONE, kPOLY_FLIP_HORIZ, kPOLY_FLIP_VERT, or kPOLY_FLIP_BOTH

Note: it is recommended that for new development the per-vertex-per-poly methods of setting texture coordinates directly be used, as opposed to the perPolyTexture methods. The perPolyTexture methods are maintained for compatability with previous releases only.

Return Codes

sInvalidObject - the polygon is invalid

int AlPolygon::shaderIndex()

Description

Returns the polyset shader list index to be used when rendering this polygon. This method returns -1 if the polygon is invalid.

statusCode AlPolygon::setShaderIndex( int index )

Description

Sets the polyset shader list to be used when rendering this polygon. Polyset shader lists are defined in the AlPolyset class. Note that the index used MUST be defined in the polyset, and MUST be less than AL_MAX_SHADERS_PER_POLYSET (currently 64).

Arguments

< int index - index to set

Return Codes

sSuccess - shader index set

sInvalidArgument - index not in polyset or >AL_MAX_SHADERS_PER_POLYSET

sFailure - polygon has no parent

sInvalidObject - the polygon is invalid

int AlPolygon::index()

Description

Returns the index of this polygon in the polyset. On errors -1 is returned.

AlPolyset* AlPolygon::polyset() const

Description

Returns a pointer to the parent polyset of this polygon. On errors NULL is returned.

statusCode AlPolygon::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 will be NULL. User_types between 0 and 11999 are reserved. If you would like to reserve a block of "user_types" please contact us.

Arguments

< user_type - user type of the data desired

> size - number of characters in the block of data

> data - address of the block of data

Return Codes

sSuccess - blind data retrieved

sFailure - blind data not retrieved

sInvalidObject - the polygon was invalid

statusCode AlPolygon::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

< size - number of characters in the block

< data - address of the block of data

Return Codes

sSuccess - operation was successful

sInsufficientMemory - not enough memory to allocate a new block

sFailure - create has not been called on this object yet

sInvalidObject - the polygon is invalid

statusCode AlPolygon::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 - operation was successful

sFailure - no such blind data existed sInvalidObject - the given object was not valid

statusCode AlPolygon::applyIteratorToVertices( AlIterator* iter, int &rc ) const

Description

Applies the given AlIterator to all vertices in the polygon. 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 vertex

> rc - the return value of the last application of the iterator

Return Codes

sSuccess - the application of the iterator terminated normally

sFailure - the application of the iterator terminated abnormally

sInvalidObject - the polygon is invalid

sInvalidArgument - the iterator was NULL.



Bookshelf Contents Previous Next Glossary Index Search

[email protected]
Copyright © 1998, Alias|Wavefront, a division of Silicon Graphics Limited. All rights reserved.