public static void SetSimpleScene(ISimulator simulator) { #region Create a box //create a rigidBody var boxRigidBodyDescriptor = new RigidBodyDescriptor(MotionType.Dynamic, Matrices.Translate(0, 10, 0)); var boxRigidBody = simulator.ActorsFactory.CreateRigidBody(boxRigidBodyDescriptor); //create a simple fixture for the rigidBody var fixtureDescriptor = new FixtureDescriptor(Matrices.I); var simpleFixture = boxRigidBody.FixtureFactory.CreateSimpleFixture(fixtureDescriptor); //define the shape for the simple fixture var boxShapeDescriptor = new BoxShapeDescriptor(3, 3, 3, _motionColor); simpleFixture.ShapeFactory.CreateBox(boxShapeDescriptor); //define the material for the simple fixture var materialDescriptor = new MaterialDescriptor(friction: 0.5f, restitution: 0.6f); simpleFixture.MaterialFactory.CreateMaterial(materialDescriptor); boxRigidBody.MassFrame.UpdateFromShape(); #endregion #region Create a plane for the ground var groundRigidBody = simulator.ActorsFactory.CreateRigidBody(new RigidBodyDescriptor(MotionType.Static, Matrices.I)); var groundSimpleFixture = groundRigidBody.FixtureFactory.CreateSimpleFixture(new FixtureDescriptor(Matrices.I)); groundSimpleFixture.ShapeFactory.CreatePlane(new PlaneShapeDescriptor(Vectors.YAxis, 0, _groundColor)); groundSimpleFixture.MaterialFactory.CreateMaterial(materialDescriptor); #endregion }
IBoxShape IFactoryOf <IBoxShape, BoxShapeDescriptor> .Create(BoxShapeDescriptor descriptor) { var boxShape = new BoxShape(descriptor); Store(boxShape.WrappedBoxShape); return(boxShape); }
private void CreateTower(UniformMaterial material, BoxShapeDescriptor descriptor, int xCount, int yCount, int zCount, float xSpace, float ySpace, float zSpace, float xOffset, float yOffset, float zOffset) { for (int x = 0; x < xCount; x++) { for (int y = 0; y < yCount; y++) { for (int z = 0; z < zCount; z++) { var box = new RigidBody { MotionType = DigitalRune.Physics.MotionType.Dynamic, Pose = new Pose(new Vector3F(xOffset + x * xSpace - ((xCount - 1) * xSpace / 2), yOffset + y * ySpace - ((yCount - 1) * ySpace / 2), zOffset + z * zSpace - ((zCount - 1) * zSpace / 2))), Shape = new BoxShape(descriptor.WidthX, descriptor.WidthY, descriptor.WidthZ), Material = material, UserData = _boxModel }; _simulation.RigidBodies.Add(box); } } } }
public BoxShape(RigidBody rigidBody, Matrix4x4 realParentPose, Material material, BoxShapeDescriptor descriptor) { var boxShapeDescription = new BoxShapeDescription(descriptor.WidthX, descriptor.WidthY, descriptor.WidthZ) { Material = material._wrappedMaterial }; _wrappedBoxShape = (StillDesign.PhysX.BoxShape) rigidBody.WrappedActor.CreateShape(boxShapeDescription); SetRealParentPose(realParentPose); UserData = descriptor.UserData; if (rigidBody.HasDefaultShape) { rigidBody.WrappedActor.Shapes[0].Dispose(); rigidBody.HasDefaultShape = false; } }
IBoxShape IFactoryOf <IBoxShape, BoxShapeDescriptor> .Create(BoxShapeDescriptor descriptor) { return(new Shapes.BoxShape(_simpleFixture._rigidBody, _simpleFixture._realPose, (Material)_simpleFixture.MaterialFactory.Element, descriptor)); }
public static IBoxShape CreateBox(this IFactory <IShape> factory, BoxShapeDescriptor descriptor) { return(factory.Create <IBoxShape, BoxShapeDescriptor>(descriptor)); }
public BoxShape(BoxShapeDescriptor descriptor) { WrappedBoxShape = new global::DigitalRune.Geometry.Shapes.BoxShape(descriptor.WidthX, descriptor.WidthY, descriptor.WidthZ); UserData = descriptor.UserData; }
public DefaultBoxShape(BoxShapeDescriptor descriptor) { Descriptor = descriptor; }