1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-17 19:10:24 +00:00
OpenMW/apps/opencs/view/render/scenewidget.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

163 lines
3.8 KiB
C++
Raw Normal View History

2013-11-02 01:48:30 +00:00
#ifndef OPENCS_VIEW_SCENEWIDGET_H
#define OPENCS_VIEW_SCENEWIDGET_H
2016-03-14 04:04:11 +00:00
#include <memory>
2022-10-10 11:41:36 +00:00
#include <string>
2016-03-10 09:29:24 +00:00
2022-10-10 11:41:36 +00:00
#include <QColor>
#include <QObject>
#include <QTimer>
2013-11-02 01:48:30 +00:00
#include <QWidget>
2014-03-23 14:14:26 +00:00
2022-10-19 17:02:00 +00:00
#include <osg/Timer>
2022-10-10 11:41:36 +00:00
#include <osg/Vec4f>
#include <osg/ref_ptr>
2016-08-03 17:39:46 +00:00
#include <osgViewer/CompositeViewer>
2014-03-26 17:29:15 +00:00
#include "lightingbright.hpp"
2014-03-26 16:47:56 +00:00
#include "lightingday.hpp"
2014-03-26 16:59:42 +00:00
#include "lightingnight.hpp"
2014-03-23 14:14:26 +00:00
2022-10-19 17:02:00 +00:00
class QMouseEvent;
class QWheelEvent;
class osgQOpenGLWidget;
class CompositeOsgRenderer;
namespace Resource
{
class ResourceSystem;
}
namespace osg
{
class Group;
2016-02-16 15:02:29 +00:00
class Camera;
2022-10-19 17:02:00 +00:00
class Geometry;
}
namespace osg
{
class View;
}
namespace CSVWidget
2014-03-23 14:14:26 +00:00
{
class SceneToolMode;
class SceneToolbar;
2013-11-02 01:48:30 +00:00
}
2016-03-10 09:29:24 +00:00
namespace CSMPrefs
{
class Setting;
}
2013-11-02 01:48:30 +00:00
namespace CSVRender
{
2016-03-14 04:04:11 +00:00
class CameraController;
class FreeCameraController;
class OrbitCameraController;
2014-03-23 14:14:26 +00:00
class Lighting;
class RenderWidget : public QWidget
2013-11-02 01:48:30 +00:00
{
2016-03-14 04:14:28 +00:00
Q_OBJECT
2022-09-22 18:26:05 +00:00
public:
2016-03-14 04:14:28 +00:00
RenderWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
virtual ~RenderWidget();
/// Initiates a request to redraw the view
void flagAsModified();
2016-03-14 04:14:28 +00:00
void setVisibilityMask(unsigned int mask);
2016-02-16 15:02:29 +00:00
osg::Camera* getCamera();
2016-03-14 04:14:28 +00:00
protected:
osgQOpenGLWidget* mWidget;
CompositeOsgRenderer* mRenderer;
2016-03-14 04:14:28 +00:00
osg::ref_ptr<osgViewer::View> mView;
2016-08-03 17:39:46 +00:00
osg::ref_ptr<osg::Group> mRootNode;
void updateCameraParameters(double overrideAspect = -1.0);
2017-12-08 17:18:27 +00:00
2016-08-03 17:39:46 +00:00
protected slots:
void toggleRenderStats();
};
2016-08-03 17:39:46 +00:00
/// Extension of RenderWidget to support lighting mode selection & toolbar
class SceneWidget : public RenderWidget
{
2016-03-14 04:14:28 +00:00
Q_OBJECT
public:
2020-06-22 06:05:25 +00:00
SceneWidget(std::shared_ptr<Resource::ResourceSystem> resourceSystem, QWidget* parent = nullptr,
Qt::WindowFlags f = Qt::WindowFlags(), bool retrieveInput = true);
2016-03-14 04:14:28 +00:00
virtual ~SceneWidget();
2016-03-14 04:14:28 +00:00
CSVWidget::SceneToolMode* makeLightingSelector(CSVWidget::SceneToolbar* parent);
///< \attention The created tool is not added to the toolbar (via addTool). Doing that
/// is the responsibility of the calling function.
2016-03-14 04:14:28 +00:00
void setDefaultAmbient(const osg::Vec4f& colour);
///< \note The actual ambient colour may differ based on lighting settings.
void setExterior(bool isExterior);
2016-03-14 04:14:28 +00:00
protected:
void setLighting(Lighting* lighting);
///< \attention The ownership of \a lighting is not transferred to *this.
2016-03-14 04:14:28 +00:00
void setAmbient(const osg::Vec4f& ambient);
2015-03-28 20:26:16 +00:00
void mouseMoveEvent(QMouseEvent* event) override;
void wheelEvent(QWheelEvent* event) override;
2016-03-10 09:29:24 +00:00
osg::ref_ptr<osg::Geometry> createGradientRectangle(QColor bgColour, QColor gradientColour);
osg::ref_ptr<osg::Camera> createGradientCamera(QColor bgColour, QColor gradientColour);
void updateGradientCamera(QColor bgColour, QColor gradientColour);
std::shared_ptr<Resource::ResourceSystem> mResourceSystem;
2016-03-14 04:14:28 +00:00
Lighting* mLighting;
2016-08-03 17:20:55 +00:00
osg::ref_ptr<osg::Camera> mGradientCamera;
osg::Vec4f mDefaultAmbient;
bool mHasDefaultAmbient;
bool mIsExterior;
2016-03-14 04:14:28 +00:00
LightingDay mLightingDay;
LightingNight mLightingNight;
2016-03-14 04:14:28 +00:00
LightingBright mLightingBright;
2016-08-03 17:39:46 +00:00
int mPrevMouseX, mPrevMouseY;
2016-03-10 09:29:24 +00:00
2016-03-14 04:14:28 +00:00
/// Tells update that camera isn't set
bool mCamPositionSet;
2016-03-14 04:04:11 +00:00
2016-03-14 04:14:28 +00:00
FreeCameraController* mFreeCamControl;
2016-08-03 17:39:46 +00:00
OrbitCameraController* mOrbitCamControl;
CameraController* mCurrentCamControl;
2016-03-10 09:29:24 +00:00
2016-03-14 04:14:28 +00:00
public slots:
void update(double dt);
2016-03-10 09:29:24 +00:00
2016-03-14 04:14:28 +00:00
protected slots:
2016-03-14 04:14:28 +00:00
virtual void settingChanged(const CSMPrefs::Setting* setting);
2016-03-14 04:14:28 +00:00
void selectNavigationMode(const std::string& mode);
private slots:
2016-03-14 04:14:28 +00:00
void selectLightingMode(const std::string& mode);
2022-09-22 18:26:05 +00:00
signals:
2016-03-14 04:14:28 +00:00
void focusToolbarRequest();
2022-09-22 18:26:05 +00:00
};
2013-11-02 01:48:30 +00:00
}
#endif