aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples3d/all_examples3.rs3
-rw-r--r--examples3d/spherical_joint_testing.rs38
2 files changed, 41 insertions, 0 deletions
diff --git a/examples3d/all_examples3.rs b/examples3d/all_examples3.rs
index 851bc8a..178fca7 100644
--- a/examples3d/all_examples3.rs
+++ b/examples3d/all_examples3.rs
@@ -53,6 +53,8 @@ mod trimesh3;
mod vehicle_controller3;
mod vehicle_joints3;
+mod spherical_joint_testing;
+
fn demo_name_from_command_line() -> Option<String> {
let mut args = std::env::args();
@@ -149,6 +151,7 @@ pub fn main() {
debug_shape_modification3::init_world,
),
("(Debug) deserialize", debug_deserialize3::init_world),
+ ("Spherical Joint testing", spherical_joint_testing::init_world)
];
// Lexicographic sort, with stress tests moved at the end of the list.
diff --git a/examples3d/spherical_joint_testing.rs b/examples3d/spherical_joint_testing.rs
new file mode 100644
index 0000000..e5f6ace
--- /dev/null
+++ b/examples3d/spherical_joint_testing.rs
@@ -0,0 +1,38 @@
+use rapier3d::prelude::*;
+use rapier_testbed3d::{Testbed, TestbedApp};
+
+pub fn init_world(testbed: &mut Testbed) {
+
+ let mut bodies = RigidBodySet::new();
+ let mut colliders = ColliderSet::new();
+ let impulse_joints = ImpulseJointSet::new();
+ let mut multibody_joints = MultibodyJointSet::new();
+
+
+ let ground = RigidBodyBuilder::fixed().translation(vector![0.0, 0.0, 0.0]);
+ let body = bodies.insert(ground);
+ let collider = ColliderBuilder::cuboid(1.0, 1.0, 1.0);
+ colliders.insert_with_parent(collider, body, &mut bodies);
+
+
+ let rigid_body = RigidBodyBuilder::dynamic().position(Isometry::translation(0.0, 1.0, 0.0));
+ let body_part = bodies.insert(rigid_body);
+ let collider = ColliderBuilder::cuboid(1.0, 1.0, 1.0).density(1.0);
+ colliders.insert_with_parent(collider, body_part, &mut bodies);
+
+
+ let joint = SphericalJointBuilder::new()
+ .local_anchor1(point![0.0, 4.0, 0.0])
+ .local_anchor2(point![0.0, 0.0, 0.0])
+
+ .motor_position(JointAxis::AngX, 1.0, 1000.0, 200.0)
+ .motor_position(JointAxis::AngY, 0.0, 1000.0, 200.0)
+ .motor_position(JointAxis::AngZ, 0.0, 1000.0, 200.0);
+
+
+ multibody_joints.insert(body, body_part, joint, true);
+
+
+ testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
+ testbed.look_at(point![20.0, 0.0, 0.0], point![0.0, 0.0, 0.0]);
+} \ No newline at end of file