//------------------------------------------------------------------------ bool CVehicleMovementTank::Init(IVehicle* pVehicle, const CVehicleParams& table) { if (!CVehicleMovementStdWheeled::Init(pVehicle, table)) return false; MOVEMENT_VALUE("pedalSpeed", m_pedalSpeed); MOVEMENT_VALUE_OPT("pedalThreshold", m_pedalThreshold, table); MOVEMENT_VALUE("steerSpeed", m_steerSpeed); MOVEMENT_VALUE_OPT("steerSpeedRelax", m_steerSpeedRelax, table); MOVEMENT_VALUE_OPT("steerLimit", m_steerLimit, table); MOVEMENT_VALUE("latFricMin", m_latFricMin); MOVEMENT_VALUE("latFricMinSteer", m_latFricMinSteer); MOVEMENT_VALUE("latFricMax", m_latFricMax); MOVEMENT_VALUE("latSlipMin", m_latSlipMin); MOVEMENT_VALUE("latSlipMax", m_latSlipMax); MOVEMENT_VALUE_OPT("steeringImpulseMin", m_steeringImpulseMin, table); MOVEMENT_VALUE_OPT("steeringImpulseMax", m_steeringImpulseMax, table); MOVEMENT_VALUE_OPT("steeringImpulseRelaxMin", m_steeringImpulseRelaxMin, table); MOVEMENT_VALUE_OPT("steeringImpulseRelaxMax", m_steeringImpulseRelaxMax, table); m_maxSoundSlipSpeed = 10.f; return true; }
//------------------------------------------------------------------------ bool CVehicleMovementStdBoat::Init(IVehicle* pVehicle, const CVehicleParams& table) { if (!CVehicleMovementBase::Init(pVehicle, table)) return false; MOVEMENT_VALUE("velMax", m_velMax); MOVEMENT_VALUE("velMaxReverse", m_velMaxReverse); MOVEMENT_VALUE("acceleration", m_accel); MOVEMENT_VALUE("accelerationVelMax", m_accelVelMax); MOVEMENT_VALUE("accelerationMultiplier", m_accelCoeff); MOVEMENT_VALUE("pushTilt", m_pushTilt); MOVEMENT_VALUE("turnRateMax", m_turnRateMax); MOVEMENT_VALUE("turnAccel", m_turnAccel); MOVEMENT_VALUE("cornerForce", m_cornerForceCoeff); MOVEMENT_VALUE("cornerTilt", m_cornerTilt); MOVEMENT_VALUE("turnDamping", m_turnDamping); MOVEMENT_VALUE("turnAccelMultiplier", m_turnAccelCoeff); MOVEMENT_VALUE_OPT("rollAccel", m_rollAccel, table); MOVEMENT_VALUE_OPT("pedalLimitReverse", m_pedalLimitReverse, table); MOVEMENT_VALUE_OPT("turnVelocityMult", m_turnVelocityMult, table); MOVEMENT_VALUE_OPT("velLift", m_velLift, table); MOVEMENT_VALUE_OPT("lateralDamping", m_lateralDamping, table); table.getAttr("waveIdleStrength", m_waveIdleStrength); table.getAttr("waveSpeedMult", m_waveSpeedMult); if (table.haveAttr("cornerHelper")) { if (IVehicleHelper* pHelper = m_pVehicle->GetHelper(table.getAttr("cornerHelper"))) m_cornerOffset = pHelper->GetVehicleSpaceTranslation(); } if (table.haveAttr("pushHelper")) { if (IVehicleHelper* pHelper = m_pVehicle->GetHelper(table.getAttr("pushHelper"))) m_pushOffset = pHelper->GetVehicleSpaceTranslation(); } // compute inertia [assumes box] AABB bbox; IVehiclePart* pMassPart = pVehicle->GetPart("mass"); if (!pMassPart) pMassPart = pVehicle->GetPart("massBox"); if (pMassPart) { bbox = pMassPart->GetLocalBounds(); } else { GameWarning("[CVehicleMovementStdBoat]: initialization: No \"mass\" geometry found!"); m_pEntity->GetLocalBounds(bbox); } m_maxSpeed = m_velMax; float mass = pVehicle->GetMass(); float width = bbox.max.x - bbox.min.x; float length = bbox.max.y - bbox.min.y; float height = bbox.max.z - bbox.min.z; m_Inertia.x = mass * (sqr(length)+ sqr(height)) / 12; m_Inertia.y = mass * (sqr(width) + sqr(height)) / 12; m_Inertia.z = mass * (sqr(width) + sqr(length)) / 12; m_massOffset = bbox.GetCenter(); //CryLog("[StdBoat movement]: got mass offset (%f, %f, %f)", m_massOffset.x, m_massOffset.y, m_massOffset.z); m_pSplashPos = m_pVehicle->GetHelper("splashPos"); if (m_pSplashPos) m_lastWakePos = m_pSplashPos->GetWorldSpaceTranslation(); else m_lastWakePos = m_pVehicle->GetEntity()->GetWorldTM().GetTranslation(); const char* waveEffect = ""; MOVEMENT_VALUE_OPT("waveEffect", &waveEffect, table); m_pWaveEffect = gEnv->pParticleManager->FindEffect(waveEffect, "MovementStdBoat"); m_waveTimer = cry_random(0.0f, gf_PI); m_diving = false; m_wakeSlot = -1; m_waveSoundPitch = 0.f; m_rpmPitchDir = 0; m_waveSoundAmount = 0.1f; // AI related m_prevAngle = 0.0f; m_factorMaxSpeed = 1.f; m_factorAccel = 1.f; return true; }