pub struct D6Joint { /* private fields */ }
Expand description
D6Joint
component. A D6 joint, like a Joint
, connects two dynamic, or one static and one dynamic, entity physically.
It doesn’t have to be a component of one of the entities it connects, but that can be convenient at times.
The D6Joint
has 6 degrees of freedom (hence the name): 3 translational, and 3 rotational.
These can all be controlled individually.
Important: By default all six dimensions of motion are locked, so by default a D6Joint
acts like a fix-joint,
gluing the bodies to each other. To do something else you need to unlock the dimensions with the motion
accessor.
For instance, so create a ball-socket joint you would unlock the rotational degrees of movement but keep the
translational degrees locked.
A joint normally connects two entities, but you can also leave one of the entities
to the default None
value too attach an entity to the world frame,
a static infinite-mass invisible global frame.
Usually accessed through entity.d6_joint
().
The NVIDIA PhysX
documentation
has some more details. Some naming is a little different from the official API, but overall the concepts are the same.
Implementations
sourceimpl D6Joint
impl D6Joint
sourcepub fn entity_1(&self) -> ValueAccessorReadWrite<Entity>
pub fn entity_1(&self) -> ValueAccessorReadWrite<Entity>
The first entity of the joint.
sourcepub fn entity_2(&self) -> ValueAccessorReadWrite<Entity>
pub fn entity_2(&self) -> ValueAccessorReadWrite<Entity>
The second entity of the joint.
sourcepub fn relative_offset_1(&self) -> ValueAccessorReadWrite<Vec3>
pub fn relative_offset_1(&self) -> ValueAccessorReadWrite<Vec3>
The position of the joint relative to the first entity (entity_1
)
sourcepub fn relative_orientation_1(&self) -> ValueAccessorReadWrite<Quat>
pub fn relative_orientation_1(&self) -> ValueAccessorReadWrite<Quat>
The orientation of the joint relative to the first entity (entity_1
)
sourcepub fn relative_offset_2(&self) -> ValueAccessorReadWrite<Vec3>
pub fn relative_offset_2(&self) -> ValueAccessorReadWrite<Vec3>
The position of the joint relative to the second entity (entity_2
)
sourcepub fn relative_orientation_2(&self) -> ValueAccessorReadWrite<Quat>
pub fn relative_orientation_2(&self) -> ValueAccessorReadWrite<Quat>
The orientation of the joint relative to the second entity (entity_2
)
sourcepub fn break_force(&self) -> ValueAccessorReadWrite<f32>
pub fn break_force(&self) -> ValueAccessorReadWrite<f32>
Sets the force threshold for breaking the joint. Default is std::f32::MAX (effectively unbreakable).
sourcepub fn break_torque(&self) -> ValueAccessorReadWrite<f32>
pub fn break_torque(&self) -> ValueAccessorReadWrite<f32>
Sets the torque threshold for breaking the joint. Default is std::f32::MAX (effectively unbreakable).
sourcepub fn is_broken(&self) -> ValueAccessorRead<bool>
pub fn is_broken(&self) -> ValueAccessorRead<bool>
Lets you check whether the joint is broken. Cannot be modified.
sourcepub fn projection_linear_tolerance(&self) -> ValueAccessorReadWriteAnimate<f32>
pub fn projection_linear_tolerance(&self) -> ValueAccessorReadWriteAnimate<f32>
If non-zero, linear projection is enabled (a way of resolving tricky physics situations by moving the parts into place), and the linear projection tolerance is set to this value.
Projection is a on-physical process that violates conservation laws and collision meshes. Only turn it on if you absolutely need to.
sourcepub fn projection_angular_tolerance(&self) -> ValueAccessorReadWriteAnimate<f32>
pub fn projection_angular_tolerance(&self) -> ValueAccessorReadWriteAnimate<f32>
If non-zero, projection is enabled (a way of resolving tricky physics situations by turning the parts into place), and the angular projection tolerance is set to this value.
Projection is a on-physical process that violates conservation laws and collision meshes. Only turn it on if you absolutely need to.
sourcepub fn drive_enable(&self) -> ValueAccessorReadWriteAnimate<bool>
pub fn drive_enable(&self) -> ValueAccessorReadWriteAnimate<bool>
Turns on joint drive. Note that this disables the use of limits on the joint.
sourcepub fn relative_position(&self) -> ValueAccessorRead<Vec3>
pub fn relative_position(&self) -> ValueAccessorRead<Vec3>
Get the raw translation between the two parts of the joint.
sourcepub fn relative_rotation(&self) -> ValueAccessorRead<Quat>
pub fn relative_rotation(&self) -> ValueAccessorRead<Quat>
Get the raw rotation between the two parts of the joint. Not decomposed into TSS (twist, swing1, swing2).
sourcepub fn relative_angles(&self) -> ValueAccessorRead<Vec3>
pub fn relative_angles(&self) -> ValueAccessorRead<Vec3>
Gets the rotation decomposed into TSS (twist, swing1, swing2).
sourcepub fn linear_limit(&self) -> ValueAccessorReadWrite<f32>
pub fn linear_limit(&self) -> ValueAccessorReadWrite<f32>
The limit bounds of a D6 joint. x is min, y is max, what exactly it limits depends on the joint type.
sourcepub fn linear_limit_type(&self) -> ValueAccessorReadWrite<JointLimitType>
pub fn linear_limit_type(&self) -> ValueAccessorReadWrite<JointLimitType>
The linear limit type of a D6 joint.
sourcepub fn linear_limit_spring(&self) -> ValueAccessorReadWrite<D6SpringParams>
pub fn linear_limit_spring(&self) -> ValueAccessorReadWrite<D6SpringParams>
The linear limit spring of a D6 joint.
sourcepub fn twist_limit(&self) -> ValueAccessorReadWrite<Vec2>
pub fn twist_limit(&self) -> ValueAccessorReadWrite<Vec2>
The twist limit bounds of a D6 joint.
sourcepub fn twist_limit_type(&self) -> ValueAccessorReadWrite<JointLimitType>
pub fn twist_limit_type(&self) -> ValueAccessorReadWrite<JointLimitType>
The linear limit type of a D6 joint.
sourcepub fn twist_limit_spring(&self) -> ValueAccessorReadWrite<D6SpringParams>
pub fn twist_limit_spring(&self) -> ValueAccessorReadWrite<D6SpringParams>
The linear limit spring of a D6 joint.
sourcepub fn swing_limit(&self) -> ValueAccessorReadWrite<Vec2>
pub fn swing_limit(&self) -> ValueAccessorReadWrite<Vec2>
The swing limit bounds of a D6 joint (angular)
sourcepub fn swing_limit_type(&self) -> ValueAccessorReadWrite<JointLimitType>
pub fn swing_limit_type(&self) -> ValueAccessorReadWrite<JointLimitType>
The linear limit type of a D6 joint.
sourcepub fn swing_limit_spring(&self) -> ValueAccessorReadWrite<D6SpringParams>
pub fn swing_limit_spring(&self) -> ValueAccessorReadWrite<D6SpringParams>
The swing limit spring of a D6 joint.
sourcepub fn drive_position(&self) -> ValueAccessorReadWrite<Vec3>
pub fn drive_position(&self) -> ValueAccessorReadWrite<Vec3>
Goal position of the D6 drive.
sourcepub fn drive_rotation(&self) -> ValueAccessorReadWrite<Quat>
pub fn drive_rotation(&self) -> ValueAccessorReadWrite<Quat>
Goal rotation of the D6 drive.
sourcepub fn drive_linear_velocity(&self) -> ValueAccessorReadWrite<Vec3>
pub fn drive_linear_velocity(&self) -> ValueAccessorReadWrite<Vec3>
Goal linear velocity of the D6 drive.
sourcepub fn drive_angular_velocity(&self) -> ValueAccessorReadWrite<Vec3>
pub fn drive_angular_velocity(&self) -> ValueAccessorReadWrite<Vec3>
Goal angular velocity of the D6 drive.
sourcepub fn motion(&self, index: D6Axis) -> ValueAccessorReadWrite<D6MotionType>
pub fn motion(&self, index: D6Axis) -> ValueAccessorReadWrite<D6MotionType>
Set the motion type of each of the D6 joint’s six axes, D6Axis
. Can be locked, limited or free.
By default, all six axis are locked, so you need to unlock any axis you would like enable movement of.
Hinge
Free movement aroudn the X axis:
joint.motion(D6Axis::Twist).set(D6MotionType::Free);
Ball-socket joint
joint.motion(D6Axis::Twist).set(D6MotionType::Free);
joint.motion(D6Axis::Swing1).set(D6MotionType::Free);
joint.motion(D6Axis::Swing2).set(D6MotionType::Free);
sourcepub fn drive_params(
&self,
index: D6Drive
) -> ValueAccessorReadWrite<D6DriveParams>
pub fn drive_params(
&self,
index: D6Drive
) -> ValueAccessorReadWrite<D6DriveParams>
Lets you control the six possible drives from D6Drive
by setting a D6DriveParams
.
sourcepub fn drive_is_acceleration(&self) -> ValueAccessorReadWrite<bool>
pub fn drive_is_acceleration(&self) -> ValueAccessorReadWrite<bool>
Controls whether drive is a force (false) or acceleration (true). Acceleration is much easier to tune since it will automatically compute the appropriate force for the masses involved, so it’s the default and recommended value.
sourcepub fn linear_force(&self) -> ValueAccessorRead<Vec3>
pub fn linear_force(&self) -> ValueAccessorRead<Vec3>
Returns the linear force currently exerted on the joint constraint.
sourcepub fn angular_force(&self) -> ValueAccessorRead<Vec3>
pub fn angular_force(&self) -> ValueAccessorRead<Vec3>
Returns the angular force currently exerted on the joint constraint.
Trait Implementations
sourceimpl ComponentTrait for D6Joint
impl ComponentTrait for D6Joint
sourcefn get_type() -> ComponentType
fn get_type() -> ComponentType
The type of the component, as a ComponentType
enum.
sourcefn from_entity(handle: Entity) -> Self
fn from_entity(handle: Entity) -> Self
Adopt an Entity
, wrap in a component struct.
Auto Trait Implementations
impl RefUnwindSafe for D6Joint
impl Send for D6Joint
impl Sync for D6Joint
impl Unpin for D6Joint
impl UnwindSafe for D6Joint
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more