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;
virtual AlPolygon* asPolygonPtr();
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 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, float, float );
statusCode st( int vertex, float &, float & );
statusCode normal( int vertex, float &, float &, float & );
statusCode setNormal( int vertex, float, float, float );
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

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.

AlPolygon* AlPolygon::asPolygonPtr()

Description

This virtual function returns a non-null pointer to itself, indicating that it is safe to cast to an object of this class.

int AlPolygon::numberOfVertices() const

Description

Return 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

Find 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

Calculate 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

Find 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

statusCode AlPolygon::doUpdates( boolean newState )

Description

See AlDagNode for information

statusCode AlPolygon::addVertex( int index )

Description

Add 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

Remove 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, float s, float 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

statusCode AlPolygon::setNormal( int vertex, float x, float y, float 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

sFailure - the normal was frozen

statusCode AlPolygon::st( int vertex, float &s, float &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

statusCode AlPolygon::normal( int vertex, float &x, float &y, float &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

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

Calculate 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 )

Return code

sInvalidObject - the polygon is invalid

boolean AlPolygon::queryPerPolyTextures() const

Description

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

Description

Arguments

Return code

sInvalidObject - the polygon is invalid

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

Description

Arguments

Return code

sInvalidObject - the polygon is invalid

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

Description

Arguments

Return code

sInvalidObject - the polygon is invalid

statusCode AlPolygon::queryPerPolyTextureRotation( int &flag ) const

Description

Arguments

Return code

sInvalidObject - the polygon is invalid

statusCode AlPolygon::queryPerPolyTextureFlip( int &flag ) const

Description

Arguments

Return code

sInvalidObject - the polygon is invalid

statusCode AlPolygon::setPerPolyTextureOther1( unsigned short index )

Description

Arguments

Return code

sInvalidObject - the polygon is invalid

statusCode AlPolygon::setPerPolyTextureOther2( unsigned short index )

Description

Arguments

Return code

sInvalidObject - the polygon is invalid

statusCode AlPolygon::setPerPolyTextureIndex( unsigned short index )

Description

Arguments

Return code

sInvalidObject - the polygon is invalid

statusCode AlPolygon::setPerPolyTextureRotation( int flag )

Description

Arguments

Return code

sInvalidObject - the polygon is invalid

statusCode AlPolygon::setPerPolyTextureFlip( int flag )

Description

Arguments

Return code

sInvalidObject - the polygon is invalid

int AlPolygon::shaderIndex()

Description

Return 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

Set 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

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

AlPolyset* AlPolygon::polyset() const

Description

Return 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 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.

> 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 - everything is okay.

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 - everthing is okay

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

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

Description

Apply 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.





aliasdocs@aw.sgi.com
Copyright © 1996, Alias|Wavefront, a Silicon Graphics Company. All rights reserved.