예제 #1
0
        private void CreateBoxes(Nx.Material material)
        {
            for (int x = 0; x < XCount; x++)
                for (int y = 0; y < YCount; y++)
                    for (int z = 0; z < ZCount; z++)
                    {
                        var rigidBodyDesc = new BodyDescription();

                        var boxDesc = new BoxShapeDescription
                        {
                            Material = material,
                            Dimensions = new NxVector3(WidthX / 2, WidthY / 2, WidthZ / 2)
                        };

                        var actorDesc = new ActorDescription(boxDesc)
                        {
                            BodyDescription = rigidBodyDesc,
                            Density = 10.0f,
                            GlobalPose = NxMath.Matrix.Translation(
                                                   XOffset + x * XSpace - ((XCount - 1) * XSpace / 2),
                                                   YOffset + y * YSpace - ((YCount - 1) * YSpace / 2),
                                                   ZOffset + z * ZSpace - ((ZCount - 1) * ZSpace / 2)),
                            UserData = _boxModel
                        };

                        if (!actorDesc.IsValid())
                            throw new Exception("ActorDesc invalid!");

                        var actor = _scene.CreateActor(actorDesc);
                        if (actor == null)
                            throw new Exception("Actor invalid!");
                    }
        }
예제 #2
0
		public void RequiredMassSpaceInertia()
		{
			var shapeDescription = new SphereShapeDescription( 5 );
			shapeDescription.Flags |= ( ShapeFlag.TriggerOnEnter | ShapeFlag.TriggerOnLeave );

			var actorDesc = new ActorDescription()
			{
				BodyDescription = new BodyDescription( 1 )
				{
					MassSpaceInertia = new Vector3( 1, 1, 1 ),
					BodyFlags = BodyFlag.Kinematic
				},
				Shapes = { shapeDescription }
			};

			Assert.IsTrue( actorDesc.IsValid() );
		}
예제 #3
0
        public void RequiredMassSpaceInertia()
        {
            var shapeDescription = new SphereShapeDescription(5);

            shapeDescription.Flags |= (ShapeFlag.TriggerOnEnter | ShapeFlag.TriggerOnLeave);

            var actorDesc = new ActorDescription()
            {
                BodyDescription = new BodyDescription(1)
                {
                    MassSpaceInertia = new Vector3(1, 1, 1),
                    BodyFlags        = BodyFlag.Kinematic
                },
                Shapes = { shapeDescription }
            };

            Assert.IsTrue(actorDesc.IsValid());
        }
예제 #4
0
        private void CreateBoxes(Nx.Material material)
        {
            for (int x = 0; x < XCount; x++)
            {
                for (int y = 0; y < YCount; y++)
                {
                    for (int z = 0; z < ZCount; z++)
                    {
                        var rigidBodyDesc = new BodyDescription();

                        var boxDesc = new BoxShapeDescription
                        {
                            Material   = material,
                            Dimensions = new NxVector3(WidthX / 2, WidthY / 2, WidthZ / 2)
                        };

                        var actorDesc = new ActorDescription(boxDesc)
                        {
                            BodyDescription = rigidBodyDesc,
                            Density         = 10.0f,
                            GlobalPose      = NxMath.Matrix.Translation(
                                XOffset + x * XSpace - ((XCount - 1) * XSpace / 2),
                                YOffset + y * YSpace - ((YCount - 1) * YSpace / 2),
                                ZOffset + z * ZSpace - ((ZCount - 1) * ZSpace / 2)),
                            UserData = _boxModel
                        };

                        if (!actorDesc.IsValid())
                        {
                            throw new Exception("ActorDesc invalid!");
                        }

                        var actor = _scene.CreateActor(actorDesc);
                        if (actor == null)
                        {
                            throw new Exception("Actor invalid!");
                        }
                    }
                }
            }
        }
예제 #5
0
        private void CreateTower(Nx.Material material, NxVector3 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 rigidBodyDesc = new BodyDescription();

                        var boxDesc = new BoxShapeDescription
                        {
                            Material   = material,
                            Dimensions = new NxVector3(descriptor.X / 2, descriptor.Y / 2, descriptor.Z / 2)
                        };

                        var actorDesc = new ActorDescription(boxDesc)
                        {
                            BodyDescription = rigidBodyDesc,
                            Density         = 10.0f,
                            GlobalPose      = NxMath.Matrix.Translation(
                                xOffset + x * xSpace - ((xCount - 1) * xSpace / 2),
                                yOffset + y * ySpace - ((yCount - 1) * ySpace / 2),
                                zOffset + z * zSpace - ((zCount - 1) * zSpace / 2)),
                            UserData = _boxModel
                        };

                        if (!actorDesc.IsValid())
                        {
                            throw new Exception("ActorDesc invalid!");
                        }

                        var actor = _scene.CreateActor(actorDesc);
                        if (actor == null)
                        {
                            throw new Exception("Actor invalid!");
                        }
                    }
                }
            }
        }
예제 #6
0
        private void CreateTower(Nx.Material material, NxVector3 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 rigidBodyDesc = new BodyDescription();

                        var boxDesc = new BoxShapeDescription
                                          {
                                              Material = material,
                                              Dimensions = new NxVector3(descriptor.X / 2, descriptor.Y / 2, descriptor.Z / 2)
                                          };

                        var actorDesc = new ActorDescription(boxDesc)
                                            {
                                                BodyDescription = rigidBodyDesc,
                                                Density = 10.0f,
                                                GlobalPose = NxMath.Matrix.Translation(
                                                                       xOffset + x * xSpace - ((xCount - 1) * xSpace / 2),
                                                                       yOffset + y * ySpace - ((yCount - 1) * ySpace / 2),
                                                                       zOffset + z * zSpace - ((zCount - 1) * zSpace / 2)),
                                                UserData = _boxModel
                                            };

                        if (!actorDesc.IsValid())
                            throw new Exception("ActorDesc invalid!");

                        var actor = _scene.CreateActor(actorDesc);
                        if (actor == null)
                            throw new Exception("Actor invalid!");
                    }
        }