//------------------------------------------------------------------------ void TApplySetup_CameraUp::WorkFromThread_Ogre() { Ogre::Camera* pCamera = TModuleLogic::Get()->GetC()->pGraphicEngine->GetGE()->GetCamera(); nsMathTools::TVector3 point(0,0,0); pCamera->setPosition(point.x, point.y, point.z); pCamera->lookAt(mVCameraUp.x, mVCameraUp.y, mVCameraUp.z); Ogre::Degree degree; degree = 90; Ogre::Radian rad; rad = degree.valueRadians(); pCamera->pitch(rad); }
void LandVehicleSimulation::UpdateVehicle(Actor* vehicle, float seconds_since_last_frame) { if (vehicle->isBeingReset() || vehicle->ar_physics_paused || vehicle->ar_replay_mode) return; #ifdef USE_ANGELSCRIPT if (vehicle->ar_vehicle_ai && vehicle->ar_vehicle_ai->IsActive()) return; #endif // USE_ANGELSCRIPT EngineSim* engine = vehicle->ar_engine; if (engine && engine->HasStarterContact() && engine->GetAutoShiftMode() == SimGearboxMode::AUTO && engine->getAutoShift() != EngineSim::NEUTRAL) { Ogre::Vector3 dirDiff = vehicle->getDirection(); Ogre::Degree pitchAngle = Ogre::Radian(asin(dirDiff.dotProduct(Ogre::Vector3::UNIT_Y))); if (std::abs(pitchAngle.valueDegrees()) > 2.0f) { if (engine->getAutoShift() > EngineSim::NEUTRAL && vehicle->ar_avg_wheel_speed < +0.02f && pitchAngle.valueDegrees() > 0.0f || engine->getAutoShift() < EngineSim::NEUTRAL && vehicle->ar_avg_wheel_speed > -0.02f && pitchAngle.valueDegrees() < 0.0f) { // anti roll back in SimGearboxMode::AUTO (DRIVE, TWO, ONE) mode // anti roll forth in SimGearboxMode::AUTO (REAR) mode float g = std::abs(App::GetSimTerrain()->getGravity()); float downhill_force = std::abs(sin(pitchAngle.valueRadians()) * vehicle->getTotalMass()) * g; float engine_force = std::abs(engine->GetTorque()) / vehicle->getAvgPropedWheelRadius(); float ratio = std::max(0.0f, 1.0f - (engine_force / downhill_force)); if (vehicle->ar_avg_wheel_speed * pitchAngle.valueDegrees() > 0.0f) { ratio *= sqrt((0.02f - vehicle->ar_avg_wheel_speed) / 0.02f); } vehicle->ar_brake = sqrt(ratio); } } else if (vehicle->ar_brake == 0.0f && !vehicle->ar_parking_brake && engine->GetTorque() == 0.0f) { float ratio = std::max(0.0f, 0.2f - std::abs(vehicle->ar_avg_wheel_speed)) / 0.2f; vehicle->ar_brake = ratio; } } if (vehicle->cc_mode) { LandVehicleSimulation::UpdateCruiseControl(vehicle, seconds_since_last_frame); } if (vehicle->sl_enabled) { LandVehicleSimulation::CheckSpeedLimit(vehicle, seconds_since_last_frame); } }