diff options
| author | Sébastien Crozet <developer@crozet.re> | 2020-08-31 19:03:56 +0200 |
|---|---|---|
| committer | Sébastien Crozet <developer@crozet.re> | 2020-08-31 19:05:14 +0200 |
| commit | ce26fe107727ee4ef25ee728b3bb3a40914fdc99 (patch) | |
| tree | 01998c193ef4462b2a5ecc5978a9f427119224b6 /examples3d/compound3.rs | |
| parent | 5731b994634661f403cf589fdf1337d0184c7d8e (diff) | |
| download | rapier-ce26fe107727ee4ef25ee728b3bb3a40914fdc99.tar.gz rapier-ce26fe107727ee4ef25ee728b3bb3a40914fdc99.tar.bz2 rapier-ce26fe107727ee4ef25ee728b3bb3a40914fdc99.zip | |
Add compound demo.
Diffstat (limited to 'examples3d/compound3.rs')
| -rw-r--r-- | examples3d/compound3.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/examples3d/compound3.rs b/examples3d/compound3.rs index eb8a472..1c594c6 100644 --- a/examples3d/compound3.rs +++ b/examples3d/compound3.rs @@ -1,4 +1,4 @@ -use na::Point3; +use na::{Point3, Vector3}; use rapier3d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet}; use rapier3d::geometry::{ColliderBuilder, ColliderSet}; use rapier_testbed3d::Testbed; @@ -41,14 +41,20 @@ pub fn init_world(testbed: &mut Testbed) { for i in 0..num { for k in 0usize..num { let x = i as f32 * shift - centerx + offset; - let y = j as f32 * shift + centery + 3.0; + let y = j as f32 * (shift * 2.0) + centery + 3.0; let z = k as f32 * shift - centerz + offset; // Build the rigid body. let rigid_body = RigidBodyBuilder::new_dynamic().translation(x, y, z).build(); let handle = bodies.insert(rigid_body); - let collider = ColliderBuilder::cuboid(rad, rad, rad).density(1.0).build(); - colliders.insert(collider, handle, &mut bodies); + let collider1 = ColliderBuilder::cuboid(rad, rad, rad).density(1.0).build(); + let collider2 = ColliderBuilder::cuboid(rad, rad, rad) + .translation(0.0, -rad * 3.0, 0.0) + .rotation(Vector3::x() * 0.5) + .density(1.0) + .build(); + colliders.insert(collider1, handle, &mut bodies); + colliders.insert(collider2, handle, &mut bodies); } } |
