Ticket #941: FOV-controls-09042011.patch
File FOV-controls-09042011.patch, 11.6 KB (added by , 13 years ago) |
---|
-
binaries/data/config/default.cfg
85 85 view.zoom.min = 96.0 86 86 view.zoom.max = 512.0 87 87 view.zoom.default = 192.0 88 view.fov.min = 20 89 view.fov.max = 70 90 view.fov.speed = 0.5 91 view.fov.speed.wheel = 0.1 92 view.fov.default = 45 88 93 view.pos.smoothness = 0.1 89 94 view.zoom.smoothness = 0.4 90 95 view.rotate.x.smoothness = 0.5 91 96 view.rotate.y.smoothness = 0.3 97 view.fov.smoothness = 0.3 92 98 93 99 ; HOTKEY MAPPINGS: 94 100 … … 120 126 hotkey.camera.rotate.ccw = "Ctrl+RightArrow", "Ctrl+D", E ; Rotate camera anticlockwise around terrain 121 127 hotkey.camera.rotate.wheel.cw = "Shift+WheelUp", MouseX1 ; Rotate camera clockwise around terrain (stepped control) 122 128 hotkey.camera.rotate.wheel.ccw = "Shift+WheelDown", MouseX2 ; Rotate camera anticlockwise around terrain (stepped control) 129 hotkey.camera.fov.wheel.increase = "Ctrl+WheelUp" 130 hotkey.camera.fov.wheel.decrease = "Ctrl+WheelDown" 123 131 hotkey.camera.pan = MouseMiddle, ForwardSlash ; Enable scrolling by moving mouse 124 132 hotkey.camera.left = A, LeftArrow ; Scroll or rotate left 125 133 hotkey.camera.right = D, RightArrow ; Scroll or rotate right -
source/graphics/GameView.cpp
59 59 60 60 extern int g_xres, g_yres; 61 61 62 const float CGameView::defaultFOV = DEGTORAD(20.f);63 62 const float CGameView::defaultNear = 16.f; 64 63 const float CGameView::defaultFar = 4096.f; 65 const float CGameView::defaultCullFOV = CGameView::defaultFOV + DEGTORAD(6.0f); //add 6 degrees to the default FOV for use with the culling frustum66 64 67 65 // Maximum distance outside the edge of the map that the camera's 68 66 // focus point can be moved … … 184 182 ViewZoomMin(0), 185 183 ViewZoomMax(0), 186 184 ViewZoomDefault(0), 185 ViewFOVMin(0), 186 ViewFOVMax(0), 187 ViewFOVDefault(0), 188 ViewFOVSpeed(0), 189 ViewFOVSpeedWheel(0), 187 190 JoystickPanX(-1), 188 191 JoystickPanY(-1), 189 192 JoystickRotateX(-1), … … 196 199 PosZ(0, 0, 0.01f), 197 200 Zoom(0, 0, 0.1f), 198 201 RotateX(0, 0, 0.001f), 199 RotateY(0, 0, 0.001f) 202 RotateY(0, 0, 0.001f), 203 FOV(DEGTORAD(45.0f), 0, 0.1f) 200 204 { 201 205 } 202 206 … … 280 284 float ViewZoomMin; 281 285 float ViewZoomMax; 282 286 float ViewZoomDefault; 287 float ViewFOVMin; 288 float ViewFOVMax; 289 float ViewFOVDefault; 290 float ViewFOVSpeed; 291 float ViewFOVSpeedWheel; 283 292 int JoystickPanX; 284 293 int JoystickPanY; 285 294 int JoystickRotateX; … … 295 304 CSmoothedValue Zoom; 296 305 CSmoothedValue RotateX; // inclination around x axis (relative to camera) 297 306 CSmoothedValue RotateY; // rotation around y (vertical) axis 307 CSmoothedValue FOV; 298 308 299 309 static void ScriptingInit(); 300 310 }; … … 333 343 vp.m_Height=g_yres; 334 344 m->ViewCamera.SetViewPort(vp); 335 345 336 m->ViewCamera.SetProjection(defaultNear, defaultFar, defaultFOV);346 m->ViewCamera.SetProjection(defaultNear, defaultFar, m->FOV.GetValue()); 337 347 SetupCameraMatrixSmooth(m, &m->ViewCamera.m_Orientation); 338 348 m->ViewCamera.UpdateFrustum(); 339 349 … … 351 361 void CGameView::SetViewport(const SViewPort& vp) 352 362 { 353 363 m->ViewCamera.SetViewPort(vp); 354 m->ViewCamera.SetProjection(defaultNear, defaultFar, defaultFOV);364 m->ViewCamera.SetProjection(defaultNear, defaultFar, m->FOV.GetValue()); 355 365 } 356 366 357 367 CObjectManager& CGameView::GetObjectManager() const … … 415 425 CFG_GET_SYS_VAL("view.zoom.min", Float, m->ViewZoomMin); 416 426 CFG_GET_SYS_VAL("view.zoom.max", Float, m->ViewZoomMax); 417 427 CFG_GET_SYS_VAL("view.zoom.default", Float, m->ViewZoomDefault); 428 CFG_GET_SYS_VAL("view.fov.min", Float, m->ViewFOVMin); 429 CFG_GET_SYS_VAL("view.fov.max", Float, m->ViewFOVMax); 430 CFG_GET_SYS_VAL("view.fov.default", Float, m->ViewFOVDefault); 431 CFG_GET_SYS_VAL("view.fov.speed", Float, m->ViewFOVSpeed); 432 CFG_GET_SYS_VAL("view.fov.speed.wheel", Float, m->ViewFOVSpeedWheel); 418 433 419 434 CFG_GET_SYS_VAL("joystick.camera.pan.x", Int, m->JoystickPanX); 420 435 CFG_GET_SYS_VAL("joystick.camera.pan.y", Int, m->JoystickPanY); … … 429 444 CFG_GET_SYS_VAL("view.zoom.smoothness", Float, m->Zoom.m_Smoothness); 430 445 CFG_GET_SYS_VAL("view.rotate.x.smoothness", Float, m->RotateX.m_Smoothness); 431 446 CFG_GET_SYS_VAL("view.rotate.y.smoothness", Float, m->RotateY.m_Smoothness); 447 CFG_GET_SYS_VAL("view.fov.smoothness", Float, m->FOV.m_Smoothness); 432 448 433 449 m->RotateX.SetValue(DEGTORAD(m->ViewRotateXDefault)); 434 450 m->RotateY.SetValue(DEGTORAD(m->ViewRotateYDefault)); 451 m->FOV.SetValue(DEGTORAD(m->ViewFOVDefault)); 435 452 436 453 return 0; 437 454 } … … 463 480 // from model rendering; as it is now, a shadow map is only rendered if its associated model is to be 464 481 // rendered. 465 482 // (See http://trac.wildfiregames.com/ticket/504) 466 m->CullCamera.SetProjection(defaultNear, defaultFar, defaultCullFOV);483 m->CullCamera.SetProjection(defaultNear, defaultFar, GetCullFOV()); 467 484 m->CullCamera.UpdateFrustum(); 468 485 } 469 486 g_Renderer.SetSceneCamera(m->ViewCamera, m->CullCamera); … … 774 791 } 775 792 776 793 if (m->ConstrainCamera) 794 { 777 795 m->RotateX.ClampSmoothly(DEGTORAD(m->ViewRotateXMin), DEGTORAD(m->ViewRotateXMax)); 796 m->FOV.ClampSmoothly(DEGTORAD(m->ViewFOVMin), DEGTORAD(m->ViewFOVMax)); 797 } 778 798 779 799 ClampDistance(m, true); 780 800 … … 889 909 890 910 m->RotateY.Wrap(-(float)M_PI, (float)M_PI); 891 911 912 m->FOV.Update(DeltaTime); 913 892 914 // Update the camera matrix 915 m->ViewCamera.SetProjection(defaultNear, defaultFar, m->FOV.GetValue()); 893 916 SetupCameraMatrixSmooth(m, &m->ViewCamera.m_Orientation); 894 917 m->ViewCamera.UpdateFrustum(); 895 918 } … … 934 957 m->PosZ.SetValue(target.Z - delta.Z); 935 958 m->RotateX.SetValue(DEGTORAD(m->ViewRotateXDefault)); 936 959 m->RotateY.SetValue(DEGTORAD(m->ViewRotateYDefault)); 960 m->FOV.SetValue(DEGTORAD(m->ViewFOVDefault)); 937 961 938 962 ClampDistance(m, false); 939 963 … … 958 982 // Reset orientations to default 959 983 m->RotateX.SetValueSmoothly(DEGTORAD(m->ViewRotateXDefault)); 960 984 m->RotateY.SetValueSmoothly(DEGTORAD(m->ViewRotateYDefault)); 985 m->FOV.SetValue(DEGTORAD(m->ViewFOVDefault)); 961 986 } 962 987 963 988 void CGameView::CameraFollow(entity_id_t entity, bool firstPerson) … … 971 996 return m->FollowEntity; 972 997 } 973 998 999 float CGameView::GetFOV() const 1000 { 1001 return m->FOV.GetValue(); 1002 } 1003 1004 float CGameView::GetCullFOV() const 1005 { 1006 return m->FOV.GetValue() + DEGTORAD(6.0f); //add 6 degrees to the default FOV for use with the culling frustum; 1007 } 1008 974 1009 InReaction game_view_handler(const SDL_Event_* ev) 975 1010 { 976 1011 // put any events that must be processed even if inactive here … … 1032 1067 m->RotateY.AddSmoothly(-m->ViewRotateYSpeedWheel); 1033 1068 return IN_HANDLED; 1034 1069 } 1070 else if (hotkey == "camera.fov.wheel.increase") 1071 { 1072 m->FOV.AddSmoothly(m->ViewFOVSpeedWheel); 1073 return IN_HANDLED; 1074 } 1075 else if (hotkey == "camera.fov.wheel.decrease") 1076 { 1077 m->FOV.AddSmoothly(-m->ViewFOVSpeedWheel); 1078 return IN_HANDLED; 1079 } 1035 1080 else if (hotkey == "camera.reset") 1036 1081 { 1037 1082 ResetCameraAngleZoom(); -
source/graphics/GameView.h
38 38 { 39 39 NONCOPYABLE(CGameView); 40 40 public: 41 static const float default FOV, defaultCullFOV, defaultNear, defaultFar;41 static const float defaultNear, defaultFar; 42 42 43 43 private: 44 44 CGameViewImpl* m; … … 88 88 void CameraFollow(entity_id_t entity, bool firstPerson); 89 89 entity_id_t GetFollowedEntity(); 90 90 91 float GetFOV() const; 92 float GetCullFOV() const; 93 91 94 CCamera *GetCamera(); 92 95 CCinemaManager* GetCinema(); 93 96 -
source/ps/Util.cpp
296 296 g_Renderer.Resize(tile_w, tile_h); 297 297 SViewPort vp = { 0, 0, tile_w, tile_h }; 298 298 g_Game->GetView()->GetCamera()->SetViewPort(vp); 299 g_Game->GetView()->GetCamera()->SetProjection(CGameView::defaultNear, CGameView::defaultFar, CGameView::defaultFOV);299 g_Game->GetView()->GetCamera()->SetProjection(CGameView::defaultNear, CGameView::defaultFar, g_Game->GetView()->GetFOV()); 300 300 } 301 301 302 302 // Temporarily move everything onto the front buffer, so the user can … … 350 350 g_Renderer.Resize(g_xres, g_yres); 351 351 SViewPort vp = { 0, 0, g_xres, g_yres }; 352 352 g_Game->GetView()->GetCamera()->SetViewPort(vp); 353 g_Game->GetView()->GetCamera()->SetProjection(CGameView::defaultNear, CGameView::defaultFar, CGameView::defaultFOV);353 g_Game->GetView()->GetCamera()->SetProjection(CGameView::defaultNear, CGameView::defaultFar, g_Game->GetView()->GetFOV()); 354 354 355 355 g_Game->GetView()->GetCamera()->SetProjectionTile(1, 0, 0); 356 356 } -
source/renderer/Renderer.cpp
1220 1220 vp.m_X = 0; 1221 1221 vp.m_Y = 0; 1222 1222 m_ViewCamera.SetViewPort(vp); 1223 m_ViewCamera.SetProjection(CGameView::defaultNear, CGameView::defaultFar, CGameView::defaultFOV*1.05f); // Slightly higher than view FOV1223 m_ViewCamera.SetProjection(CGameView::defaultNear, CGameView::defaultFar, g_Game->GetView()->GetFOV()*1.05f); // Slightly higher than view FOV 1224 1224 CMatrix3D scaleMat; 1225 1225 scaleMat.SetScaling(m_Height/float(std::max(1, m_Width)), 1.0f, 1.0f); 1226 1226 m_ViewCamera.m_ProjMat = scaleMat * m_ViewCamera.m_ProjMat; … … 1304 1304 vp.m_X = 0; 1305 1305 vp.m_Y = 0; 1306 1306 m_ViewCamera.SetViewPort(vp); 1307 m_ViewCamera.SetProjection(CGameView::defaultNear, CGameView::defaultFar, CGameView::defaultFOV*1.05f); // Slightly higher than view FOV1307 m_ViewCamera.SetProjection(CGameView::defaultNear, CGameView::defaultFar, g_Game->GetView()->GetFOV()*1.05f); // Slightly higher than view FOV 1308 1308 CMatrix3D scaleMat; 1309 1309 scaleMat.SetScaling(m_Height/float(std::max(1, m_Width)), 1.0f, 1.0f); 1310 1310 m_ViewCamera.m_ProjMat = scaleMat * m_ViewCamera.m_ProjMat; -
source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp
60 60 g_Renderer.Resize(w, h); 61 61 SViewPort vp = { 0, 0, w, h }; 62 62 g_Game->GetView()->GetCamera()->SetViewPort(vp); 63 g_Game->GetView()->GetCamera()->SetProjection(CGameView::defaultNear, CGameView::defaultFar, CGameView::defaultFOV);63 g_Game->GetView()->GetCamera()->SetProjection(CGameView::defaultNear, CGameView::defaultFar, g_Game->GetView()->GetFOV()); 64 64 } 65 65 66 66 unsigned char* img = new unsigned char [w*h*3]; … … 113 113 g_Renderer.Resize(g_xres, g_yres); 114 114 SViewPort vp = { 0, 0, g_xres, g_yres }; 115 115 g_Game->GetView()->GetCamera()->SetViewPort(vp); 116 g_Game->GetView()->GetCamera()->SetProjection(CGameView::defaultNear, CGameView::defaultFar, CGameView::defaultFOV);116 g_Game->GetView()->GetCamera()->SetProjection(CGameView::defaultNear, CGameView::defaultFar, g_Game->GetView()->GetFOV()); 117 117 } 118 118 119 119 } -
source/tools/atlas/GameInterface/View.cpp
220 220 SViewPort vp = { 0, 0, g_xres, g_yres }; 221 221 CCamera& camera = GetCamera(); 222 222 camera.SetViewPort(vp); 223 camera.SetProjection(CGameView::defaultNear, CGameView::defaultFar, CGameView::defaultFOV);223 camera.SetProjection(CGameView::defaultNear, CGameView::defaultFar, g_Game->GetView()->GetFOV()); 224 224 camera.UpdateFrustum(); 225 225 226 226 // Update the pathfinder display if necessary