Quark Physics  1.0
2D Rigid and Soft Body Physics Engine
QParticle Class Reference

QParticle objects form the network structures of QMesh objects defined for all body object types. They are the smallest building blocks of physics simulation and are manipulated differently in different body object types. For example, in QRigidBody objects, particles are collectively forced into positions obtained through various calculations based on the current body properties. However, in soft body objects, simulation particles are individually manipulated and can move freely, determining the next steps of the simulation through their individual movements. QMesh objects offer a number of methods to manage particles. For more information on restrictions between particles in soft body objects, see the QSpring object. More...

#include <qparticle.h>

Public Member Functions

 QParticle (float posX, float posY, float radius=0.5f)
 
 QParticle (QVector pos, float radius=0.5f)
 
QVector GetGlobalPosition ()
 
QVector GetPreviousGlobalPosition ()
 
QVector GetPosition ()
 
float GetMass ()
 
QMeshGetOwnerMesh ()
 
float GetRadius ()
 
bool GetIsInternal ()
 
QVector GetForce ()
 
QParticleSetGlobalPosition (QVector value)
 
QParticleAddGlobalPosition (QVector value)
 
QParticleSetPreviousGlobalPosition (QVector value)
 
QParticleAddPreviousGlobalPosition (QVector value)
 
QParticleSetPosition (QVector value)
 
QParticleAddPosition (QVector value)
 
QParticleSetMass (float value)
 
QParticleSetOwnerMesh (QMesh *mesh)
 
QParticleSetRadius (float radius)
 
QParticleSetIsInternal (bool value)
 
QParticleApplyForce (QVector value)
 
QParticleSetForce (QVector value)
 
QParticleAddForce (QVector value)
 
QParticleAddAccumulatedForce (QVector value)
 
QParticleClearAccumulatedForces ()
 
QParticleApplyAccumulatedForces ()
 

Static Public Member Functions

static void ApplyForceToParticleSegment (QParticle *pA, QParticle *pB, QVector force, QVector fromPosition)
 

Detailed Description

QParticle objects form the network structures of QMesh objects defined for all body object types. They are the smallest building blocks of physics simulation and are manipulated differently in different body object types. For example, in QRigidBody objects, particles are collectively forced into positions obtained through various calculations based on the current body properties. However, in soft body objects, simulation particles are individually manipulated and can move freely, determining the next steps of the simulation through their individual movements. QMesh objects offer a number of methods to manage particles. For more information on restrictions between particles in soft body objects, see the QSpring object.

Member Function Documentation

◆ AddAccumulatedForce()

QParticle * QParticle::AddAccumulatedForce ( QVector  value)

Adds a new force to the accumulated forces. The purpose of the accumulated forces is to apply their arithmetic average using ApplyAccumulatedForce(). Before performing operations with the accumulated forces, they must be cleared using ClearAccumulatedForce().

Parameters
valueA value to add.
Returns
A pointer to the particle itself.

◆ AddForce()

QParticle * QParticle::AddForce ( QVector  value)

Adds a value to the force of the particle.Set forces determine the force to be applied to a particle object at the next physics step from the current step.

Parameters
valueA value to add.
Returns
A pointer to the particle itself.

◆ AddGlobalPosition()

QParticle * QParticle::AddGlobalPosition ( QVector  value)

Sets the global position of the particle.

Parameters
valueA position value to set.
Returns
A pointer to the particle itself.

◆ AddPosition()

QParticle * QParticle::AddPosition ( QVector  value)

Adds a value to the local position of the particle.

Parameters
valueA value to add.
Returns
A pointer to the particle itself.

◆ AddPreviousGlobalPosition()

QParticle * QParticle::AddPreviousGlobalPosition ( QVector  value)

Adds a value to the previous global position of the particle.

Parameters
valueA value to add.
Returns
A pointer to the particle itself.

◆ ApplyAccumulatedForces()

QParticle * QParticle::ApplyAccumulatedForces ( )

Calculates the arithmetic average of the accumulated forces based on the number of forces, applies it to the particle, and then clears all forces.

◆ ApplyForce()

QParticle * QParticle::ApplyForce ( QVector  value)

Applies a force immediately to the particle. You can use the method safely before the physics step (e.g. at the OnPreStep event of QBody objects). If you want to use this method after physics step, it can break the simulation.(Collisions and constraints may not be applied properly.) if you want to apply force at the next physic step safely, use SetForce() and AddForce() methods.

Parameters
valueA force value to apply.

◆ ApplyForceToParticleSegment()

void QParticle::ApplyForceToParticleSegment ( QParticle pA,
QParticle pB,
QVector  force,
QVector  fromPosition 
)
static

Applies a specified force to a segment created by two particles at a specific position.

Parameters
pAA particle in the world.
pBAnother particle in the world.
forceA force value to apply.
fromPositionThe position of the force.

◆ ClearAccumulatedForces()

QParticle * QParticle::ClearAccumulatedForces ( )

Clears the accumulated forces. It should be called before working with accumulated forces. Additionally, the accumulated forces are automatically cleared after the ApplyAccumulatedForce() method is called.

◆ GetForce()

QVector QParticle::GetForce ( )
inline

Returns the current force value of the particle.

◆ GetGlobalPosition()

QVector QParticle::GetGlobalPosition ( )
inline

Returns the global position of the particle.

◆ GetIsInternal()

bool QParticle::GetIsInternal ( )
inline

Returns whether the particle is internal. Internal particle definition is used not for the particles that define the collision boundaries of a mesh, but for the grid particles inside these boundaries. This feature is important for simulation types that require different internal particle simulation, such as volume preserved soft bodies.

◆ GetMass()

float QParticle::GetMass ( )
inline

Returns the mass of the particle.

◆ GetOwnerMesh()

QMesh* QParticle::GetOwnerMesh ( )
inline

Returns owner mesh of the particle. The Owner mesh is the mesh in which the particle is appointed.

◆ GetPosition()

QVector QParticle::GetPosition ( )
inline

Returns the local position of the particle.

◆ GetPreviousGlobalPosition()

QVector QParticle::GetPreviousGlobalPosition ( )
inline

Returns the previous global position of the particle.

◆ GetRadius()

float QParticle::GetRadius ( )
inline

Returns the radius of the particle.

◆ SetForce()

QParticle * QParticle::SetForce ( QVector  value)

Sets the force value of the particle. Set forces determine the force to be applied to a particle object at the next physics step from the current step.

Parameters
valueA value to set.
Returns
A pointer to the particle itself.

◆ SetGlobalPosition()

QParticle * QParticle::SetGlobalPosition ( QVector  value)

Sets the local position of the particle.

Parameters
valueA position value to set.
Returns
A pointer to the particle itself.

◆ SetIsInternal()

QParticle * QParticle::SetIsInternal ( bool  value)

Sets whether the particle is internal.Internal particle definition is used not for the particles that define the collision boundaries of a mesh, but for the grid particles inside these boundaries. This feature is important for simulation types that require different internal particle simulation, such as volume preserved soft bodies.

Parameters
valueTrue or false.
Returns
A pointer to the particle itself.

◆ SetMass()

QParticle * QParticle::SetMass ( float  value)

Sets the mass of the particle.

Parameters
valueA value to set.
Returns
A pointer to the particle itself.

◆ SetOwnerMesh()

QParticle * QParticle::SetOwnerMesh ( QMesh mesh)

Sets the owner mesh of the particle. Usually the owner mesh is defining when a particle added to a mesh.

Parameters
meshA pointer of the mesh to set.
Returns
A pointer to the particle itself.

◆ SetPreviousGlobalPosition()

QParticle * QParticle::SetPreviousGlobalPosition ( QVector  value)

Sets the previous global position of the particle.

Parameters
valueA position value to set.
Returns
A pointer to the particle itself.

◆ SetRadius()

QParticle * QParticle::SetRadius ( float  radius)

Sets the radius of the particle.

Parameters
radiusA value to set.
Returns
A pointer to the particle itself.

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