forked from mirror/openmw-tes3mp
added lighting switching
This commit is contained in:
parent
205354ba30
commit
d5506172e8
8 changed files with 102 additions and 10 deletions
|
@ -69,7 +69,7 @@ opencs_units (view/render
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units_noqt (view/render
|
opencs_units_noqt (view/render
|
||||||
navigation navigation1st navigationfree navigationorbit
|
navigation navigation1st navigationfree navigationorbit lighting
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units_noqt (view/world
|
opencs_units_noqt (view/world
|
||||||
|
|
4
apps/opencs/view/render/lighting.cpp
Normal file
4
apps/opencs/view/render/lighting.cpp
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
#include "lighting.hpp"
|
||||||
|
|
||||||
|
CSVRender::Lighting::~Lighting() {}
|
27
apps/opencs/view/render/lighting.hpp
Normal file
27
apps/opencs/view/render/lighting.hpp
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef OPENCS_VIEW_LIGHTING_H
|
||||||
|
#define OPENCS_VIEW_LIGHTING_H
|
||||||
|
|
||||||
|
namespace Ogre
|
||||||
|
{
|
||||||
|
class SceneManager;
|
||||||
|
class ColourValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace CSVRender
|
||||||
|
{
|
||||||
|
class Lighting
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
virtual ~Lighting();
|
||||||
|
|
||||||
|
virtual void activate (Ogre::SceneManager *sceneManager,
|
||||||
|
const Ogre::ColourValue *defaultAmbient = 0) = 0;
|
||||||
|
|
||||||
|
virtual void deactivate() = 0;
|
||||||
|
|
||||||
|
virtual void setDefaultAmbient (const Ogre::ColourValue& colour) = 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -11,7 +11,10 @@
|
||||||
#include <OgreSceneNode.h>
|
#include <OgreSceneNode.h>
|
||||||
#include <OgreViewport.h>
|
#include <OgreViewport.h>
|
||||||
|
|
||||||
|
#include "../world/scenetoolmode.hpp"
|
||||||
|
|
||||||
#include "navigation.hpp"
|
#include "navigation.hpp"
|
||||||
|
#include "lighting.hpp"
|
||||||
|
|
||||||
namespace CSVRender
|
namespace CSVRender
|
||||||
{
|
{
|
||||||
|
@ -19,11 +22,12 @@ namespace CSVRender
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, mWindow(NULL)
|
, mWindow(NULL)
|
||||||
, mCamera(NULL)
|
, mCamera(NULL)
|
||||||
, mSceneMgr(NULL), mNavigation (0), mUpdate (false)
|
, mSceneMgr(NULL), mNavigation (0), mLighting (0), mUpdate (false)
|
||||||
, mKeyForward (false), mKeyBackward (false), mKeyLeft (false), mKeyRight (false)
|
, mKeyForward (false), mKeyBackward (false), mKeyLeft (false), mKeyRight (false)
|
||||||
, mKeyRollLeft (false), mKeyRollRight (false)
|
, mKeyRollLeft (false), mKeyRollRight (false)
|
||||||
, mFast (false), mDragging (false), mMod1 (false)
|
, mFast (false), mDragging (false), mMod1 (false)
|
||||||
, mFastFactor (4) /// \todo make this configurable
|
, mFastFactor (4) /// \todo make this configurable
|
||||||
|
, mDefaultAmbient (0, 0, 0, 0), mHasDefaultAmbient (false)
|
||||||
{
|
{
|
||||||
setAttribute(Qt::WA_PaintOnScreen);
|
setAttribute(Qt::WA_PaintOnScreen);
|
||||||
setAttribute(Qt::WA_NoSystemBackground);
|
setAttribute(Qt::WA_NoSystemBackground);
|
||||||
|
@ -53,9 +57,27 @@ namespace CSVRender
|
||||||
timer->start (20); /// \todo make this configurable
|
timer->start (20); /// \todo make this configurable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSVWorld::SceneToolMode *SceneWidget::makeLightingSelector (CSVWorld::SceneToolbar *parent)
|
||||||
|
{
|
||||||
|
CSVWorld::SceneToolMode *tool = new CSVWorld::SceneToolMode (parent);
|
||||||
|
|
||||||
|
tool->addButton (":door.png", "day"); /// \todo replace icons
|
||||||
|
tool->addButton (":GMST.png", "night");
|
||||||
|
tool->addButton (":Info.png", "bright");
|
||||||
|
|
||||||
|
connect (tool, SIGNAL (modeChanged (const std::string&)),
|
||||||
|
this, SLOT (selectLightingMode (const std::string&)));
|
||||||
|
|
||||||
|
return tool;
|
||||||
|
}
|
||||||
|
|
||||||
void SceneWidget::setDefaultAmbient (const Ogre::ColourValue& colour)
|
void SceneWidget::setDefaultAmbient (const Ogre::ColourValue& colour)
|
||||||
{
|
{
|
||||||
mSceneMgr->setAmbientLight (colour);
|
mDefaultAmbient = colour;
|
||||||
|
mHasDefaultAmbient = true;
|
||||||
|
|
||||||
|
if (mLighting)
|
||||||
|
mLighting->setDefaultAmbient (colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SceneWidget::updateOgreWindow()
|
void SceneWidget::updateOgreWindow()
|
||||||
|
@ -312,4 +334,18 @@ namespace CSVRender
|
||||||
{
|
{
|
||||||
return mFast ? mFastFactor : 1;
|
return mFast ? mFastFactor : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SceneWidget::setLighting (Lighting *lighting)
|
||||||
|
{
|
||||||
|
if (mLighting)
|
||||||
|
mLighting->deactivate();
|
||||||
|
|
||||||
|
mLighting = lighting;
|
||||||
|
mLighting->activate (mSceneManager, mHasDefaultAmbient ? &mDefaultAmbient : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SceneWidget::selectLightingMode (const std::string& mode)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,17 +3,25 @@
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include <OgreColourValue.h>
|
||||||
|
|
||||||
namespace Ogre
|
namespace Ogre
|
||||||
{
|
{
|
||||||
class Camera;
|
class Camera;
|
||||||
class SceneManager;
|
class SceneManager;
|
||||||
class RenderWindow;
|
class RenderWindow;
|
||||||
class ColourValue;
|
}
|
||||||
|
|
||||||
|
namespace CSVWorld
|
||||||
|
{
|
||||||
|
class SceneToolMode;
|
||||||
|
class SceneToolbar;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace CSVRender
|
namespace CSVRender
|
||||||
{
|
{
|
||||||
class Navigation;
|
class Navigation;
|
||||||
|
class Lighting;
|
||||||
|
|
||||||
class SceneWidget : public QWidget
|
class SceneWidget : public QWidget
|
||||||
{
|
{
|
||||||
|
@ -26,6 +34,10 @@ namespace CSVRender
|
||||||
|
|
||||||
QPaintEngine* paintEngine() const;
|
QPaintEngine* paintEngine() const;
|
||||||
|
|
||||||
|
CSVWorld::SceneToolMode *makeLightingSelector (CSVWorld::SceneToolbar *parent);
|
||||||
|
///< \attention The created tool is not added to the toolbar (via addTool). Doing that
|
||||||
|
/// is the responsibility of the calling function.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void setNavigation (Navigation *navigation);
|
void setNavigation (Navigation *navigation);
|
||||||
|
@ -61,11 +73,15 @@ namespace CSVRender
|
||||||
|
|
||||||
int getFastFactor() const;
|
int getFastFactor() const;
|
||||||
|
|
||||||
|
void setLighting (Lighting *lighting);
|
||||||
|
///< \attention The ownership of \a lighting is not transferred to *this.
|
||||||
|
|
||||||
Ogre::Camera* mCamera;
|
Ogre::Camera* mCamera;
|
||||||
Ogre::SceneManager* mSceneMgr;
|
Ogre::SceneManager* mSceneMgr;
|
||||||
Ogre::RenderWindow* mWindow;
|
Ogre::RenderWindow* mWindow;
|
||||||
|
|
||||||
Navigation *mNavigation;
|
Navigation *mNavigation;
|
||||||
|
Lighting *mLighting;
|
||||||
bool mUpdate;
|
bool mUpdate;
|
||||||
bool mKeyForward;
|
bool mKeyForward;
|
||||||
bool mKeyBackward;
|
bool mKeyBackward;
|
||||||
|
@ -78,10 +94,14 @@ namespace CSVRender
|
||||||
bool mMod1;
|
bool mMod1;
|
||||||
QPoint mOldPos;
|
QPoint mOldPos;
|
||||||
int mFastFactor;
|
int mFastFactor;
|
||||||
|
Ogre::ColourValue mDefaultAmbient;
|
||||||
|
bool mHasDefaultAmbient;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
|
void selectLightingMode (const std::string& mode);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace CSVRender
|
||||||
WorldspaceWidget (QWidget *parent = 0);
|
WorldspaceWidget (QWidget *parent = 0);
|
||||||
|
|
||||||
CSVWorld::SceneToolMode *makeNavigationSelector (CSVWorld::SceneToolbar *parent);
|
CSVWorld::SceneToolMode *makeNavigationSelector (CSVWorld::SceneToolbar *parent);
|
||||||
///< \important The created tool is not added to the toolbar (via addTool). Doing that
|
///< \attention The created tool is not added to the toolbar (via addTool). Doing that
|
||||||
/// is the responsibility of the calling function.
|
/// is the responsibility of the calling function.
|
||||||
|
|
||||||
void selectDefaultNavigationMode();
|
void selectDefaultNavigationMode();
|
||||||
|
|
|
@ -3,11 +3,10 @@
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
#include "../render/scenewidget.hpp"
|
#include "../render/previewwidget.hpp"
|
||||||
|
|
||||||
#include "scenetoolbar.hpp"
|
#include "scenetoolbar.hpp"
|
||||||
|
#include "scenetoolmode.hpp"
|
||||||
#include "../render/previewwidget.hpp"
|
|
||||||
|
|
||||||
CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
||||||
: SubView (id)
|
: SubView (id)
|
||||||
|
@ -31,6 +30,9 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo
|
||||||
|
|
||||||
SceneToolbar *toolbar = new SceneToolbar (48, this);
|
SceneToolbar *toolbar = new SceneToolbar (48, this);
|
||||||
|
|
||||||
|
SceneToolMode *lightingTool = mScene->makeLightingSelector (toolbar);
|
||||||
|
toolbar->addTool (lightingTool);
|
||||||
|
|
||||||
layout->addWidget (toolbar, 0);
|
layout->addWidget (toolbar, 0);
|
||||||
|
|
||||||
layout->addWidget (mScene, 1);
|
layout->addWidget (mScene, 1);
|
||||||
|
|
|
@ -39,8 +39,11 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D
|
||||||
else
|
else
|
||||||
mScene = new CSVRender::UnpagedWorldspaceWidget (id.getId(), document, this);
|
mScene = new CSVRender::UnpagedWorldspaceWidget (id.getId(), document, this);
|
||||||
|
|
||||||
SceneToolMode *tool = mScene->makeNavigationSelector (toolbar);
|
SceneToolMode *navigationTool = mScene->makeNavigationSelector (toolbar);
|
||||||
toolbar->addTool (tool);
|
toolbar->addTool (navigationTool);
|
||||||
|
|
||||||
|
SceneToolMode *lightingTool = mScene->makeLightingSelector (toolbar);
|
||||||
|
toolbar->addTool (lightingTool);
|
||||||
|
|
||||||
layout2->addWidget (toolbar, 0);
|
layout2->addWidget (toolbar, 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue