forked from 0ad/0ad
Moves camera projection settings to default.cfg.
Changes field of view (FOV) to 45 degrees per discussion. Fixes #941. Tweaks default camera zoom and rotation accordingly. This was SVN commit r10548.
This commit is contained in:
parent
432a48c849
commit
39d100c732
@ -73,22 +73,25 @@ sound.mastergain = 0.5
|
||||
; Camera control settings
|
||||
view.scroll.speed = 120.0
|
||||
view.rotate.x.speed = 1.2
|
||||
view.rotate.x.min = 20
|
||||
view.rotate.x.max = 60
|
||||
view.rotate.x.default = 30
|
||||
view.rotate.x.min = 28.0
|
||||
view.rotate.x.max = 60.0
|
||||
view.rotate.x.default = 35.0
|
||||
view.rotate.y.speed = 2.0
|
||||
view.rotate.y.speed.wheel = 0.45
|
||||
view.rotate.y.default = 0.0
|
||||
view.drag.speed = 0.5
|
||||
view.zoom.speed = 256.0
|
||||
view.zoom.speed.wheel = 32.0
|
||||
view.zoom.min = 96.0
|
||||
view.zoom.max = 512.0
|
||||
view.zoom.default = 192.0
|
||||
view.zoom.min = 64.0
|
||||
view.zoom.max = 256.0
|
||||
view.zoom.default = 112.0
|
||||
view.pos.smoothness = 0.1
|
||||
view.zoom.smoothness = 0.4
|
||||
view.rotate.x.smoothness = 0.5
|
||||
view.rotate.y.smoothness = 0.3
|
||||
view.near = 16.0 ; Near plane distance
|
||||
view.far = 4096.0 ; Far plane distance
|
||||
view.fov = 45.0 ; Field of view (degrees), lower is narrow, higher is wide
|
||||
|
||||
; HOTKEY MAPPINGS:
|
||||
|
||||
|
@ -59,11 +59,6 @@
|
||||
|
||||
extern int g_xres, g_yres;
|
||||
|
||||
const float CGameView::defaultFOV = DEGTORAD(20.f);
|
||||
const float CGameView::defaultNear = 16.f;
|
||||
const float CGameView::defaultFar = 4096.f;
|
||||
const float CGameView::defaultCullFOV = CGameView::defaultFOV + DEGTORAD(6.0f); //add 6 degrees to the default FOV for use with the culling frustum
|
||||
|
||||
// Maximum distance outside the edge of the map that the camera's
|
||||
// focus point can be moved
|
||||
static const float CAMERA_EDGE_MARGIN = 2.0f*CELL_SIZE;
|
||||
@ -280,6 +275,9 @@ public:
|
||||
float ViewZoomMin;
|
||||
float ViewZoomMax;
|
||||
float ViewZoomDefault;
|
||||
float ViewFOV;
|
||||
float ViewNear;
|
||||
float ViewFar;
|
||||
int JoystickPanX;
|
||||
int JoystickPanY;
|
||||
int JoystickRotateX;
|
||||
@ -333,7 +331,7 @@ CGameView::CGameView(CGame *pGame):
|
||||
vp.m_Height=g_yres;
|
||||
m->ViewCamera.SetViewPort(vp);
|
||||
|
||||
m->ViewCamera.SetProjection(defaultNear, defaultFar, defaultFOV);
|
||||
m->ViewCamera.SetProjection(m->ViewNear, m->ViewFar, m->ViewFOV);
|
||||
SetupCameraMatrixSmooth(m, &m->ViewCamera.m_Orientation);
|
||||
m->ViewCamera.UpdateFrustum();
|
||||
|
||||
@ -351,7 +349,7 @@ CGameView::~CGameView()
|
||||
void CGameView::SetViewport(const SViewPort& vp)
|
||||
{
|
||||
m->ViewCamera.SetViewPort(vp);
|
||||
m->ViewCamera.SetProjection(defaultNear, defaultFar, defaultFOV);
|
||||
m->ViewCamera.SetProjection(m->ViewNear, m->ViewFar, m->ViewFOV);
|
||||
}
|
||||
|
||||
CObjectManager& CGameView::GetObjectManager() const
|
||||
@ -430,8 +428,14 @@ int CGameView::Initialize()
|
||||
CFG_GET_SYS_VAL("view.rotate.x.smoothness", Float, m->RotateX.m_Smoothness);
|
||||
CFG_GET_SYS_VAL("view.rotate.y.smoothness", Float, m->RotateY.m_Smoothness);
|
||||
|
||||
CFG_GET_SYS_VAL("view.near", Float, m->ViewNear);
|
||||
CFG_GET_SYS_VAL("view.far", Float, m->ViewFar);
|
||||
CFG_GET_SYS_VAL("view.fov", Float, m->ViewFOV);
|
||||
|
||||
// Convert to radians
|
||||
m->RotateX.SetValue(DEGTORAD(m->ViewRotateXDefault));
|
||||
m->RotateY.SetValue(DEGTORAD(m->ViewRotateYDefault));
|
||||
m->ViewFOV = DEGTORAD(m->ViewFOV);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -463,7 +467,7 @@ void CGameView::BeginFrame()
|
||||
// from model rendering; as it is now, a shadow map is only rendered if its associated model is to be
|
||||
// rendered.
|
||||
// (See http://trac.wildfiregames.com/ticket/504)
|
||||
m->CullCamera.SetProjection(defaultNear, defaultFar, defaultCullFOV);
|
||||
m->CullCamera.SetProjection(m->ViewNear, m->ViewFar, GetCullFOV());
|
||||
m->CullCamera.UpdateFrustum();
|
||||
}
|
||||
g_Renderer.SetSceneCamera(m->ViewCamera, m->CullCamera);
|
||||
@ -890,6 +894,7 @@ void CGameView::Update(float DeltaTime)
|
||||
m->RotateY.Wrap(-(float)M_PI, (float)M_PI);
|
||||
|
||||
// Update the camera matrix
|
||||
m->ViewCamera.SetProjection(m->ViewNear, m->ViewFar, m->ViewFOV);
|
||||
SetupCameraMatrixSmooth(m, &m->ViewCamera.m_Orientation);
|
||||
m->ViewCamera.UpdateFrustum();
|
||||
}
|
||||
@ -971,6 +976,31 @@ entity_id_t CGameView::GetFollowedEntity()
|
||||
return m->FollowEntity;
|
||||
}
|
||||
|
||||
float CGameView::GetNear() const
|
||||
{
|
||||
return m->ViewNear;
|
||||
}
|
||||
|
||||
float CGameView::GetFar() const
|
||||
{
|
||||
return m->ViewFar;
|
||||
}
|
||||
|
||||
float CGameView::GetFOV() const
|
||||
{
|
||||
return m->ViewFOV;
|
||||
}
|
||||
|
||||
float CGameView::GetCullFOV() const
|
||||
{
|
||||
return m->ViewFOV + DEGTORAD(6.0f); //add 6 degrees to the default FOV for use with the culling frustum;
|
||||
}
|
||||
|
||||
void CGameView::SetCameraProjection()
|
||||
{
|
||||
m->ViewCamera.SetProjection(m->ViewNear, m->ViewFar, m->ViewFOV);
|
||||
}
|
||||
|
||||
InReaction game_view_handler(const SDL_Event_* ev)
|
||||
{
|
||||
// put any events that must be processed even if inactive here
|
||||
|
@ -37,9 +37,6 @@ class CGameViewImpl;
|
||||
class CGameView : private Scene
|
||||
{
|
||||
NONCOPYABLE(CGameView);
|
||||
public:
|
||||
static const float defaultFOV, defaultCullFOV, defaultNear, defaultFar;
|
||||
|
||||
private:
|
||||
CGameViewImpl* m;
|
||||
|
||||
@ -88,6 +85,14 @@ public:
|
||||
void CameraFollow(entity_id_t entity, bool firstPerson);
|
||||
entity_id_t GetFollowedEntity();
|
||||
|
||||
float GetNear() const;
|
||||
float GetFar() const;
|
||||
float GetFOV() const;
|
||||
float GetCullFOV() const;
|
||||
|
||||
// Set projection of current camera using near, far, and FOV values
|
||||
void SetCameraProjection();
|
||||
|
||||
CCamera *GetCamera();
|
||||
CCinemaManager* GetCinema();
|
||||
|
||||
|
@ -296,7 +296,7 @@ void WriteBigScreenshot(const VfsPath& extension, int tiles)
|
||||
g_Renderer.Resize(tile_w, tile_h);
|
||||
SViewPort vp = { 0, 0, tile_w, tile_h };
|
||||
g_Game->GetView()->GetCamera()->SetViewPort(vp);
|
||||
g_Game->GetView()->GetCamera()->SetProjection(CGameView::defaultNear, CGameView::defaultFar, CGameView::defaultFOV);
|
||||
g_Game->GetView()->SetCameraProjection();
|
||||
}
|
||||
|
||||
// Temporarily move everything onto the front buffer, so the user can
|
||||
@ -350,8 +350,7 @@ void WriteBigScreenshot(const VfsPath& extension, int tiles)
|
||||
g_Renderer.Resize(g_xres, g_yres);
|
||||
SViewPort vp = { 0, 0, g_xres, g_yres };
|
||||
g_Game->GetView()->GetCamera()->SetViewPort(vp);
|
||||
g_Game->GetView()->GetCamera()->SetProjection(CGameView::defaultNear, CGameView::defaultFar, CGameView::defaultFOV);
|
||||
|
||||
g_Game->GetView()->SetCameraProjection();
|
||||
g_Game->GetView()->GetCamera()->SetProjectionTile(1, 0, 0);
|
||||
}
|
||||
|
||||
|
@ -1223,7 +1223,7 @@ SScreenRect CRenderer::RenderReflections(const CBound& scissor)
|
||||
vp.m_X = 0;
|
||||
vp.m_Y = 0;
|
||||
m_ViewCamera.SetViewPort(vp);
|
||||
m_ViewCamera.SetProjection(CGameView::defaultNear, CGameView::defaultFar, CGameView::defaultFOV*1.05f); // Slightly higher than view FOV
|
||||
m_ViewCamera.SetProjection(normalCamera.GetNearPlane(), normalCamera.GetFarPlane(), normalCamera.GetFOV()*1.05f); // Slightly higher than view FOV
|
||||
CMatrix3D scaleMat;
|
||||
scaleMat.SetScaling(m_Height/float(std::max(1, m_Width)), 1.0f, 1.0f);
|
||||
m_ViewCamera.m_ProjMat = scaleMat * m_ViewCamera.m_ProjMat;
|
||||
@ -1307,7 +1307,7 @@ SScreenRect CRenderer::RenderRefractions(const CBound &scissor)
|
||||
vp.m_X = 0;
|
||||
vp.m_Y = 0;
|
||||
m_ViewCamera.SetViewPort(vp);
|
||||
m_ViewCamera.SetProjection(CGameView::defaultNear, CGameView::defaultFar, CGameView::defaultFOV*1.05f); // Slightly higher than view FOV
|
||||
m_ViewCamera.SetProjection(normalCamera.GetNearPlane(), normalCamera.GetFarPlane(), normalCamera.GetFOV()*1.05f); // Slightly higher than view FOV
|
||||
CMatrix3D scaleMat;
|
||||
scaleMat.SetScaling(m_Height/float(std::max(1, m_Width)), 1.0f, 1.0f);
|
||||
m_ViewCamera.m_ProjMat = scaleMat * m_ViewCamera.m_ProjMat;
|
||||
|
@ -60,7 +60,7 @@ QUERYHANDLER(CinemaRecord)
|
||||
g_Renderer.Resize(w, h);
|
||||
SViewPort vp = { 0, 0, w, h };
|
||||
g_Game->GetView()->GetCamera()->SetViewPort(vp);
|
||||
g_Game->GetView()->GetCamera()->SetProjection(CGameView::defaultNear, CGameView::defaultFar, CGameView::defaultFOV);
|
||||
g_Game->GetView()->SetCameraProjection();
|
||||
}
|
||||
|
||||
unsigned char* img = new unsigned char [w*h*3];
|
||||
@ -113,7 +113,7 @@ QUERYHANDLER(CinemaRecord)
|
||||
g_Renderer.Resize(g_xres, g_yres);
|
||||
SViewPort vp = { 0, 0, g_xres, g_yres };
|
||||
g_Game->GetView()->GetCamera()->SetViewPort(vp);
|
||||
g_Game->GetView()->GetCamera()->SetProjection(CGameView::defaultNear, CGameView::defaultFar, CGameView::defaultFOV);
|
||||
g_Game->GetView()->SetCameraProjection();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ void ViewGame::Render()
|
||||
SViewPort vp = { 0, 0, g_xres, g_yres };
|
||||
CCamera& camera = GetCamera();
|
||||
camera.SetViewPort(vp);
|
||||
camera.SetProjection(CGameView::defaultNear, CGameView::defaultFar, CGameView::defaultFOV);
|
||||
camera.SetProjection(g_Game->GetView()->GetNear(), g_Game->GetView()->GetFar(), g_Game->GetView()->GetFOV());
|
||||
camera.UpdateFrustum();
|
||||
|
||||
// Update the pathfinder display if necessary
|
||||
|
Loading…
Reference in New Issue
Block a user