ReactPhysics3D
v0.10.2
C++ Physics engine library
|
This class is a singleton that needs to be instanciated once at the beginning. More...
#include <include/reactphysics3d/engine/PhysicsCommon.h>
Public Member Functions | |
PhysicsCommon (MemoryAllocator *baseMemoryAllocator=nullptr) | |
Constructor. | |
~PhysicsCommon () | |
Destructor. | |
PhysicsWorld * | createPhysicsWorld (const PhysicsWorld::WorldSettings &worldSettings=PhysicsWorld::WorldSettings()) |
Create and return an instance of PhysicsWorld. | |
void | destroyPhysicsWorld (PhysicsWorld *world) |
Destroy an instance of PhysicsWorld. | |
SphereShape * | createSphereShape (const decimal radius) |
Create and return a sphere collision shape. | |
void | destroySphereShape (SphereShape *sphereShape) |
Destroy a sphere collision shape. | |
BoxShape * | createBoxShape (const Vector3 &extent) |
Create and return a box collision shape. | |
void | destroyBoxShape (BoxShape *boxShape) |
Destroy a box collision shape. | |
CapsuleShape * | createCapsuleShape (decimal radius, decimal height) |
Create and return a capsule shape. | |
void | destroyCapsuleShape (CapsuleShape *capsuleShape) |
Destroy a capsule collision shape. | |
ConvexMeshShape * | createConvexMeshShape (ConvexMesh *convexMesh, const Vector3 &scaling=Vector3(1, 1, 1)) |
Create and return a convex mesh shape. | |
void | destroyConvexMeshShape (ConvexMeshShape *convexMeshShape) |
Destroy a convex mesh shape. | |
HeightField * | createHeightField (int nbGridColumns, int nbGridRows, const void *heightFieldData, HeightField::HeightDataType dataType, std::vector< Message > &messages, decimal integerHeightScale=1.0f) |
Create and return a height-field. | |
HeightFieldShape * | createHeightFieldShape (HeightField *heightField, const Vector3 &scaling=Vector3(1, 1, 1)) |
Create and return a height-field shape. | |
void | destroyHeightFieldShape (HeightFieldShape *heightFieldShape) |
Destroy a height-field shape. | |
ConcaveMeshShape * | createConcaveMeshShape (TriangleMesh *triangleMesh, const Vector3 &scaling=Vector3(1, 1, 1)) |
Create and return a concave mesh shape. | |
void | destroyConcaveMeshShape (ConcaveMeshShape *concaveMeshShape) |
Destroy a concave mesh shape. | |
ConvexMesh * | createConvexMesh (const PolygonVertexArray &polygonVertexArray, std::vector< Message > &messages) |
Create a convex mesh from a PolygonVertexArray describing vertices and faces. | |
ConvexMesh * | createConvexMesh (const VertexArray &vertexArray, std::vector< Message > &messages) |
Create a convex mesh from an array of vertices (automatically computing the convex hull using QuickHull) | |
void | destroyConvexMesh (ConvexMesh *convexMesh) |
Destroy a convex mesh. | |
TriangleMesh * | createTriangleMesh (const TriangleVertexArray &triangleVertexArray, std::vector< Message > &messages) |
Create a triangle mesh. | |
void | destroyTriangleMesh (TriangleMesh *triangleMesh) |
Destroy a triangle mesh. | |
void | destroyHeightField (HeightField *heightField) |
Destroy a height-field. | |
DefaultLogger * | createDefaultLogger () |
Create and return a new default logger. | |
void | destroyDefaultLogger (DefaultLogger *logger) |
Destroy a default logger. | |
Static Public Member Functions | |
static Logger * | getLogger () |
Return the current logger. | |
static void | setLogger (Logger *logger) |
Set the logger. | |
This class is a singleton that needs to be instanciated once at the beginning.
Then this class is used by the user as a factory to create the physics world and other objects.
PhysicsCommon::PhysicsCommon | ( | MemoryAllocator * | baseMemoryAllocator = nullptr | ) |
Constructor.
baseMemoryAllocator | Pointer to a user custom memory allocator |
Create and return a box collision shape.
halfExtents | A vector with the three half-extents of the box shape |
CapsuleShape * PhysicsCommon::createCapsuleShape | ( | decimal | radius, |
decimal | height | ||
) |
Create and return a capsule shape.
radius | The radius of the sphere of the capsule shape |
height | The height of the capsule shape (distance betwen the two spheres centers) |
ConcaveMeshShape * PhysicsCommon::createConcaveMeshShape | ( | TriangleMesh * | triangleMesh, |
const Vector3 & | scaling = Vector3(1, 1, 1) |
||
) |
Create and return a concave mesh shape.
triangleMesh | A pointer to the triangle mesh to use to create the concave mesh shape |
scaling | An optional scaling factor to scale the triangle mesh |
ConvexMesh * PhysicsCommon::createConvexMesh | ( | const PolygonVertexArray & | polygonVertexArray, |
std::vector< Message > & | messages | ||
) |
Create a convex mesh from a PolygonVertexArray describing vertices and faces.
The data (vertices, faces indices, ...) are copied from the PolygonVertexArray into the created ConvexMesh.
polygonVertexArray | A pointer to the polygon vertex array to use to create the convex mesh |
messages | A reference to a vector of messages. This vector might contains errors that occured during the creation |
ConvexMesh * PhysicsCommon::createConvexMesh | ( | const VertexArray & | vertexArray, |
std::vector< Message > & | messages | ||
) |
Create a convex mesh from an array of vertices (automatically computing the convex hull using QuickHull)
The data (vertices) are copied from the VertexArray into the created ConvexMesh.
vertexArray | A reference to the vertex object describing the vertices used to compute the convex hull |
messages | A reference to the array of messages with errors that might have happened during convex mesh creation |
ConvexMeshShape * PhysicsCommon::createConvexMeshShape | ( | ConvexMesh * | convexMesh, |
const Vector3 & | scaling = Vector3(1,1,1) |
||
) |
Create and return a convex mesh shape.
convexMesh | A pointer to the convex mesh for this shape |
scaling | Scaling factor to scale the convex mesh if necessary |
DefaultLogger * PhysicsCommon::createDefaultLogger | ( | ) |
Create and return a new default logger.
HeightField * PhysicsCommon::createHeightField | ( | int | nbGridColumns, |
int | nbGridRows, | ||
const void * | heightFieldData, | ||
HeightField::HeightDataType | dataType, | ||
std::vector< Message > & | messages, | ||
decimal | integerHeightScale = 1.0f |
||
) |
Create and return a height-field.
nbGridColumns | Number of columns in the grid of the height field (along the local x axis) | |
nbGridRows | Number of rows in the grid of the height field (along the local z axis) | |
heightFieldData | Pointer to the first height value data (note that values are copied into the heigh-field) | |
dataType | Data type for the height values (int, float, double) | |
[out] | messages | A reference to the array where the messages (warnings, errors, ...) will be stored |
integerHeightScale | Scaling factor for the height values of the height field |
HeightFieldShape * PhysicsCommon::createHeightFieldShape | ( | HeightField * | heightField, |
const Vector3 & | scaling = Vector3(1,1,1) |
||
) |
Create and return a height-field shape.
heightField | A pointer to a HeightField object |
scaling | Scaling vector for the height field |
PhysicsWorld * PhysicsCommon::createPhysicsWorld | ( | const PhysicsWorld::WorldSettings & | worldSettings = PhysicsWorld::WorldSettings() | ) |
Create and return an instance of PhysicsWorld.
worldSettings | The settings of the physics world |
SphereShape * PhysicsCommon::createSphereShape | ( | const decimal | radius | ) |
Create and return a sphere collision shape.
radius | The radius of the sphere collision shape |
TriangleMesh * PhysicsCommon::createTriangleMesh | ( | const TriangleVertexArray & | triangleVertexArray, |
std::vector< Message > & | messages | ||
) |
Create a triangle mesh.
The data (vertices, faces indices) are copied from the TriangleVertexArray into the created ConvexMesh.
triangleVertexArray | A reference to the input TriangleVertexArray |
messages | A reference to the array to stored the messages (warnings, erros, ...) |
void PhysicsCommon::destroyBoxShape | ( | BoxShape * | boxShape | ) |
Destroy a box collision shape.
boxShape | A pointer to the box shape to destroy |
void PhysicsCommon::destroyCapsuleShape | ( | CapsuleShape * | capsuleShape | ) |
Destroy a capsule collision shape.
capsuleShape | A pointer to the capsule shape to destroy |
void PhysicsCommon::destroyConcaveMeshShape | ( | ConcaveMeshShape * | concaveMeshShape | ) |
Destroy a concave mesh shape.
concaveMeshShape | A pointer to the concave mesh shape to destroy |
void PhysicsCommon::destroyConvexMesh | ( | ConvexMesh * | convexMesh | ) |
Destroy a convex mesh.
convexMesh | A pointer to the convex mesh to destroy |
void PhysicsCommon::destroyConvexMeshShape | ( | ConvexMeshShape * | convexMeshShape | ) |
Destroy a convex mesh shape.
convexMeshShape | A pointer to the convex mesh shape to destroy |
void PhysicsCommon::destroyDefaultLogger | ( | DefaultLogger * | logger | ) |
Destroy a default logger.
logger | A pointer to the default logger to destroy |
void PhysicsCommon::destroyHeightField | ( | HeightField * | heightField | ) |
Destroy a height-field.
heightField | A pointer to the height field to destroy |
void PhysicsCommon::destroyHeightFieldShape | ( | HeightFieldShape * | heightFieldShape | ) |
Destroy a height-field shape.
heightFieldShape | A pointer to the height field shape to destroy |
void PhysicsCommon::destroyPhysicsWorld | ( | PhysicsWorld * | world | ) |
Destroy an instance of PhysicsWorld.
world | A pointer to the physics world to destroy |
void PhysicsCommon::destroySphereShape | ( | SphereShape * | sphereShape | ) |
Destroy a sphere collision shape.
sphereShape | A pointer to the sphere collision shape to destroy |
void PhysicsCommon::destroyTriangleMesh | ( | TriangleMesh * | triangleMesh | ) |
Destroy a triangle mesh.
triangleMesh | A pointer to the triangle mesh to destroy |
|
static |
Return the current logger.
|
static |
Set the logger.
logger | A pointer to the logger to use |