ReactPhysics3D  v0.10.2
C++ Physics engine library
Loading...
Searching...
No Matches
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.
 
 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.
 
TriangleVertexArrayoperator= (const TriangleVertexArray &triangleVertexArray)=delete
 Deleted assignment operator.
 
 TriangleVertexArray (const TriangleVertexArray &triangleVertexArray)=delete
 Deleted copy-constructor.
 
VertexDataType getVertexDataType () const
 Return the vertex data type.
 
NormalDataType getVertexNormalDataType () const
 Return the vertex normal data type.
 
bool getHasNormals () const
 Return true if the vertices normal have been provided by the user.
 
IndexDataType getIndexDataType () const
 Return the index data type.
 
uint32 getNbVertices () const
 Return the number of vertices.
 
uint32 getNbTriangles () const
 Return the number of triangles.
 
uint32 getVerticesStride () const
 Return the vertices stride (number of bytes)
 
uint32 getVerticesNormalsStride () const
 Return the vertex normals stride (number of bytes)
 
uint32 getIndicesStride () const
 Return the indices stride (number of bytes)
 
const void * getVerticesStart () const
 Return the pointer to the start of the vertices array.
 
const void * getVerticesNormalsStart () const
 Return the pointer to the start of the vertex normals array.
 
const void * getIndicesStart () const
 Return the pointer to the start of the indices array.
 
void getTriangleVerticesIndices (uint32 triangleIndex, uint32 &outV1Index, uint32 &outV2Index, uint32 &outV3Index) const
 Return the three vertex indices of a given triangle face.
 
Vector3 getVertex (uint32 vertexIndex) const
 Return a vertex of the array.
 
Vector3 getVertexNormal (uint32 vertexIndex) const
 Return a vertex normal of the array.
 

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: