Ticket #941: FOV-improved-11162011.patch
File FOV-improved-11162011.patch, 9.0 KB (added by , 12 years ago) |
---|
-
binaries/data/config/default.cfg
75 75 view.rotate.x.speed = 1.2 76 76 view.rotate.x.min = 20 77 77 view.rotate.x.max = 60 78 view.rotate.x.default = 3078 view.rotate.x.default = 40 79 79 view.rotate.y.speed = 2.0 80 80 view.rotate.y.speed.wheel = 0.45 81 81 view.rotate.y.default = 0.0 82 82 view.drag.speed = 0.5 83 83 view.zoom.speed = 256.0 84 84 view.zoom.speed.wheel = 32.0 85 view.zoom.min = 96.086 view.zoom.max = 512.087 view.zoom.default = 1 92.085 view.zoom.min = 64.0 86 view.zoom.max = 256.0 87 view.zoom.default = 128.0 88 88 view.pos.smoothness = 0.1 89 89 view.zoom.smoothness = 0.4 90 90 view.rotate.x.smoothness = 0.5 91 91 view.rotate.y.smoothness = 0.3 92 view.near = 16.0 ; Near plane distance 93 view.far = 4096.0 ; Far plane distance 94 view.fov = 45.0 ; Field of view (degrees), lower is narrow, higher is wide 92 95 93 96 ; HOTKEY MAPPINGS: 94 97 -
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 const float CGameView::defaultNear = 16.f;64 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 67 62 // Maximum distance outside the edge of the map that the camera's 68 63 // focus point can be moved 69 64 static const float CAMERA_EDGE_MARGIN = 2.0f*CELL_SIZE; … … 280 275 float ViewZoomMin; 281 276 float ViewZoomMax; 282 277 float ViewZoomDefault; 278 float ViewFOV; 279 float ViewNear; 280 float ViewFar; 283 281 int JoystickPanX; 284 282 int JoystickPanY; 285 283 int JoystickRotateX; … … 333 331 vp.m_Height=g_yres; 334 332 m->ViewCamera.SetViewPort(vp); 335 333 336 m->ViewCamera.SetProjection( defaultNear, defaultFar, defaultFOV);334 m->ViewCamera.SetProjection(m->ViewNear, m->ViewFar, m->ViewFOV); 337 335 SetupCameraMatrixSmooth(m, &m->ViewCamera.m_Orientation); 338 336 m->ViewCamera.UpdateFrustum(); 339 337 … … 351 349 void CGameView::SetViewport(const SViewPort& vp) 352 350 { 353 351 m->ViewCamera.SetViewPort(vp); 354 m->ViewCamera.SetProjection( defaultNear, defaultFar, defaultFOV);352 m->ViewCamera.SetProjection(m->ViewNear, m->ViewFar, m->ViewFOV); 355 353 } 356 354 357 355 CObjectManager& CGameView::GetObjectManager() const … … 430 428 CFG_GET_SYS_VAL("view.rotate.x.smoothness", Float, m->RotateX.m_Smoothness); 431 429 CFG_GET_SYS_VAL("view.rotate.y.smoothness", Float, m->RotateY.m_Smoothness); 432 430 431 CFG_GET_SYS_VAL("view.near", Float, m->ViewNear); 432 CFG_GET_SYS_VAL("view.far", Float, m->ViewFar); 433 CFG_GET_SYS_VAL("view.fov", Float, m->ViewFOV); 434 435 // Convert to radians 433 436 m->RotateX.SetValue(DEGTORAD(m->ViewRotateXDefault)); 434 437 m->RotateY.SetValue(DEGTORAD(m->ViewRotateYDefault)); 438 m->ViewFOV = DEGTORAD(m->ViewFOV); 435 439 436 440 return 0; 437 441 } … … 463 467 // from model rendering; as it is now, a shadow map is only rendered if its associated model is to be 464 468 // rendered. 465 469 // (See http://trac.wildfiregames.com/ticket/504) 466 m->CullCamera.SetProjection( defaultNear, defaultFar, defaultCullFOV);470 m->CullCamera.SetProjection(m->ViewNear, m->ViewFar, GetCullFOV()); 467 471 m->CullCamera.UpdateFrustum(); 468 472 } 469 473 g_Renderer.SetSceneCamera(m->ViewCamera, m->CullCamera); … … 774 778 } 775 779 776 780 if (m->ConstrainCamera) 781 { 777 782 m->RotateX.ClampSmoothly(DEGTORAD(m->ViewRotateXMin), DEGTORAD(m->ViewRotateXMax)); 783 } 778 784 779 785 ClampDistance(m, true); 780 786 … … 890 896 m->RotateY.Wrap(-(float)M_PI, (float)M_PI); 891 897 892 898 // Update the camera matrix 899 m->ViewCamera.SetProjection(m->ViewNear, m->ViewFar, m->ViewFOV); 893 900 SetupCameraMatrixSmooth(m, &m->ViewCamera.m_Orientation); 894 901 m->ViewCamera.UpdateFrustum(); 895 902 } … … 971 978 return m->FollowEntity; 972 979 } 973 980 981 float CGameView::GetNear() const 982 { 983 return m->ViewNear; 984 } 985 986 float CGameView::GetFar() const 987 { 988 return m->ViewFar; 989 } 990 991 float CGameView::GetFOV() const 992 { 993 return m->ViewFOV; 994 } 995 996 float CGameView::GetCullFOV() const 997 { 998 return m->ViewFOV + DEGTORAD(6.0f); //add 6 degrees to the default FOV for use with the culling frustum; 999 } 1000 1001 void CGameView::SetCameraProjection() 1002 { 1003 m->ViewCamera.SetProjection(m->ViewNear, m->ViewFar, m->ViewFOV); 1004 } 1005 974 1006 InReaction game_view_handler(const SDL_Event_* ev) 975 1007 { 976 1008 // put any events that must be processed even if inactive here -
source/graphics/GameView.h
37 37 class CGameView : private Scene 38 38 { 39 39 NONCOPYABLE(CGameView); 40 public:41 static const float defaultFOV, defaultCullFOV, defaultNear, defaultFar;42 43 40 private: 44 41 CGameViewImpl* m; 45 42 … … 88 85 void CameraFollow(entity_id_t entity, bool firstPerson); 89 86 entity_id_t GetFollowedEntity(); 90 87 88 float GetNear() const; 89 float GetFar() const; 90 float GetFOV() const; 91 float GetCullFOV() const; 92 93 // Set projection of current camera using near, far, and FOV values 94 void SetCameraProjection(); 95 91 96 CCamera *GetCamera(); 92 97 CCinemaManager* GetCinema(); 93 98 -
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()->SetCameraProjection(); 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); 354 353 g_Game->GetView()->SetCameraProjection(); 355 354 g_Game->GetView()->GetCamera()->SetProjectionTile(1, 0, 0); 356 355 } 357 356 -
source/renderer/Renderer.cpp
1223 1223 vp.m_X = 0; 1224 1224 vp.m_Y = 0; 1225 1225 m_ViewCamera.SetViewPort(vp); 1226 m_ViewCamera.SetProjection( CGameView::defaultNear, CGameView::defaultFar, CGameView::defaultFOV*1.05f); // Slightly higher than view FOV1226 m_ViewCamera.SetProjection(g_Game->GetView()->GetNear(), g_Game->GetView()->GetFar(), g_Game->GetView()->GetFOV()*1.05f); // Slightly higher than view FOV 1227 1227 CMatrix3D scaleMat; 1228 1228 scaleMat.SetScaling(m_Height/float(std::max(1, m_Width)), 1.0f, 1.0f); 1229 1229 m_ViewCamera.m_ProjMat = scaleMat * m_ViewCamera.m_ProjMat; … … 1307 1307 vp.m_X = 0; 1308 1308 vp.m_Y = 0; 1309 1309 m_ViewCamera.SetViewPort(vp); 1310 m_ViewCamera.SetProjection( CGameView::defaultNear, CGameView::defaultFar, CGameView::defaultFOV*1.05f); // Slightly higher than view FOV1310 m_ViewCamera.SetProjection(g_Game->GetView()->GetNear(), g_Game->GetView()->GetFar(), g_Game->GetView()->GetFOV()*1.05f); // Slightly higher than view FOV 1311 1311 CMatrix3D scaleMat; 1312 1312 scaleMat.SetScaling(m_Height/float(std::max(1, m_Width)), 1.0f, 1.0f); 1313 1313 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()->SetCameraProjection(); 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()->SetCameraProjection(); 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(g_Game->GetView()->GetNear(), g_Game->GetView()->GetFar(), g_Game->GetView()->GetFOV()); 224 224 camera.UpdateFrustum(); 225 225 226 226 // Update the pathfinder display if necessary