ReactPhysics3D  v0.10.1
C++ Physics engine library
reactphysics3d::TriangleVertexArray Class Reference

This class is used to describe the vertices and faces of a triangular mesh. More...

#include <include/reactphysics3d/collision/TriangleVertexArray.h>

Public Types

enum class  VertexDataType { VERTEX_FLOAT_TYPE , VERTEX_DOUBLE_TYPE }
 Data type for the vertices in the array.
 
enum class  NormalDataType { NORMAL_FLOAT_TYPE , NORMAL_DOUBLE_TYPE }
 Data type for the vertex normals in the array.
 
enum class  IndexDataType { INDEX_INTEGER_TYPE , INDEX_SHORT_TYPE }
 Data type for the indices in the array.
 

Public Member Functions

 TriangleVertexArray (uint32 nbVertices, const void *verticesStart, uint32 verticesStride, uint32 nbTriangles, const void *indexesStart, uint32 indexesStride, VertexDataType vertexDataType, IndexDataType indexDataType)
 Constructor without vertices normals. More...
 
 TriangleVertexArray (uint32 nbVertices, const void *verticesStart, uint32 verticesStride, const void *verticesNormalsStart, uint32 uverticesNormalsStride, uint32 nbTriangles, const void *indexesStart, uint32 indexesStride, VertexDataType vertexDataType, NormalDataType normalDataType, IndexDataType indexDataType)
 Constructor with vertices normals. More...
 
TriangleVertexArrayoperator= (const TriangleVertexArray &triangleVertexArray)=delete
 Deleted assignment operator.
 
 TriangleVertexArray (const TriangleVertexArray &triangleVertexArray)=delete
 Deleted copy-constructor.
 
VertexDataType getVertexDataType () const
 Return the vertex data type. More...
 
NormalDataType getVertexNormalDataType () const
 Return the vertex normal data type. More...
 
bool getHasNormals () const
 Return true if the vertices normal have been provided by the user. More...
 
IndexDataType getIndexDataType () const
 Return the index data type. More...
 
uint32 getNbVertices () const
 Return the number of vertices. More...
 
uint32 getNbTriangles () const
 Return the number of triangles. More...
 
uint32 getVerticesStride () const
 Return the vertices stride (number of bytes) More...
 
uint32 getVerticesNormalsStride () const
 Return the vertex normals stride (number of bytes) More...
 
uint32 getIndicesStride () const
 Return the indices stride (number of bytes) More...
 
const void * getVerticesStart () const
 Return the pointer to the start of the vertices array. More...
 
const void * getVerticesNormalsStart () const
 Return the pointer to the start of the vertex normals array. More...
 
const void * getIndicesStart () const
 Return the pointer to the start of the indices array. More...
 
void getTriangleVerticesIndices (uint32 triangleIndex, uint32 &outV1Index, uint32 &outV2Index, uint32 &outV3Index) const
 Return the three vertex indices of a given triangle face. More...
 
Vector3 getVertex (uint32 vertexIndex) const
 Return a vertex of the array. More...
 
Vector3 getVertexNormal (uint32 vertexIndex) const
 Return a vertex normal of the array. More...
 

Detailed Description

This class is used to describe the vertices and faces of a triangular mesh.

A TriangleVertexArray represents a continuous array of vertices and indexes of a triangular mesh. When you create a TriangleVertexArray, no data is copied into the array. It only stores pointer to the data. part. Therefore, make sure that the data pointed by a TriangleVertexArray remains valid during the TriangleVertexArray life.

Constructor & Destructor Documentation

◆ TriangleVertexArray() [1/2]

TriangleVertexArray::TriangleVertexArray ( uint32  nbVertices,
const void *  verticesStart,
uint32  verticesStride,
uint32  nbTriangles,
const void *  indexesStart,
uint32  indexesStride,
VertexDataType  vertexDataType,
IndexDataType  indexDataType 
)

Constructor without vertices normals.

Note that your data will not be copied into the TriangleVertexArray and therefore, you need to make sure that those data are always valid during the lifetime of the TriangleVertexArray.

With this constructor, you do not need to provide vertices normals for smooth mesh collision. Therefore, the vertices normals will be computed automatically. The vertices normals are computed with weighted average of the associated triangle face normal. The weights are the angle between the associated edges of neighbor triangle face.

Parameters
nbVerticesNumber of vertices in the array
verticesStartPointer to the first vertices of the array
verticesStrideNumber of bytes between the beginning of two consecutive vertices
nbTrianglesNumber of triangles in the array
indexesStartPointer to the first triangle index
indexesStrideNumber of bytes between the beginning of the three indices of two triangles
vertexDataTypeType of data for the vertices (float, double)
indexDataTypeType of data for the indices (short, int)

◆ TriangleVertexArray() [2/2]

TriangleVertexArray::TriangleVertexArray ( uint32  nbVertices,
const void *  verticesStart,
uint32  verticesStride,
const void *  verticesNormalsStart,
uint32  verticesNormalsStride,
uint32  nbTriangles,
const void *  indexesStart,
uint32  indexesStride,
VertexDataType  vertexDataType,
NormalDataType  normalDataType,
IndexDataType  indexDataType 
)

Constructor with vertices normals.

Note that your data will not be copied into the TriangleVertexArray and therefore, you need to make sure that those data are always valid during the lifetime of the TriangleVertexArray.

With this constructor, you need to provide the vertices normals that will be used for smooth mesh collision.

Parameters
nbVerticesNumber of vertices in the array
verticesStartPointer to the first vertices of the array
verticesStrideNumber of bytes between the beginning of two consecutive vertices
verticesNormalsStartPointer to the first vertex normal of the array
verticesNormalsStrideNumber of bytes between the beginning of two consecutive vertex normals
nbTrianglesNumber of triangles in the array
indexesStartPointer to the first triangle index
indexesStrideNumber of bytes between the beginning of two consecutive triangle indices
vertexDataTypeType of data for the vertices (float, double)
normalDataTypeType of data for the normals (float, double)
indexDataTypeType of data for the indices (short, int)

Member Function Documentation

◆ getHasNormals()

RP3D_FORCE_INLINE bool reactphysics3d::TriangleVertexArray::getHasNormals ( ) const

Return true if the vertices normal have been provided by the user.

Returns
True if the vertices normals have been provided by the user

◆ getIndexDataType()

RP3D_FORCE_INLINE TriangleVertexArray::IndexDataType reactphysics3d::TriangleVertexArray::getIndexDataType ( ) const

Return the index data type.

Returns
The data type of the face indices in the array

◆ getIndicesStart()

RP3D_FORCE_INLINE const void * reactphysics3d::TriangleVertexArray::getIndicesStart ( ) const

Return the pointer to the start of the indices array.

Returns
A pointer to the start of the face indices data in the array

◆ getIndicesStride()

RP3D_FORCE_INLINE uint32 reactphysics3d::TriangleVertexArray::getIndicesStride ( ) const

Return the indices stride (number of bytes)

Returns
The number of bytes separating two consecutive face indices in the array

◆ getNbTriangles()

RP3D_FORCE_INLINE uint32 reactphysics3d::TriangleVertexArray::getNbTriangles ( ) const

Return the number of triangles.

Returns
The number of triangles in the array

◆ getNbVertices()

RP3D_FORCE_INLINE uint32 reactphysics3d::TriangleVertexArray::getNbVertices ( ) const

Return the number of vertices.

Returns
The number of vertices in the array

◆ getTriangleVerticesIndices()

void TriangleVertexArray::getTriangleVerticesIndices ( uint32  triangleIndex,
uint32 &  outV1Index,
uint32 &  outV2Index,
uint32 &  outV3Index 
) const

Return the three vertex indices of a given triangle face.

Parameters
triangleIndexIndex of a given triangle in the array
[out]outV1IndexIndex of the first vertex of the triangle in the vertex array
[out]outV2IndexIndex of the first vertex of the triangle in the vertex array
[out]outV3IndexIndex of the first vertex of the triangle in the vertex array

◆ getVertex()

Vector3 TriangleVertexArray::getVertex ( uint32  vertexIndex) const

Return a vertex of the array.

Parameters
vertexIndexIndex of a given vertex of the array
Returns
The vertex coordinates

◆ getVertexDataType()

RP3D_FORCE_INLINE TriangleVertexArray::VertexDataType reactphysics3d::TriangleVertexArray::getVertexDataType ( ) const

Return the vertex data type.

Returns
The data type of the vertices in the array

◆ getVertexNormal()

Vector3 TriangleVertexArray::getVertexNormal ( uint32  vertexIndex) const

Return a vertex normal of the array.

Parameters
vertexIndexIndex of a given vertex of the array
Returns
The normal vector of the vertex

◆ getVertexNormalDataType()

RP3D_FORCE_INLINE TriangleVertexArray::NormalDataType reactphysics3d::TriangleVertexArray::getVertexNormalDataType ( ) const

Return the vertex normal data type.

Returns
The data type of the normals in the array

◆ getVerticesNormalsStart()

RP3D_FORCE_INLINE const void * reactphysics3d::TriangleVertexArray::getVerticesNormalsStart ( ) const

Return the pointer to the start of the vertex normals array.

Returns
A pointer to the start of the normals data in the array

◆ getVerticesNormalsStride()

RP3D_FORCE_INLINE uint32 reactphysics3d::TriangleVertexArray::getVerticesNormalsStride ( ) const

Return the vertex normals stride (number of bytes)

Returns
The number of bytes separating two consecutive normals in the array

◆ getVerticesStart()

RP3D_FORCE_INLINE const void * reactphysics3d::TriangleVertexArray::getVerticesStart ( ) const

Return the pointer to the start of the vertices array.

Returns
A pointer to the start of the vertices data in the array

◆ getVerticesStride()

RP3D_FORCE_INLINE uint32 reactphysics3d::TriangleVertexArray::getVerticesStride ( ) const

Return the vertices stride (number of bytes)

Returns
The number of bytes separating two consecutive vertices in the array

The documentation for this class was generated from the following files: