Beispiel #1
0
        public override void Update()
        {
            this.actor.WakeUp();
            if (this.actor.IsSleeping)
            {
                Console.Write("");
            }
            //this.actor.BodyFlags.FrozenPositionY = true;

            if (game.stackControl.ContainsKey(id))
            {
                WheelShape shape = this.shape as WheelShape;
                //this.actor.WakeUp();
                if (game.stackControl[id].ContainsKey("MotorTorque"))
                {
                    shape.MotorTorque = game.stackControl[id]["MotorTorque"];
                }
                if (game.stackControl[id].ContainsKey("AxleSpeed"))
                {
                    //shape.AxleSpeed = game.stackControl[id]["AxleSpeed"];
                }

                this.shape = shape;
            }

            base.Update();
        }
Beispiel #2
0
 public void SetSuspention(SpringDesc suspention)
 {
     foreach (var wheel in _wheels)
     {
         if (wheel is RayCastWheel)
         {
             WheelShape shape = ((RayCastWheel)wheel).ActorShape;
             shape.Suspension = suspention;
         }
     }
 }
Beispiel #3
0
        public RayCastWheel(WheelShape shape)
        {
            if (shape == null)
            {
                throw new ArgumentNullException("shape");
            }

            _wheelShape = shape;
            _actor      = shape.Actor;
            var material = shape.Material;

            material.Flags        |= MaterialFlag.DISABLE_FRICTION;
            Name                   = shape.Name;
            shape.InverseWheelMass = 0.1f;
        }
Beispiel #4
0
        public VehicleWheel(VehicleChassis chassis, CWheelActor cactor, WheelShape wheel, float axleOffset)
        {
            Shape       = wheel;
            _chassis    = chassis;
            _axleOffset = axleOffset;
            CActor      = cactor;

            SmokeEmitter = new ParticleEmitter(null, 15, Vector3.Zero);

            IsRear = !CActor.IsFront;

            _latTireFn          = Shape.LateralTireForceFunction;
            _lngTireFn          = Shape.LongitudalTireForceFunction;
            _defaultLatExtremum = _latTireFn.ExtremumValue;
            _defaultLngExtremum = _lngTireFn.ExtremumValue;
        }
Beispiel #5
0
        public WheelControl()
        {
            InitializeComponent();
            DoubleBuffered = true;
            Rectangle ctrlRect = this.ClientRectangle;

            ControlLength = ctrlRect.Height;
            ControlWidth  = ctrlRect.Width;

            gradColor1              = Color.Black;
            gradColor2              = Color.White;
            IndentColor             = Color.Gray;
            backColor               = Color.White;
            IndentH                 = 10;
            gradAlpha1              = 200;
            gradAlpha2              = 50;
            gradAngle               = 90.0f;
            repeatNum               = 10;
            BorderThickness         = 5;
            MinRange                = 0.0f;
            position                = 0.0f;
            WheelTick               = 100.0f;
            _Hovering               = false;
            _LeftPressed            = false;
            MouseDnPos              = 0;
            RotNum                  = 100;
            MaxRange                = (RotNum * NumWheelTick * repeatNum) + MinRange;
            bRedraw                 = true;
            gradientBrush           = new LinearGradientBrush(ctrlRect, gradColor1, gradColor2, gradAngle, false);
            indentShape             = WheelShape.Rectangle;
            ControlOrientation      = WheelOrientation.Vertical;
            DesiredRangeMax         = 10.0;
            DesiredRangeMin         = -10.0;
            DesiredPosition         = PosToDesiredPos();
            clrIndentTexTransparent = Color.White;
            bInertia                = false;
            newTime                 = DateTime.Now;
            oldTime                 = DateTime.Now;
            dMovingSpeed            = 0.0;
            oldMousePosInertia      = 0;
            inStiffness             = 0.98;
        }
Beispiel #6
0
        private void DrawShape(ActorShape shape, GraphicDevice device)
        {
            Matrix scale;

            if (shape is BoxShape)
            {
                BoxShape boxShape = (BoxShape)shape;
                scale = Matrix.Scale(boxShape.Dimensions);
                Effect.Input.World = scale * boxShape.GlobalPose;
                DrawMesh(_box, device);
            }
            else if (shape is SphereShape)
            {
                SphereShape sphereShape = (SphereShape)shape;
                scale = Matrix.Scale(new Vector3(sphereShape.Radius));
                Effect.Input.World = scale * shape.GlobalPose;
                DrawMesh(_sphere, device);
            }
            else if (shape is PlaneShape)
            {
                scale = Matrix.Scale(Engine.Scene.ActiveCamera.ZFar, 0, Engine.Scene.ActiveCamera.ZFar);
                Effect.Input.World = scale * shape.GlobalPose;
                DrawMesh(_box, device);
            }
            else if (shape is WheelShape)
            {
                WheelShape wheel = (WheelShape)shape;

                Effect.Input.World = Matrix.Scale(wheel.Radius, 0, wheel.Radius) *
                                     Matrix.RotationZ(Numerics.PIover2) *
                                     Matrix.RotationY(wheel.SteerAngle) *
                                     shape.GlobalPose;

                DrawMesh(_cylindre, device);
            }
            else if (shape is CapsuleShape)
            {
                CapsuleShape capsuleShape = (CapsuleShape)shape;
                float        radius       = capsuleShape.Radius;
                float        height       = capsuleShape.Height;
                Effect.Input.World = Matrix.Translate(0, -0.5f, 0) *
                                     Matrix.Scale(radius, radius, radius) *
                                     Matrix.Translate(0, height * 0.5f, 0) * shape.GlobalPose;

                DrawMeshPart(_capsule, _capsule.Layers[0], device);

                Effect.Input.World = Matrix.Translate(0, 0.5f, 0) *
                                     Matrix.Scale(radius, radius, radius) *
                                     Matrix.Translate(0, -(height * 0.5f), 0) * shape.GlobalPose;
                DrawMeshPart(_capsule, _capsule.Layers[2], device);

                Effect.Input.World = Matrix.Scale(radius, height, radius) * shape.GlobalPose;
                DrawMeshPart(_capsule, _capsule.Layers[1], device);
            }
            else if (shape is TriangleMeshShape)
            {
                TriangleMesh tmesh = ((TriangleMeshShape)shape).Mesh;
                var          mesh  = (Mesh)tmesh.GraphicMesh;
                if (mesh != null)
                {
                    Effect.Input.World = shape.GlobalPose;

                    DrawMesh(mesh, device);
                }
            }
        }