Пример #1
0
 /// <summary>
 /// Make some nodes for us to attach wheel particles to
 /// </summary>
 protected override void PostInitialiseComponents(ThingBlock template, ThingDefinition def)
 {
     Vector3 frontleft  = def.GetVectorProperty("FrontLeftWheelPosition",  null);
     Vector3 frontright = def.GetVectorProperty("FrontRightWheelPosition", null);
     Vector3 backleft   = def.GetVectorProperty("BackLeftWheelPosition",   null);
     Vector3 backright  = def.GetVectorProperty("BackRightWheelPosition",  null);
     LeftParticleNode   = RootNode.CreateChildSceneNode(frontleft.MidPoint(backleft));
     RightParticleNode  = RootNode.CreateChildSceneNode(frontright.MidPoint(backright));
 }
Пример #2
0
        /// <summary>
        /// After we create our RigidBody, we turn it into a vehicle
        /// </summary>
        protected override void PostCreateBody(ThingDefinition def)
        {
            kartMotionState = MotionState as KartMotionState;

            Body.CcdMotionThreshold = 0.001f;
            Body.CcdSweptSphereRadius = 0.04f;

            Raycaster = new DefaultVehicleRaycaster(LKernel.GetG<PhysicsMain>().World);
            Tuning = new RaycastVehicle.VehicleTuning();
            _vehicle = new RaycastVehicle(Tuning, Body, Raycaster);
            _vehicle.SetCoordinateSystem(0, 1, 2); // I have no idea what this does... I'm assuming something to do with a rotation matrix?

            LKernel.GetG<PhysicsMain>().World.AddAction(_vehicle);

            var wheelFac = LKernel.GetG<WheelFactory>();
            string frontWheelName = def.GetStringProperty("FrontWheel", null);
            string backWheelName = def.GetStringProperty("BackWheel", null);
            WheelFL = wheelFac.CreateWheel(frontWheelName, WheelID.FrontLeft, this, def.GetVectorProperty("FrontLeftWheelPosition", null), def.GetStringProperty("FrontLeftWheelMesh", null));
            WheelFR = wheelFac.CreateWheel(frontWheelName, WheelID.FrontRight, this, def.GetVectorProperty("FrontRightWheelPosition", null), def.GetStringProperty("FrontRightWheelMesh", null));
            WheelBL = wheelFac.CreateWheel(backWheelName, WheelID.BackLeft, this, def.GetVectorProperty("BackLeftWheelPosition", null), def.GetStringProperty("BackLeftWheelMesh", null));
            WheelBR = wheelFac.CreateWheel(backWheelName, WheelID.BackRight, this, def.GetVectorProperty("BackRightWheelPosition", null), def.GetStringProperty("BackRightWheelMesh", null));

            LeftParticleNode.Position -= new Vector3(0, WheelBL.DefaultRadius * 0.7f, 0);
            RightParticleNode.Position -= new Vector3(0, WheelBR.DefaultRadius * 0.7f, 0);

            Body.LinearVelocity = new Vector3(0, 1, 0);

            PhysicsMain.FinaliseBeforeSimulation += FinaliseBeforeSimulation;
            RaceCountdown.OnCountdown += OnCountdown;
        }