This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Migration
Migrating to UNIGINE 2.0
C++ API Migration
Migrating from UNIGINE 2.0 to UNIGINE 2.1
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

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

This class inherits from Body

Members


void addParticleForce (int num, vec3 force)

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

Arguments

  • int num - Particle number.
  • vec3 force - Amount of force to apply.

void addParticleImpulse (int num, vec3 impulse)

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

Arguments

  • int num - Particle number.
  • vec3 impulse - Amount of impulse to apply.

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 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.

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.

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.

float getDistance ()

Returns the current distance of body simulation.

Return value

Distance of simulation.

float getFriction ()

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

Return value

Body friction.

float getLinearDamping ()

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

Return value

Linear damping value.

float getLinearRestitution ()

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

Return value

Joints linear restitution.

float getLinearStretch ()

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

Return value

Stretch scale for linear joints.

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.

float getMass ()

Returns the current mass of the body.

Return value

Mass of the body.

int getNumIterations ()

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

Return value

Number of iterations.

int getNumParticles ()

Returns the total number of particles that constitute the body.

Return value

The number of particles.

float getParticleMass (int num)

Returns the current mass of the specified particle.

Arguments

  • int num - Particle number.

Return value

Particle mass.

vec3 getParticlePosition (int num)

Returns the current position of the specified particle.

Arguments

  • int num - Particle number.

Return value

Particle position in world coordinates.

vec3 getParticleVelocity (int num)

Returns the current velocity of the specified particle.

Arguments

  • int num - Particle number.

Return value

Particle velocity.

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.

float getRestitution ()

Returns the current restitution of the body by bouncing.

Return value

Body 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.

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 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 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.

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 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.

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.

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.

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 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 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.

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.

void setNumIterations (int num_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 num_iterations - Number of iterations. If a non-positive value is provided, 1 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.

void setParticlePosition (int num, vec3 position)

Sets the position of the specified body's particle.

Arguments

  • int num - Particle number.
  • vec3 position - Particle position in world coordinates.

void setParticleVelocity (int num, vec3 velocity)

Sets the velocity of the specified particle.

Arguments

  • int num - Particle number.
  • vec3 velocity - Particle velocity.

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.

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].

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.
Last update: 03.07.2017
Build: ()