vtMesh Class Reference
[Scene Graph]

Inheritance diagram for vtMesh:

Inheritance graph
[legend]
List of all members.

Detailed Description

A Mesh is a set of graphical primitives (such as lines, triangles, or fans).
The vtMesh class allows you to define and access a Mesh, including many functions useful for creating and dynamically changing Meshes. To add the vtMesh to the visible scene graph, add it to a vtGeom node.
Most of the useful methods of this class are defined on its parent class, vtMeshBase.


Public Member Functions

 vtMesh (enum PrimType ePrimType, int VertType, int NumVertices)
void Release ()
 Use this method instead of delete, when you are done with this object.
void GetBoundBox (FBox3 &box) const
void AddTri (int p0, int p1, int p2)
void AddFan (int p0, int p1, int p2=-1, int p3=-1, int p4=-1, int p5=-1)
void AddFan (int *idx, int iNVerts)
void AddStrip (int iNVerts, unsigned short *pIndices)
void AddLine (int p0, int p1)
int AddLine (const FPoint3 &pos1, const FPoint3 &pos2)
void AddQuad (int p0, int p1, int p2, int p3)
void SetVtxPos (unsigned int, const FPoint3 &)
FPoint3 GetVtxPos (unsigned int i) const
void SetVtxNormal (unsigned int, const FPoint3 &)
FPoint3 GetVtxNormal (unsigned int i) const
void SetVtxColor (unsigned int, const RGBAf &)
RGBAf GetVtxColor (unsigned int i) const
void SetVtxTexCoord (unsigned int, const FPoint2 &)
FPoint2 GetVtxTexCoord (unsigned int i) const
void SetLineWidth (float fWidth)
void ReOptimize ()
void AllowOptimize (bool bAllow)
void SetNormalsFromPrimitives ()

Friends

class vtGeom


Constructor & Destructor Documentation

vtMesh::vtMesh enum PrimType  ePrimType,
int  VertType,
int  NumVertices
 

Construct a Mesh. A Mesh is a container for a set of vertices and primitives.

Parameters:
ePrimType The type of primitive this mesh will contain. Allowed values are:
  • GL_POINTS
  • GL_LINES
  • GL_LINE_STRIP
  • GL_TRIANGLES
  • GL_TRIANGLE_STRIP
  • GL_TRIANGLE_FAN
  • GL_QUADS
  • GL_POLYGON
VertType Flags which indicate what type of information is stored with each vertex. This can be any combination of the following bit flags:
  • VT_Normals - a normal per vertex.
  • VT_Colors - a color per vertex.
  • VT_TexCoords - a texture coordinate (UV) per vertex.
NumVertices The expected number of vertices that the mesh will contain. If more than this number of vertices are added, the mesh will automatically grow to contain them. However it is more efficient if you know the number at creation time and pass it in this parameter.


Member Function Documentation

void vtMesh::AddFan int *  idx,
int  iNVerts
[virtual]
 

Add a triangle fan with any number of points.

Parameters:
idx An array of vertex indices for the fan.
iNVerts the number of vertices in the fan.

Implements vtMeshBase.

void vtMesh::AddFan int  p0,
int  p1,
int  p2 = -1,
int  p3 = -1,
int  p4 = -1,
int  p5 = -1
[virtual]
 

Add a triangle fan with up to 6 points (center + 5 points). The first 3 arguments are required, the rest are optional. A fan will be created with as many point indices as you pass.

Implements vtMeshBase.

int vtMesh::AddLine const FPoint3 pos1,
const FPoint3 pos2
 

Add a single line primitive to a mesh.

Parameters:
pos1,pos2 The positions of the two vertices of the line.
Returns:
The index of the first vertex added.

void vtMesh::AddLine int  p0,
int  p1
 

Add a single line primitive to a mesh.

Parameters:
p0,p1 The indices of the two vertices of the line.

void vtMesh::AddQuad int  p0,
int  p1,
int  p2,
int  p3
[virtual]
 

Add a triangle. p0, p1, p2 are the indices of the vertices of the triangle.

Implements vtMeshBase.

void vtMesh::AddStrip int  iNVerts,
unsigned short *  pIndices
[virtual]
 

Adds an indexed triangle strip to the mesh.

Parameters:
iNVerts The number of vertices in the strip.
pIndices An array of the indices of the vertices in the strip.

Implements vtMeshBase.

void vtMesh::AddTri int  p0,
int  p1,
int  p2
[virtual]
 

Add a triangle. p0, p1, p2 are the indices of the vertices of the triangle.

Implements vtMeshBase.

void vtMesh::AllowOptimize bool  bAllow  ) 
 

Set whether to allow rendering optimization of this mesh. With OpenGL, this optimization is called a "display list", which increases the speed of rendering by creating a special representation of the mesh the first time it is drawn. The tradeoff is that subsequent changes to the mesh are not applied unless you call ReOptimize().

Parameters:
bAllow True to allow optimization. The default is true.

void vtMesh::GetBoundBox FBox3 box  )  const [virtual]
 

Computes the bounding box of the mesh, based on the extent of its vertices. Result is placed in the 'box' parameter. If there are no vertices, then 'box' is unchanged.

Reimplemented from vtMeshBase.

RGBAf vtMesh::GetVtxColor unsigned int  i  )  const [virtual]
 

Get the color of a vertex.

Implements vtMeshBase.

FPoint3 vtMesh::GetVtxNormal unsigned int  i  )  const [virtual]
 

Get the normal of a vertex.

Implements vtMeshBase.

FPoint3 vtMesh::GetVtxPos unsigned int  i  )  const [virtual]
 

Get the position of a vertex.

Implements vtMeshBase.

FPoint2 vtMesh::GetVtxTexCoord unsigned int  i  )  const [virtual]
 

Get the texture coordinates of a vertex.

Implements vtMeshBase.

void vtMesh::ReOptimize  ) 
 

For a mesh with rendering optimization enabled, forces an update of the optimized representation.

void vtMesh::SetLineWidth float  fWidth  ) 
 

Set the line width, in pixels, for this mesh's geometry.

You should call this method _after_ the mesh has been added to some geometry with vtGeom::AddMesh() (this requirement was found with the OSG flavor of vtlib.)

void vtMesh::SetNormalsFromPrimitives  ) 
 

Set the normals of the vertices by combining the normals of the surrounding faces. This requires going through all the primitives to average their contribution to each vertex.

void vtMesh::SetVtxColor unsigned int  i,
const RGBAf color
[virtual]
 

Set the color of a vertex. This color multiplies with the color of the material used with the mesh, so if you want the vertex color to be dominant, use a white material.

Parameters:
i Index of the vertex.
color The color.

Implements vtMeshBase.

void vtMesh::SetVtxNormal unsigned int  i,
const FPoint3 norm
[virtual]
 

Set the normal of a vertex. This is used for lighting, if the mesh is used with a material with lighting enabled. Generally you will want to use a vector of unit length.

Parameters:
i Index of the vertex.
norm The normal vector.

Implements vtMeshBase.

void vtMesh::SetVtxPos unsigned int  i,
const FPoint3 p
[virtual]
 

Set the position of a vertex.

Parameters:
i Index of the vertex.
p The position.

Implements vtMeshBase.

void vtMesh::SetVtxTexCoord unsigned int  i,
const FPoint2 uv
[virtual]
 

Set the texture coordinates of a vertex. Generally these values are in the range of 0 to 1, although you can use higher values if you want repeating tiling. The components of the texture coordinates are usually called "u" and "v".

Parameters:
i Index of the vertex.
uv The texture coordinate.

Implements vtMeshBase.


Generated on Tue Apr 22 10:11:07 2008 for vtlib library by  doxygen 1.4.5