AlMesh
 
 
 

Interface to Alias meshes.

Synopsis

#include <AlMesh.h>
class AlMesh : public AlObject
AlMesh();
	virtual	~AlMesh();
	virtual statusCode	deleteObject();
	virtual AlObject*	copyWrapper() const;
	virtual AlObjectType	type() const;
	AlMeshNode*	meshNode() const;
	statusCode	create( int numVertices, const float* vertices,
 int numTriangles, const int* triangles,
		const float* normals = 0,
		const float* uvs = 0);
	int numberOfVertices() const;
	int	numberOfTriangles() const;
	const float*	vertices() const;
	const int*	triangles() const;
	const float*	normals() const;
	const float*	uvs() const;
	void	uvRange( float* ) const;
	statusCode	setUVRange( float * );
	int	drawFlag() const;
	API_BOOLEAN	isDrawFlag( int ) const;
	statusCode	setDrawFlag( int, bool );
	statusCode	setDrawFlag( int );
	API_BOOLEAN	isFlatShaded() const;
	statusCode	setFlatShaded( bool );
	float*	affectedVertices( const AlTM& tm );
	float*	affectedNormals( const AlTM& tm );
	statusCode	removeDuplicateTris();
	statusCode	compact();
	statusCode	transform( double [4][4] ) const;
	statusCode	boundingBox( double *min, double *max ) const;
	AlShader*	firstShader() const;
	AlShader*	nextShader( AlShader* ) const;
	statusCode	nextShaderD( AlShader *) const;
	statusCode	assignShader( AlShader* );
	statusCode	layerShader( AlShader* );
	statusCode	renderInfo( AlRenderInfo& ) const;
	statusCode	setRenderInfo( const AlRenderInfo& ) const;

Description

AlMesh is the interface to meshes and their data in Alias. This class lets a developer create and manipulate mesh objects. Data access methods to all properties are provided. The following properties are used throughout the mesh class.

vertices

Vertices are passed by this class using an array of floating point values. A vertex consists of three values; x,y,z respectively. Refer to the definition of triangles for a description of the relationship between vertices and triangles.

numVertices

The number of vertices is equivalent to the number of x,y,z triplets stored in the vertices array. The total number of floats in the vertices array is equivalent to three times the number of vertices.

triangles

Triangles are passed by this class using an array of integer values. A triangle consists of three integer indices. These indices reference a vertex in the vertices array such that vertices[3*index] returns the x coordinate of the vertex. Similarly, vertices[3*index+1] and vertices[3*index+2] return the y and z coordinate respectively. Indices are to be specified in counter clockwise order relative to the front of their face.

numTriangles

The number of triangles is equivalent to the number of integer triplets stored in the triangles array. The total number of integers in the triangles array is equivalent to three times the number of triangles.

normals

Normals are passed by this class using an array of floating point values. They consist of three values; x,y,z respectively. Normals are per vertex. They are referenced by triangles in the same manner that vertices are referenced.

uvs

UVs are passed by this class using an array of float values. They consist of two floating point values; u,v respectively. UVs are per vertex. They are referenced by triangles in the same manner that vertices are referenced.

AlMesh::AlMesh()

Description

Constructs an AlMesh wrapper object.

AlMesh::~AlMesh()

Description

Deletes an AlMesh wrapper object.

statusCode AlMesh::deleteObject()

Description

This method deletes the AlMesh, and its parent AlMeshNode.

Return Codes

sSuccess - the mesh was deleted.

sInvalidObject - the mesh was invalid.

AlObject * AlMesh::copyWrapper() const

Description

Makes an exact copy of the AlMesh wrapper.

AlObjectType AlMesh::type() const

Description

Returns the class identifier kMeshExtType.

AlMeshNode * AlMesh::meshNode() const

Description

Returns a pointer to the AlMeshNode for this mesh. Returns NULL if there is not an attached mesh node.

statusCode AlMesh::create( int numVertices, const float* vertices, int numTriangles, const int* triangles, const float* normals, const float* uvs)

Description

Creates a mesh object with the supplied data. The user This is expected to allocate memory and seed data for the various arrays. Refer to the description of this class for detailed information on the arguments passed. Passing a uv array is optional. Passing a normal array is optional. Note that normals are recalculated as the mesh is changed.

Return Codes

sSuccess - The mesh was successfully created.

sInsufficientMemory - Sufficient memeory for the provided mesh could not be allocated.

sFailure - Failed to complete request. This result may occur because of insufficient memory.

int AlMesh::numberOfVertices() const

Description

Returns the number of vertices currently stored in the mesh. The function will return -1 if the mesh was not created properly.

int AlMesh::numberOfTriangles() const

Description

Returns the number of triangles currently stored in the mesh. The function will return -1 if the mesh was not created properly.

const float * AlMesh::vertices() const

Description

Returns a const pointer to the mesh's vertex data. The function will return 0 if the mesh was not created properly. Refer to the description of this class for more information.

const int * AlMesh::triangles() const

Description

Returns a const pointer to the mesh's triangle data. The function will return 0 if the mesh was not created properly. Refer to the description of this class for more information.

const float * AlMesh::normals() const

Description

Returns a const pointer to the mesh's normal data. The function will return 0 if the mesh was not created properly. Refer to the description of this class for more information.

const float * AlMesh::uvs() const

Description

Returns a const pointer to the mesh's uv data. The function will return 0 if the mesh was not created properly. Refer to the description of this class for more information.

void AlMesh::uvRange( float* range ) const

Description

Stores the uv range of the mesh in 'range'. 'range' is an array with four elements; minu, minv, maxu, maxv respectively.The function will return if the mesh was not created properly leaving 'range' unaltered.

statusCode AlMesh::setUVRange( float *uvrange )

Description

Sets the uv range of the mesh. 'uvrange' is an array with four elements; minu, minv, maxu, maxv respectively.

Return Codes

sSuccess - The range was properly set.

sInvalidObject - Returned if uvrange is 0 or the mesh was not created properly.

sFailure - Unable to process request.

int AlMesh::drawFlag() const

Description

Returns the mesh's draw flags. The function will return 0 if the mesh was not created properly.

boolean AlMesh::isDrawFlag( int flag ) const

Description

Returns TRUE if 'flag' is set in the mesh's draw flag. FALSE otherwise. The function will return FALSE if the mesh was not created properly.

statusCode AlMesh::setDrawFlag( int flag, bool on )

Description

Sets the 'flag' bit to the value of 'on' in the mesh's draw flag.

Return Codes

sSuccess - The flag was properly set.

sInvalidObject - The mesh was not created properly.

sFailure - Unable to process request.

statusCode AlMesh::setDrawFlag( int flag )

Description

Directly assigns 'flag' to the mesh's draw flag.

Return Codes

sSuccess - The flag was properly set.

sInvalidObject - The mesh was not created properly.

sFailure - Unable to process request.

boolean AlMesh::isFlatShaded() const

Description

Returns TRUE if the mesh is flat shaded. FALSE otherwise. The function will return FALSE if the mesh was not created properly.

statusCode AlMesh::setFlatShaded( bool flat )

Description

Sets the mesh's flat shading property to the value of 'flat'.

Return Codes

sSuccess - Flat shading was properly set.

sInvalidObject - The mesh was not created properly.

sFailure - Unable to process request.

statusCode AlMesh::transform( double tm[4][4] ) const

Description

Transforms the mesh by the matrix 'tm'.

Return Codes

sSuccess - The mesh was properly transformed.

sInvalidObject - The mesh was not created properly.

sFailure - Unable to process request.

statusCode AlMesh::removeDuplicateTris()

Description

Removes duplicate triangles from the mesh.

Return Codes

sSuccess - Duplicate triangles were removed successfully.

sInvalidObject - The mesh was not created properly.

sFailure - Unable to process request.

float * AlMesh::affectedVertices( const AlTM& tm )

Description

Returns a pointer to a float array of affected vertices. Refer to vertices in the description of this class for more information on the format of the array. The function will return 0 if the mesh was not created properly.

float * AlMesh::affectedNormals( const AlTM& tm )

Description

Returns a pointer to a float array of affected normals. Refer to normals in the description of this class for more information on the format of the array. The function will return 0 if the mesh was not created properly.

statusCode AlMesh::compact()

Description

This algorithm compacts the mesh by eliminating numerically identical vertices. This algorithm is useful when processing STL files, which duplicate vertex coordinates for adjacent triangles.

Return Codes

sSuccess - The mesh was successfully compacted.

sInvalidObject - The mesh was not created properly.

sFailure - Unable to process request.

statusCode AlMesh::boundingBox( double *min, double *max ) const

Description

Retrieves the bounding box of the mesh. The 'min' and 'max' arguments are arrays that contain the min or max x,y,z values respectively.

Return Codes

sSuccess - The bounding box was successfully sent to minimum and maximum.

sInvalidObject - The mesh was not created properly. The arguments remain unaltered.

sFailure - Unable to process request. The arguments remain unaltered.

AlShader * AlMesh::firstShader() const

Description

Returns the first shader that this mesh object references. The function will return 0 if there are no shaders or the mesh was not created properly.

AlShader * AlMesh::nextShader( AlShader* shader ) const

Description

Returns the shader after the one specified by 'shader'. The function will return 0 if:

  • the end of the shading list has been reached.
  • the argument, 'shader', is 0.
  • the mesh was not created properly.
  • there are no shaders.

statusCode AlMesh::nextShaderD( AlShader* shader ) const

Description

Destructively points the argument 'shader' to the shader that follows.

Return Codes

sSuccess - The 'shader' was properly set to the next shader in the list.

sFailure - Unable to process request. Refer to AlMesh::nextShader for possible reasons for a failure.

statusCode AlMesh::assignShader( AlShader* shader )

Description

Assigns 'shader' to the mesh.

Return Codes

sSuccess - The shader was successfully assigned to the mesh.

sInvalidArgument - 'shader' is invalid.

sInvalidObject - The mesh was not created properly.

sFailure - Unable to process request.

statusCode AlMesh::layerShader( AlShader* shader )

Description

Layers the 'shader' on the mesh.

Return Codes

sSuccess - the shader was successfully layered on the mesh.

sInvalidArgument - 'shader' is invalid.

sInvalidObject - The mesh was not created properly.

sFailure - Unable to process request.

statusCode AlMesh::renderInfo( AlRenderInfo& renderInfo ) const

Description

Fills in 'renderInfo' with the render info for this mesh.

Return Codes

sSuccess - 'renderInfo' was properly set.

sInvalidArgument - 'renderInfo' is NULL.

sInvalidObject - The mesh was not created properly.

sFailure - Unable to process request.

statusCode AlMesh::setRenderInfo( const AlRenderInfo& renderInfo ) const

Description

Sets the render info for this mesh to the contents of 'renderInfo'.

Return Codes

sSuccess - The mesh's render info was properly set.

sInvalidArgument - 'renderInfo' is NULL or a parameter in renderInfo is out of range.

sInvalidObject - The mesh was not created properly.

sFailure - Unable to process request.