forked from mirror/openmw-tes3mp
CS: Add ortho camera setting
This commit is contained in:
parent
bfad5ebde4
commit
1b77e3ed62
3 changed files with 30 additions and 7 deletions
|
@ -194,6 +194,8 @@ void CSMPrefs::State::declare()
|
||||||
|
|
||||||
declareCategory ("Rendering");
|
declareCategory ("Rendering");
|
||||||
declareDouble ("camera-fov", "Camera FOV", 90.).setPrecision(5).setRange(10.0, 160.0);
|
declareDouble ("camera-fov", "Camera FOV", 90.).setPrecision(5).setRange(10.0, 160.0);
|
||||||
|
declareBool ("camera-ortho", "Orthographic projection for camera", false);
|
||||||
|
declareDouble ("camera-ortho-size", "Orthographic projection size parameter", 100.0).setPrecision(5).setRange(0.0, 1000.0);
|
||||||
|
|
||||||
declareCategory ("Tooltips");
|
declareCategory ("Tooltips");
|
||||||
declareBool ("scene", "Show Tooltips in 3D scenes", true);
|
declareBool ("scene", "Show Tooltips in 3D scenes", true);
|
||||||
|
|
|
@ -67,10 +67,7 @@ RenderWidget::RenderWidget(QWidget *parent, Qt::WindowFlags f)
|
||||||
mView->getCamera()->setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) );
|
mView->getCamera()->setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) );
|
||||||
mView->getCamera()->setViewport( new osg::Viewport(0, 0, traits->width, traits->height) );
|
mView->getCamera()->setViewport( new osg::Viewport(0, 0, traits->width, traits->height) );
|
||||||
|
|
||||||
mView->getCamera()->setProjectionMatrixAsPerspective(
|
updateCameraParameters();
|
||||||
CSMPrefs::get()["Rendering"]["camera-fov"].toDouble(),
|
|
||||||
static_cast<double>(traits->width)/static_cast<double>(traits->height),
|
|
||||||
1.0f, 10000.0f);
|
|
||||||
|
|
||||||
SceneUtil::LightManager* lightMgr = new SceneUtil::LightManager;
|
SceneUtil::LightManager* lightMgr = new SceneUtil::LightManager;
|
||||||
lightMgr->setStartLight(1);
|
lightMgr->setStartLight(1);
|
||||||
|
@ -374,12 +371,34 @@ void SceneWidget::settingChanged (const CSMPrefs::Setting *setting)
|
||||||
{
|
{
|
||||||
mOrbitCamControl->setOrbitSpeedMultiplier(setting->toDouble());
|
mOrbitCamControl->setOrbitSpeedMultiplier(setting->toDouble());
|
||||||
}
|
}
|
||||||
else if (*setting=="Rendering/camera-fov")
|
else if (*setting=="Rendering/camera-fov" ||
|
||||||
|
*setting=="Rendering/camera-ortho" ||
|
||||||
|
*setting=="Rendering/camera-ortho-size")
|
||||||
{
|
{
|
||||||
|
updateCameraParameters();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderWidget::updateCameraParameters()
|
||||||
|
{
|
||||||
|
const float near = 1.0;
|
||||||
|
const float far = 1000.0;
|
||||||
|
|
||||||
|
if (CSMPrefs::get()["Rendering"]["camera-ortho"].isTrue())
|
||||||
|
{
|
||||||
|
const float size = CSMPrefs::get()["Rendering"]["camera-ortho-size"].toDouble();
|
||||||
|
const float half_w = size / 100.0 * static_cast<double>(width());
|
||||||
|
const float half_h = size / 100.0 * static_cast<double>(height());
|
||||||
|
|
||||||
|
mView->getCamera()->setProjectionMatrixAsOrtho(
|
||||||
|
-half_w, half_w, -half_h, half_h, near, far);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
mView->getCamera()->setProjectionMatrixAsPerspective(
|
mView->getCamera()->setProjectionMatrixAsPerspective(
|
||||||
setting->toDouble(),
|
CSMPrefs::get()["Rendering"]["camera-fov"].toDouble(),
|
||||||
static_cast<double>(width())/static_cast<double>(height()),
|
static_cast<double>(width())/static_cast<double>(height()),
|
||||||
1.0f, 10000.0f);
|
near, far);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,8 @@ namespace CSVRender
|
||||||
osg::ref_ptr<osgViewer::View> mView;
|
osg::ref_ptr<osgViewer::View> mView;
|
||||||
osg::ref_ptr<osg::Group> mRootNode;
|
osg::ref_ptr<osg::Group> mRootNode;
|
||||||
|
|
||||||
|
void updateCameraParameters();
|
||||||
|
|
||||||
QTimer mTimer;
|
QTimer mTimer;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
|
Loading…
Reference in a new issue