This page has been translated automatically.
Programming
Fundamentials
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Bounds-Related Classes
Containers
Controls-Related Classes
Core Library
Engine-Related Classes
GUI-Related Classes
Node-Related Classes
Pathfinding-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Utility Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

BodyParticles Class

BodyParticles is a base class for BodyCloth and BodyRope classes. It uses a mass-spring simulation model, i.e. particles that are connected by inner joints. The particles are of sphere shape and characterized by a position, mass and velocity. The total mass of the whole cloth is distributed among them. Particles can be acted upon by a force or an impulse. The inner joints can be stretched (linear and angular separately), or linear joints can also be scaled, which provides the same stretching effect. When stretched to the specified distance, joins are torn (the distance is set separately for linear and angular joints).

BodyParticles Class

Members


int getNumParticles ()

Returns the total number of particles that constitute the body.

Return value

The number of particles.

float getAngularRestitution ()

Returns the current restitution of the body's inner joints, when triangles formed by particles are folded angularly relative to each other.

Return value

Joints angular restitution.

float getLinearRestitution ()

Returns the current restitution of the body's inner joints by linear stretching.

Return value

Joints linear restitution.

float getRigidity ()

Returns the current rigidity of the body's inner joints movement, i.e. how much interpolated linear and angular velocities of all joints corrects velocities of each separate joint.

Return value

Rigidity of joints movement:
  • By the value of 0, joints move independently.
  • By the value of 1, joints move uniformly, as interpolated velocity greatly changes velocities of each joint.

float getLinearDamping ()

Returns a value indicating how much the linear velocity of the particles decreases over time.

Return value

Linear damping value.

void addParticleImpulse (int num, const Math::vec3 & impulse)

Applies an impulse to the given particle. Impulses immediately affect particles velocities.

Arguments

  • int num - Particle number.
  • const Math::vec3 & impulse - Amount of impulse to apply.

void setLinearRestitution (float restitution)

Sets the restitution of the body's inner joints by linear stretching.

Arguments

  • float restitution - Joints linear restitution. Provided value is saturated in range [0;1.0].

void setDistance (float distance)

Sets the distance of body simulation.

Arguments

  • float distance - Distance of simulation. If a negative value is provided, 0 will be used instead.

float getFriction ()

Returns the current friction of the body by its contact with other surfaces.

Return value

Body friction.

void setLinearStretch (float stretch)

Sets the scale for the length of linear joints (relative the source mesh topology).

Arguments

  • float stretch - Stretch scale for linear joints. If a negative value is provided, 0 will be used instead.

void setCollisionMask (int mask)

Sets a collision bit mask for the body. Two objects collide, if they both have matching masks.

Arguments

  • int mask - Integer, each bit of which is a mask.

float getLinearStretch ()

Returns the current scale for the length of linear joints (relative the source mesh topology).

Return value

Stretch scale for linear joints.

Math::Vec3 getParticlePosition (int num)

Returns the current position of the specified particle.

Arguments

  • int num - Particle number.

Return value

Particle position in world coordinates.

float getParticleMass (int num)

Returns the current mass of the specified particle.

Arguments

  • int num - Particle number.

Return value

Particle mass.

void setParticleVelocity (int num, const Math::vec3 & velocity)

Sets the velocity of the specified particle.

Arguments

  • int num - Particle number.
  • const Math::vec3 & velocity - Particle velocity.

void setLinearDamping (float damping)

Sets a value indicating how much the linear velocity of the particles decreases over time.

Arguments

  • float damping - Linear damping value. If a negative value is provided, 0 will be used instead.

int getCollisionMask ()

Returns a collision bit mask for the body. Two objects collide, if they both have matching masks.

Return value

Integer, each bit of which is a mask.

void setAngularThreshold (float threshold)

Sets the threshold for angular folding of particles triangles connected by inner joints. When passing this threshold, the joints tear up.

Arguments

  • float threshold - Joints angular folding threshold. If a negative value is provided, 0 will be used instead.

void setParticleMass (int num, float mass)

Sets the mass for the specified particle.

Arguments

  • int num - Particle number.
  • float mass - Particle mass.

float getDistance ()

Returns the current distance of body simulation.

Return value

Distance of simulation.

float getLinearThreshold ()

Returns the current linear stretching of the body's inner joints. When passing this threshold, the joints tear up.

Return value

Joints linear stretching threshold.

void setRadius (float radius)

Sets the radius of the particles forming the body and represented as sphere shapes.

Arguments

  • float radius - Radius of the sphere-shaped particles.

Ptr<BodyParticles> getBodyParticles ()

Return value

void setLinearThreshold (float threshold)

Sets the threshold for linear stretching of the body's inner joints. When passing this threshold, the joints tear up.

Arguments

  • float threshold - Linear stretching threshold. If a negative value is provided, 0 will be used instead.

float getRestitution ()

Returns the current restitution of the body by bouncing.

Return value

Body restitution.

float getAngularThreshold ()

Returns the current threshold for angular folding of particles triangles connected by inner joints. When passing this threshold, the joints tear up.

Return value

Joints angular folding threshold.

void setFriction (float friction)

Sets the friction of the body by its contact with other surfaces.

Arguments

  • float friction - Body friction. If a negative value is provided, 0 will be used instead.

Math::vec3 getParticleVelocity (int num)

Returns the current velocity of the specified particle.

Arguments

  • int num - Particle number.

Return value

Particle velocity.

int getCollision ()

Returns a value indicating if collision with a body is enabled or not.

Return value

Positive value if collision is enabled, 0 if disabled.

void setNumIterations (int iterations)

Sets the number of iterations used to solve inner joints between the particles. Note that if this value is too low, the precision of calculations will suffer.

Arguments

  • int iterations - Number of iterations. If a non-positive value is provided, 1 will be used instead.

void addParticleForce (int num, const Math::vec3 & force)

Applies a force to the given particle. Integrated forces are applied after calling the update.

Arguments

  • int num - Particle number.
  • const Math::vec3 & force - Amount of force to apply.

float getMass ()

Returns the current mass of the body.

Return value

Mass of the body.

void setParticlePosition (int num, const Math::Vec3 & position)

Sets the position of the specified body's particle.

Arguments

  • int num - Particle number.
  • const Math::Vec3 & position - Particle position in world coordinates.

float getRadius ()

Returns the current radius of the particles forming the body and represented as sphere shapes.

Return value

Radius of the sphere-shaped particles.

void setAngularRestitution (float restitution)

Sets the restitution of the body's inner joints, when triangles formed by particles are folded angularly relative to each other.

Arguments

  • float restitution - Joints angular restitution. Provided value is saturated in range [0;1.0].

void setRigidity (float rigidity)

Sets rigidity of the body's inner joints movement, i.e. how much interpolated linear and angular velocities of all joints corrects velocities of each separate joint.

Arguments

  • float rigidity - Rigidity of joints interaction. Provided value is saturated in range [0;1.0]:
    • By the value of 0, joints move independently.
    • By the value of 1, joints move uniformly, as interpolated velocity greatly changes velocities of each joint.

void setCollision (int collision)

Sets a value indicating if collision with a body is enabled or not.

Arguments

  • int collision - Positive value to enable collision, 0 to disable it.

void setMass (float mass)

Sets a mass of the body.

Arguments

  • float mass - Mass of the body. If a negative value is provided, 0 will be used instead.

int getNumIterations ()

Returns the current number of iterations used to solve inner joints between particles.

Return value

Number of iterations.

void setRestitution (float restitution)

Sets the restitution of the body by bouncing.

Arguments

  • float restitution - Body restitution. Provided value is saturated in range [0;1.0].
Last update: 2017-07-03
Build: ()