Added camera FOV control (and better initial fov)
This commit is contained in:
parent
134158c33a
commit
eb795b0f83
6 changed files with 39 additions and 1 deletions
|
@ -17,7 +17,7 @@ CameraDefinition::CameraDefinition():
|
|||
|
||||
width = 1.0;
|
||||
height = 1.0;
|
||||
perspective.yfov = 1.57;
|
||||
perspective.yfov = 1.0;
|
||||
perspective.xratio = 1.0;
|
||||
perspective.znear = 1.0;
|
||||
perspective.zfar = 1000.0;
|
||||
|
@ -32,6 +32,7 @@ void CameraDefinition::save(PackStream* stream) const
|
|||
stream->write(&direction.phi);
|
||||
stream->write(&direction.theta);
|
||||
stream->write(&roll);
|
||||
stream->write(&perspective.yfov);
|
||||
}
|
||||
|
||||
void CameraDefinition::load(PackStream* stream)
|
||||
|
@ -41,6 +42,7 @@ void CameraDefinition::load(PackStream* stream)
|
|||
stream->read(&direction.phi);
|
||||
stream->read(&direction.theta);
|
||||
stream->read(&roll);
|
||||
stream->read(&perspective.yfov);
|
||||
|
||||
validate();
|
||||
}
|
||||
|
@ -53,6 +55,8 @@ void CameraDefinition::copy(BaseDefinition* _destination) const
|
|||
destination->direction = direction;
|
||||
destination->roll = roll;
|
||||
|
||||
destination->perspective = perspective;
|
||||
|
||||
destination->validate();
|
||||
}
|
||||
|
||||
|
@ -143,6 +147,13 @@ void CameraDefinition::setZoomToTarget(double zoom)
|
|||
validate();
|
||||
}
|
||||
|
||||
void CameraDefinition::setFov(double fov)
|
||||
{
|
||||
perspective.yfov = fov;
|
||||
|
||||
validate();
|
||||
}
|
||||
|
||||
void CameraDefinition::strafeForward(double value)
|
||||
{
|
||||
location = location.add(forward.scale(value));
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
void setTargetCoords(double x, double y, double z);
|
||||
void setRoll(double angle);
|
||||
void setZoomToTarget(double zoom);
|
||||
void setFov(double fov);
|
||||
|
||||
void strafeForward(double value);
|
||||
void strafeRight(double value);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QSlider>
|
||||
#include "WidgetExplorer.h"
|
||||
#include "DesktopScenery.h"
|
||||
#include "CameraDefinition.h"
|
||||
|
@ -12,6 +13,7 @@ DialogExplorer::DialogExplorer(QWidget* parent, CameraDefinition* camera, bool c
|
|||
{
|
||||
QWidget* panel;
|
||||
QPushButton* button;
|
||||
QLabel* label;
|
||||
|
||||
setModal(true);
|
||||
setWindowTitle(tr("Paysages 3D - Explore"));
|
||||
|
@ -29,6 +31,16 @@ DialogExplorer::DialogExplorer(QWidget* parent, CameraDefinition* camera, bool c
|
|||
panel->setLayout(new QVBoxLayout());
|
||||
panel->setMaximumWidth(230);
|
||||
|
||||
label = new QLabel(tr("Field of vision"), panel);
|
||||
label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||
panel->layout()->addWidget(label);
|
||||
QSlider* slider = new QSlider(Qt::Horizontal, panel);
|
||||
slider->setRange(0, 1000);
|
||||
slider->setValue((int)(1000.0 * (camera->getPerspective().yfov - 0.7) / 1.0));
|
||||
slider->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(fovChanged(int)));
|
||||
panel->layout()->addWidget(slider);
|
||||
|
||||
panel->layout()->addWidget(new QLabel(tr("COMMANDS\n\nLeft click : Look around\nRight click : Pan (adjust framing)\nWheel : Move forward/backward\nHold SHIFT : Faster\nHold CTRL : Slower"), panel));
|
||||
|
||||
button = new QPushButton(tr("Reset camera"), panel);
|
||||
|
@ -61,3 +73,8 @@ void DialogExplorer::validateCamera()
|
|||
accept();
|
||||
}
|
||||
|
||||
void DialogExplorer::fovChanged(int value)
|
||||
{
|
||||
_wanderer->setCameraFov(0.7 + 1.0 * ((double)value) / 1000.0);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ public:
|
|||
|
||||
protected slots:
|
||||
void validateCamera();
|
||||
void fovChanged(int value);
|
||||
|
||||
private:
|
||||
WidgetExplorer* _wanderer;
|
||||
|
|
|
@ -43,6 +43,12 @@ WidgetExplorer::~WidgetExplorer()
|
|||
delete _renderer;
|
||||
}
|
||||
|
||||
void WidgetExplorer::setCameraFov(double fov)
|
||||
{
|
||||
_current_camera->setFov(fov);
|
||||
updateGL();
|
||||
}
|
||||
|
||||
void WidgetExplorer::resetCamera()
|
||||
{
|
||||
_base_camera->copy(_current_camera);
|
||||
|
|
|
@ -15,6 +15,8 @@ public:
|
|||
WidgetExplorer(QWidget* parent, CameraDefinition* camera, Scenery* scenery);
|
||||
~WidgetExplorer();
|
||||
|
||||
void setCameraFov(double fov);
|
||||
|
||||
public slots:
|
||||
void resetCamera();
|
||||
void validateCamera();
|
||||
|
|
Loading…
Reference in a new issue