JointParticles Class
The scope of applications for UnigineScript is limited to implementing materials-related logic (material expressions, scriptable materials, brush materials). Do not use UnigineScript as a language for application logic, please consider C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScipt (beyond its scope of applications) is not guaranteed, as the current level of support assumes only fixing critical issues.
Inherits: | Joint |
This class is used to pin cloth body or rope body to rigid bodies, ragdolls or dummy bodies.
Example#
The following code illustrates connection of a rope body (rope) and a dummy body (dummy) using a particles joint. The anchor is placed at the position of a dummy body.
//the anchor point is placed at the position of a dummy body, pinning area size is (0.5f, 0.5f, 1.5f)
JointParticles joint = class_remove(new JointParticles(dummy, rope, dummy.getObject().getPosition(), Vec3(0.5f, 0.5f, 1.5f)));
// setting pinning threshold
joint.setThreshold(0.001f);
// setting number of iterations
joint.setNumIterations(4);
See Also#
Usage examples:
JointParticles Class
Members
static JointParticles ( ) #
Constructor. Creates a particle joint with an anchor at the origin of the world coordinates.static JointParticles ( Body body0, Body body1 ) #
Constructor. Creates a particle joint connecting two given bodies. An anchor is placed in the center of the body to which the cloth or rope is pinned.Arguments
- Body body0 - First body to be connected with the joint. It can be one of the following:
- Body body1 - Second body to be connected with the joint. It can be one of the following:
static JointParticles ( Body body0, Body body1, Vec3 anchor, vec3 size ) #
Constructor. Creates a particles joint connecting two given bodies with specified pinning area size and an anchor placed at specified coordinates.Arguments
- Body body0 - First body to be connected with the joint. It can be one of the following:
- Body body1 - Second body to be connected with the joint. It can be one of the following:
- Vec3 anchor - Anchor coordinates.
- vec3 size - Area for pinning vertices of cloth or rope body to another body.
int getNumParticles ( ) #
Returns the total number of pinned particles of the cloth or rope body.Return value
The number of pinned particles.float getParticleMass ( int num ) #
Returns the mass of the pinned particle of the cloth or rope body.Arguments
- int num - Particle number.
Return value
Particle mass.vec3 getParticlePosition ( int num ) #
Returns the position of the pinned particle of the cloth or rope body.Arguments
- int num - Particle number.
Return value
Particle position.void setSize ( vec3 size ) #
Updates a size of the area for pinning vertices of cloth or rope body to another body.Arguments
- vec3 size - Size of the area to be pinned.
vec3 getSize ( ) #
Returns the current size of the area of pinned vertices of cloth or rope body to another body.Return value
Size of the pinned area.void setThreshold ( float threshold ) #
Updates a threshold that determines the distance for pinning vertices of cloth or rope body to another body. If vertices are closer than the threshold, they are pinned together; otherwise, particles stay loose.Arguments
- float threshold - Threshold of pinning distance.
float getThreshold ( ) #
Returns the current threshold that determines the distance for pinning vertices of cloth or rope body to another body. If vertices are closer than the threshold, they are pinned together; otherwise, particles stay loose.Return value
Threshold of pinning distance.void clearParticles ( ) #
Unpins the cloth or rope body completely.Last update:
2020-07-31
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)