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

# DynamicRigidBody QML Type

A physical body that can move or be moved. More...

Import Statement: | `import QtQuick3D.Physics`
Since: | Qt 6.4
Inherits: | PhysicsBody

- List of all members, including inherited members

## Properties

- angularAxisLock : AxisLock
- centerOfMassPosition : vector3d
- centerOfMassRotation : quaternion
- density : float
- gravityEnabled : bool
- inertiaMatrix : list<float>
- inertiaTensor : vector3d
- isKinematic : bool
- kinematicEulerRotation : vector4d `(since 6.5)`
- kinematicPivot : vector3d `(since 6.5)`
- kinematicPosition : vector3d `(since 6.5)`
- kinematicRotation : vector3d `(since 6.5)`
- linearAxisLock : AxisLock
- 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)
- setAngularVelocity(vector3d angularVelocity)
- setLinearVelocity(vector3d linearVelocity)

## Detailed Description

This type defines a dynamic rigid body: an object that is part of the physics scene and behaves like a physical object with mass and velocity.

Note: triangle mesh, height field and plane geometry shapes are not allowed as collision shapes when isKinematic is `false`.

## Property Documentation

angularAxisLock : AxisLock

This property locks the angular velocity of the body along the axes defined by the DynamicRigidBody.AxisLock enum. To lock several axes just bitwise-or their enum values.

Available options:

Constant | Description
--- | ---
`DynamicRigidBody.None` | No axis lock.
`DynamicRigidBody.LockX` | Lock X axis.
`DynamicRigidBody.LockY` | Lock Y axis.
`DynamicRigidBody.LockZ` | Lock Z axis.

Default value: `DynamicRigidBody.None`

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

Default value: `(0, 0, 0)`

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

Default value: `(1, 0, 0, 0)`

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

Default value: `0.001`

Range: `(0, inf]`

See also massMode.

gravityEnabled : bool

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

Default value: `true`

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

Default value: A 3x3 identity matrix

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: `(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. Note that to move and rotate the kinematic object you need to use the kinematicPosition, kinematicRotation, kinematicEulerRotation and kinematicPivot properties.

Default value: `false`

See also kinematicPosition, kinematicRotation, kinematicEulerRotation, and kinematicPivot.

kinematicEulerRotation : vector4d `[since 6.5]`

Defines the euler rotation of the object when it is kinematic, i.e. when isKinematic is set to `true`. On each iteration of the simulation the physical object will be updated according to this value.

Default value: `(1, 0, 0, 0)`

This property was introduced in Qt 6.5.

See also isKinematic, kinematicPosition, kinematicEulerRotation, and kinematicPivot.

kinematicPivot : vector3d `[since 6.5]`

Defines the pivot of the object when it is kinematic, i.e. when isKinematic is set to `true`. On each iteration of the simulation the physical object will be updated according to this value.

Default value: `(0, 0, 0)`

This property was introduced in Qt 6.5.

See also isKinematic, kinematicPosition, kinematicEulerRotation, and kinematicRotation.

kinematicPosition : vector3d `[since 6.5]`

Defines the position of the object when it is kinematic, i.e. when isKinematic is set to `true`. On each iteration of the simulation the physical object will be updated according to this value.

Default value: `(0, 0, 0)`

This property was introduced in Qt 6.5.

See also isKinematic, kinematicRotation, kinematicEulerRotation, and kinematicPivot.

kinematicRotation : vector3d `[since 6.5]`

Defines the rotation of the object when it is kinematic, i.e. when isKinematic is set to `true`. On each iteration of the simulation the physical object will be updated according to this value.

Default value: `(0, 0, 0)`

This property was introduced in Qt 6.5.

See also isKinematic, kinematicPosition, kinematicEulerRotation, and kinematicPivot.

linearAxisLock : AxisLock

This property locks the linear velocity of the body along the axes defined by the DynamicRigidBody.AxisLock enum. To lock several axes just bitwise-or their enum values.

Available options:

Constant | Description
--- | ---
`DynamicRigidBody.None` | No axis lock.
`DynamicRigidBody.LockX` | Lock X axis.
`DynamicRigidBody.LockY` | Lock Y axis.
`DynamicRigidBody.LockZ` | Lock Z axis.

Default value: `DynamicRigidBody.None`

mass : float

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

Default value: `1`

Range: `[0, inf]`

See also massMode.

massMode : MassMode

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

Available options:

Constant | Description
--- | ---
`DynamicRigidBody.DefaultDensity` | Use the density specified in the defaultDensity property in PhysicsWorld to calculate mass and inertia assuming a uniform density.
`DynamicRigidBody.CustomDensity` | Use specified density in the specified in the density to calculate mass and inertia assuming a uniform density.
`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.

Default value: `DynamicRigidBody.DefaultDensity`

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

setAngularVelocity(vector3d angularVelocity)

Sets the angularVelocity of the body.

setLinearVelocity(vector3d linearVelocity)

Sets the linearVelocity of the body.