16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-20 02:09:19 +02:00

build 180527. smoother camera rotation, semi-persistent cab camera angle between view swaps, configurable default cab camera view angle, diesel engine power calculation fix, minor refactoring and fixes for content files lookups and loading

This commit is contained in:
tmj-fstate
2018-05-27 02:31:40 +02:00
parent aa520aa3e7
commit 2c1c29600e
17 changed files with 272 additions and 169 deletions

View File

@@ -607,6 +607,7 @@ void TWorld::InOutKey( bool const Near )
if (Train) {
// cache current cab position so there's no need to set it all over again after each out-in switch
Train->pMechSittingPosition = Train->pMechOffset;
Train->Dynamic()->bDisplayCab = false;
DistantView( Near );
}
@@ -618,9 +619,8 @@ void TWorld::InOutKey( bool const Near )
if (Train)
{
Train->Dynamic()->bDisplayCab = true;
Train->Dynamic()->ABuSetModelShake(
Math3D::vector3(0, 0, 0)); // zerowanie przesunięcia przed powrotem?
// Camera.Stop(); //zatrzymanie ruchu
// zerowanie przesunięcia przed powrotem?
Train->Dynamic()->ABuSetModelShake( { 0, 0, 0 } );
Train->MechStop();
FollowView(); // na pozycję mecha
}
@@ -694,14 +694,12 @@ void TWorld::FollowView(bool wycisz) {
// tu ustawić nową, bo od niej liczą się odległości
Global.pCameraPosition = Camera.Pos;
}
else if (Train)
{ // korekcja ustawienia w kabinie - OK
if( wycisz ) {
// wyciszenie dźwięków z poprzedniej pozycji
// trzymanie prawego w kabinie daje marny efekt
// TODO: re-implement, old one kinda didn't really work
}
else if (Train) {
Camera.Pos = Train->pMechPosition;
// potentially restore cached camera angles
Camera.Pitch = Train->pMechViewAngle.x;
Camera.Yaw = Train->pMechViewAngle.y;
Camera.Roll = std::atan(Train->pMechShake.x * Train->fMechRoll); // hustanie kamery na boki
Camera.Pitch -= 0.5 * std::atan(Train->vMechVelocity.z * Train->fMechPitch); // hustanie kamery przod tyl
@@ -946,6 +944,14 @@ TWorld::Update_Camera( double const Deltatime ) {
if( DebugCameraFlag ) { DebugCamera.Update(); }
else { Camera.Update(); } // uwzględnienie ruchu wywołanego klawiszami
if( ( false == FreeFlyModeFlag )
&& ( false == Global.CabWindowOpen )
&& ( Train != nullptr ) ) {
// cache cab camera view angles in case of view type switch
Train->pMechViewAngle = { Camera.Pitch, Camera.Yaw };
}
// reset window state, it'll be set again if applicable in a check below
Global.CabWindowOpen = false;
@@ -954,7 +960,7 @@ TWorld::Update_Camera( double const Deltatime ) {
&& ( false == DebugCameraFlag ) ) {
// jeśli jazda w kabinie, przeliczyć trzeba parametry kamery
auto tempangle = Controlled->VectorFront() * ( Controlled->MoverParameters->ActiveCab == -1 ? -1 : 1 );
double modelrotate = atan2( -tempangle.x, tempangle.z );
// double modelrotate = atan2( -tempangle.x, tempangle.z );
if( ( true == Global.ctrlState )
&& ( ( glfwGetKey( Global.window, GLFW_KEY_LEFT ) == GLFW_TRUE )
@@ -982,6 +988,11 @@ TWorld::Update_Camera( double const Deltatime ) {
}
else {
// patrzenie standardowe
// potentially restore view angle after returning from external view
// TODO: mirror view toggle as separate method
Camera.Pitch = Train->pMechViewAngle.x;
Camera.Yaw = Train->pMechViewAngle.y;
Camera.Pos = Train->GetWorldMechPosition(); // Train.GetPosition1();
if( !Global.iPause ) {
// podczas pauzy nie przeliczać kątów przypadkowymi wartościami
@@ -991,8 +1002,8 @@ TWorld::Update_Camera( double const Deltatime ) {
// Ra: tu jest uciekanie kamery w górę!!!
Camera.Pitch -= 0.5 * atan( Train->vMechVelocity.z * Train->fMechPitch );
}
// ABu011104: rzucanie pudlem
/*
// ABu011104: rzucanie pudlem
vector3 temp;
if( abs( Train->pMechShake.y ) < 0.25 )
temp = vector3( 0, 0, 6 * Train->pMechShake.y );
@@ -1004,7 +1015,6 @@ TWorld::Update_Camera( double const Deltatime ) {
Controlled->ABuSetModelShake( temp );
// ABu: koniec rzucania
*/
if( Train->Dynamic()->MoverParameters->ActiveCab == 0 )
Camera.LookAt = Train->GetWorldMechPosition() + Train->GetDirection() * 5.0; // gdy w korytarzu
else // patrzenie w kierunku osi pojazdu, z uwzględnieniem kabiny