public override void Build() { AddGround(); RigidBody body1 = new RigidBody(new BoxShape(1, 1, 1)); RigidBody body2 = new RigidBody(new BoxShape(1, 1, 1)); body1.Position = new JVector(0, 7, 0); body2.Position = new JVector(0, 4, 0); // add a prismatic joint. // the minimum allowed distance is 3 // the maximum allowed distance is also 3 // => the body should be fixed on the slider PrismaticJoint pj = new PrismaticJoint(Demo.World, body1, body2, 3, 3); // but we set very heigh softness (1.0f) to the minimum distance // so we have something like a suspension effect. pj.MaximumDistanceConstraint.Softness = 0.0f; pj.MinimumDistanceConstraint.Softness = 1.0f; pj.Activate(); Demo.World.AddBody(body1); Demo.World.AddBody(body2); }
protected override void Init() { base.Init(); var cubeTexture = new Texture("BoxDiffuse.jpg"); cubes = new Cube[PyramidHeight, PyramidHeight]; for (int z=0; z<PyramidHeight; z++) for (int x=0; x<PyramidHeight; x++) cubes[x, z] = new Cube(cubeTexture, new Vector3D( 1.1f*(x-(PyramidHeight)/2.0f), 0, 1.1f*z+2.55f)); for (int z = 0; z < PyramidHeight; z++) for (int x = 0; x < PyramidHeight - 1; x++) { var horizontalJoint = new PrismaticJoint(Entities.world3D, cubes[x, z].body, cubes[x+1, z].body, 1.1f, 1.1f); horizontalJoint.FixedAngleConstraint.Softness = 1; horizontalJoint.Activate(); if (z < PyramidHeight - 1) { var verticalJoint = new PrismaticJoint(Entities.world3D, cubes[x, z].body, cubes[x, z + 1].body, 1.1f, 1.1f); verticalJoint.FixedAngleConstraint.Softness = 1; verticalJoint.Activate(); } } }