You can apply distance constraints between 2 particles using the QSpring. The physics engine uses QSpring to impose distance constraints between particles in objects already simulated using mass-spring models (e.g. QSoftBody objects). However, if the user wants, they can apply specific distance constraints between any 2 particles using QSpring. QWorld also provides methods to manage QSpring objects.
More...
#include <qspring.h>
You can apply distance constraints between 2 particles using the QSpring. The physics engine uses QSpring to impose distance constraints between particles in objects already simulated using mass-spring models (e.g. QSoftBody objects). However, if the user wants, they can apply specific distance constraints between any 2 particles using QSpring. QWorld also provides methods to manage QSpring objects.
- Note
- You can think of QSpring objects as similar to QJoint, which provides special distance constraints for rigid body objects in particle-based simulations. You can also use QSpring to connect objects with each other, but the constraints are enforced between particles.
- Warning
- QSpring will not work correctly on objects that are not simulated with particle dynamics, such as rigid bodies whose positions are fixed by transformations. QSpring relies on the ability to change the positions of particles with freedom of movement to apply constraints correctly.
◆ QSpring() [1/2]
Creates a spring between two particles. But auto calculates length with the distance between two particles.
- Parameters
-
particleA | A particle in the world. |
particleB | Another particle in the world. |
internal | Determines whether the spring connection between two particles is an internal connection within an object. It can usually be set to false. This setting is important for soft body objects with the volume preserving option enabled, where internal spring connections are restricted in different ways. |
◆ QSpring() [2/2]
QSpring::QSpring |
( |
QParticle * |
particleA, |
|
|
QParticle * |
particleB, |
|
|
float |
length, |
|
|
bool |
internal = false |
|
) |
| |
Creates a spring between two particles with a specified length.
- Parameters
-
particleA | A particle in the world. |
particleB | Another particle in the world. |
length | The distance between the two particles. |
internal | Determines whether the spring connection between two particles is an internal connection within an object.It can usually be set to false. This setting is important for soft body objects with the volume preserving option enabled, where internal spring connections are restricted in different ways. |
◆ GetEnabled()
bool QSpring::GetEnabled |
( |
| ) |
|
|
inline |
Returns whether the spring is enabled.
◆ GetIsInternal()
bool QSpring::GetIsInternal |
( |
| ) |
|
|
inline |
Returns whether the spring is internal.
◆ GetLength()
float QSpring::GetLength |
( |
| ) |
|
|
inline |
Returns the length of the spring.
◆ GetParticleA()
Returns particleA of the spring.
◆ GetParticleB()
Returns particleB of the spring.
◆ GetRigidity()
float QSpring::GetRigidity |
( |
| ) |
|
|
inline |
Returns the rigidity of the spring.
◆ SetEnabled()
QSpring* QSpring::SetEnabled |
( |
bool |
value | ) |
|
|
inline |
Sets whether the spring is enabled.
- Parameters
-
- Returns
- A pointer to the spring itself.
◆ SetIsInternal()
QSpring* QSpring::SetIsInternal |
( |
bool |
value | ) |
|
|
inline |
Sets whether the spring is internal.
- Parameters
-
- Returns
- A pointer to the spring itself.
◆ SetLength()
QSpring* QSpring::SetLength |
( |
float |
length | ) |
|
|
inline |
Sets the length of the spring.
- Parameters
-
- Returns
- A pointer to the spring itself.
◆ SetParticleA()
Sets particleA of the spring.
- Parameters
-
particle | A pointer to the particle. |
- Returns
- A pointer to the spring itself.
◆ SetParticleB()
Sets particleB of the spring.
- Parameters
-
particle | A pointer to the particle. |
- Returns
- A pointer to the spring itself.
◆ SetRigidity()
QSpring* QSpring::SetRigidity |
( |
float |
rigidity | ) |
|
|
inline |
Sets the rigidity of the spring.
- Parameters
-
rigidity | The rigidity value to set.It must be a value between 0.0 and 1.0. |
- Returns
- A pointer to the spring itself.
◆ Update()
void QSpring::Update |
( |
float |
rigidity, |
|
|
bool |
internalsException, |
|
|
bool |
isWorldSpring = false |
|
) |
| |
|
virtual |
Applies spring constraints and updates particle positions.
- Parameters
-
rigidity | The rigidity of the constraint. The rigidity must be a value between 0.0 and 1.0. |
internalsException | It is usually set to false. However, if set to true, it pays attention to internal particle connections and applies the constraints accordingly. This setting is important for soft body objects with the volume preserving option enabled. \Note This method is virtual and users can implement custom spring update methods in an interited class of QSpring. |
The documentation for this class was generated from the following files:
- QuarkPhysics/qspring.h
- QuarkPhysics/qspring.cpp