JointDef

Struct JointDef 

Source
pub struct JointDef { /* private fields */ }
Expand description

A struct that defines the properties of a joint to be created.

Implementations§

Source§

impl JointDef

Source

pub fn set_center(&mut self, val: &Vec2)

Sets the center point of the joint, in local coordinates.

Source

pub fn get_center(&self) -> Vec2

Gets the center point of the joint, in local coordinates.

Source

pub fn set_position(&mut self, val: &Vec2)

Sets the position of the joint, in world coordinates.

Source

pub fn get_position(&self) -> Vec2

Gets the position of the joint, in world coordinates.

Source

pub fn set_angle(&mut self, val: f32)

Sets the angle of the joint, in degrees.

Source

pub fn get_angle(&self) -> f32

Gets the angle of the joint, in degrees.

Source

pub fn distance( collision: bool, body_a: &str, body_b: &str, anchor_a: &Vec2, anchor_b: &Vec2, frequency: f32, damping: f32, ) -> JointDef

Creates a distance joint definition.

§Arguments
  • can_collide - Whether or not the physics body connected to joint will collide with each other.
  • body_a - The name of first physics body to connect with the joint.
  • body_b - The name of second physics body to connect with the joint.
  • anchor_a - The position of the joint on the first physics body.
  • anchor_b - The position of the joint on the second physics body.
  • frequency - The frequency of the joint, in Hertz.
  • damping - The damping ratio of the joint.
§Returns
  • JointDef - The new joint definition.
Source

pub fn friction( collision: bool, body_a: &str, body_b: &str, world_pos: &Vec2, max_force: f32, max_torque: f32, ) -> JointDef

Creates a friction joint definition.

§Arguments
  • can_collide - Whether or not the physics body connected to joint will collide with each other.
  • body_a - The first physics body to connect with the joint.
  • body_b - The second physics body to connect with the joint.
  • world_pos - The position of the joint in the game world.
  • max_force - The maximum force that can be applied to the joint.
  • max_torque - The maximum torque that can be applied to the joint.
§Returns
  • Joint - The new friction joint definition.
Source

pub fn gear( collision: bool, joint_a: &str, joint_b: &str, ratio: f32, ) -> JointDef

Creates a gear joint definition.

§Arguments
  • can_collide - Whether or not the physics bodies connected to the joint can collide with each other.
  • joint_a - The first joint to connect with the gear joint.
  • joint_b - The second joint to connect with the gear joint.
  • ratio - The gear ratio.
§Returns
  • Joint - The new gear joint definition.
Source

pub fn spring( collision: bool, body_a: &str, body_b: &str, linear_offset: &Vec2, angular_offset: f32, max_force: f32, max_torque: f32, correction_factor: f32, ) -> JointDef

Creates a new spring joint definition.

§Arguments
  • can_collide - Whether the connected bodies should collide with each other.
  • body_a - The first body connected to the joint.
  • body_b - The second body connected to the joint.
  • linear_offset - Position of body-B minus the position of body-A, in body-A’s frame.
  • angular_offset - Angle of body-B minus angle of body-A.
  • max_force - The maximum force the joint can exert.
  • max_torque - The maximum torque the joint can exert.
  • correction_factor - Correction factor. 0.0 = no correction, 1.0 = full correction.
§Returns
  • Joint - The created joint definition.
Source

pub fn prismatic( collision: bool, body_a: &str, body_b: &str, world_pos: &Vec2, axis_angle: f32, lower_translation: f32, upper_translation: f32, max_motor_force: f32, motor_speed: f32, ) -> JointDef

Creates a new prismatic joint definition.

§Arguments
  • can_collide - Whether the connected bodies should collide with each other.
  • body_a - The first body connected to the joint.
  • body_b - The second body connected to the joint.
  • world_pos - The world position of the joint.
  • axis_angle - The axis angle of the joint.
  • lower_translation - Lower translation limit.
  • upper_translation - Upper translation limit.
  • max_motor_force - Maximum motor force.
  • motor_speed - Motor speed.
§Returns
  • MotorJoint - The created prismatic joint definition.
Source

pub fn pulley( collision: bool, body_a: &str, body_b: &str, anchor_a: &Vec2, anchor_b: &Vec2, ground_anchor_a: &Vec2, ground_anchor_b: &Vec2, ratio: f32, ) -> JointDef

Creates a pulley joint definition.

§Arguments
  • can_collide - Whether or not the connected bodies will collide with each other.
  • body_a - The first physics body to connect.
  • body_b - The second physics body to connect.
  • anchor_a - The position of the anchor point on the first body.
  • anchor_b - The position of the anchor point on the second body.
  • ground_anchor_a - The position of the ground anchor point on the first body in world coordinates.
  • ground_anchor_b - The position of the ground anchor point on the second body in world coordinates.
  • ratio - The pulley ratio.
§Returns
  • Joint - The pulley joint definition.
Source

pub fn revolute( collision: bool, body_a: &str, body_b: &str, world_pos: &Vec2, lower_angle: f32, upper_angle: f32, max_motor_torque: f32, motor_speed: f32, ) -> JointDef

Creates a revolute joint definition.

§Arguments
  • can_collide - Whether or not the connected bodies will collide with each other.
  • body_a - The first physics body to connect.
  • body_b - The second physics body to connect.
  • world_pos - The position in world coordinates where the joint will be created.
  • lower_angle - The lower angle limit in radians.
  • upper_angle - The upper angle limit in radians.
  • max_motor_torque - The maximum torque that can be applied to the joint to achieve the target speed.
  • motor_speed - The desired speed of the joint.
§Returns
  • MotorJoint - The revolute joint definition.
Source

pub fn rope( collision: bool, body_a: &str, body_b: &str, anchor_a: &Vec2, anchor_b: &Vec2, max_length: f32, ) -> JointDef

Creates a rope joint definition.

§Arguments
  • can_collide - Whether or not the connected bodies will collide with each other.
  • body_a - The first physics body to connect.
  • body_b - The second physics body to connect.
  • anchor_a - The position of the anchor point on the first body.
  • anchor_b - The position of the anchor point on the second body.
  • max_length - The maximum distance between the anchor points.
§Returns
  • Joint - The rope joint definition.
Source

pub fn weld( collision: bool, body_a: &str, body_b: &str, world_pos: &Vec2, frequency: f32, damping: f32, ) -> JointDef

Creates a weld joint definition.

§Arguments
  • can_collide - Whether or not the bodies connected to the joint can collide with each other.
  • body_a - The first body to be connected by the joint.
  • body_b - The second body to be connected by the joint.
  • world_pos - The position in the world to connect the bodies together.
  • frequency - The frequency at which the joint should be stiff.
  • damping - The damping rate of the joint.
§Returns
  • Joint - The newly created weld joint definition.
Source

pub fn wheel( collision: bool, body_a: &str, body_b: &str, world_pos: &Vec2, axis_angle: f32, max_motor_torque: f32, motor_speed: f32, frequency: f32, damping: f32, ) -> JointDef

Creates a wheel joint definition.

§Arguments
  • can_collide - Whether or not the bodies connected to the joint can collide with each other.
  • body_a - The first body to be connected by the joint.
  • body_b - The second body to be connected by the joint.
  • world_pos - The position in the world to connect the bodies together.
  • axis_angle - The angle of the joint axis in radians.
  • max_motor_torque - The maximum torque the joint motor can exert.
  • motor_speed - The target speed of the joint motor.
  • frequency - The frequency at which the joint should be stiff.
  • damping - The damping rate of the joint.
§Returns
  • MotorJoint - The newly created wheel joint definition.

Trait Implementations§

Source§

impl Clone for JointDef

Source§

fn clone(&self) -> JointDef

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Drop for JointDef

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl IObject for JointDef

Source§

fn raw(&self) -> i64

Source§

fn obj(&self) -> &dyn IObject

Source§

fn as_any(&self) -> &dyn Any

Source§

fn get_id(&self) -> i32

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.