- Qt 6.4
- Qt Quick 3D Physics
- QML Types
- DynamicRigidBody
- Qt Quick 3D Physics | Commercial or GPLv3

# DynamicRigidBody QML Type

Dynamic rigid body. More...

Import Statement: | import QtQuick3DPhysics
Since: | Qt 6.4
Inherits: | PhysicsBody

- List of all members, including inherited members

## Properties

- angularVelocity : vector3d
- axisLockAngularX : bool
- axisLockAngularY : bool
- axisLockAngularZ : bool
- axisLockLinearX : bool
- axisLockLinearY : bool
- axisLockLinearZ : bool
- centerOfMassPosition : vector3d
- centerOfMassRotation : quaternion
- density : float
- gravityEnabled : bool
- inertiaMatrix : list<float>
- inertiaTensor : vector3d
- isKinematic : bool
- linearVelocity : vector3d
- mass : float
- massMode : MassMode

## Methods

- applyCentralForce(vector3d force)
- applyCentralImpulse(vector3d impulse)
- applyForce(vector3d force, vector3d position)
- applyImpulse(vector3d impulse, vector3d position)
- applyTorque(vector3d torque)
- applyTorqueImpulse(vector3d impulse)
- reset(vector3d position, vector3d eulerRotation)

## Detailed Description

This is the dynamic rigid body. A dynamic rigid body is an object that is part of the physics scene and behaves like a physical object with mass and velocity. Note that triangle mesh, heightfield and plane geometry shapes are only allowed as collision shapes when isKinematic is `true`.

## Property Documentation

angularVelocity : vector3d

This property defines the angular velocity of the body.

axisLockAngularX : bool

This property locks the angular velocity of the body along the X-axis.

axisLockAngularY : bool

This property locks the angular velocity of the body along the Y-axis.

axisLockAngularZ : bool

This property locks the angular velocity of the body along the Z-axis.

axisLockLinearX : bool

This property locks the linear velocity of the body along the X-axis.

axisLockLinearY : bool

This property locks the linear velocity of the body along the Y-axis.

axisLockLinearZ : bool

This property locks the linear velocity of the body along the Z-axis.

centerOfMassPosition : vector3d

Defines the position of the center of mass relative to the body. Note that this is only used when massMode is set to `DynamicRigidBody.MassAndInertiaTensor`.

See also massMode and inertiaTensor.

centerOfMassRotation : quaternion

Defines the rotation of the center of mass pose, i.e. it specifies the orientation of the body's principal inertia axes relative to the body. Note that this is only used when massMode is set to `DynamicRigidBody.MassAndInertiaTensor`.

See also massMode and inertiaTensor.

density : float

This property defines the density of the body. This is only used when massMode is set to `DynamicRigidBody.Density`. When this property is less than or equal to zero, this body will use the defaultDensity value.

Default value is `-1`.

See also massMode.

gravityEnabled : bool

This property defines whether the object is going to be affected by gravity or not.

inertiaMatrix : list<float>

Defines the inertia tensor matrix. This is a 3x3 matrix in column-major order. Note that this matrix is expected to be diagonalizable. Note that this is only used when massMode is set to `DynamicRigidBody.MassAndInertiaMatrix`.

See also massMode and inertiaTensor.

inertiaTensor : vector3d

Defines the inertia tensor vector, using a parameter specified in mass space coordinates.

This is the diagonal vector of a 3x3 diagonal matrix, if you have a non diagonal world/actor space inertia tensor then you should use inertiaMatrix instead.

The inertia tensor components must be positive and a value of 0 in any component is interpreted as infinite inertia along that axis. Note that this is only used when massMode is set to `DynamicRigidBody.MassAndInertiaTensor`.

Default value is (1, 1, 1).

See also massMode and inertiaMatrix.

isKinematic : bool

This property defines whether the object is kinematic or not. A kinematic object does not get influenced by external forces and can be seen as an object of infinite mass. If this property is set then in every simulation frame the physical object will be moved to its target position regardless of external forces.

linearVelocity : vector3d

This property defines the linear velocity of the body.

mass : float

This property defines the mass of the body. Note that this is only used when massMode is not `DynamicRigidBody.Density`. Also note that a value of 0 is interpreted as infinite mass and that negative numbers are not allowed.

Default value is `1`.

See also massMode.

massMode : MassMode

This property holds the enum which describes how mass and inertia are calculated for this body.

By default, `DynamicRigidBody.Density` is used.

Available options:

Constant | Description
--- | ---
`DynamicRigidBody.Density` | Use the specified density to calculate mass and inertia assuming a uniform density. If density is non-positive then the defaultDensity property in DynamicsWorld is used.
`DynamicRigidBody.Mass` | Use the specified mass to calculate inertia assuming a uniform density.
`DynamicRigidBody.MassAndInertiaTensor` | Use the specified mass value and inertia tensor.
`DynamicRigidBody.MassAndInertiaMatrix` | Use the specified mass value and calculate inertia from the specified inertia matrix.

## Method Documentation

applyCentralForce(vector3d force)

Applies a force on the center of the body.

applyCentralImpulse(vector3d impulse)

Applies an impulse on the center of the body.

applyForce(vector3d force, vector3d position)

Applies a force at a position on the body.

applyImpulse(vector3d impulse, vector3d position)

Applies an impulse at a position on the body.

applyTorque(vector3d torque)

Applies a torque on the body.

applyTorqueImpulse(vector3d impulse)

Applies a torque impulse on the body.

reset(vector3d position, vector3d eulerRotation)

Resets the body's position and eulerRotation.