Every QBody object requires meshes. In other traditional physics engines, the term 'shape' is used instead. However, in Quark Physics, meshes do not only contain information about primitive shapes. A QMesh includes collision shapes, collision behaviors, internal and external spring connections, particle informations, and necessary collective information for rendering. In the QMesh class, there are methods to quickly create primitive types such as circles, rectangles, and polygons that are suitable for the types and needs of body objects. However, QMesh objects are created with a struct called MeshData. Therefore, it is also possible to create many complex mesh examples for body types.
More...
#include <qmesh.h>
|
enum | CollisionBehaviors { CIRCLES
, POLYGONS
, POLYLINE
} |
|
|
static QMesh * | CreateWithCircle (float radius, QVector centerPosition=QVector::Zero()) |
| Creates a mesh with a circle shape. More...
|
|
static QMesh * | CreateWithPolygon (float radius, int sideCount, QVector centerPosition=QVector::Zero(), int polarGrid=-1, bool enableSprings=true, bool enablePolygons=true, float particleRadius=0.5f) |
| Creates a mesh with a convex polygon shape. More...
|
|
static QMesh * | CreateWithRect (QVector size, QVector centerPosition=QVector::Zero(), QVector grid=QVector::Zero(), bool enableSprings=true, bool enablePolygons=true, float particleRadius=0.5f) |
| Creates a mesh with a rectangle shape. More...
|
|
static QMesh * | CreateWithMeshData (QMesh::MeshData &data, bool enableSprings=true, bool enablePolygons=true) |
|
static vector< QMesh::MeshData > | GetMeshDatasFromFile (string filePath) |
|
static vector< QMesh::MeshData > | GetMeshDatasFromJsonData (std::string &jsonBasedData) |
|
static float | GetPolygonArea (vector< QParticle * > &polygonPoints, bool withLocalPositions=false) |
| Returns the area of a polygon. More...
|
|
static bool | CheckCollisionBehaviors (QMesh *meshA, QMesh *meshB, CollisionBehaviors firstBehavior, CollisionBehaviors secondBehavior) |
| Checks collision behaviors between two bodies. If the specified body pair is the same as the specified collision behavior pair, returns true. More...
|
|
static MeshData | GenerateRectangleMeshData (QVector size, QVector centerPosition=QVector::Zero(), QVector grid=QVector::Zero(), float particleRadius=0.5f) |
| Generates rectangle mesh data with specified properties. More...
|
|
static MeshData | GeneratePolygonMeshData (float radius, int sideCount, QVector centerPosition=QVector::Zero(), int polarGrid=-1, float particleRadius=0.5f) |
| Generates a regular polygon mesh data with specified properties. More...
|
|
static pair< QVector, float > | GetAveragePositionAndRotation (vector< QParticle * > particleCollection) |
|
static vector< QVector > | GetMatchingParticlePositions (vector< QParticle * > particleCollection, QVector targetPosition, float targetRotation) |
|
|
void | UpdateCollisionBehavior () |
|
void | UpdateSubConvexPolygons () |
|
void | ApplyAngleConstraintsToPolygon () |
|
bool | CheckIsPolygonConcave (vector< QParticle * > polygonParticles) |
|
|
static bool | CheckIsReflex (QVector pA, QVector pB, QVector pC) |
|
static bool | CheckIsReflex (int indexA, int indexB, int indexC, vector< QParticle * > polygonParticles) |
|
static void | TriangulatePolygon (vector< QParticle * > &polygonParticles, vector< vector< int >> &triangles) |
|
static void | DecompositePolygon (vector< QParticle * > &polygonParticles, vector< vector< QParticle * >> &polygons) |
|
|
vector< QParticle * > | particles =vector<QParticle*>() |
|
QVector | position =QVector::Zero() |
|
QVector | globalPosition =QVector::Zero() |
|
float | rotation =0.0f |
|
float | globalRotation =0.0f |
|
vector< QSpring * > | springs =vector<QSpring*>() |
|
vector< QParticle * > | polygon =vector<QParticle*>() |
|
vector< vector< QParticle * > > | subConvexPolygons =vector<vector<QParticle*>>() |
|
float | circumference =0.0f |
|
QBody * | ownerBody =nullptr |
|
CollisionBehaviors | collisionBehavior =CollisionBehaviors::CIRCLES |
|
vector< vector< int > > | UVMaps =vector<vector<int>>() |
|
bool | collisionBehaviorNeedsUpdate =false |
|
vector< float > | lastPolygonCornerAngles |
|
float | minAngleConstraintOfPolygon =M_PI*0.3 |
|
bool | subConvexPolygonsNeedsUpdate =false |
|
|
class | QWorld |
|
class | QBody |
|
class | QRigidBody |
|
class | QSoftBody |
|
class | QRaycast |
|
class | QCollision |
|
Every QBody object requires meshes. In other traditional physics engines, the term 'shape' is used instead. However, in Quark Physics, meshes do not only contain information about primitive shapes. A QMesh includes collision shapes, collision behaviors, internal and external spring connections, particle informations, and necessary collective information for rendering. In the QMesh class, there are methods to quickly create primitive types such as circles, rectangles, and polygons that are suitable for the types and needs of body objects. However, QMesh objects are created with a struct called MeshData. Therefore, it is also possible to create many complex mesh examples for body types.
◆ QMesh()
◆ AddClosedPolygon()
Adds a polygon to the mesh
- Parameters
-
polygon | A particle pointers collection of the polygon. |
◆ AddParticle()
Adds a particle to the mesh
- Parameters
-
particle | A particle to be added. |
- Returns
- QMesh* A pointer to mesh itself.
◆ AddParticleToPolygon()
QMesh * QMesh::AddParticleToPolygon |
( |
QParticle * |
particle, |
|
|
int |
position = -1 |
|
) |
| |
Adds a particle of the mesh to the polygon. If you want to add a particle to the end of the polygon, set the position value as -1.
- Parameters
-
particle | A pointer to a particle |
position | A position index. Default value is -1, indicating the end of the polygon. |
- Returns
- QMesh* A pointer to mesh itself.
◆ AddSpring()
Adds a spring to the mesh
- Parameters
-
spring | A spring to be added. |
- Returns
- QMesh* A pointer to mesh itself.
◆ AddUVMap()
QMesh * QMesh::AddUVMap |
( |
vector< int > |
map | ) |
|
Adds a UV map to the mesh
- Parameters
-
map | A particle index collection to be added. |
- Returns
- QMesh* A pointer to mesh itself.
◆ CheckCollisionBehaviors()
bool QMesh::CheckCollisionBehaviors |
( |
QMesh * |
meshA, |
|
|
QMesh * |
meshB, |
|
|
CollisionBehaviors |
firstBehavior, |
|
|
CollisionBehaviors |
secondBehavior |
|
) |
| |
|
static |
Checks collision behaviors between two bodies. If the specified body pair is the same as the specified collision behavior pair, returns true.
- Parameters
-
meshA | A mesh to check |
meshB | Another mesh to check |
firstBehavior | A behavior to check |
secondBehavior | Another behavior to check. |
◆ ClearUVMaps()
QMesh * QMesh::ClearUVMaps |
( |
| ) |
|
Removes all UV maps of the mesh.
- Returns
- QMesh* A pointer to mesh itself.
◆ CreateWithCircle()
QMesh * QMesh::CreateWithCircle |
( |
float |
radius, |
|
|
QVector |
centerPosition = QVector::Zero() |
|
) |
| |
|
static |
Creates a mesh with a circle shape.
- Parameters
-
radius | The radius of the circle |
centerPosition | The center position of the circle in the mesh. |
- Returns
- QMesh* A pointer to the created mesh.
◆ CreateWithMeshData()
QMesh * QMesh::CreateWithMeshData |
( |
QMesh::MeshData & |
data, |
|
|
bool |
enableSprings = true , |
|
|
bool |
enablePolygons = true |
|
) |
| |
|
static |
Creates a mesh with a specified mesh data.
- Parameters
-
data | Mesh data. |
enableSprings | Allow springs to the mesh.(It's unnecessary for rigid bodies) |
enablePolygons | Allow polygon colliders to the mesh. Set to false for PBD type soft body needs.
|
- Returns
- QMesh* A pointer to the created mesh.
◆ CreateWithPolygon()
QMesh * QMesh::CreateWithPolygon |
( |
float |
radius, |
|
|
int |
sideCount, |
|
|
QVector |
centerPosition = QVector::Zero() , |
|
|
int |
polarGrid = -1 , |
|
|
bool |
enableSprings = true , |
|
|
bool |
enablePolygons = true , |
|
|
float |
particleRadius = 0.5f |
|
) |
| |
|
static |
Creates a mesh with a convex polygon shape.
- Parameters
-
radius | The radius of the regular polygon |
sideCount | The number of sides of the polygon |
centerPosition | The center position of the polygon in the mesh. |
polarGrid | Applies a polar grid to the polygon with the specified layer count.(It's unnecessary for rigid bodies) |
enableSprings | Allow springs to the polygon.(It's unnecessary for rigid bodies) |
enablePolygons | Allow polygon colliders to the mesh. Set to false for PBD type soft body needs. |
particleRadius | The radius of the particles |
- Returns
- QMesh* A pointer to the created mesh.
◆ CreateWithRect()
QMesh * QMesh::CreateWithRect |
( |
QVector |
size, |
|
|
QVector |
centerPosition = QVector::Zero() , |
|
|
QVector |
grid = QVector::Zero() , |
|
|
bool |
enableSprings = true , |
|
|
bool |
enablePolygons = true , |
|
|
float |
particleRadius = 0.5f |
|
) |
| |
|
static |
Creates a mesh with a rectangle shape.
- Parameters
-
size | The size of the rectangle |
centerPosition | The center position of the rectangle in the mesh. |
grid | The grid property of the rectangle. Applies a grid to the rectangle.(It's unnecessary for rigid bodies) |
enableSprings | Allow springs to the rectangle.(It's unnecessary for rigid bodies) |
enablePolygons | Allows polygon colliders to the mesh. Set to false for PBD type soft body needs.
|
particleRadius | The radius of the particles. |
- Returns
- QMesh* A pointer to the created mesh.
◆ GeneratePolygonMeshData()
QMesh::MeshData QMesh::GeneratePolygonMeshData |
( |
float |
radius, |
|
|
int |
sideCount, |
|
|
QVector |
centerPosition = QVector::Zero() , |
|
|
int |
polarGrid = -1 , |
|
|
float |
particleRadius = 0.5f |
|
) |
| |
|
static |
Generates a regular polygon mesh data with specified properties.
- Parameters
-
radius | The radius of the regular polygon. |
sideCount | The number of sides of the polygon. |
centerPosition | The center position of the polygon. |
polarGrid | Applies a polar grid to the polygon with the specified layer count.(It's unnecessary for rigid bodies) |
particleRadius | The radius of the particles. |
- Returns
- MeshData The data needed to create a mesh.
◆ GenerateRectangleMeshData()
Generates rectangle mesh data with specified properties.
- Parameters
-
size | Size of the rectangle. |
centerPosition | The center position of the rectangle. |
grid | The grid property of the rectangle. Applies a grid to the rectangle.(It's unnecessary for rigid bodies) |
particleRadius | The radius of the particles. |
- Returns
- MeshData The data needed to create a mesh.
◆ GetArea()
Returns total area of the mesh with global positions of particles
◆ GetAveragePositionAndRotation()
pair< QVector, float > QMesh::GetAveragePositionAndRotation |
( |
vector< QParticle * > |
particleCollection | ) |
|
|
static |
Calculates the average position and rotation values of the specified particles.
- Parameters
-
particleCollection | A Particles collection |
- Returns
- Returns a position-rotation pair.
◆ GetCircumference()
float QMesh::GetCircumference |
( |
| ) |
|
|
inline |
Returns total circumference of all polygons of the mesh (Calculates with local positions of particles)
◆ GetCollisionBehavior()
CollisionBehaviors QMesh::GetCollisionBehavior |
( |
| ) |
|
|
inline |
Returns collision behaviors of the mesh. Collision behaviors can be circles, polygons, polylines.
The behaviors feature is important to determine collision methods for the mesh in the runtime.
◆ GetGlobalPosition()
QVector QMesh::GetGlobalPosition |
( |
| ) |
|
|
inline |
Returns the global position of the mesh.
◆ GetGlobalRotation()
float QMesh::GetGlobalRotation |
( |
| ) |
|
|
inline |
Returns the global rotation of the mesh.
◆ GetInitialArea()
float QMesh::GetInitialArea |
( |
| ) |
|
|
inline |
Returns the total area of the mesh with local positions of particles
◆ GetInitialPolygonsArea()
float QMesh::GetInitialPolygonsArea |
( |
| ) |
|
|
inline |
Returns the total polygon area of the mesh with local positions of particles
◆ GetMatchingParticlePositions()
vector< QVector > QMesh::GetMatchingParticlePositions |
( |
vector< QParticle * > |
particleCollection, |
|
|
QVector |
targetPosition, |
|
|
float |
targetRotation |
|
) |
| |
|
static |
Returns the non-deformed particle positions based on the target position and rotation. This method is also used for shape matching operations.
- Parameters
-
particleCollection | A collection of particles |
targetPosition | Target center position to transformation. |
targetRotation | Target center rotation to transformation. |
- Returns
- Returns A list of positions.
◆ GetMeshDatasFromFile()
Returns mesh data list from a json based *.qmesh file.You can use the returned mesh data of the collection with the QWorld::CreateWithMeshData method.
- Parameters
-
filePath | The filePath to load |
- Returns
- vector<QMesh::MeshData> A Mesh data list.
◆ GetMeshDatasFromJsonData()
vector< QMesh::MeshData > QMesh::GetMeshDatasFromJsonData |
( |
std::string & |
jsonBasedData | ) |
|
|
static |
Returns mesh data list from a json based data.You can use the returned mesh data of the collection with the QWorld::CreateWithMeshData method.
- Parameters
-
jsonBasedData | The json data to parse. |
- Returns
- vector<QMesh::MeshData> A Mesh data list.
◆ GetMinAngleConstraintOfPolygon()
float QMesh::GetMinAngleConstraintOfPolygon |
( |
| ) |
|
|
inline |
Returns the minimum angle for the angle constraints of the polygon. If the constraints are disabled, the value will be 0. The default value is pi * 0.1.
- Returns
- The minimum angle value in radians of the angle constraints of the polygon.
◆ GetOwnerBody()
QBody* QMesh::GetOwnerBody |
( |
| ) |
|
|
inline |
Returns owner body of the mesh. Owner body is the body in which the mesh is appointed.
◆ GetParticleAt()
QParticle * QMesh::GetParticleAt |
( |
int |
index | ) |
|
Returns a particle at the specified index
- Parameters
-
particle | The index of particle to get. |
◆ GetParticleCount()
int QMesh::GetParticleCount |
( |
| ) |
|
Returns the total particle count in the mesh.
◆ GetParticleFromPolygon()
QParticle * QMesh::GetParticleFromPolygon |
( |
int |
index | ) |
|
Returns a particle of the polygon at the specified index
- Parameters
-
- Returns
- QParticle* A pointer to the particle.
◆ GetParticleIndex()
int QMesh::GetParticleIndex |
( |
QParticle * |
particle | ) |
|
|
inline |
Returns the index of the specified particle.
- Parameters
-
particle | A particle in the mesh. |
- Returns
- If the particle is found, it returns the index value, otherwise it returns -1.
◆ GetPolygonArea()
float QMesh::GetPolygonArea |
( |
vector< QParticle * > & |
polygonPoints, |
|
|
bool |
withLocalPositions = false |
|
) |
| |
|
static |
Returns the area of a polygon.
- Parameters
-
polygonPoints | A collection of particle pointers of the polygon |
withLocalPositions | Defines whether the calculations will be done with local positions. |
◆ GetPolygonParticleCount()
int QMesh::GetPolygonParticleCount |
( |
| ) |
|
Returns the total particle count of the polygon
◆ GetPolygonsArea()
float QMesh::GetPolygonsArea |
( |
| ) |
|
|
inline |
Returns total polygon area of the mesh with global positions of particles
◆ GetPosition()
Returns the local position of the mesh.
◆ GetRotation()
float QMesh::GetRotation |
( |
| ) |
|
|
inline |
Returns the local rotation of the mesh.
◆ GetSpringAt()
QSpring* QMesh::GetSpringAt |
( |
int |
index | ) |
|
|
inline |
Returns the spring at the specified index.
- Parameters
-
index | The index of the spring to be get. |
◆ GetSpringCount()
int QMesh::GetSpringCount |
( |
| ) |
|
|
inline |
Returns the total spring count in the mesh.
◆ GetSpringIndex()
int QMesh::GetSpringIndex |
( |
QSpring * |
spring | ) |
|
|
inline |
Returns the index of the specified spring.
- Parameters
-
spring | A spring in the mesh. |
- Returns
- If the spring is found, it returns the index value, otherwise it returns -1.
◆ GetSubConvexPolygonAt()
vector<QParticle*>& QMesh::GetSubConvexPolygonAt |
( |
int |
index | ) |
|
|
inline |
Returns polygon at the specified index
- Parameters
-
index | The index of the polygon to get. |
◆ GetSubConvexPolygonCount()
int QMesh::GetSubConvexPolygonCount |
( |
| ) |
|
|
inline |
Returns the total polygon count in the mesh.
◆ GetUVMapAt()
vector<int> QMesh::GetUVMapAt |
( |
int |
index | ) |
|
|
inline |
Returns the UV map at the specified index.
- Parameters
-
index | The index of the UV map to be get. |
◆ GetUVMapCount()
int QMesh::GetUVMapCount |
( |
| ) |
|
|
inline |
Returns the count of the UV maps .
◆ RemoveClosedPolygonAt()
QMesh* QMesh::RemoveClosedPolygonAt |
( |
int |
index | ) |
|
Removes a polygon from the mesh at the specified index.
- Parameters
-
index | The index of the polygon. |
- Returns
- QMesh* A pointer to mesh itself.
◆ RemoveMatchingSprings()
Removes the springs that contain the specified particle.
- Parameters
-
particle | A particle to be matched. |
- Returns
- QMesh* A pointer to mesh itself.
◆ RemoveMatchingUVMaps()
QMesh * QMesh::RemoveMatchingUVMaps |
( |
int |
particleIndex | ) |
|
Removes the UV maps or UV map particle reference that contain the specified particle index.
- Parameters
-
particleIndex | A particle index to be matched. |
- Returns
- QMesh* A pointer to mesh itself.
◆ RemoveParticle()
Removes a particle from the mesh
- Parameters
-
particle | A particle to be removed. |
- Returns
- QMesh* A pointer to mesh itself.
◆ RemoveParticleAt()
QMesh * QMesh::RemoveParticleAt |
( |
int |
index | ) |
|
Removes the particle from the mesh at the specified index.
- Parameters
-
particle | The index of particle to be removed. |
- Returns
- QMesh* A pointer to mesh itself.
◆ RemoveParticleFromPolygon()
Removes a particle from to the polygon.
- Parameters
-
particle | A pointer to a particle |
- Returns
- QMesh* A pointer to mesh itself.
- Note
- A polygon requires at least 3 particles. Please check the number of particles in the polygon before removing any particle from it.
◆ RemoveParticleFromPolygonAt()
QMesh * QMesh::RemoveParticleFromPolygonAt |
( |
int |
index | ) |
|
Removes a particle from to the polygon at the specified index.
- Parameters
-
- Returns
- QMesh* A pointer to mesh itself.
- Note
- A polygon requires at least 3 particles. Please check the number of particles in the polygon before removing any particle from it.
◆ RemovePolygon()
QMesh * QMesh::RemovePolygon |
( |
| ) |
|
Removes the polygon from the mesh.
- Returns
- QMesh* A pointer to mesh itself.
◆ RemoveSpring()
Removes a spring to the mesh
- Parameters
-
spring | A spring to be removed. |
- Returns
- QMesh* A pointer to mesh itself.
◆ RemoveSpringAt()
QMesh * QMesh::RemoveSpringAt |
( |
int |
index | ) |
|
Removes a spring to the mesh at the specified index.
- Parameters
-
index | The index of the spring to be removed. |
- Returns
- QMesh* A pointer to mesh itself.
◆ RemoveUVMapAt()
QMesh * QMesh::RemoveUVMapAt |
( |
int |
index | ) |
|
Removes the springs that contain the specified particle.
- Parameters
-
index | The index of the UV map to be removed. |
- Returns
- QMesh* A pointer to mesh itself.
◆ SetGlobalPosition()
Sets the global position of the mesh
- Parameters
-
value | The global position value to set. |
- Returns
- QMesh* A pointer to mesh itself.
◆ SetMinAngleConstraintOfPolygon()
QMesh* QMesh::SetMinAngleConstraintOfPolygon |
( |
float |
radian | ) |
|
|
inline |
Sets the minimum angle for the angle constraints of the polygon. If the value is 0, it means constraints are disabled. The default value is pi * 0.1.
- Parameters
-
radian | The minimum angle value in radians. |
- Returns
- QMesh* A pointer to mesh itself.
◆ SetPolygon()
Sets a polygon to the mesh
- Parameters
-
polygonParticles | A particle pointers collection of the polygon. |
- Returns
- QMesh* A pointer to mesh itself.
◆ SetPosition()
Sets the local position of the mesh
- Parameters
-
value | The local position value to set. |
- Returns
- QMesh* A pointer to mesh itself.
◆ SetRotation()
QMesh* QMesh::SetRotation |
( |
float |
value | ) |
|
|
inline |
Sets the rotation of the mesh
- Parameters
-
value | The rotation value to set. |
- Returns
- QMesh* A pointer to mesh itself.
The documentation for this struct was generated from the following files:
- QuarkPhysics/qmesh.h
- QuarkPhysics/qmesh.cpp