From 1ea207b60fabc14959a03c3531dad6eaa53dfe16 Mon Sep 17 00:00:00 2001 From: tmj-fstate Date: Mon, 20 Feb 2017 16:17:04 +0100 Subject: [PATCH] field of view setting, t3d loader fix --- Globals.cpp | 9 +++++++++ Globals.h | 1 + Model3d.cpp | 3 +++ World.cpp | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Globals.cpp b/Globals.cpp index 3e0c0f9b..e841346a 100644 --- a/Globals.cpp +++ b/Globals.cpp @@ -52,6 +52,7 @@ HWND Global::hWnd = NULL; // uchwyt okna int Global::ScreenWidth = 1; int Global::ScreenHeight = 1; float Global::ZoomFactor = 1.0f; +float Global::FieldOfView = 45.0f; int Global::iCameraLast = -1; std::string Global::asRelease = "16.0.1172.482"; std::string Global::asVersion = @@ -261,6 +262,14 @@ void Global::ConfigParse(cParser &Parser) Parser.getTokens(); Parser >> Global::asHumanCtrlVehicle; } + else if( token == "fieldofview" ) { + + Parser.getTokens( 1, false ); + Parser >> Global::FieldOfView; + // guard against incorrect values + Global::FieldOfView = std::min( 75.0f, Global::FieldOfView ); + Global::FieldOfView = std::max( 15.0f, Global::FieldOfView ); + } else if (token == "width") { diff --git a/Globals.h b/Globals.h index c4970efe..ff7fef81 100644 --- a/Globals.h +++ b/Globals.h @@ -256,6 +256,7 @@ class Global static int ScreenWidth; // current window dimensions. TODO: move it to renderer static int ScreenHeight; static float ZoomFactor; // determines current camera zoom level. TODO: move it to the renderer + static float FieldOfView; // vertical field of view for the camera. TODO: move it to the renderer static int iCameraLast; static std::string asRelease; // numer static std::string asVersion; // z opisem diff --git a/Model3d.cpp b/Model3d.cpp index fec5b563..22b956b5 100644 --- a/Model3d.cpp +++ b/Model3d.cpp @@ -219,6 +219,9 @@ template inline void readColor(cParser &parser, ColorT *color) double discard; parser.getTokens(4, false); parser >> discard >> color[0] >> color[1] >> color[2]; + color[ 0 ] /= 255.0; + color[ 1 ] /= 255.0; + color[ 2 ] /= 255.0; }; inline void readColor(cParser &parser, int &color) diff --git a/World.cpp b/World.cpp index 5e47971c..ee9eb1bd 100644 --- a/World.cpp +++ b/World.cpp @@ -1517,7 +1517,7 @@ bool TWorld::Render() glMatrixMode( GL_PROJECTION ); // select the Projection Matrix glLoadIdentity(); // reset the Projection Matrix // calculate the aspect ratio of the window - gluPerspective( 45.0f / Global::ZoomFactor, (GLdouble)Global::ScreenWidth / (GLdouble)Global::ScreenHeight, 0.1f * Global::ZoomFactor, 2500.0f * Global::ZoomFactor ); + gluPerspective( Global::FieldOfView / Global::ZoomFactor, (GLdouble)Global::ScreenWidth / (GLdouble)Global::ScreenHeight, 0.1f * Global::ZoomFactor, 2500.0f * Global::ZoomFactor ); glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glLoadIdentity();