예제 #1
0
        // This is an overridable version of SetVehicle() that works for all physics engines.
        // This is VERY inefficient. It behoves any physics engine to override this and
        //     implement a more efficient setting of all the vehicle parameters.
        public virtual void SetVehicle(object pvdata)
        {
            VehicleData vdata = (VehicleData)pvdata;

            // vehicleActor.ProcessSetVehicle((VehicleData)vdata);

            this.VehicleType = (int)vdata.m_type;
            this.VehicleFlags(-1, false);   // clears all flags
            this.VehicleFlags((int)vdata.m_flags, false);

            // Linear properties
            this.VehicleVectorParam((int)Vehicle.LINEAR_MOTOR_DIRECTION, vdata.m_linearMotorDirection);
            this.VehicleVectorParam((int)Vehicle.LINEAR_FRICTION_TIMESCALE, vdata.m_linearFrictionTimescale);
            this.VehicleFloatParam((int)Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE, vdata.m_linearMotorDecayTimescale);
            this.VehicleFloatParam((int)Vehicle.LINEAR_MOTOR_TIMESCALE, vdata.m_linearMotorTimescale);
            this.VehicleVectorParam((int)Vehicle.LINEAR_MOTOR_OFFSET, vdata.m_linearMotorOffset);

            //Angular properties
            this.VehicleVectorParam((int)Vehicle.ANGULAR_MOTOR_DIRECTION, vdata.m_angularMotorDirection);
            this.VehicleFloatParam((int)Vehicle.ANGULAR_MOTOR_TIMESCALE, vdata.m_angularMotorTimescale);
            this.VehicleFloatParam((int)Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE, vdata.m_angularMotorDecayTimescale);
            this.VehicleVectorParam((int)Vehicle.ANGULAR_FRICTION_TIMESCALE, vdata.m_angularFrictionTimescale);

            //Deflection properties
            this.VehicleFloatParam((int)Vehicle.ANGULAR_DEFLECTION_EFFICIENCY, vdata.m_angularDeflectionEfficiency);
            this.VehicleFloatParam((int)Vehicle.ANGULAR_DEFLECTION_TIMESCALE, vdata.m_angularDeflectionTimescale);
            this.VehicleFloatParam((int)Vehicle.LINEAR_DEFLECTION_EFFICIENCY, vdata.m_linearDeflectionEfficiency);
            this.VehicleFloatParam((int)Vehicle.LINEAR_DEFLECTION_TIMESCALE, vdata.m_linearDeflectionTimescale);

            //Banking properties
            this.VehicleFloatParam((int)Vehicle.BANKING_EFFICIENCY, vdata.m_bankingEfficiency);
            this.VehicleFloatParam((int)Vehicle.BANKING_MIX, vdata.m_bankingMix);
            this.VehicleFloatParam((int)Vehicle.BANKING_TIMESCALE, vdata.m_bankingTimescale);

            //Hover and Buoyancy properties
            this.VehicleFloatParam((int)Vehicle.HOVER_HEIGHT, vdata.m_VhoverHeight);
            this.VehicleFloatParam((int)Vehicle.HOVER_EFFICIENCY, vdata.m_VhoverEfficiency);
            this.VehicleFloatParam((int)Vehicle.HOVER_TIMESCALE, vdata.m_VhoverTimescale);
            this.VehicleFloatParam((int)Vehicle.BUOYANCY, vdata.m_VehicleBuoyancy);

            //Attractor properties
            this.VehicleFloatParam((int)Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, vdata.m_verticalAttractionEfficiency);
            this.VehicleFloatParam((int)Vehicle.VERTICAL_ATTRACTION_TIMESCALE, vdata.m_verticalAttractionTimescale);

            this.VehicleRotationParam((int)Vehicle.REFERENCE_FRAME, vdata.m_referenceFrame);
        }
예제 #2
0
        public void DoSetVehicle(VehicleData vd)
        {
            m_type = vd.m_type;
            m_flags = vd.m_flags;

            
            // Linear properties
            m_linearMotorDirection = vd.m_linearMotorDirection;

            m_linearFrictionTimescale = vd.m_linearFrictionTimescale;
            if (m_linearFrictionTimescale.X < m_timestep) m_linearFrictionTimescale.X = m_timestep;
            if (m_linearFrictionTimescale.Y < m_timestep) m_linearFrictionTimescale.Y = m_timestep;
            if (m_linearFrictionTimescale.Z < m_timestep) m_linearFrictionTimescale.Z = m_timestep;

            m_linearMotorDecayTimescale = vd.m_linearMotorDecayTimescale;
            if (m_linearMotorDecayTimescale < m_timestep) m_linearMotorDecayTimescale = m_timestep;
            m_linearMotorDecayTimescale += 0.2f;
            m_linearMotorDecayTimescale *= m_invtimestep;

            m_linearMotorTimescale = vd.m_linearMotorTimescale;
            if (m_linearMotorTimescale < m_timestep) m_linearMotorTimescale = m_timestep;

            m_linearMotorOffset = vd.m_linearMotorOffset;

            //Angular properties
            m_angularMotorDirection = vd.m_angularMotorDirection;
            m_angularMotorTimescale = vd.m_angularMotorTimescale;
            if (m_angularMotorTimescale < m_timestep) m_angularMotorTimescale = m_timestep;

            m_angularMotorDecayTimescale = vd.m_angularMotorDecayTimescale;
            if (m_angularMotorDecayTimescale < m_timestep) m_angularMotorDecayTimescale = m_timestep;
            m_angularMotorDecayTimescale *= m_invtimestep;

            m_angularFrictionTimescale = vd.m_angularFrictionTimescale;
            if (m_angularFrictionTimescale.X < m_timestep) m_angularFrictionTimescale.X = m_timestep;
            if (m_angularFrictionTimescale.Y < m_timestep) m_angularFrictionTimescale.Y = m_timestep;
            if (m_angularFrictionTimescale.Z < m_timestep) m_angularFrictionTimescale.Z = m_timestep;

            //Deflection properties
            m_angularDeflectionEfficiency = vd.m_angularDeflectionEfficiency;
            m_angularDeflectionTimescale = vd.m_angularDeflectionTimescale;
            if (m_angularDeflectionTimescale < m_timestep) m_angularDeflectionTimescale = m_timestep;

            m_linearDeflectionEfficiency = vd.m_linearDeflectionEfficiency;
            m_linearDeflectionTimescale = vd.m_linearDeflectionTimescale;
            if (m_linearDeflectionTimescale < m_timestep) m_linearDeflectionTimescale = m_timestep;

            //Banking properties
            m_bankingEfficiency = vd.m_bankingEfficiency;
            m_bankingMix = vd.m_bankingMix;
            m_bankingTimescale = vd.m_bankingTimescale;
            if (m_bankingTimescale < m_timestep) m_bankingTimescale = m_timestep;

            //Hover and Buoyancy properties
            m_VhoverHeight = vd.m_VhoverHeight;
            m_VhoverEfficiency = vd.m_VhoverEfficiency;
            m_VhoverTimescale = vd.m_VhoverTimescale;
            if (m_VhoverTimescale < m_timestep) m_VhoverTimescale = m_timestep;

            m_VehicleBuoyancy = vd.m_VehicleBuoyancy;

            //Attractor properties
            m_verticalAttractionEfficiency = vd.m_verticalAttractionEfficiency;
            m_verticalAttractionTimescale = vd.m_verticalAttractionTimescale;
            if (m_verticalAttractionTimescale < m_timestep) m_verticalAttractionTimescale = m_timestep;

            // Axis
            m_referenceFrame = vd.m_referenceFrame;

            m_lmEfect = 0;
            m_lmDecay = (1.0f - 1.0f / m_linearMotorDecayTimescale);
            m_amEfect = 0;
            m_ffactor = 1.0f;
        }