예제 #1
0
        public static RevoluteJoint RevoluteJoint(Scene scene)
        {
            BoxShapeDescription boxShapeDescA = new BoxShapeDescription(3, 3, 3);
            BoxShapeDescription boxShapeDescB = new BoxShapeDescription(3, 3, 3);

            ActorDescription actorDescA = new ActorDescription()
            {
                BodyDescription = new BodyDescription(10.0f),
                GlobalPose      = Matrix.Translation(75, 1.5f, -55),
                Shapes          = { boxShapeDescA }
            };
            Actor actorA = scene.CreateActor(actorDescA);

            ActorDescription actorDescB = new ActorDescription()
            {
                BodyDescription = new BodyDescription(10.0f),
                GlobalPose      = Matrix.Translation(70, 1.5f, -55),
                Shapes          = { boxShapeDescB }
            };
            Actor actorB = scene.CreateActor(actorDescB);

            //

            RevoluteJointDescription revoluteJointDesc = new RevoluteJointDescription()
            {
                Actor1 = actorA,
                Actor2 = actorB,
                Motor  = new MotorDescription(20, 20.1f, true)
            };

            revoluteJointDesc.Flags |= RevoluteJointFlag.MotorEnabled;
            revoluteJointDesc.SetGlobalAnchor(new Vector3(73.5f, 1.5f, -55));
            revoluteJointDesc.SetGlobalAxis(new Vector3(1, 0, 0));

            RevoluteJoint revoluteJoint = scene.CreateJoint(revoluteJointDesc) as RevoluteJoint;

            return(revoluteJoint);
        }
예제 #2
0
		public static RevoluteJoint RevoluteJoint(Scene scene)
		{
			BoxShapeDescription boxShapeDescA = new BoxShapeDescription(3, 3, 3);
			BoxShapeDescription boxShapeDescB = new BoxShapeDescription(3, 3, 3);

			ActorDescription actorDescA = new ActorDescription()
			{
				BodyDescription = new BodyDescription(10.0f),
				GlobalPose = Matrix.Translation(75, 1.5f, -55),
				Shapes = { boxShapeDescA }
			};
			Actor actorA = scene.CreateActor(actorDescA);

			ActorDescription actorDescB = new ActorDescription()
			{
				BodyDescription = new BodyDescription(10.0f),
				GlobalPose = Matrix.Translation(70, 1.5f, -55),
				Shapes = { boxShapeDescB }
			};
			Actor actorB = scene.CreateActor(actorDescB);

			//

			RevoluteJointDescription revoluteJointDesc = new RevoluteJointDescription()
			{
				Actor1 = actorA,
				Actor2 = actorB,
				Motor = new MotorDescription(20, 20.1f, true)
			};
			revoluteJointDesc.Flags |= RevoluteJointFlag.MotorEnabled;
			revoluteJointDesc.SetGlobalAnchor(new Vector3(73.5f, 1.5f, -55));
			revoluteJointDesc.SetGlobalAxis(new Vector3(1, 0, 0));

			RevoluteJoint revoluteJoint = scene.CreateJoint(revoluteJointDesc) as RevoluteJoint;

			return revoluteJoint;
		}
예제 #3
0
        public void LoadPhysics()
        {
            Core  _core  = this.Core;
            Scene _scene = this.Scene;

            #region Some Boxes
            for (int x = 0; x < 5; x++)
            {
                BoxShapeDescription boxShapeDesc = new BoxShapeDescription(2, 3, 8);

                ActorDescription actorDesc = new ActorDescription()
                {
                    Name            = String.Format("Box {0}", x),
                    BodyDescription = new BodyDescription(10.0f),
                    GlobalPose      = Matrix.Translation(100, 15 + 3 * x, 20),
                    Shapes          = { boxShapeDesc }
                };

                Actor actor = _scene.CreateActor(actorDesc);
            }
            #endregion

            //#region Cloth (Flag)
            //{
            //    // Create a Grid of Points
            //    VertexGrid grid = VertexGrid.CreateGrid( 10, 10 );

            //    ClothMeshDescription clothMeshDesc = new ClothMeshDescription();
            //        clothMeshDesc.AllocateVertices<Vector3>( grid.Points.Length );
            //        clothMeshDesc.AllocateTriangles<int>( grid.Indices.Length / 3 );

            //        clothMeshDesc.VertexCount = grid.Points.Length;
            //        clothMeshDesc.TriangleCount = grid.Indices.Length / 3;

            //        clothMeshDesc.VerticesStream.SetData( grid.Points );
            //        clothMeshDesc.TriangleStream.SetData( grid.Indices );

            //        // We are using 32 bit integers, so make sure the 16 bit flag is removed.
            //        // 32 bits are the default, so this isn't technically needed
            //        clothMeshDesc.Flags &= ~MeshFlag.Indices16Bit;

            //    // Write the cooked data to memory
            //    MemoryStream memoryStream = new MemoryStream();

            //    Cooking.InitializeCooking();
            //    Cooking.CookClothMesh( clothMeshDesc, memoryStream );
            //    Cooking.CloseCooking();

            //    // Need to reset the position of the stream to the beginning
            //    memoryStream.Position = 0;

            //    ClothMesh clothMesh = _core.CreateClothMesh( memoryStream );

            //    //

            //    ClothDescription clothDesc = new ClothDescription()
            //    {
            //        ClothMesh = clothMesh,
            //        Flags = ClothFlag.Gravity | ClothFlag.Bending | ClothFlag.CollisionTwoway | ClothFlag.Visualization,
            //        GlobalPose =
            //            Matrix.CreateFromYawPitchRoll( 0, (float)Math.PI / 2.0f, (float)Math.PI / 2.0f ) *
            //            Matrix.CreateTranslation( 0, 20, 0 )
            //    };
            //    clothDesc.MeshData.AllocatePositions<Vector3>( grid.Points.Length );
            //    clothDesc.MeshData.AllocateIndices<int>( grid.Indices.Length );

            //    clothDesc.MeshData.MaximumVertices = grid.Points.Length;
            //    clothDesc.MeshData.MaximumIndices = grid.Indices.Length;

            //    clothDesc.MeshData.NumberOfVertices = grid.Points.Length;
            //    clothDesc.MeshData.NumberOfIndices = grid.Indices.Length;

            //    _flag = _scene.CreateCloth( clothDesc );

            //    // Flag Pole
            //    ActorDescription flagPoleActorDesc = new ActorDescription()
            //    {
            //        GlobalPose = Matrix.CreateTranslation( 0, 10, 0 ),
            //        Shapes = { new BoxShapeDescription( 1.0f, 20.0f, 1.0f ) }
            //    };

            //    Actor flagPoleActor = _scene.CreateActor( flagPoleActorDesc );

            //    _flag.AttachToShape( flagPoleActor.Shapes[ 0 ], 0 );
            //    _flag.WindAcceleration = new Vector3( 10, 10, 10 );
            //    _flag.BendingStiffness = 0.1f;
            //}
            //#endregion

            #region Revolute Joint
            {
                BoxShapeDescription boxShapeDescA = new BoxShapeDescription(3, 3, 3);
                BoxShapeDescription boxShapeDescB = new BoxShapeDescription(3, 3, 3);

                ActorDescription actorDescA = new ActorDescription()
                {
                    BodyDescription = new BodyDescription(10.0f),
                    GlobalPose      = Matrix.Translation(75, 1.5f, 55),
                    Shapes          = { boxShapeDescA }
                };
                Actor actorA = _scene.CreateActor(actorDescA);

                ActorDescription actorDescB = new ActorDescription()
                {
                    BodyDescription = new BodyDescription(10.0f),
                    GlobalPose      = Matrix.Translation(70, 1.5f, 55),
                    Shapes          = { boxShapeDescB }
                };
                Actor actorB = _scene.CreateActor(actorDescB);

                //

                RevoluteJointDescription revoluteJointDesc = new RevoluteJointDescription()
                {
                    Actor1 = actorA,
                    Actor2 = actorB,
                    Motor  = new MotorDescription(20, 20.1f, true)
                };
                revoluteJointDesc.Flags |= RevoluteJointFlag.MotorEnabled;
                revoluteJointDesc.SetGlobalAnchor(new Vector3(73.5f, 1.5f, 55));
                revoluteJointDesc.SetGlobalAxis(new Vector3(1, 0, 0));

                RevoluteJoint revoluteJoint = _scene.CreateJoint(revoluteJointDesc) as RevoluteJoint;
            }
            #endregion

            #region Prismatic Joint with Limit
            {
                Actor actorA, actorB;
                {
                    BoxShapeDescription boxShapeDesc = new BoxShapeDescription(3, 3, 3);

                    BodyDescription bodyDesc = new BodyDescription(10.0f);
                    bodyDesc.BodyFlags |= BodyFlag.Kinematic;

                    ActorDescription actorDesc = new ActorDescription()
                    {
                        BodyDescription = bodyDesc,
                        GlobalPose      = Matrix.Translation(70, 25, 65),
                        Shapes          = { boxShapeDesc }
                    };
                    actorA = _scene.CreateActor(actorDesc);
                }
                {
                    BoxShapeDescription boxShapeDesc = new BoxShapeDescription(3, 3, 3);

                    ActorDescription actorDesc = new ActorDescription()
                    {
                        BodyDescription = new BodyDescription(10.0f),
                        GlobalPose      = Matrix.Translation(70, 15, 65),
                        Shapes          = { boxShapeDesc }
                    };
                    actorB = _scene.CreateActor(actorDesc);
                }

                PrismaticJointDescription prismaticJointDesc = new PrismaticJointDescription()
                {
                    Actor1 = actorA,
                    Actor2 = actorB,
                };
                prismaticJointDesc.SetGlobalAnchor(new Vector3(70, 20, 65));
                prismaticJointDesc.SetGlobalAxis(new Vector3(0, 1, 0));

                PrismaticJoint prismaticJoint = _scene.CreateJoint(prismaticJointDesc) as PrismaticJoint;

                LimitPlane limitPlane = new LimitPlane(new Vector3(0, 1, 0), new Vector3(-30, 8, -30), 0);
                prismaticJoint.AddLimitPlane(limitPlane);
            }
            #endregion

            #region Fluid
            {
                const int maximumParticles = 1000;

                FluidEmitterDescription fluidEmitterDesc = new FluidEmitterDescription()
                {
                    DimensionX   = 0.5f,
                    DimensionY   = 0.5f,
                    Rate         = 15,
                    RelativePose = Matrix.Translation(-40, 10, 50),
                    Shape        = EmitterShape.Rectangular,
                    Type         = EmitterType.ConstantFlowRate,
                    RandomAngle  = 0.5f
                };
                fluidEmitterDesc.Flags |= (FluidEmitterFlag.Enabled | FluidEmitterFlag.Visualization);

                FluidDescription fluidDesc = new FluidDescription()
                {
                    Emitters         = { fluidEmitterDesc },
                    Flags            = FluidFlag.Enabled | FluidFlag.Visualization,
                    MaximumParticles = maximumParticles
                };
                fluidDesc.ParticleWriteData.AllocatePositionBuffer <Vector3>(maximumParticles);
                fluidDesc.ParticleWriteData.NumberOfParticles = maximumParticles;

                Fluid fluid = _scene.CreateFluid(fluidDesc);

                // Ledge
                {
                    BoxShapeDescription boxShapeDesc = new BoxShapeDescription(5, 0.1f, 5);

                    ActorDescription drainActorDesc = new ActorDescription()
                    {
                        GlobalPose = Matrix.RotationX(0.5f) * Matrix.Translation(-40, 5, 52),
                        Shapes     = { boxShapeDesc }
                    };

                    Actor drianActor = _scene.CreateActor(drainActorDesc);
                }

                // Drain
                {
                    BoxShapeDescription boxShapeDesc = new BoxShapeDescription(5, 0.1f, 5);
                    boxShapeDesc.Flags |= ShapeFlag.FluidDrain;

                    ActorDescription drainActorDesc = new ActorDescription()
                    {
                        GlobalPose = Matrix.Translation(-40, 0, 55),
                        Shapes     = { boxShapeDesc }
                    };

                    Actor drianActor = _scene.CreateActor(drainActorDesc);
                }
            }
            #endregion

            #region Force Field
            {
                BoxForceFieldShapeDescription boxForceFieldShapeDesc = new BoxForceFieldShapeDescription()
                {
                    Size = new Vector3(10, 10, 10)
                };

                ForceFieldLinearKernelDescription kernelDesc = new ForceFieldLinearKernelDescription()
                {
                    Constant = new Vector3(0, 100.0f, 0)
                };

                ForceFieldLinearKernel kernel = _scene.CreateForceFieldLinearKernel(kernelDesc);

                ForceFieldShapeGroupDescription shapeGroupDesc = new ForceFieldShapeGroupDescription()
                {
                    Shapes = { boxForceFieldShapeDesc }
                };

                ForceFieldShapeGroup shapeGroup = _scene.CreateForceFieldShapeGroup(shapeGroupDesc);

                BoxForceFieldShape boxForceFieldShape = shapeGroup.CreateShape(boxForceFieldShapeDesc) as BoxForceFieldShape;
                boxForceFieldShape.Pose = Matrix.Translation(30, 5, 0);

                ForceFieldDescription forceFieldDesc = new ForceFieldDescription()
                {
                    Kernel      = kernel,
                    ShapeGroups = { shapeGroup }
                };
                ForceField forceField = _scene.CreateForceField(forceFieldDesc);
            }
            #endregion

            #region Heightfield
            {
                int rows    = 25;
                int columns = 25;

                HeightFieldSample[] samples = new HeightFieldSample[rows * columns];
                for (int r = 0; r < rows; r++)
                {
                    for (int c = 0; c < columns; c++)
                    {
                        // Put a z and x curve together
                        double h = Math.Sin(c) * Math.Cos(r) * short.MaxValue;

                        HeightFieldSample sample = new HeightFieldSample()
                        {
                            Height           = (short)h,
                            MaterialIndex0   = 0,
                            MaterialIndex1   = 1,
                            TessellationFlag = 0
                        };

                        samples[r * columns + c] = sample;
                    }
                }

                HeightFieldDescription heightFieldDesc = new HeightFieldDescription()
                {
                    NumberOfRows    = rows,
                    NumberOfColumns = columns
                };
                heightFieldDesc.SetSamples(samples);

                HeightField heightField = _core.CreateHeightField(heightFieldDesc);

                //

                HeightFieldShapeDescription heightFieldShapeDesc = new HeightFieldShapeDescription()
                {
                    HeightField  = heightField,
                    HoleMaterial = 2,
                    // The max height of our samples is short.MaxValue and we want it to be 1
                    HeightScale = 1.0f / (float)short.MaxValue,
                    RowScale    = 3,
                    ColumnScale = 3
                };
                heightFieldShapeDesc.LocalPosition = new Vector3(-0.5f * rows * 1 * heightFieldShapeDesc.RowScale, 0, -0.5f * columns * 1 * heightFieldShapeDesc.ColumnScale);

                ActorDescription actorDesc = new ActorDescription()
                {
                    GlobalPose = Matrix.Translation(100, 0, 0),
                    Shapes     = { heightFieldShapeDesc }
                };
                Actor actor = _scene.CreateActor(actorDesc);
            }
            #endregion

            //#region Convex Mesh
            //{
            //    ModelMesh mesh = _torusModel.Meshes.First();

            //    Matrix[] transforms = new Matrix[ _torusModel.Bones.Count ];
            //    _torusModel.CopyAbsoluteBoneTransformsTo( transforms );

            //    // Gets the vertices from the mesh
            //    VertexPositionNormalTexture[] vertices = new VertexPositionNormalTexture[ mesh.MeshParts[ 0 ].NumVertices ];
            //    mesh.VertexBuffer.GetData<VertexPositionNormalTexture>( vertices );

            //    //

            //    // Allocate memory for the points and triangles
            //    var convexMeshDesc = new ConvexMeshDescription()
            //    {
            //        PointCount = vertices.Length
            //    };
            //    convexMeshDesc.Flags |= ConvexFlag.ComputeConvex;
            //    convexMeshDesc.AllocatePoints<Vector3>( vertices.Length );

            //    // Write in the points and triangles
            //    // We only want the Position component of the vertex. Also scale down the mesh
            //    foreach( VertexPositionNormalTexture vertex in vertices )
            //    {
            //        Vector3 position = Vector3.Transform( vertex.Position, Matrix.CreateScale( 0.1f, 0.1f, 0.1f ) * transforms[ 0 ] );

            //        convexMeshDesc.PointsStream.Write( position );
            //    }

            //    //

            //    // Cook to memory or to a file
            //    MemoryStream stream = new MemoryStream();
            //    //FileStream stream = new FileStream( @"Convex Mesh.cooked", FileMode.CreateNew );

            //    Cooking.InitializeCooking( new ConsoleOutputStream() );
            //    Cooking.CookConvexMesh( convexMeshDesc, stream );
            //    Cooking.CloseCooking();

            //    stream.Position = 0;

            //    ConvexMesh convexMesh = _core.CreateConvexMesh( stream );

            //    ConvexShapeDescription convexShapeDesc = new ConvexShapeDescription( convexMesh );

            //    ActorDescription actorDesc = new ActorDescription()
            //    {
            //        BodyDescription = new BodyDescription( 10.0f ),
            //        GlobalPose = Matrix.CreateTranslation( 30, 30, 0 )
            //    };
            //    actorDesc.Shapes.Add( convexShapeDesc );

            //    _torusActor = _scene.CreateActor( actorDesc );
            //}
            //#endregion

            //#region SoftBody
            //if( false ) // Enable to view soft bodies, they run slowly
            //{
            //    XmlDocument doc = new XmlDocument();
            //        doc.Load( "Teapot.xml" );

            //    // Not how NxuStream are meant to used but what ever :S
            //    Vector3[] vertices = ReadVertices( doc.SelectSingleNode( "/NXUSTREAM2/NxuPhysicsCollection/NxSoftBodyMeshDesc/vertices" ) );
            //    int[] tetrahedraSingles = ReadTetrahedra( doc.SelectSingleNode( "/NXUSTREAM2/NxuPhysicsCollection/NxSoftBodyMeshDesc/tetrahedra" ) );

            //    var softBodyMeshDesc = new SoftBodyMeshDescription()
            //    {
            //        VertexCount = vertices.Length,
            //        TetrahedraCount = tetrahedraSingles.Length / 4 // Tetrahedras come in quadruples of ints
            //    };

            //    softBodyMeshDesc.AllocateVertices<Vector3>( softBodyMeshDesc.VertexCount );
            //    softBodyMeshDesc.AllocateTetrahedra<int>( softBodyMeshDesc.TetrahedraCount ); // Note: T is an int. T is the type of each point

            //    softBodyMeshDesc.VertexStream.SetData( vertices );
            //    softBodyMeshDesc.TetrahedraStream.SetData( tetrahedraSingles );

            //    MemoryStream memoryStream = new MemoryStream();

            //    Cooking.InitializeCooking();
            //    Cooking.CookSoftBodyMesh( softBodyMeshDesc, memoryStream );
            //    Cooking.CloseCooking();

            //    memoryStream.Position = 0;

            //    SoftBodyMesh softBodyMesh = _core.CreateSoftBodyMesh( memoryStream );

            //    SoftBodyDescription desc = new SoftBodyDescription()
            //    {
            //        GlobalPose = Matrix.CreateTranslation( -30, 20, -30 ),
            //        SoftBodyMesh = softBodyMesh
            //    };
            //    desc.Flags |= SoftBodyFlag.Visualization;

            //    desc.MeshData.AllocatePositions<Vector3>( vertices.Length );
            //    desc.MeshData.AllocateIndices<int>( tetrahedraSingles.Length );

            //    SoftBody softBody = _scene.CreateSoftBody( desc );
            //}
            //#endregion

            //#region Reports
            //// Contact report
            //// When the capsule actor hits the ground make it bounce by using the conact report
            //{
            //    CapsuleShapeDescription capsuleShapeDesc = new CapsuleShapeDescription( 1, 5 );

            //    ActorDescription actorDesc = new ActorDescription()
            //    {
            //        GlobalPose = Matrix.CreateTranslation( -30, 20, 0 ),
            //        BodyDescription = new BodyDescription( 10.0f ),
            //        Name = "Report Capsule",
            //        Shapes = { capsuleShapeDesc }
            //    };

            //    _contactReportActor = _scene.CreateActor( actorDesc );

            //    _scene.SetActorPairFlags( _contactReportActor, _groundActor, ContactPairFlag.All );

            //    _scene.UserContactReport = new ContactReport( this );
            //}

            //// Trigger Reports
            //{
            //    BoxShapeDescription boxShapeDesc = new BoxShapeDescription( 15, 8, 15 );
            //        boxShapeDesc.Flags |= ( ShapeFlag.TriggerOnEnter | ShapeFlag.TriggerOnLeave );

            //    ActorDescription actorDesc = new ActorDescription()
            //    {
            //        GlobalPose = Matrix.CreateTranslation( -30, 4, 0 ),
            //        Shapes = { boxShapeDesc }
            //    };
            //    _scene.CreateActor( actorDesc );

            //    _scene.UserTriggerReport = new TriggerReport( this );
            //}

            //_scene.UserNotify = new Notify( this );
            //#endregion

            //#region Wheel
            //{
            //    _basicVehicle = new Vehicle( this );
            //}
            //#endregion

            #region Controller
            {
                ControllerManager manager = _scene.CreateControllerManager();

                CapsuleControllerDescription capsuleControllerDesc = new CapsuleControllerDescription(4, 3);

                CapsuleController capsuleController = manager.CreateController <CapsuleController>(capsuleControllerDesc);
                capsuleController.Position   = new Vector3(0, 1.5f + 2, -15);
                capsuleController.Actor.Name = "BoxController";
                capsuleController.SetCollisionEnabled(true);
            }
            #endregion
        }
예제 #4
0
		public void LoadPhysics()
		{
			Core _core = this.Core;
			Scene _scene = this.Scene;

			#region Some Boxes
			for( int x = 0; x < 5; x++ )
			{
				BoxShapeDescription boxShapeDesc = new BoxShapeDescription( 2, 3, 8 );
				
				ActorDescription actorDesc = new ActorDescription()
				{
					Name = String.Format( "Box {0}", x ),
					BodyDescription = new BodyDescription( 10.0f ),
					GlobalPose = Matrix.Translation( 100, 15 + 3 * x, 20 ),
					Shapes = { boxShapeDesc }
				};

				Actor actor = _scene.CreateActor( actorDesc );
			}
			#endregion

			//#region Cloth (Flag)
			//{
			//    // Create a Grid of Points
			//    VertexGrid grid = VertexGrid.CreateGrid( 10, 10 );

			//    ClothMeshDescription clothMeshDesc = new ClothMeshDescription();
			//        clothMeshDesc.AllocateVertices<Vector3>( grid.Points.Length );
			//        clothMeshDesc.AllocateTriangles<int>( grid.Indices.Length / 3 );

			//        clothMeshDesc.VertexCount = grid.Points.Length;
			//        clothMeshDesc.TriangleCount = grid.Indices.Length / 3;

			//        clothMeshDesc.VerticesStream.SetData( grid.Points );
			//        clothMeshDesc.TriangleStream.SetData( grid.Indices );

			//        // We are using 32 bit integers, so make sure the 16 bit flag is removed.
			//        // 32 bits are the default, so this isn't technically needed
			//        clothMeshDesc.Flags &= ~MeshFlag.Indices16Bit;

			//    // Write the cooked data to memory
			//    MemoryStream memoryStream = new MemoryStream();

			//    Cooking.InitializeCooking();
			//    Cooking.CookClothMesh( clothMeshDesc, memoryStream );
			//    Cooking.CloseCooking();

			//    // Need to reset the position of the stream to the beginning
			//    memoryStream.Position = 0;

			//    ClothMesh clothMesh = _core.CreateClothMesh( memoryStream );

			//    //

			//    ClothDescription clothDesc = new ClothDescription()
			//    {
			//        ClothMesh = clothMesh,
			//        Flags = ClothFlag.Gravity | ClothFlag.Bending | ClothFlag.CollisionTwoway | ClothFlag.Visualization,
			//        GlobalPose =
			//            Matrix.CreateFromYawPitchRoll( 0, (float)Math.PI / 2.0f, (float)Math.PI / 2.0f ) *
			//            Matrix.CreateTranslation( 0, 20, 0 )
			//    };
			//    clothDesc.MeshData.AllocatePositions<Vector3>( grid.Points.Length );
			//    clothDesc.MeshData.AllocateIndices<int>( grid.Indices.Length );

			//    clothDesc.MeshData.MaximumVertices = grid.Points.Length;
			//    clothDesc.MeshData.MaximumIndices = grid.Indices.Length;

			//    clothDesc.MeshData.NumberOfVertices = grid.Points.Length;
			//    clothDesc.MeshData.NumberOfIndices = grid.Indices.Length;

			//    _flag = _scene.CreateCloth( clothDesc );

			//    // Flag Pole
			//    ActorDescription flagPoleActorDesc = new ActorDescription()
			//    {
			//        GlobalPose = Matrix.CreateTranslation( 0, 10, 0 ),
			//        Shapes = { new BoxShapeDescription( 1.0f, 20.0f, 1.0f ) }
			//    };

			//    Actor flagPoleActor = _scene.CreateActor( flagPoleActorDesc );

			//    _flag.AttachToShape( flagPoleActor.Shapes[ 0 ], 0 );
			//    _flag.WindAcceleration = new Vector3( 10, 10, 10 );
			//    _flag.BendingStiffness = 0.1f;
			//}
			//#endregion
			
			#region Revolute Joint
			{
				BoxShapeDescription boxShapeDescA = new BoxShapeDescription( 3, 3, 3 );
				BoxShapeDescription boxShapeDescB = new BoxShapeDescription( 3, 3, 3 );

				ActorDescription actorDescA = new ActorDescription()
				{
					BodyDescription = new BodyDescription( 10.0f ),
					GlobalPose = Matrix.Translation( 75, 1.5f, 55 ),
					Shapes = { boxShapeDescA }
				};
				Actor actorA = _scene.CreateActor( actorDescA );

				ActorDescription actorDescB = new ActorDescription()
				{
					BodyDescription = new BodyDescription( 10.0f ),
					GlobalPose = Matrix.Translation( 70, 1.5f, 55 ),
					Shapes = { boxShapeDescB }
				};
				Actor actorB = _scene.CreateActor( actorDescB );

				//

				RevoluteJointDescription revoluteJointDesc = new RevoluteJointDescription()
				{
					Actor1 = actorA,
					Actor2 = actorB,
					Motor = new MotorDescription( 20, 20.1f, true )
				};
				revoluteJointDesc.Flags |= RevoluteJointFlag.MotorEnabled;
				revoluteJointDesc.SetGlobalAnchor( new Vector3( 73.5f, 1.5f, 55 ) );
				revoluteJointDesc.SetGlobalAxis( new Vector3( 1, 0, 0 ) );

				RevoluteJoint revoluteJoint = _scene.CreateJoint( revoluteJointDesc ) as RevoluteJoint;
			}
			#endregion

			#region Prismatic Joint with Limit
			{
				Actor actorA, actorB;
				{
					BoxShapeDescription boxShapeDesc = new BoxShapeDescription( 3, 3, 3 );

					BodyDescription bodyDesc = new BodyDescription( 10.0f );
						bodyDesc.BodyFlags |= BodyFlag.Kinematic;

					ActorDescription actorDesc = new ActorDescription()
					{
						BodyDescription = bodyDesc,
						GlobalPose = Matrix.Translation( 70, 25, 65 ),
						Shapes = { boxShapeDesc }
					};
					actorA = _scene.CreateActor( actorDesc );
				}
				{
					BoxShapeDescription boxShapeDesc = new BoxShapeDescription( 3, 3, 3 );

					ActorDescription actorDesc = new ActorDescription()
					{
						BodyDescription = new BodyDescription( 10.0f ),
						GlobalPose = Matrix.Translation( 70, 15, 65 ),
						Shapes = { boxShapeDesc }
					};
					actorB = _scene.CreateActor( actorDesc );
				}

				PrismaticJointDescription prismaticJointDesc = new PrismaticJointDescription()
				{
					Actor1 = actorA,
					Actor2 = actorB,
				};
				prismaticJointDesc.SetGlobalAnchor( new Vector3( 70, 20, 65 ) );
				prismaticJointDesc.SetGlobalAxis( new Vector3( 0, 1, 0 ) );

				PrismaticJoint prismaticJoint = _scene.CreateJoint( prismaticJointDesc ) as PrismaticJoint;

				LimitPlane limitPlane = new LimitPlane( new Vector3( 0, 1, 0 ), new Vector3( -30, 8, -30 ), 0 );
					prismaticJoint.AddLimitPlane( limitPlane );
			}
			#endregion
			
			#region Fluid
			{
				const int maximumParticles = 1000;

				FluidEmitterDescription fluidEmitterDesc = new FluidEmitterDescription()
				{
					DimensionX = 0.5f,
					DimensionY = 0.5f,
					Rate = 15,
					RelativePose = Matrix.Translation( -40, 10, 50 ),
					Shape = EmitterShape.Rectangular,
					Type = EmitterType.ConstantFlowRate,
					RandomAngle = 0.5f
				};
				fluidEmitterDesc.Flags |= ( FluidEmitterFlag.Enabled | FluidEmitterFlag.Visualization );

				FluidDescription fluidDesc = new FluidDescription()
				{
					Emitters = { fluidEmitterDesc },
					Flags = FluidFlag.Enabled | FluidFlag.Visualization,
					MaximumParticles = maximumParticles
				};
				fluidDesc.ParticleWriteData.AllocatePositionBuffer<Vector3>( maximumParticles );
				fluidDesc.ParticleWriteData.NumberOfParticles = maximumParticles;

				Fluid fluid = _scene.CreateFluid( fluidDesc );

				// Ledge
				{
					BoxShapeDescription boxShapeDesc = new BoxShapeDescription( 5, 0.1f, 5 );
					
					ActorDescription drainActorDesc = new ActorDescription()
					{
						GlobalPose = Matrix.RotationX( 0.5f ) * Matrix.Translation( -40, 5, 52 ),
						Shapes =  { boxShapeDesc }
					};

					Actor drianActor = _scene.CreateActor( drainActorDesc );
				}

				// Drain
				{
					BoxShapeDescription boxShapeDesc = new BoxShapeDescription( 5, 0.1f, 5 );
						boxShapeDesc.Flags |= ShapeFlag.FluidDrain;

					ActorDescription drainActorDesc = new ActorDescription()
					{
						GlobalPose = Matrix.Translation( -40, 0, 55 ),
						Shapes = { boxShapeDesc }
					};

					Actor drianActor = _scene.CreateActor( drainActorDesc );
				}
			}
			#endregion
			
			#region Force Field
			{
				BoxForceFieldShapeDescription boxForceFieldShapeDesc = new BoxForceFieldShapeDescription()
				{
					Size = new Vector3( 10, 10, 10 )
				};

				ForceFieldLinearKernelDescription kernelDesc = new ForceFieldLinearKernelDescription()
				{
					Constant = new Vector3( 0, 100.0f, 0 )
				};

				ForceFieldLinearKernel kernel = _scene.CreateForceFieldLinearKernel( kernelDesc );

				ForceFieldShapeGroupDescription shapeGroupDesc = new ForceFieldShapeGroupDescription()
				{
					Shapes = { boxForceFieldShapeDesc }
				};

				ForceFieldShapeGroup shapeGroup = _scene.CreateForceFieldShapeGroup( shapeGroupDesc );

				BoxForceFieldShape boxForceFieldShape = shapeGroup.CreateShape( boxForceFieldShapeDesc ) as BoxForceFieldShape;
				boxForceFieldShape.Pose = Matrix.Translation( 30, 5, 0 );

				ForceFieldDescription forceFieldDesc = new ForceFieldDescription()
				{
					Kernel = kernel,
					ShapeGroups = { shapeGroup }
				};
				ForceField forceField = _scene.CreateForceField( forceFieldDesc );
			}
			#endregion
			
			#region Heightfield
			{
				int rows = 25;
				int columns = 25;

				HeightFieldSample[] samples = new HeightFieldSample[ rows * columns ];
				for( int r = 0; r < rows; r++ )
				{
					for( int c = 0; c < columns; c++ )
					{
						// Put a z and x curve together
						double h = Math.Sin( c ) * Math.Cos( r ) * short.MaxValue;

						HeightFieldSample sample = new HeightFieldSample()
						{
							Height = (short)h,
							MaterialIndex0 = 0,
							MaterialIndex1 = 1,
							TessellationFlag = 0
						};

						samples[ r * columns + c ] = sample;
					}
				}

				HeightFieldDescription heightFieldDesc = new HeightFieldDescription()
				{
					NumberOfRows = rows,
					NumberOfColumns = columns
				};
				heightFieldDesc.SetSamples( samples );

				HeightField heightField = _core.CreateHeightField( heightFieldDesc );
				
				//

				HeightFieldShapeDescription heightFieldShapeDesc = new HeightFieldShapeDescription()
				{
					HeightField = heightField,
					HoleMaterial = 2,
					// The max height of our samples is short.MaxValue and we want it to be 1
					HeightScale = 1.0f / (float)short.MaxValue,
					RowScale = 3,
					ColumnScale = 3
				};
				heightFieldShapeDesc.LocalPosition = new Vector3( -0.5f * rows * 1 * heightFieldShapeDesc.RowScale, 0, -0.5f * columns * 1 * heightFieldShapeDesc.ColumnScale );

				ActorDescription actorDesc = new ActorDescription()
				{
					GlobalPose = Matrix.Translation( 100, 0, 0 ),
					Shapes = { heightFieldShapeDesc }
				};
				Actor actor = _scene.CreateActor( actorDesc );
			}
			#endregion
			
			//#region Convex Mesh
			//{
			//    ModelMesh mesh = _torusModel.Meshes.First();

			//    Matrix[] transforms = new Matrix[ _torusModel.Bones.Count ];
			//    _torusModel.CopyAbsoluteBoneTransformsTo( transforms );

			//    // Gets the vertices from the mesh
			//    VertexPositionNormalTexture[] vertices = new VertexPositionNormalTexture[ mesh.MeshParts[ 0 ].NumVertices ];
			//    mesh.VertexBuffer.GetData<VertexPositionNormalTexture>( vertices );

			//    //

			//    // Allocate memory for the points and triangles
			//    var convexMeshDesc = new ConvexMeshDescription()
			//    {
			//        PointCount = vertices.Length
			//    };
			//    convexMeshDesc.Flags |= ConvexFlag.ComputeConvex;
			//    convexMeshDesc.AllocatePoints<Vector3>( vertices.Length );

			//    // Write in the points and triangles
			//    // We only want the Position component of the vertex. Also scale down the mesh
			//    foreach( VertexPositionNormalTexture vertex in vertices )
			//    {
			//        Vector3 position = Vector3.Transform( vertex.Position, Matrix.CreateScale( 0.1f, 0.1f, 0.1f ) * transforms[ 0 ] );

			//        convexMeshDesc.PointsStream.Write( position );
			//    }

			//    //

			//    // Cook to memory or to a file
			//    MemoryStream stream = new MemoryStream();
			//    //FileStream stream = new FileStream( @"Convex Mesh.cooked", FileMode.CreateNew );

			//    Cooking.InitializeCooking( new ConsoleOutputStream() );
			//    Cooking.CookConvexMesh( convexMeshDesc, stream );
			//    Cooking.CloseCooking();

			//    stream.Position = 0;

			//    ConvexMesh convexMesh = _core.CreateConvexMesh( stream );

			//    ConvexShapeDescription convexShapeDesc = new ConvexShapeDescription( convexMesh );

			//    ActorDescription actorDesc = new ActorDescription()
			//    {
			//        BodyDescription = new BodyDescription( 10.0f ),
			//        GlobalPose = Matrix.CreateTranslation( 30, 30, 0 )
			//    };
			//    actorDesc.Shapes.Add( convexShapeDesc );

			//    _torusActor = _scene.CreateActor( actorDesc );
			//}
			//#endregion
			
			//#region SoftBody
			//if( false ) // Enable to view soft bodies, they run slowly
			//{
			//    XmlDocument doc = new XmlDocument();
			//        doc.Load( "Teapot.xml" );
				
			//    // Not how NxuStream are meant to used but what ever :S
			//    Vector3[] vertices = ReadVertices( doc.SelectSingleNode( "/NXUSTREAM2/NxuPhysicsCollection/NxSoftBodyMeshDesc/vertices" ) );
			//    int[] tetrahedraSingles = ReadTetrahedra( doc.SelectSingleNode( "/NXUSTREAM2/NxuPhysicsCollection/NxSoftBodyMeshDesc/tetrahedra" ) );

			//    var softBodyMeshDesc = new SoftBodyMeshDescription()
			//    {
			//        VertexCount = vertices.Length,
			//        TetrahedraCount = tetrahedraSingles.Length / 4 // Tetrahedras come in quadruples of ints
			//    };

			//    softBodyMeshDesc.AllocateVertices<Vector3>( softBodyMeshDesc.VertexCount );
			//    softBodyMeshDesc.AllocateTetrahedra<int>( softBodyMeshDesc.TetrahedraCount ); // Note: T is an int. T is the type of each point

			//    softBodyMeshDesc.VertexStream.SetData( vertices );
			//    softBodyMeshDesc.TetrahedraStream.SetData( tetrahedraSingles );

			//    MemoryStream memoryStream = new MemoryStream();

			//    Cooking.InitializeCooking();
			//    Cooking.CookSoftBodyMesh( softBodyMeshDesc, memoryStream );
			//    Cooking.CloseCooking();

			//    memoryStream.Position = 0;

			//    SoftBodyMesh softBodyMesh = _core.CreateSoftBodyMesh( memoryStream );

			//    SoftBodyDescription desc = new SoftBodyDescription()
			//    {
			//        GlobalPose = Matrix.CreateTranslation( -30, 20, -30 ),
			//        SoftBodyMesh = softBodyMesh
			//    };
			//    desc.Flags |= SoftBodyFlag.Visualization;

			//    desc.MeshData.AllocatePositions<Vector3>( vertices.Length );
			//    desc.MeshData.AllocateIndices<int>( tetrahedraSingles.Length );

			//    SoftBody softBody = _scene.CreateSoftBody( desc );
			//}
			//#endregion

			//#region Reports
			//// Contact report
			//// When the capsule actor hits the ground make it bounce by using the conact report
			//{
			//    CapsuleShapeDescription capsuleShapeDesc = new CapsuleShapeDescription( 1, 5 );
				
			//    ActorDescription actorDesc = new ActorDescription()
			//    {
			//        GlobalPose = Matrix.CreateTranslation( -30, 20, 0 ),
			//        BodyDescription = new BodyDescription( 10.0f ),
			//        Name = "Report Capsule",
			//        Shapes = { capsuleShapeDesc }
			//    };

			//    _contactReportActor = _scene.CreateActor( actorDesc );

			//    _scene.SetActorPairFlags( _contactReportActor, _groundActor, ContactPairFlag.All );

			//    _scene.UserContactReport = new ContactReport( this );
			//}

			//// Trigger Reports
			//{
			//    BoxShapeDescription boxShapeDesc = new BoxShapeDescription( 15, 8, 15 );
			//        boxShapeDesc.Flags |= ( ShapeFlag.TriggerOnEnter | ShapeFlag.TriggerOnLeave );

			//    ActorDescription actorDesc = new ActorDescription()
			//    {
			//        GlobalPose = Matrix.CreateTranslation( -30, 4, 0 ),
			//        Shapes = { boxShapeDesc }
			//    };
			//    _scene.CreateActor( actorDesc );

			//    _scene.UserTriggerReport = new TriggerReport( this );
			//}

			//_scene.UserNotify = new Notify( this );
			//#endregion

			//#region Wheel
			//{
			//    _basicVehicle = new Vehicle( this );
			//}
			//#endregion

			#region Controller
			{
				ControllerManager manager = _scene.CreateControllerManager();

				CapsuleControllerDescription capsuleControllerDesc = new CapsuleControllerDescription( 4, 3 );

				CapsuleController capsuleController = manager.CreateController<CapsuleController>( capsuleControllerDesc );
					capsuleController.Position = new Vector3( 0, 1.5f + 2, -15 );
					capsuleController.Actor.Name = "BoxController";
					capsuleController.SetCollisionEnabled( true );
			}
			#endregion
		}
예제 #5
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            //Initialize the core of physics engine
            CoreDescription coreDesc = new CoreDescription();

            _core = new Core(coreDesc, null);
            //Create a physics scene
            _scene = _core.CreateScene(new StillDesign.PhysX.MathPrimitives.Vector3(0, -9.81f, 0), true);

            _boxActor = new List <Actor>();
            _wheel    = new List <Actor>();
            wheelj    = new List <RevoluteJoint>();
            boxes     = new List <FixedJoint>();

            //Create a material
            MaterialDescription materialDec = new MaterialDescription();

            materialDec.DirectionOfAnisotropy = new StillDesign.PhysX.MathPrimitives.Vector3(0, 0, 1);
            materialDec.DynamicFriction       = 0.5f;
            materialDec.DynamicFrictionV      = 0.5f;
            materialDec.StaticFriction        = 0.5f;
            materialDec.StaticFrictionV       = 0.5f;
            materialDec.Restitution           = 0.8f;
            materialDec.Flags = MaterialFlag.Ansiotropic;

            Material material1 = _scene.CreateMaterial(materialDec);

            ActorDescription boxADec = new ActorDescription();

            boxADec.BodyDescription = new BodyDescription(5);
            boxADec.Shapes.Add(new BoxShapeDescription(2, 2, 2)
            {
                LocalPosition = new StillDesign.PhysX.MathPrimitives.Vector3(0, 1, 0), Material = material1
            });
            boxADec.Shapes.Add(new BoxShapeDescription(1, 3, 1)
            {
                LocalPosition = new StillDesign.PhysX.MathPrimitives.Vector3(0, 3f, 0), Material = material1
            });
            boxADec.Shapes.Add(new BoxShapeDescription(3, 1, 1)
            {
                LocalPosition = new StillDesign.PhysX.MathPrimitives.Vector3(-1f, 5, 0), Material = material1
            });
            boxADec.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(47f, 1f, 6f);
            _boxActor.Add(_scene.CreateActor(boxADec));

            ActorDescription wheel1 = new ActorDescription();

            wheel1.BodyDescription = new BodyDescription(5);
            wheel1.Shapes.Add(new SphereShapeDescription(1)
            {
                Material = material1
            });
            wheel1.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(45.3f, 1f, 4.3f);
            _wheel.Add(_scene.CreateActor(wheel1));

            ActorDescription wheel2 = new ActorDescription();

            wheel2.BodyDescription = new BodyDescription(5);
            wheel2.Shapes.Add(new SphereShapeDescription(1)
            {
                Material = material1
            });
            wheel2.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(45.3f, 1, 7.8f);
            _wheel.Add(_scene.CreateActor(wheel2));

            ActorDescription wheel3 = new ActorDescription();

            wheel3.BodyDescription = new BodyDescription(5);
            wheel3.Shapes.Add(new SphereShapeDescription(1)
            {
                Material = material1
            });
            wheel3.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(48.7f, 1, 4.3f);
            _wheel.Add(_scene.CreateActor(wheel3));

            ActorDescription wheel4 = new ActorDescription();

            wheel4.BodyDescription = new BodyDescription(5);
            wheel4.Shapes.Add(new SphereShapeDescription(1)
            {
                Material = material1
            });
            wheel4.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(48.7f, 1, 7.8f);
            _wheel.Add(_scene.CreateActor(wheel4));

            ActorDescription boxADec1 = new ActorDescription();

            boxADec1.BodyDescription = new BodyDescription(1000);
            boxADec1.Shapes.Add(new BoxShapeDescription(35, 10, 1));
            boxADec1.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(33f, 5, 12.1f);
            _boxActor.Add(_scene.CreateActor(boxADec1));

            ActorDescription boxADec2 = new ActorDescription();

            boxADec2.BodyDescription = new BodyDescription(1000);
            boxADec2.Shapes.Add(new BoxShapeDescription(1, 10, 25.5f));
            boxADec2.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(15f, 5, 24.4f);
            _boxActor.Add(_scene.CreateActor(boxADec2));

            ActorDescription boxADec3 = new ActorDescription();

            boxADec3.BodyDescription = new BodyDescription(1000);
            boxADec3.Shapes.Add(new BoxShapeDescription(4f, 10, 1f));
            boxADec3.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(49f, 5, -1f);
            _boxActor.Add(_scene.CreateActor(boxADec3));

            ActorDescription boxADec4 = new ActorDescription();

            boxADec4.BodyDescription = new BodyDescription(1000);
            boxADec4.Shapes.Add(new BoxShapeDescription(1f, 10, 70f));
            boxADec4.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(51f, 5, -3f);
            _boxActor.Add(_scene.CreateActor(boxADec4));

            ActorDescription boxADec5 = new ActorDescription();

            boxADec5.BodyDescription = new BodyDescription(1000);
            boxADec5.Shapes.Add(new BoxShapeDescription(105f, 10, 1f));
            boxADec5.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(0f, 5, 37.7f);
            _boxActor.Add(_scene.CreateActor(boxADec5));

            ActorDescription boxADec6 = new ActorDescription();

            boxADec6.BodyDescription = new BodyDescription(1000);
            boxADec6.Shapes.Add(new BoxShapeDescription(1, 10, 25.5f));
            boxADec6.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(-16.6f, 5, 24.4f);
            _boxActor.Add(_scene.CreateActor(boxADec6));

            ActorDescription boxADec7 = new ActorDescription();

            boxADec7.BodyDescription = new BodyDescription(1000);
            boxADec7.Shapes.Add(new BoxShapeDescription(1, 10, 42f));
            boxADec7.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(-51f, 5, 16.5f);
            _boxActor.Add(_scene.CreateActor(boxADec7));

            ActorDescription boxADec8 = new ActorDescription();

            boxADec8.BodyDescription = new BodyDescription(1000);
            boxADec8.Shapes.Add(new BoxShapeDescription(8.5f, 10, 1f));
            boxADec8.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(-46.25f, 5, 12.15f);
            _boxActor.Add(_scene.CreateActor(boxADec8));

            ActorDescription boxADec9 = new ActorDescription();

            boxADec9.BodyDescription = new BodyDescription(1000);
            boxADec9.Shapes.Add(new BoxShapeDescription(8.5f, 10, 1f));
            boxADec9.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(-21f, 5, 12.15f);
            _boxActor.Add(_scene.CreateActor(boxADec9));

            ActorDescription boxADec10 = new ActorDescription();

            boxADec10.BodyDescription = new BodyDescription(1);
            boxADec10.Shapes.Add(new BoxShapeDescription(1, 1, 1));
            boxADec10.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(-20, 0.5f, 30);
            _boxActor.Add(_scene.CreateActor(boxADec10));

            ActorDescription boxADec11 = new ActorDescription();

            boxADec11.BodyDescription = new BodyDescription(5);
            boxADec11.Shapes.Add(new BoxShapeDescription(1, 1, 1)
            {
                Material = material1
            });
            boxADec11.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(45, 4, 6);
            box11 = _scene.CreateActor(boxADec11);

            ActorDescription boxADec12 = new ActorDescription();

            boxADec12.BodyDescription = new BodyDescription(1000);
            boxADec12.Shapes.Add(new BoxShapeDescription(4f, 10, 1f));
            boxADec12.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(27.5f, 5, -1f);
            _boxActor.Add(_scene.CreateActor(boxADec12));

            ActorDescription boxADec13 = new ActorDescription();

            boxADec13.BodyDescription = new BodyDescription(1000);
            boxADec13.Shapes.Add(new BoxShapeDescription(21.5f, 10, 1f));
            boxADec13.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(36f, 5, -26.8f);
            _boxActor.Add(_scene.CreateActor(boxADec13));

            ActorDescription boxADec14 = new ActorDescription();

            boxADec14.BodyDescription = new BodyDescription(1000);
            boxADec14.Shapes.Add(new BoxShapeDescription(4f, 10, 1f));
            boxADec14.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(49f, 5, -26.8f);
            _boxActor.Add(_scene.CreateActor(boxADec14));

            ActorDescription boxADec15 = new ActorDescription();

            boxADec15.BodyDescription = new BodyDescription(1000);
            boxADec15.Shapes.Add(new BoxShapeDescription(106f, 10, 1f));
            boxADec15.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(0f, 5, -38.1f);
            _boxActor.Add(_scene.CreateActor(boxADec15));

            ActorDescription boxADec16 = new ActorDescription();

            boxADec16.BodyDescription = new BodyDescription(1000);
            boxADec16.Shapes.Add(new BoxShapeDescription(1, 10, 26.8f));
            boxADec16.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(25f, 5, -13.9f);
            _boxActor.Add(_scene.CreateActor(boxADec16));

            ActorDescription boxADec17 = new ActorDescription();

            boxADec17.BodyDescription = new BodyDescription(1000);
            boxADec17.Shapes.Add(new BoxShapeDescription(17.2f, 0.25f, 1f));
            boxADec17.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(38.1f, 0.125f, -1f);
            _boxActor.Add(_scene.CreateActor(boxADec17));

            ActorDescription boxADec18 = new ActorDescription();

            boxADec18.BodyDescription = new BodyDescription(1000);
            boxADec18.Shapes.Add(new BoxShapeDescription(25f, 0.25f, 24.5f));
            boxADec18.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(38f, 0.25f, -14f);
            _boxActor.Add(_scene.CreateActor(boxADec18));

            ActorDescription boxADec19 = new ActorDescription();

            boxADec19.BodyDescription = new BodyDescription(1000);
            boxADec19.Shapes.Add(new BoxShapeDescription(17.2f, 0.25f, 1f));
            boxADec19.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(38.1f, 0.5f, -2f);
            _boxActor.Add(_scene.CreateActor(boxADec19));

            ActorDescription boxADec20 = new ActorDescription();

            boxADec20.BodyDescription = new BodyDescription(1000);
            boxADec20.Shapes.Add(new BoxShapeDescription(17.2f, 0.5f, 1f));
            boxADec20.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(38.1f, 0.5f, -3f);
            _boxActor.Add(_scene.CreateActor(boxADec20));

            ActorDescription boxADec21 = new ActorDescription();

            boxADec21.BodyDescription = new BodyDescription(1000);
            boxADec21.Shapes.Add(new BoxShapeDescription(17.2f, 0.75f, 1f));
            boxADec21.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(38.1f, 1f, -4f);
            _boxActor.Add(_scene.CreateActor(boxADec21));

            ActorDescription boxADec22 = new ActorDescription();

            boxADec22.BodyDescription = new BodyDescription(1000);
            boxADec22.Shapes.Add(new BoxShapeDescription(17.2f, 1f, 1f));
            boxADec22.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(38.1f, 1.25f, -5f);
            _boxActor.Add(_scene.CreateActor(boxADec22));

            ActorDescription boxADec23 = new ActorDescription();

            boxADec23.BodyDescription = new BodyDescription(1000);
            boxADec23.Shapes.Add(new BoxShapeDescription(25f, 1f, 20.5f));
            boxADec23.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(38f, 1.5f, -16f);
            _boxActor.Add(_scene.CreateActor(boxADec23));

            ActorDescription boxADec24 = new ActorDescription();

            boxADec24.BodyDescription = new BodyDescription(1000);
            boxADec24.Shapes.Add(new BoxShapeDescription(75f, 10, 1f));
            boxADec24.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(-13f, 5, -1f);
            _boxActor.Add(_scene.CreateActor(boxADec24));

            ActorDescription boxADec25 = new ActorDescription();

            boxADec25.BodyDescription = new BodyDescription(5);
            boxADec25.Shapes.Add(new BoxShapeDescription(1, 1, 1)
            {
                Material = material1
            });
            boxADec25.GlobalPose = StillDesign.PhysX.MathPrimitives.Matrix.Translation(48, 4, 6);
            box12 = _scene.CreateActor(boxADec25);

            RevoluteJointDescription jointDec = new RevoluteJointDescription();

            jointDec.Actor1 = _boxActor[0];
            jointDec.Actor2 = _wheel[0];
            jointDec.SetGlobalAnchor(new StillDesign.PhysX.MathPrimitives.Vector3(45.3f, 1f, 4.3f));
            jointDec.SetGlobalAxis(new StillDesign.PhysX.MathPrimitives.Vector3(0, 0, 1));
            wheelj.Add(_scene.CreateJoint <RevoluteJoint>(jointDec));

            RevoluteJointDescription jointDec1 = new RevoluteJointDescription();

            jointDec1.Actor1 = _boxActor[0];
            jointDec1.Actor2 = _wheel[1];
            jointDec1.SetGlobalAnchor(new StillDesign.PhysX.MathPrimitives.Vector3(45.3f, 1, 7.8f));
            jointDec1.SetGlobalAxis(new StillDesign.PhysX.MathPrimitives.Vector3(0, 0, -1));
            wheelj.Add(_scene.CreateJoint <RevoluteJoint>(jointDec1));

            RevoluteJointDescription jointDec2 = new RevoluteJointDescription();

            jointDec2.Actor1 = _boxActor[0];
            jointDec2.Actor2 = _wheel[2];
            jointDec2.SetGlobalAnchor(new StillDesign.PhysX.MathPrimitives.Vector3(48.7f, 1, 4.3f));
            jointDec2.SetGlobalAxis(new StillDesign.PhysX.MathPrimitives.Vector3(0, 0, 1));
            wheelj.Add(_scene.CreateJoint <RevoluteJoint>(jointDec2));

            RevoluteJointDescription jointDec3 = new RevoluteJointDescription();

            jointDec3.Actor1 = _boxActor[0];
            jointDec3.Actor2 = _wheel[3];
            jointDec3.SetGlobalAnchor(new StillDesign.PhysX.MathPrimitives.Vector3(48.7f, 1, 7.8f));
            jointDec3.SetGlobalAxis(new StillDesign.PhysX.MathPrimitives.Vector3(0, 0, -1));
            wheelj.Add(_scene.CreateJoint <RevoluteJoint>(jointDec3));

            DistanceJointDescription jointDec4 = new DistanceJointDescription();

            jointDec4.Actor1          = _boxActor[10];
            jointDec4.Actor2          = box11;
            jointDec4.MaximumDistance = 1000000;
            jointDec4.MinimumDistance = 1;
            jointDec4.Flags           = DistanceJointFlag.EnforceMaximumDistance | DistanceJointFlag.EnforceMinimumDistance;
            boxpick = _scene.CreateJoint <DistanceJoint>(jointDec4);

            FixedJointDescription jointDec5 = new FixedJointDescription();

            jointDec5.Actor1 = _boxActor[0];
            jointDec5.Actor2 = box11;
            boxes.Add(_scene.CreateJoint <FixedJoint>(jointDec5));

            FixedJointDescription jointDec6 = new FixedJointDescription();

            jointDec6.Actor1 = _boxActor[0];
            jointDec6.Actor2 = box12;
            boxes.Add(_scene.CreateJoint <FixedJoint>(jointDec6));

            view1        = graphics.GraphicsDevice.Viewport;
            view2        = view1;
            view1.Height = 480;
            view1.Width  = 400;
            view1.X      = 400;
            view1.Y      = 0;
            view2.Height = 480;
            view2.Width  = 400;
            view2.X      = 0;
            view2.Y      = 0;

            _camera1 = new Camera("camera1", 1024, 768, 1024f / 768f, 1, 1f, 100000, true, view1);
            _camera1.Initialize(new Vector3(_boxActor[0].GlobalPosition.X, _boxActor[0].GlobalPosition.Y + 3, _boxActor[0].GlobalPosition.Z), new Vector3(0, 4, 6));

            _camera2 = new Camera("camera2", 1024, 768, 1024f / 768f, 1, 1f, 100000, true, view2);
            _camera2.Initialize(new Vector3(_boxActor[0].GlobalPosition.X, _boxActor[0].GlobalPosition.Y + 3, _boxActor[0].GlobalPosition.Z), new Vector3(100, 4, 6));
            this.IsMouseVisible = true;
            base.Initialize();
        }