예제 #1
0
        public void PostInitialise()
        {
            physicsEntity.PhysicsEntity.IsAffectedByGravity = false;
            physicsEntity.PhysicsEntity.LinearDamping       = 0.8f;
            physicsEntity.PhysicsEntity.AngularDamping      = 0.8f;

            UprightSpring uprightSpringConstraint = new UprightSpring(physicsEntity.PhysicsEntity, BEPUutilities.Vector3.Up, 0.1f, 100, 0.4f);

            SystemCore.PhysicsSimulation.Add(uprightSpringConstraint);
        }
예제 #2
0
        public DuneBuggy(PlayerIndex player, Color color, Microsoft.Xna.Framework.Vector3 position)
        {
            this.playerIndex = player;

            this.vehicle = VehicleFactory.Create(position.ToBepuVector());
            SystemCore.PhysicsSimulation.Add(vehicle);

            var shape = new ProceduralCuboid(2.5f / 2, 4.5f / 2, .75f / 2);

            shape.SetColor(color);
            BuggyObject = GameObjectFactory.CreateRenderableGameObjectFromShape(shape, EffectLoader.LoadSM5Effect("flatshaded"));
            BuggyObject.AddComponent(new ShadowCasterComponent());

            SystemCore.GameObjectManager.AddAndInitialiseGameObject(BuggyObject);

            wheels = new List <GameObject>();
            foreach (Wheel w in vehicle.Wheels)
            {
                var cube = new ProceduralCube();
                cube.SetColor(Color.Maroon);
                var wheel = GameObjectFactory.CreateRenderableGameObjectFromShape(cube, EffectLoader.LoadSM5Effect("flatshaded"));
                wheel.AddComponent(new ShadowCasterComponent());

                var particles = new SquareParticleSystem();

                wheel.AddComponent(particles);

                SystemCore.GameObjectManager.AddAndInitialiseGameObject(wheel);

                particles.settings.Duration = TimeSpan.FromSeconds(2f);

                wheels.Add(wheel);
            }

            uprightSpringConstraint = new UprightSpring(vehicle.Body, BEPUutilities.Vector3.Up, 0.1f, (float)Math.PI, 1000f);
            SystemCore.PhysicsSimulation.Add(uprightSpringConstraint);
        }