pub struct JointDef { /* private fields */ }Expand description
A struct that defines the properties of a joint to be created.
Implementations§
Source§impl JointDef
impl JointDef
Sourcepub fn set_center(&mut self, val: &Vec2)
pub fn set_center(&mut self, val: &Vec2)
Sets the center point of the joint, in local coordinates.
Sourcepub fn get_center(&self) -> Vec2
pub fn get_center(&self) -> Vec2
Gets the center point of the joint, in local coordinates.
Sourcepub fn set_position(&mut self, val: &Vec2)
pub fn set_position(&mut self, val: &Vec2)
Sets the position of the joint, in world coordinates.
Sourcepub fn get_position(&self) -> Vec2
pub fn get_position(&self) -> Vec2
Gets the position of the joint, in world coordinates.
Sourcepub fn distance(
collision: bool,
body_a: &str,
body_b: &str,
anchor_a: &Vec2,
anchor_b: &Vec2,
frequency: f32,
damping: f32,
) -> JointDef
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.
Sourcepub fn friction(
collision: bool,
body_a: &str,
body_b: &str,
world_pos: &Vec2,
max_force: f32,
max_torque: f32,
) -> JointDef
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.
Sourcepub fn gear(
collision: bool,
joint_a: &str,
joint_b: &str,
ratio: f32,
) -> JointDef
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.
Sourcepub 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
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.
Sourcepub 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
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.
Sourcepub 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
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.
Sourcepub 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
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.
Sourcepub fn rope(
collision: bool,
body_a: &str,
body_b: &str,
anchor_a: &Vec2,
anchor_b: &Vec2,
max_length: f32,
) -> JointDef
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.
Sourcepub fn weld(
collision: bool,
body_a: &str,
body_b: &str,
world_pos: &Vec2,
frequency: f32,
damping: f32,
) -> JointDef
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.
Sourcepub 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
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§
Auto Trait Implementations§
impl Freeze for JointDef
impl RefUnwindSafe for JointDef
impl Send for JointDef
impl Sync for JointDef
impl Unpin for JointDef
impl UnwindSafe for JointDef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more