Exemplo n.º 1
0
 public VehicleMotor(ref PhysxPrim _actor, ref VehicleProperties _props, ref PhysX.Physics _physics, ref PhysxScene _scene)
 {
     this._actor = _actor;
     this._props = _props;
     this._physics = _physics;
     this._scene = _scene;
 }
Exemplo n.º 2
0
        // Set the default values associated with the new vehicle type. This
        // may require adjusting the current ramping/damping values if they are
        // outside the new limits (done in simulate).
        // NOTE: These constants are from the wiki documentation and needs verification empirically.
        /// <summary>
        /// The standard LSL default parameters for each type of vehicle
        /// WARNING: This code may be executed from outside the physics thread.
        /// </summary>
        internal static void SetVehicleDefaults(VehicleProperties _props)
        {
            VehicleType newType = _props.Type;

            switch (newType)
            {
                // This is here to prepopulate the parameters to avoid an exception.
                // The parameters are also cleared to remove any previous keys that have been removed or renamed.
                case VehicleType.None:
                    _props.ParamsVec.Clear();
                    _props.ParamsVec[VectorParams.VehicleLinearFrictionTimescale]       = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleAngularFrictionTimescale]      = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleLinearMotorDirection]          = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleAngularMotorDirection]         = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleLinearMotorOffset]             = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleLinearMotorTimescale]          = new OpenMetaverse.Vector3(1000.0f, 1000.0f, 1000.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularMotorTimescale]         = new OpenMetaverse.Vector3(1000.0f, 1000.0f, 1000.0f);
                    _props.ParamsVec[VectorParams.VehicleLinearMotorDecayTimescale]     = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleAngularMotorDecayTimescale]    = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleLinearWindEfficiency]          = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleAngularWindEfficiency]         = OpenMetaverse.Vector3.Zero;

                    _props.ParamsFloat.Clear();
                    _props.ParamsFloat[FloatParams.VehicleHoverHeight]                  = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleHoverEfficiency]              = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleHoverTimescale]               = 1000.0f;
                    _props.ParamsFloat[FloatParams.VehicleBuoyancy]                     = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleLinearDeflectionEfficiency]   = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleLinearDeflectionTimescale]    = 1000.0f;
                    _props.ParamsFloat[FloatParams.VehicleAngularDeflectionEfficiency]  = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleAngularDeflectionTimescale]   = 1000.0f;
                    _props.ParamsFloat[FloatParams.VehicleVerticalAttractionEfficiency] = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleVerticalAttractionTimescale]  = 1000.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingEfficiency]            = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleInvertedBankingModifier]      = 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingMix]                   = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingTimescale]             = 1000.0f;
                    _props.ParamsFloat[FloatParams.VehicleMouselookAltitude]            = (float)Math.PI / 4.0f;
                    _props.ParamsFloat[FloatParams.VehicleMouselookAzimuth]             = (float)Math.PI / 4.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingAzimuth]               = (float)Math.PI / 2.0f;
                    _props.ParamsFloat[FloatParams.VehicleDisableMotorsAbove]           = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleDisableMotorsAfter]           = 0.0f;

                    _props.ParamsRot.Clear();
                    _props.ParamsRot[RotationParams.VehicleReferenceFrame] = new OpenMetaverse.Quaternion(0f, 0f, 0f, 1f);

                    _props.Flags = 0;
                    break;

                case VehicleType.Sled:
                    _props.ParamsVec[VectorParams.VehicleLinearFrictionTimescale]       = new OpenMetaverse.Vector3(1000.0f, 1.0f, 1000.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularFrictionTimescale]      = new OpenMetaverse.Vector3(1000.0f, 1000.0f, 1000.0f);
                    _props.ParamsVec[VectorParams.VehicleLinearMotorDirection]          = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleAngularMotorDirection]         = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleLinearMotorOffset]             = new OpenMetaverse.Vector3(0.0f, 0.0f, -0.1f);
                    _props.ParamsVec[VectorParams.VehicleLinearMotorTimescale]          = new OpenMetaverse.Vector3(1000.0f, 1000.0f, 1000.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularMotorTimescale]         = new OpenMetaverse.Vector3(1000.0f, 1000.0f, 1000.0f);
                    _props.ParamsVec[VectorParams.VehicleLinearMotorDecayTimescale]     = new OpenMetaverse.Vector3(120.0f, 120.0f, 120.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularMotorDecayTimescale]    = new OpenMetaverse.Vector3(120.0f, 120.0f, 120.0f);
                    _props.ParamsVec[VectorParams.VehicleLinearWindEfficiency]          = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleAngularWindEfficiency]         = OpenMetaverse.Vector3.Zero;

                    _props.ParamsFloat[FloatParams.VehicleHoverHeight]                  = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleHoverEfficiency]              = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleHoverTimescale]               = 1000.0f;
                    _props.ParamsFloat[FloatParams.VehicleBuoyancy]                     = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleLinearDeflectionEfficiency]   = 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleLinearDeflectionTimescale]    = 0.3f; // 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleAngularDeflectionEfficiency]  = 1.0f; // 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleAngularDeflectionTimescale]   = 1.0f; // 10.0f;
                    _props.ParamsFloat[FloatParams.VehicleVerticalAttractionEfficiency] = 0.1f;
                    _props.ParamsFloat[FloatParams.VehicleVerticalAttractionTimescale]  = 10.0f; // 1000.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingEfficiency]            = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleInvertedBankingModifier]      = 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingMix]                   = 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingTimescale]             = 10.0f;
                    _props.ParamsFloat[FloatParams.VehicleMouselookAltitude]            = (float)Math.PI / 4.0f;
                    _props.ParamsFloat[FloatParams.VehicleMouselookAzimuth]             = (float)Math.PI / 4.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingAzimuth]               = (float)Math.PI / 2.0f;
                    _props.ParamsFloat[FloatParams.VehicleDisableMotorsAbove]           = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleDisableMotorsAfter]           = 0.0f;

                    _props.ParamsRot[RotationParams.VehicleReferenceFrame] = new OpenMetaverse.Quaternion(0f, 0f, 0f, 1f);

                    _props.Flags = (VehicleFlags.NoDeflectionUp | VehicleFlags.LimitRollOnly | VehicleFlags.LimitMotorUp);
                    // ~(VehicleFlags.HoverWaterOnly | VehicleFlags.HoverTerrainOnly | VehicleFlags.HoverGlobalHeight | VehicleFlags.HoverUpOnly);
                    break;

                case VehicleType.Car:
                    _props.ParamsVec[VectorParams.VehicleLinearFrictionTimescale]       = new OpenMetaverse.Vector3(100.0f, 0.1f, 10.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularFrictionTimescale]      = new OpenMetaverse.Vector3(100.0f, 100.0f, 0.3f);
                    _props.ParamsVec[VectorParams.VehicleLinearMotorDirection]          = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleAngularMotorDirection]         = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleLinearMotorOffset]             = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleLinearMotorTimescale]          = new OpenMetaverse.Vector3(0.5f, 1.0f, 1.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularMotorTimescale]         = new OpenMetaverse.Vector3(0.2f, 0.2f, 0.05f);
                    _props.ParamsVec[VectorParams.VehicleLinearMotorDecayTimescale]     = new OpenMetaverse.Vector3(10.0f, 2.0f, 2.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularMotorDecayTimescale]    = new OpenMetaverse.Vector3(0.3f, 0.3f, 0.1f);
                    _props.ParamsVec[VectorParams.VehicleLinearWindEfficiency]          = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleAngularWindEfficiency]         = OpenMetaverse.Vector3.Zero;

                    _props.ParamsFloat[FloatParams.VehicleHoverHeight]                  = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleHoverEfficiency]              = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleHoverTimescale]               = 1000.0f;
                    _props.ParamsFloat[FloatParams.VehicleBuoyancy]                     = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleLinearDeflectionEfficiency]   = 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleLinearDeflectionTimescale]    = 2.0f;
                    _props.ParamsFloat[FloatParams.VehicleAngularDeflectionEfficiency]  = 0.5f; // 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleAngularDeflectionTimescale]   = 2.0f; // 10.0f;
                    _props.ParamsFloat[FloatParams.VehicleVerticalAttractionEfficiency] = 0.6f; // 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleVerticalAttractionTimescale]  = 2.0f; // 10.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingEfficiency]            = -0.2f;
                    _props.ParamsFloat[FloatParams.VehicleInvertedBankingModifier]      = 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingMix]                   = 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingTimescale]             = 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleMouselookAltitude]            = (float)Math.PI / 4.0f;
                    _props.ParamsFloat[FloatParams.VehicleMouselookAzimuth]             = (float)Math.PI / 4.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingAzimuth]               = (float)Math.PI / 2.0f;
                    _props.ParamsFloat[FloatParams.VehicleDisableMotorsAbove]           = 0.75f;
                    _props.ParamsFloat[FloatParams.VehicleDisableMotorsAfter]           = 2.5f;

                    _props.ParamsRot[RotationParams.VehicleReferenceFrame] = new OpenMetaverse.Quaternion(0f, 0f, 0f, 1f);

                    _props.Flags = (VehicleFlags.NoDeflectionUp | VehicleFlags.LimitRollOnly | VehicleFlags.HoverUpOnly | VehicleFlags.LimitMotorUp);
                    // ~(VehicleFlags.HoverWaterOnly | VehicleFlags.HoverTerrainOnly | VehicleFlags.HoverGlobalHeight);
                    break;

                case VehicleType.Motorcycle:    // An InWorldz vehicle type
                    _props.ParamsVec[VectorParams.VehicleLinearFrictionTimescale]       = new OpenMetaverse.Vector3(100.0f, 0.1f, 10.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularFrictionTimescale]      = new OpenMetaverse.Vector3(3.0f, 0.2f, 10.0f);
                    _props.ParamsVec[VectorParams.VehicleLinearMotorDirection]          = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleAngularMotorDirection]         = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleLinearMotorOffset]             = new OpenMetaverse.Vector3(0.0f, 0.0f, -0.1f);
                    _props.ParamsVec[VectorParams.VehicleLinearMotorTimescale]          = new OpenMetaverse.Vector3(0.5f, 1.0f, 1.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularMotorTimescale]         = new OpenMetaverse.Vector3(0.1f, 0.1f, 0.05f);
                    _props.ParamsVec[VectorParams.VehicleLinearMotorDecayTimescale]     = new OpenMetaverse.Vector3(10.0f, 1.0f, 1.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularMotorDecayTimescale]    = new OpenMetaverse.Vector3(0.2f, 0.8f, 0.1f);
                    _props.ParamsVec[VectorParams.VehicleLinearWindEfficiency]          = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleAngularWindEfficiency]         = OpenMetaverse.Vector3.Zero;

                    _props.ParamsFloat[FloatParams.VehicleHoverHeight]                  = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleHoverEfficiency]              = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleHoverTimescale]               = 1000.0f;
                    _props.ParamsFloat[FloatParams.VehicleBuoyancy]                     = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleLinearDeflectionEfficiency]   = 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleLinearDeflectionTimescale]    = 2.0f;
                    _props.ParamsFloat[FloatParams.VehicleAngularDeflectionEfficiency]  = 0.8f;
                    _props.ParamsFloat[FloatParams.VehicleAngularDeflectionTimescale]   = 2.0f;
                    _props.ParamsFloat[FloatParams.VehicleVerticalAttractionEfficiency] = 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleVerticalAttractionTimescale]  = 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingEfficiency]            = 0.95f;
                    _props.ParamsFloat[FloatParams.VehicleInvertedBankingModifier]      = -0.5f;
                    _props.ParamsFloat[FloatParams.VehicleBankingMix]                   = 0.5f;
                    _props.ParamsFloat[FloatParams.VehicleBankingTimescale]             = 0.1f;
                    _props.ParamsFloat[FloatParams.VehicleMouselookAltitude]            = (float)Math.PI / 4.0f;
                    _props.ParamsFloat[FloatParams.VehicleMouselookAzimuth]             = (float)Math.PI / 4.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingAzimuth]               = (float)Math.PI / 2.0f;
                    _props.ParamsFloat[FloatParams.VehicleDisableMotorsAbove]           = 1.5f;
                    _props.ParamsFloat[FloatParams.VehicleDisableMotorsAfter]           = 2.5f;

                    _props.ParamsRot[RotationParams.VehicleReferenceFrame] = new OpenMetaverse.Quaternion(0f, 0f, 0f, 1f);

                    _props.Flags = (VehicleFlags.NoDeflectionUp | VehicleFlags.HoverUpOnly | VehicleFlags.LimitMotorUp | VehicleFlags.LimitMotorDown |
                                    VehicleFlags.LimitRollOnly | VehicleFlags.TorqueWorldZ);
                    // ~(VehicleFlags.HoverWaterOnly | VehicleFlags.HoverTerrainOnly | VehicleFlags.HoverGlobalHeight);
                    break;

                case VehicleType.Boat:
                    _props.ParamsVec[VectorParams.VehicleLinearFrictionTimescale]       = new OpenMetaverse.Vector3(200.0f, 0.5f, 3.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularFrictionTimescale]      = new OpenMetaverse.Vector3(10.0f, 1.0f, 0.1f);
                    _props.ParamsVec[VectorParams.VehicleLinearMotorDirection]          = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleAngularMotorDirection]         = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleLinearMotorOffset]             = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleLinearMotorTimescale]          = new OpenMetaverse.Vector3(1.0f, 5.0f, 5.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularMotorTimescale]         = new OpenMetaverse.Vector3(0.2f, 2.0f, 0.1f);
                    _props.ParamsVec[VectorParams.VehicleLinearMotorDecayTimescale]     = new OpenMetaverse.Vector3(1.0f, 10.0f, 10.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularMotorDecayTimescale]    = new OpenMetaverse.Vector3(0.3f, 0.3f, 0.1f);
                    _props.ParamsVec[VectorParams.VehicleLinearWindEfficiency]          = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleAngularWindEfficiency]         = OpenMetaverse.Vector3.Zero;

                    _props.ParamsFloat[FloatParams.VehicleHoverHeight]                  = 0.5f; // 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleHoverEfficiency]              = 0.8f;
                    _props.ParamsFloat[FloatParams.VehicleHoverTimescale]               = 0.2f; // 2.0f;
                    _props.ParamsFloat[FloatParams.VehicleBuoyancy]                     = 0.0f; // 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleLinearDeflectionEfficiency]   = 0.5f;
                    _props.ParamsFloat[FloatParams.VehicleLinearDeflectionTimescale]    = 3.0f;
                    _props.ParamsFloat[FloatParams.VehicleAngularDeflectionEfficiency]  = 0.5f;
                    _props.ParamsFloat[FloatParams.VehicleAngularDeflectionTimescale]   = 5.0f;
                    _props.ParamsFloat[FloatParams.VehicleVerticalAttractionEfficiency] = 0.5f;
                    _props.ParamsFloat[FloatParams.VehicleVerticalAttractionTimescale]  = 0.2f; // 5.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingEfficiency]            = 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleInvertedBankingModifier]      = 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingMix]                   = 0.5f;
                    _props.ParamsFloat[FloatParams.VehicleBankingTimescale]             = 0.2f;
                    _props.ParamsFloat[FloatParams.VehicleMouselookAltitude]            = (float)Math.PI / 4.0f;
                    _props.ParamsFloat[FloatParams.VehicleMouselookAzimuth]             = (float)Math.PI / 4.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingAzimuth]               = (float)Math.PI / 2.0f;
                    _props.ParamsFloat[FloatParams.VehicleDisableMotorsAbove]           = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleDisableMotorsAfter]           = 0.0f;

                    _props.ParamsRot[RotationParams.VehicleReferenceFrame] = new OpenMetaverse.Quaternion(0f, 0f, 0f, 1f);

                    _props.Flags =  (VehicleFlags.NoDeflectionUp | VehicleFlags.HoverWaterOnly | VehicleFlags.LimitMotorUp | VehicleFlags.LimitMotorDown |
                                     VehicleFlags.TorqueWorldZ);
                    // ~(VehicleFlags.HoverTerrainOnly | VehicleFlags.LimitRollOnly | VehicleFlags.HoverGlobalHeight | VehicleFlags.HoverUpOnly );
                    break;

                case VehicleType.Sailboat:  // An InWorldz vehicle type
                    _props.ParamsVec[VectorParams.VehicleLinearFrictionTimescale]       = new OpenMetaverse.Vector3(200.0f, 0.5f, 3.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularFrictionTimescale]      = new OpenMetaverse.Vector3(10.0f, 1.0f, 0.2f);
                    _props.ParamsVec[VectorParams.VehicleLinearMotorDirection]          = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleAngularMotorDirection]         = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleLinearMotorOffset]             = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleLinearMotorTimescale]          = new OpenMetaverse.Vector3(1.0f, 5.0f, 5.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularMotorTimescale]         = new OpenMetaverse.Vector3(2.0f, 2.0f, 0.1f);
                    _props.ParamsVec[VectorParams.VehicleLinearMotorDecayTimescale]     = new OpenMetaverse.Vector3(1.0f, 10.0f, 10.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularMotorDecayTimescale]    = new OpenMetaverse.Vector3(0.3f, 0.3f, 0.1f);
                    _props.ParamsVec[VectorParams.VehicleLinearWindEfficiency]          = new OpenMetaverse.Vector3(0.02f, 0.001f, 0.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularWindEfficiency]         = new OpenMetaverse.Vector3(0.1f, 0.01f, 0.0f);

                    _props.ParamsFloat[FloatParams.VehicleHoverHeight]                  = 0.0001f; // 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleHoverEfficiency]              = 0.8f;
                    _props.ParamsFloat[FloatParams.VehicleHoverTimescale]               = 0.5f; // 2.0f;
                    _props.ParamsFloat[FloatParams.VehicleBuoyancy]                     = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleLinearDeflectionEfficiency]   = 0.5f;
                    _props.ParamsFloat[FloatParams.VehicleLinearDeflectionTimescale]    = 3.0f;
                    _props.ParamsFloat[FloatParams.VehicleAngularDeflectionEfficiency]  = 0.5f;
                    _props.ParamsFloat[FloatParams.VehicleAngularDeflectionTimescale]   = 5.0f;
                    _props.ParamsFloat[FloatParams.VehicleVerticalAttractionEfficiency] = 0.5f;
                    _props.ParamsFloat[FloatParams.VehicleVerticalAttractionTimescale]  = 0.3f;
                    _props.ParamsFloat[FloatParams.VehicleBankingEfficiency]            = 0.8f;
                    _props.ParamsFloat[FloatParams.VehicleInvertedBankingModifier]      = -0.2f;
                    _props.ParamsFloat[FloatParams.VehicleBankingMix]                   = 0.5f;
                    _props.ParamsFloat[FloatParams.VehicleBankingTimescale]             = 0.5f;
                    _props.ParamsFloat[FloatParams.VehicleMouselookAltitude]            = (float)Math.PI / 4.0f;
                    _props.ParamsFloat[FloatParams.VehicleMouselookAzimuth]             = (float)Math.PI / 4.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingAzimuth]               = (float)Math.PI / 2.0f;
                    _props.ParamsFloat[FloatParams.VehicleDisableMotorsAbove]           = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleDisableMotorsAfter]           = 0.0f;

                    _props.ParamsRot[RotationParams.VehicleReferenceFrame] = new OpenMetaverse.Quaternion(0f, 0f, 0f, 1f);

                    _props.Flags =  (VehicleFlags.NoDeflectionUp | VehicleFlags.HoverWaterOnly | VehicleFlags.LimitMotorUp | VehicleFlags.LimitMotorDown | 
                                     VehicleFlags.ReactToWind | VehicleFlags.ReactToCurrents | VehicleFlags.TorqueWorldZ);
                    // ~(VehicleFlags.HoverTerrainOnly | VehicleFlags.LimitRollOnly | VehicleFlags.HoverGlobalHeight | VehicleFlags.HoverUpOnly );
                    break;

                case VehicleType.Airplane:
                    _props.ParamsVec[VectorParams.VehicleLinearFrictionTimescale]       = new OpenMetaverse.Vector3(200.0f, 10.0f, 5.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularFrictionTimescale]      = new OpenMetaverse.Vector3(1.0f, 0.1f, 0.5f);
                    _props.ParamsVec[VectorParams.VehicleLinearMotorDirection]          = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleAngularMotorDirection]         = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleLinearMotorOffset]             = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleLinearMotorTimescale]          = new OpenMetaverse.Vector3(2.0f, 2.0f, 2.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularMotorTimescale]         = new OpenMetaverse.Vector3(1.0f, 2.0f, 1.0f);
                    _props.ParamsVec[VectorParams.VehicleLinearMotorDecayTimescale]     = new OpenMetaverse.Vector3(60.0f, 60.0f, 60.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularMotorDecayTimescale]    = new OpenMetaverse.Vector3(8.0f, 8.0f, 8.0f);
                    _props.ParamsVec[VectorParams.VehicleLinearWindEfficiency]          = new OpenMetaverse.Vector3(0.1f, 0.0f, 0.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularWindEfficiency]         = new OpenMetaverse.Vector3(0.05f, 0.0f, 0.0f);

                    _props.ParamsFloat[FloatParams.VehicleHoverHeight]                  = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleHoverEfficiency]              = 0.5f;
                    _props.ParamsFloat[FloatParams.VehicleHoverTimescale]               = 1000.0f;
                    _props.ParamsFloat[FloatParams.VehicleBuoyancy]                     = 0.0f; // 0.7f;
                    _props.ParamsFloat[FloatParams.VehicleLinearDeflectionEfficiency]   = 0.5f;
                    _props.ParamsFloat[FloatParams.VehicleLinearDeflectionTimescale]    = 0.5f;
                    _props.ParamsFloat[FloatParams.VehicleAngularDeflectionEfficiency]  = 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleAngularDeflectionTimescale]   = 2.0f;
                    _props.ParamsFloat[FloatParams.VehicleVerticalAttractionEfficiency] = 0.9f;
                    _props.ParamsFloat[FloatParams.VehicleVerticalAttractionTimescale]  = 2.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingEfficiency]            = 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleInvertedBankingModifier]      = 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingMix]                   = 0.7f;
                    _props.ParamsFloat[FloatParams.VehicleBankingTimescale]             = 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleMouselookAltitude]            = (float)Math.PI / 4.0f;
                    _props.ParamsFloat[FloatParams.VehicleMouselookAzimuth]             = (float)Math.PI / 4.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingAzimuth]               = (float)Math.PI / 2.0f;
                    _props.ParamsFloat[FloatParams.VehicleDisableMotorsAbove]           = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleDisableMotorsAfter]           = 0.0f;

                    _props.ParamsRot[RotationParams.VehicleReferenceFrame] = new OpenMetaverse.Quaternion(0f, 0f, 0f, 1f);

                    _props.Flags =  (VehicleFlags.TorqueWorldZ | VehicleFlags.LimitRollOnly);
                    // ~(VehicleFlags.NoDeflectionUp | VehicleFlags.HoverWaterOnly | VehicleFlags.HoverTerrainOnly | 
                    //   VehicleFlags.HoverUpOnly | VehicleFlags.HoverGlobalHeight | VehicleFlags.LimitMotorUp);
                    break;

                case VehicleType.Balloon:
                    _props.ParamsVec[VectorParams.VehicleLinearFrictionTimescale]       = new OpenMetaverse.Vector3(1.0f, 1.0f, 5.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularFrictionTimescale]      = new OpenMetaverse.Vector3(2.0f, 0.5f, 1.0f);
                    _props.ParamsVec[VectorParams.VehicleLinearMotorDirection]          = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleAngularMotorDirection]         = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleLinearMotorOffset]             = OpenMetaverse.Vector3.Zero;
                    _props.ParamsVec[VectorParams.VehicleLinearMotorTimescale]          = new OpenMetaverse.Vector3(1.0f, 5.0f, 5.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularMotorTimescale]         = new OpenMetaverse.Vector3(2.0f, 2.0f, 0.3f);
                    _props.ParamsVec[VectorParams.VehicleLinearMotorDecayTimescale]     = new OpenMetaverse.Vector3(60.0f, 60.0f, 60.0f);
                    _props.ParamsVec[VectorParams.VehicleAngularMotorDecayTimescale]    = new OpenMetaverse.Vector3(0.3f, 0.3f, 1.0f);
                    _props.ParamsVec[VectorParams.VehicleLinearWindEfficiency]          = new OpenMetaverse.Vector3(0.1f, 0.1f, 0.1f);
                    _props.ParamsVec[VectorParams.VehicleAngularWindEfficiency]         = new OpenMetaverse.Vector3(0.01f, 0.01f, 0.0f);

                    _props.ParamsFloat[FloatParams.VehicleHoverHeight]                  = 5.0f;
                    _props.ParamsFloat[FloatParams.VehicleHoverEfficiency]              = 0.8f;
                    _props.ParamsFloat[FloatParams.VehicleHoverTimescale]               = 10.0f;
                    _props.ParamsFloat[FloatParams.VehicleBuoyancy]                     = 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleLinearDeflectionEfficiency]   = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleLinearDeflectionTimescale]    = 5.0f;
                    _props.ParamsFloat[FloatParams.VehicleAngularDeflectionEfficiency]  = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleAngularDeflectionTimescale]   = 5.0f;
                    _props.ParamsFloat[FloatParams.VehicleVerticalAttractionEfficiency] = 0.5f;  // 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleVerticalAttractionTimescale]  = 4.0f; // 1000.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingEfficiency]            = 0.05f;
                    _props.ParamsFloat[FloatParams.VehicleInvertedBankingModifier]      = 1.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingMix]                   = 0.5f;
                    _props.ParamsFloat[FloatParams.VehicleBankingTimescale]             = 5.0f;
                    _props.ParamsFloat[FloatParams.VehicleMouselookAltitude]            = (float)Math.PI / 4.0f;
                    _props.ParamsFloat[FloatParams.VehicleMouselookAzimuth]             = (float)Math.PI / 4.0f;
                    _props.ParamsFloat[FloatParams.VehicleBankingAzimuth]               = (float)Math.PI / 2.0f;
                    _props.ParamsFloat[FloatParams.VehicleDisableMotorsAbove]           = 0.0f;
                    _props.ParamsFloat[FloatParams.VehicleDisableMotorsAfter]           = 0.0f;

                    _props.ParamsRot[RotationParams.VehicleReferenceFrame] = new OpenMetaverse.Quaternion(0f, 0f, 0f, 1f);

                    _props.Flags =  (VehicleFlags.ReactToWind);
                    // ~(VehicleFlags.NoDeflectionUp | VehicleFlags.HoverWaterOnly | VehicleFlags.HoverTerrainOnly | 
                    //   VehicleFlags.HoverUpOnly | VehicleFlags.HoverGlobalHeight | VehicleFlags.LimitMotorUp) |
                    //   VehicleFlags.LimitRollOnly;
                    break;
            }
        }
Exemplo n.º 3
0
        public VehicleDynamics(PhysxPrim physxPrim, VehicleProperties shadowProps, PhysX.Physics physics, PhysxScene scene)
        {
            _angularstatsX = new RunningStat();
            _angularstatsY = new RunningStat();
            _angularstatsZ = new RunningStat();
            _linearstatsX  = new RunningStat();
            _linearstatsY  = new RunningStat();
            _linearstatsZ  = new RunningStat();

            _actor = physxPrim;
            _props = new VehicleProperties();
            _physics = physics;
            _scene = scene;
            _motor = new VehicleMotor(ref _actor, ref _props, ref _physics, ref _scene);

            // Preset the defaults and new common keys. This ensures scripts with older versions of saved state
            // do not crash the simulator since the new keys do not exist in the old state.
            _props.Type = VehicleType.None;
            SetVehicleDefaults(_props);

            // Merge the new properties.
            _props.Merge(shadowProps);
            SetVehicleDefaultActions();

            if (VehicleLimits.DebugVehicleChange) m_log.InfoFormat("[VehicleDynamics] constructed type={0} name={1} at {2}", _props.Type, _actor.SOPName, _actor.Position);
            //DisplayParameters();
        }
Exemplo n.º 4
0
        internal void Merge(VehicleProperties _props)
        {
            Type = _props.Type;
            Flags = _props.Flags;

            foreach (var item in _props.ParamsFloat)
                ParamsFloat[item.Key] = item.Value;

            foreach (var item in _props.ParamsVec)
                ParamsVec[item.Key] = item.Value;

            foreach (var item in _props.ParamsRot)
                ParamsRot[item.Key] = item.Value;

            // Copy the reference to the one simulation dynamics area.
            Dynamics = _props.Dynamics;
        }