forked from mirror/openmw-tes3mp
OpenCS: Set up an osgQt GraphicsWindow in SceneWidget
This commit is contained in:
parent
40fc097722
commit
34d503017a
14 changed files with 118 additions and 590 deletions
|
@ -221,7 +221,7 @@ if (${OGRE_VERSION} VERSION_LESS "1.9")
|
||||||
message(FATAL_ERROR "OpenMW requires Ogre 1.9 or later, please install the latest stable version from http://ogre3d.org")
|
message(FATAL_ERROR "OpenMW requires Ogre 1.9 or later, please install the latest stable version from http://ogre3d.org")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(OpenSceneGraph 3.2.0 REQUIRED osgDB osgViewer osgGA osgAnimation osgParticle)
|
find_package(OpenSceneGraph 3.2.0 REQUIRED osgDB osgViewer osgGA osgAnimation osgParticle osgQt)
|
||||||
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS})
|
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS})
|
||||||
|
|
||||||
find_package(MyGUI REQUIRED)
|
find_package(MyGUI REQUIRED)
|
||||||
|
|
|
@ -157,7 +157,7 @@ endif(WIN32)
|
||||||
|
|
||||||
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
|
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
|
||||||
|
|
||||||
find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork REQUIRED)
|
find_package(Qt4 COMPONENTS QtCore QtGui QtNetwork QtOpenGL REQUIRED)
|
||||||
include(${QT_USE_FILE})
|
include(${QT_USE_FILE})
|
||||||
|
|
||||||
qt4_wrap_ui(OPENCS_UI_HDR ${OPENCS_UI})
|
qt4_wrap_ui(OPENCS_UI_HDR ${OPENCS_UI})
|
||||||
|
@ -201,6 +201,7 @@ target_link_libraries(openmw-cs
|
||||||
${OGRE_LIBRARIES}
|
${OGRE_LIBRARIES}
|
||||||
${OGRE_Overlay_LIBRARIES}
|
${OGRE_Overlay_LIBRARIES}
|
||||||
${OGRE_STATIC_PLUGINS}
|
${OGRE_STATIC_PLUGINS}
|
||||||
|
${OPENSCENEGRAPH_LIBRARIES}
|
||||||
${SHINY_LIBRARIES}
|
${SHINY_LIBRARIES}
|
||||||
${Boost_LIBRARIES}
|
${Boost_LIBRARIES}
|
||||||
${BULLET_LIBRARIES}
|
${BULLET_LIBRARIES}
|
||||||
|
|
|
@ -44,6 +44,9 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// To allow background thread drawing in OSG
|
||||||
|
QApplication::setAttribute(Qt::AA_X11InitThreads, true);
|
||||||
|
|
||||||
Q_INIT_RESOURCE (resources);
|
Q_INIT_RESOURCE (resources);
|
||||||
|
|
||||||
qRegisterMetaType<std::string> ("std::string");
|
qRegisterMetaType<std::string> ("std::string");
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace CSVRender
|
||||||
//
|
//
|
||||||
|
|
||||||
MouseState::MouseState(WorldspaceWidget *parent)
|
MouseState::MouseState(WorldspaceWidget *parent)
|
||||||
: mParent(parent), mPhysics(parent->mDocument.getPhysics()), mSceneManager(parent->getSceneManager())
|
: mParent(parent), mPhysics(parent->mDocument.getPhysics()), mSceneManager(0/*parent->getSceneManager()*/)
|
||||||
, mCurrentObj(""), mMouseState(Mouse_Default), mOldPos(0,0), mMouseEventTimer(0), mPlane(0)
|
, mCurrentObj(""), mMouseState(Mouse_Default), mOldPos(0,0), mMouseEventTimer(0), mPlane(0)
|
||||||
, mGrabbedSceneNode(""), mOrigObjPos(Ogre::Vector3()), mOrigMousePos(Ogre::Vector3())
|
, mGrabbedSceneNode(""), mOrigObjPos(Ogre::Vector3()), mOrigMousePos(Ogre::Vector3())
|
||||||
, mCurrentMousePos(Ogre::Vector3()), mOffset(0.0f)
|
, mCurrentMousePos(Ogre::Vector3()), mOffset(0.0f)
|
||||||
|
@ -447,17 +447,17 @@ namespace CSVRender
|
||||||
std::map<Ogre::SceneManager*, CSVRender::SceneWidget *>::iterator iter = sceneWidgets.begin();
|
std::map<Ogre::SceneManager*, CSVRender::SceneWidget *>::iterator iter = sceneWidgets.begin();
|
||||||
for(; iter != sceneWidgets.end(); ++iter)
|
for(; iter != sceneWidgets.end(); ++iter)
|
||||||
{
|
{
|
||||||
(*iter).second->updateScene();
|
//(*iter).second->updateScene();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ogre::Camera *MouseState::getCamera()
|
Ogre::Camera *MouseState::getCamera()
|
||||||
{
|
{
|
||||||
return mParent->getCamera();
|
return 0;//mParent->getCamera();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ogre::Viewport *MouseState::getViewport()
|
Ogre::Viewport *MouseState::getViewport()
|
||||||
{
|
{
|
||||||
return mParent->getCamera()->getViewport();
|
return 0;//mParent->getCamera()->getViewport();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
bool CSVRender::PagedWorldspaceWidget::adjustCells()
|
bool CSVRender::PagedWorldspaceWidget::adjustCells()
|
||||||
{
|
{
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
bool setCamera = false;
|
//bool setCamera = false;
|
||||||
|
|
||||||
const CSMWorld::IdCollection<CSMWorld::Cell>& cells = mDocument.getData().getCells();
|
const CSMWorld::IdCollection<CSMWorld::Cell>& cells = mDocument.getData().getCells();
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells()
|
||||||
}
|
}
|
||||||
|
|
||||||
// destroy manual objects
|
// destroy manual objects
|
||||||
getSceneManager()->destroyManualObject("manual"+iter->first.getId(mWorldspace));
|
//getSceneManager()->destroyManualObject("manual"+iter->first.getId(mWorldspace));
|
||||||
|
|
||||||
delete iter->second;
|
delete iter->second;
|
||||||
mCells.erase (iter++);
|
mCells.erase (iter++);
|
||||||
|
@ -98,8 +98,8 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCells.begin()==mCells.end())
|
//if (mCells.begin()==mCells.end())
|
||||||
setCamera = true;
|
//setCamera = true;
|
||||||
|
|
||||||
// add
|
// add
|
||||||
for (CSMWorld::CellSelection::Iterator iter (mSelection.begin()); iter!=mSelection.end();
|
for (CSMWorld::CellSelection::Iterator iter (mSelection.begin()); iter!=mSelection.end();
|
||||||
|
@ -110,6 +110,7 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells()
|
||||||
if (index > 0 && cells.getRecord (index).mState!=CSMWorld::RecordBase::State_Deleted &&
|
if (index > 0 && cells.getRecord (index).mState!=CSMWorld::RecordBase::State_Deleted &&
|
||||||
mCells.find (*iter)==mCells.end())
|
mCells.find (*iter)==mCells.end())
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
Cell *cell = new Cell (mDocument.getData(), getSceneManager(),
|
Cell *cell = new Cell (mDocument.getData(), getSceneManager(),
|
||||||
iter->getId (mWorldspace), mDocument.getPhysics());
|
iter->getId (mWorldspace), mDocument.getPhysics());
|
||||||
mCells.insert (std::make_pair (*iter, cell));
|
mCells.insert (std::make_pair (*iter, cell));
|
||||||
|
@ -167,6 +168,8 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells()
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,28 +245,6 @@ void CSVRender::PagedWorldspaceWidget::addEditModeSelectorButtons (
|
||||||
"terrain-move");
|
"terrain-move");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::PagedWorldspaceWidget::updateOverlay()
|
|
||||||
{
|
|
||||||
if(getCamera()->getViewport())
|
|
||||||
{
|
|
||||||
if((uint32_t)getCamera()->getViewport()->getVisibilityMask()
|
|
||||||
& (uint32_t)CSVRender::Element_CellMarker)
|
|
||||||
mDisplayCellCoord = true;
|
|
||||||
else
|
|
||||||
mDisplayCellCoord = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!mTextOverlays.empty())
|
|
||||||
{
|
|
||||||
std::map<CSMWorld::CellCoordinates, TextOverlay *>::iterator it = mTextOverlays.begin();
|
|
||||||
for(; it != mTextOverlays.end(); ++it)
|
|
||||||
{
|
|
||||||
it->second->enable(mDisplayCellCoord);
|
|
||||||
it->second->update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVRender::PagedWorldspaceWidget::referenceableDataChanged (const QModelIndex& topLeft,
|
void CSVRender::PagedWorldspaceWidget::referenceableDataChanged (const QModelIndex& topLeft,
|
||||||
const QModelIndex& bottomRight)
|
const QModelIndex& bottomRight)
|
||||||
{
|
{
|
||||||
|
@ -329,6 +310,7 @@ void CSVRender::PagedWorldspaceWidget::referenceAdded (const QModelIndex& parent
|
||||||
|
|
||||||
std::string CSVRender::PagedWorldspaceWidget::getStartupInstruction()
|
std::string CSVRender::PagedWorldspaceWidget::getStartupInstruction()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
Ogre::Vector3 position = getCamera()->getPosition();
|
Ogre::Vector3 position = getCamera()->getPosition();
|
||||||
|
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
|
@ -339,6 +321,8 @@ std::string CSVRender::PagedWorldspaceWidget::getStartupInstruction()
|
||||||
<< ", 0";
|
<< ", 0";
|
||||||
|
|
||||||
return stream.str();
|
return stream.str();
|
||||||
|
*/
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget* parent, CSMDoc::Document& document)
|
CSVRender::PagedWorldspaceWidget::PagedWorldspaceWidget (QWidget* parent, CSMDoc::Document& document)
|
||||||
|
@ -363,7 +347,7 @@ CSVRender::PagedWorldspaceWidget::~PagedWorldspaceWidget()
|
||||||
{
|
{
|
||||||
delete iter->second;
|
delete iter->second;
|
||||||
|
|
||||||
getSceneManager()->destroyManualObject("manual"+iter->first.getId(mWorldspace));
|
//getSceneManager()->destroyManualObject("manual"+iter->first.getId(mWorldspace));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::map<CSMWorld::CellCoordinates, TextOverlay *>::iterator iter (mTextOverlays.begin());
|
for (std::map<CSMWorld::CellCoordinates, TextOverlay *>::iterator iter (mTextOverlays.begin());
|
||||||
|
|
|
@ -86,8 +86,6 @@ namespace CSVRender
|
||||||
|
|
||||||
virtual void addEditModeSelectorButtons (CSVWidget::SceneToolMode *tool);
|
virtual void addEditModeSelectorButtons (CSVWidget::SceneToolMode *tool);
|
||||||
|
|
||||||
virtual void updateOverlay();
|
|
||||||
|
|
||||||
virtual void mousePressEvent (QMouseEvent *event);
|
virtual void mousePressEvent (QMouseEvent *event);
|
||||||
|
|
||||||
virtual void mouseReleaseEvent (QMouseEvent *event);
|
virtual void mouseReleaseEvent (QMouseEvent *event);
|
||||||
|
|
|
@ -9,10 +9,9 @@
|
||||||
|
|
||||||
CSVRender::PreviewWidget::PreviewWidget (CSMWorld::Data& data,
|
CSVRender::PreviewWidget::PreviewWidget (CSMWorld::Data& data,
|
||||||
const std::string& id, bool referenceable, QWidget *parent)
|
const std::string& id, bool referenceable, QWidget *parent)
|
||||||
: SceneWidget (parent), mData (data),
|
: SceneWidget (parent), mData (data)
|
||||||
mObject (data, getSceneManager()->getRootSceneNode(), id, referenceable, boost::shared_ptr<CSVWorld::PhysicsSystem>(), true)
|
|
||||||
{
|
{
|
||||||
setNavigation (&mOrbit);
|
//setNavigation (&mOrbit);
|
||||||
|
|
||||||
QAbstractItemModel *referenceables =
|
QAbstractItemModel *referenceables =
|
||||||
mData.getTableModel (CSMWorld::UniversalId::Type_Referenceables);
|
mData.getTableModel (CSMWorld::UniversalId::Type_Referenceables);
|
||||||
|
@ -37,6 +36,7 @@ CSVRender::PreviewWidget::PreviewWidget (CSMWorld::Data& data,
|
||||||
void CSVRender::PreviewWidget::referenceableDataChanged (const QModelIndex& topLeft,
|
void CSVRender::PreviewWidget::referenceableDataChanged (const QModelIndex& topLeft,
|
||||||
const QModelIndex& bottomRight)
|
const QModelIndex& bottomRight)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
if (mObject.referenceableDataChanged (topLeft, bottomRight))
|
if (mObject.referenceableDataChanged (topLeft, bottomRight))
|
||||||
flagAsModified();
|
flagAsModified();
|
||||||
|
|
||||||
|
@ -51,11 +51,13 @@ void CSVRender::PreviewWidget::referenceableDataChanged (const QModelIndex& topL
|
||||||
if (referenceables.data (index).toInt()==CSMWorld::RecordBase::State_Deleted)
|
if (referenceables.data (index).toInt()==CSMWorld::RecordBase::State_Deleted)
|
||||||
emit closeRequest();
|
emit closeRequest();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::PreviewWidget::referenceableAboutToBeRemoved (const QModelIndex& parent, int start,
|
void CSVRender::PreviewWidget::referenceableAboutToBeRemoved (const QModelIndex& parent, int start,
|
||||||
int end)
|
int end)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
if (mObject.referenceableAboutToBeRemoved (parent, start, end))
|
if (mObject.referenceableAboutToBeRemoved (parent, start, end))
|
||||||
flagAsModified();
|
flagAsModified();
|
||||||
|
|
||||||
|
@ -75,11 +77,13 @@ void CSVRender::PreviewWidget::referenceableAboutToBeRemoved (const QModelIndex&
|
||||||
emit closeRequest();
|
emit closeRequest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::PreviewWidget::referenceDataChanged (const QModelIndex& topLeft,
|
void CSVRender::PreviewWidget::referenceDataChanged (const QModelIndex& topLeft,
|
||||||
const QModelIndex& bottomRight)
|
const QModelIndex& bottomRight)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
if (mObject.referenceDataChanged (topLeft, bottomRight))
|
if (mObject.referenceDataChanged (topLeft, bottomRight))
|
||||||
flagAsModified();
|
flagAsModified();
|
||||||
|
|
||||||
|
@ -108,11 +112,13 @@ void CSVRender::PreviewWidget::referenceDataChanged (const QModelIndex& topLeft,
|
||||||
if (index.row()>=topLeft.row() && index.row()<=bottomRight.row())
|
if (index.row()>=topLeft.row() && index.row()<=bottomRight.row())
|
||||||
if (index.column()>=topLeft.column() && index.column()<=bottomRight.row())
|
if (index.column()>=topLeft.column() && index.column()<=bottomRight.row())
|
||||||
emit referenceableIdChanged (mObject.getReferenceableId());
|
emit referenceableIdChanged (mObject.getReferenceableId());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::PreviewWidget::referenceAboutToBeRemoved (const QModelIndex& parent, int start,
|
void CSVRender::PreviewWidget::referenceAboutToBeRemoved (const QModelIndex& parent, int start,
|
||||||
int end)
|
int end)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
if (mObject.getReferenceId().empty())
|
if (mObject.getReferenceId().empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -123,4 +129,5 @@ void CSVRender::PreviewWidget::referenceAboutToBeRemoved (const QModelIndex& par
|
||||||
|
|
||||||
if (index.row()>=start && index.row()<=end)
|
if (index.row()>=start && index.row()<=end)
|
||||||
emit closeRequest();
|
emit closeRequest();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace CSVRender
|
||||||
|
|
||||||
CSMWorld::Data& mData;
|
CSMWorld::Data& mData;
|
||||||
CSVRender::NavigationOrbit mOrbit;
|
CSVRender::NavigationOrbit mOrbit;
|
||||||
Object mObject;
|
//Object mObject;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,7 @@
|
||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
|
#include <QLayout>
|
||||||
#include <OgreRoot.h>
|
|
||||||
#include <OgreRenderWindow.h>
|
|
||||||
#include <OgreEntity.h>
|
|
||||||
#include <OgreCamera.h>
|
|
||||||
#include <OgreSceneNode.h>
|
|
||||||
#include <OgreViewport.h>
|
|
||||||
|
|
||||||
#include "../widget/scenetoolmode.hpp"
|
#include "../widget/scenetoolmode.hpp"
|
||||||
#include "../../model/settings/usersettings.hpp"
|
#include "../../model/settings/usersettings.hpp"
|
||||||
|
@ -18,445 +12,75 @@
|
||||||
#include "navigation.hpp"
|
#include "navigation.hpp"
|
||||||
#include "lighting.hpp"
|
#include "lighting.hpp"
|
||||||
|
|
||||||
|
#include <osgQt/GraphicsWindowQt>
|
||||||
|
#include <osg/GraphicsContext>
|
||||||
|
|
||||||
|
#include <osgGA/TrackballManipulator>
|
||||||
|
|
||||||
namespace CSVRender
|
namespace CSVRender
|
||||||
{
|
{
|
||||||
SceneWidget::SceneWidget(QWidget *parent)
|
|
||||||
: QWidget(parent)
|
|
||||||
, mCamera(NULL)
|
|
||||||
, mSceneMgr(NULL)
|
|
||||||
, mWindow(NULL)
|
|
||||||
, mViewport(NULL)
|
|
||||||
, mNavigation (0), mLighting (0), mUpdate (false), mKeyForward (false)
|
|
||||||
, mKeyBackward (false), mKeyLeft (false), mKeyRight (false)
|
|
||||||
, mKeyRollLeft (false), mKeyRollRight (false)
|
|
||||||
, mFast (false), mDragging (false), mMod1 (false)
|
|
||||||
, mFastFactor (4)
|
|
||||||
, mDefaultAmbient (0, 0, 0, 0), mHasDefaultAmbient (false)
|
|
||||||
{
|
|
||||||
setAttribute(Qt::WA_PaintOnScreen);
|
|
||||||
setAttribute(Qt::WA_NoSystemBackground);
|
|
||||||
|
|
||||||
setFocusPolicy (Qt::StrongFocus);
|
SceneWidget::SceneWidget(QWidget *parent, Qt::WindowFlags f)
|
||||||
|
: QWidget(parent, f)
|
||||||
|
{
|
||||||
|
|
||||||
mSceneMgr = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC);
|
#if QT_VERSION >= 0x050000
|
||||||
|
// Qt5 is currently crashing and reporting "Cannot make QOpenGLContext current in a different thread" when the viewer is run multi-threaded, this is regression from Qt4
|
||||||
mSceneMgr->setAmbientLight (Ogre::ColourValue (0,0,0,1));
|
osgViewer::ViewerBase::ThreadingModel threadingModel = osgViewer::ViewerBase::SingleThreaded;
|
||||||
|
|
||||||
mCamera = mSceneMgr->createCamera("foo");
|
|
||||||
|
|
||||||
mCamera->setPosition (300, 0, 0);
|
|
||||||
mCamera->lookAt (0, 0, 0);
|
|
||||||
mCamera->setNearClipDistance (0.1);
|
|
||||||
|
|
||||||
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
|
||||||
|
|
||||||
float farClipDist = userSettings.setting("3d-render/far-clip-distance", QString("300000")).toFloat();
|
|
||||||
mCamera->setFarClipDistance (farClipDist);
|
|
||||||
|
|
||||||
mFastFactor = userSettings.setting("scene-input/fast-factor", QString("4")).toInt();
|
|
||||||
|
|
||||||
mCamera->roll (Ogre::Degree (90));
|
|
||||||
|
|
||||||
setLighting (&mLightingDay);
|
|
||||||
|
|
||||||
QTimer *timer = new QTimer (this);
|
|
||||||
|
|
||||||
connect (timer, SIGNAL (timeout()), this, SLOT (update()));
|
|
||||||
|
|
||||||
int timerStart = userSettings.setting("scene-input/timer", QString("20")).toInt();
|
|
||||||
timer->start (timerStart);
|
|
||||||
|
|
||||||
/// \todo make shortcut configurable
|
|
||||||
QShortcut *focusToolbar = new QShortcut (Qt::Key_T, this, 0, 0, Qt::WidgetWithChildrenShortcut);
|
|
||||||
connect (focusToolbar, SIGNAL (activated()), this, SIGNAL (focusToolbarRequest()));
|
|
||||||
}
|
|
||||||
|
|
||||||
CSVWidget::SceneToolMode *SceneWidget::makeLightingSelector (CSVWidget::SceneToolbar *parent)
|
|
||||||
{
|
|
||||||
CSVWidget::SceneToolMode *tool = new CSVWidget::SceneToolMode (parent, "Lighting Mode");
|
|
||||||
|
|
||||||
/// \todo replace icons
|
|
||||||
tool->addButton (":scenetoolbar/day", "day",
|
|
||||||
"Day"
|
|
||||||
"<ul><li>Cell specific ambient in interiors</li>"
|
|
||||||
"<li>Low ambient in exteriors</li>"
|
|
||||||
"<li>Strong directional light source/lir>"
|
|
||||||
"<li>This mode closely resembles day time in-game</li></ul>");
|
|
||||||
tool->addButton (":scenetoolbar/night", "night",
|
|
||||||
"Night"
|
|
||||||
"<ul><li>Cell specific ambient in interiors</li>"
|
|
||||||
"<li>Low ambient in exteriors</li>"
|
|
||||||
"<li>Weak directional light source</li>"
|
|
||||||
"<li>This mode closely resembles night time in-game</li></ul>");
|
|
||||||
tool->addButton (":scenetoolbar/bright", "bright",
|
|
||||||
"Bright"
|
|
||||||
"<ul><li>Maximum ambient</li>"
|
|
||||||
"<li>Strong directional light source</li></ul>");
|
|
||||||
|
|
||||||
connect (tool, SIGNAL (modeChanged (const std::string&)),
|
|
||||||
this, SLOT (selectLightingMode (const std::string&)));
|
|
||||||
|
|
||||||
return tool;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneWidget::setDefaultAmbient (const Ogre::ColourValue& colour)
|
|
||||||
{
|
|
||||||
mDefaultAmbient = colour;
|
|
||||||
mHasDefaultAmbient = true;
|
|
||||||
|
|
||||||
if (mLighting)
|
|
||||||
mLighting->setDefaultAmbient (colour);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneWidget::updateOgreWindow()
|
|
||||||
{
|
|
||||||
if (mWindow)
|
|
||||||
{
|
|
||||||
Ogre::Root::getSingleton().destroyRenderTarget(mWindow);
|
|
||||||
mWindow = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::stringstream windowHandle;
|
|
||||||
#ifdef WIN32
|
|
||||||
windowHandle << Ogre::StringConverter::toString((uintptr_t)(this->winId()));
|
|
||||||
#else
|
#else
|
||||||
windowHandle << this->winId();
|
osgViewer::ViewerBase::ThreadingModel threadingModel = osgViewer::ViewerBase::CullDrawThreadPerContext;
|
||||||
#endif
|
|
||||||
std::stringstream windowTitle;
|
|
||||||
static int count=0;
|
|
||||||
windowTitle << ++count;
|
|
||||||
|
|
||||||
Ogre::NameValuePairList params;
|
|
||||||
|
|
||||||
params.insert(std::make_pair("externalWindowHandle", windowHandle.str()));
|
|
||||||
params.insert(std::make_pair("title", windowTitle.str()));
|
|
||||||
|
|
||||||
std::string antialiasing =
|
|
||||||
CSMSettings::UserSettings::instance().settingValue("3d-render/antialiasing").toStdString();
|
|
||||||
if(antialiasing == "MSAA 16") antialiasing = "16";
|
|
||||||
else if(antialiasing == "MSAA 8") antialiasing = "8";
|
|
||||||
else if(antialiasing == "MSAA 4") antialiasing = "4";
|
|
||||||
else if(antialiasing == "MSAA 2") antialiasing = "2";
|
|
||||||
else antialiasing = "0";
|
|
||||||
params.insert(std::make_pair("FSAA", antialiasing));
|
|
||||||
|
|
||||||
params.insert(std::make_pair("vsync", "false")); // TODO setting
|
|
||||||
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE
|
|
||||||
params.insert(std::make_pair("macAPI", "cocoa"));
|
|
||||||
params.insert(std::make_pair("macAPICocoaUseNSView", "true"));
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mWindow = Ogre::Root::getSingleton().createRenderWindow(windowTitle.str(), this->width(), this->height(), false, ¶ms);
|
setThreadingModel(threadingModel);
|
||||||
|
|
||||||
mViewport = mWindow->addViewport (mCamera);
|
// disable the default setting of viewer.done() by pressing Escape.
|
||||||
mViewport->setBackgroundColour (Ogre::ColourValue (0.3,0.3,0.3,1));
|
setKeyEventSetsDone(0);
|
||||||
|
|
||||||
Ogre::Real aspectRatio = Ogre::Real(width()) / Ogre::Real(height());
|
osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
|
||||||
mCamera->setAspectRatio(aspectRatio);
|
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
||||||
}
|
traits->windowName = "";
|
||||||
|
traits->windowDecoration = true;
|
||||||
|
traits->x = 0;
|
||||||
|
traits->y = 0;
|
||||||
|
traits->width = width();
|
||||||
|
traits->height = height();
|
||||||
|
traits->doubleBuffer = true;
|
||||||
|
traits->alpha = ds->getMinimumNumAlphaBits();
|
||||||
|
traits->stencil = ds->getMinimumNumStencilBits();
|
||||||
|
traits->sampleBuffers = ds->getMultiSamples();
|
||||||
|
traits->samples = ds->getNumMultiSamples();
|
||||||
|
|
||||||
SceneWidget::~SceneWidget()
|
osgQt::GraphicsWindowQt* window = new osgQt::GraphicsWindowQt(traits.get());
|
||||||
{
|
QLayout* layout = new QHBoxLayout(this);
|
||||||
if (mWindow)
|
layout->addWidget(window->getGLWidget());
|
||||||
Ogre::Root::getSingleton().destroyRenderTarget (mWindow);
|
setLayout(layout);
|
||||||
|
|
||||||
if (mSceneMgr)
|
getCamera()->setGraphicsContext(window);
|
||||||
Ogre::Root::getSingleton().destroySceneManager (mSceneMgr);
|
|
||||||
|
|
||||||
}
|
getCamera()->setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) );
|
||||||
|
getCamera()->setViewport( new osg::Viewport(0, 0, traits->width, traits->height) );
|
||||||
|
//getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(traits->width)/static_cast<double>(traits->height), 1.0f, 10000.0f );
|
||||||
|
|
||||||
void SceneWidget::setVisibilityMask (unsigned int mask)
|
osg::Node* root = new osg::Node;
|
||||||
{
|
setSceneData(root);
|
||||||
mViewport->setVisibilityMask (mask);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneWidget::setNavigation (Navigation *navigation)
|
setCameraManipulator(new osgGA::TrackballManipulator);
|
||||||
{
|
|
||||||
if ((mNavigation = navigation))
|
|
||||||
{
|
|
||||||
mNavigation->setFastModeFactor (mFast ? mFastFactor : 1);
|
|
||||||
if (mNavigation->activate (mCamera))
|
|
||||||
mUpdate = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneWidget::addRenderTargetListener(Ogre::RenderTargetListener *listener)
|
// Only render when the camera position changed, or content flagged dirty
|
||||||
{
|
//setRunFrameScheme(osgViewer::ViewerBase::ON_DEMAND);
|
||||||
mWindow->addListener(listener);
|
|
||||||
}
|
connect( &mTimer, SIGNAL(timeout()), this, SLOT(update()) );
|
||||||
|
mTimer.start( 10 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void SceneWidget::paintEvent(QPaintEvent *event)
|
||||||
|
{
|
||||||
|
frame();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SceneWidget::flagAsModified()
|
||||||
|
{
|
||||||
|
_requestRedraw = true;
|
||||||
|
}
|
||||||
|
|
||||||
void SceneWidget::removeRenderTargetListener(Ogre::RenderTargetListener *listener)
|
|
||||||
{
|
|
||||||
mWindow->removeListener(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ogre::Viewport *SceneWidget::getViewport()
|
|
||||||
{
|
|
||||||
if (!mWindow)
|
|
||||||
updateOgreWindow();
|
|
||||||
|
|
||||||
return mViewport;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ogre::SceneManager *SceneWidget::getSceneManager()
|
|
||||||
{
|
|
||||||
return mSceneMgr;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ogre::Camera *SceneWidget::getCamera()
|
|
||||||
{
|
|
||||||
return mCamera;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneWidget::flagAsModified()
|
|
||||||
{
|
|
||||||
mUpdate = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneWidget::paintEvent(QPaintEvent* e)
|
|
||||||
{
|
|
||||||
if (!mWindow)
|
|
||||||
updateOgreWindow();
|
|
||||||
|
|
||||||
mWindow->update();
|
|
||||||
e->accept();
|
|
||||||
}
|
|
||||||
|
|
||||||
QPaintEngine* SceneWidget::paintEngine() const
|
|
||||||
{
|
|
||||||
// We don't want another paint engine to get in the way.
|
|
||||||
// So we return nothing.
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneWidget::resizeEvent(QResizeEvent *e)
|
|
||||||
{
|
|
||||||
if (!mWindow)
|
|
||||||
return;
|
|
||||||
|
|
||||||
const QSize &newSize = e->size();
|
|
||||||
|
|
||||||
// TODO: Fix Ogre to handle this more consistently (fixed in 1.9)
|
|
||||||
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX
|
|
||||||
mWindow->resize(newSize.width(), newSize.height());
|
|
||||||
#else
|
|
||||||
mWindow->windowMovedOrResized();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Ogre::Real aspectRatio = Ogre::Real(newSize.width()) / Ogre::Real(newSize.height());
|
|
||||||
mCamera->setAspectRatio(aspectRatio);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SceneWidget::event(QEvent *e)
|
|
||||||
{
|
|
||||||
if (e->type() == QEvent::WinIdChange)
|
|
||||||
{
|
|
||||||
// I haven't actually seen this happen yet.
|
|
||||||
if (mWindow)
|
|
||||||
updateOgreWindow();
|
|
||||||
}
|
|
||||||
return QWidget::event(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneWidget::keyPressEvent (QKeyEvent *event)
|
|
||||||
{
|
|
||||||
switch (event->key())
|
|
||||||
{
|
|
||||||
case Qt::Key_W: mKeyForward = true; break;
|
|
||||||
case Qt::Key_S: mKeyBackward = true; break;
|
|
||||||
case Qt::Key_A: mKeyLeft = true; break;
|
|
||||||
case Qt::Key_D: mKeyRight = true; break;
|
|
||||||
case Qt::Key_Q: mKeyRollLeft = true; break;
|
|
||||||
case Qt::Key_E: mKeyRollRight = true; break;
|
|
||||||
case Qt::Key_Control: mMod1 = true; break;
|
|
||||||
|
|
||||||
case Qt::Key_Shift:
|
|
||||||
|
|
||||||
mFast = true;
|
|
||||||
|
|
||||||
if (mNavigation)
|
|
||||||
mNavigation->setFastModeFactor (mFastFactor);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: QWidget::keyPressEvent (event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneWidget::keyReleaseEvent (QKeyEvent *event)
|
|
||||||
{
|
|
||||||
switch (event->key())
|
|
||||||
{
|
|
||||||
case Qt::Key_W: mKeyForward = false; break;
|
|
||||||
case Qt::Key_S: mKeyBackward = false; break;
|
|
||||||
case Qt::Key_A: mKeyLeft = false; break;
|
|
||||||
case Qt::Key_D: mKeyRight = false; break;
|
|
||||||
case Qt::Key_Q: mKeyRollLeft = false; break;
|
|
||||||
case Qt::Key_E: mKeyRollRight = false; break;
|
|
||||||
case Qt::Key_Control: mMod1 = false; break;
|
|
||||||
|
|
||||||
case Qt::Key_Shift:
|
|
||||||
|
|
||||||
mFast = false;
|
|
||||||
|
|
||||||
if (mNavigation)
|
|
||||||
mNavigation->setFastModeFactor (1);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: QWidget::keyReleaseEvent (event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneWidget::wheelEvent (QWheelEvent *event)
|
|
||||||
{
|
|
||||||
if (mNavigation)
|
|
||||||
if (event->delta())
|
|
||||||
if (mNavigation->wheelMoved (event->delta()))
|
|
||||||
mUpdate = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneWidget::leaveEvent (QEvent *event)
|
|
||||||
{
|
|
||||||
mDragging = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneWidget::mouseMoveEvent (QMouseEvent *event)
|
|
||||||
{
|
|
||||||
if (event->buttons() & Qt::LeftButton)
|
|
||||||
{
|
|
||||||
if (mDragging)
|
|
||||||
{
|
|
||||||
QPoint diff = mOldPos-event->pos();
|
|
||||||
mOldPos = event->pos();
|
|
||||||
|
|
||||||
if (mNavigation)
|
|
||||||
if (mNavigation->mouseMoved (diff, mMod1 ? 1 : 0))
|
|
||||||
mUpdate = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mDragging = true;
|
|
||||||
mOldPos = event->pos();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneWidget::mouseReleaseEvent (QMouseEvent *event)
|
|
||||||
{
|
|
||||||
if (!(event->buttons() & Qt::LeftButton))
|
|
||||||
mDragging = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneWidget::focusOutEvent (QFocusEvent *event)
|
|
||||||
{
|
|
||||||
mKeyForward = false;
|
|
||||||
mKeyBackward = false;
|
|
||||||
mKeyLeft = false;
|
|
||||||
mKeyRight = false;
|
|
||||||
mFast = false;
|
|
||||||
mMod1 = false;
|
|
||||||
|
|
||||||
QWidget::focusOutEvent (event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneWidget::update()
|
|
||||||
{
|
|
||||||
if (mNavigation)
|
|
||||||
{
|
|
||||||
int horizontal = 0;
|
|
||||||
int vertical = 0;
|
|
||||||
|
|
||||||
if (mKeyForward && !mKeyBackward)
|
|
||||||
vertical = 1;
|
|
||||||
else if (!mKeyForward && mKeyBackward)
|
|
||||||
vertical = -1;
|
|
||||||
|
|
||||||
if (mKeyLeft && !mKeyRight)
|
|
||||||
horizontal = -1;
|
|
||||||
else if (!mKeyLeft && mKeyRight)
|
|
||||||
horizontal = 1;
|
|
||||||
|
|
||||||
if (horizontal || vertical)
|
|
||||||
if (mNavigation->handleMovementKeys (vertical, horizontal))
|
|
||||||
mUpdate = true;
|
|
||||||
|
|
||||||
int roll = 0;
|
|
||||||
|
|
||||||
if (mKeyRollLeft && !mKeyRollRight)
|
|
||||||
roll = 1;
|
|
||||||
else if (!mKeyRollLeft && mKeyRollRight)
|
|
||||||
roll = -1;
|
|
||||||
|
|
||||||
if (roll)
|
|
||||||
if (mNavigation->handleRollKeys (roll))
|
|
||||||
mUpdate = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mUpdate && mWindow)
|
|
||||||
{
|
|
||||||
mUpdate = false;
|
|
||||||
mWindow->update();
|
|
||||||
updateOverlay();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneWidget::updateScene()
|
|
||||||
{
|
|
||||||
flagAsModified();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneWidget::updateOverlay()
|
|
||||||
{ }
|
|
||||||
|
|
||||||
void SceneWidget::setLighting (Lighting *lighting)
|
|
||||||
{
|
|
||||||
if (mLighting)
|
|
||||||
mLighting->deactivate();
|
|
||||||
|
|
||||||
mLighting = lighting;
|
|
||||||
mLighting->activate (mSceneMgr, mHasDefaultAmbient ? &mDefaultAmbient : 0);
|
|
||||||
|
|
||||||
if (mWindow)
|
|
||||||
mWindow->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneWidget::selectLightingMode (const std::string& mode)
|
|
||||||
{
|
|
||||||
if (mode=="day")
|
|
||||||
setLighting (&mLightingDay);
|
|
||||||
else if (mode=="night")
|
|
||||||
setLighting (&mLightingNight);
|
|
||||||
else if (mode=="bright")
|
|
||||||
setLighting (&mLightingBright);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SceneWidget::updateUserSetting (const QString &key, const QStringList &list)
|
|
||||||
{
|
|
||||||
if(key.contains(QRegExp("^\\b(Objects|Shader|Scene)", Qt::CaseInsensitive)))
|
|
||||||
flagAsModified();
|
|
||||||
|
|
||||||
if(key == "3d-render/far-clip-distance" && !list.empty())
|
|
||||||
{
|
|
||||||
if(mCamera->getFarClipDistance() != list.at(0).toFloat())
|
|
||||||
mCamera->setFarClipDistance(list.at(0).toFloat());
|
|
||||||
}
|
|
||||||
|
|
||||||
// minimise unnecessary ogre window creation by updating only when there is a change
|
|
||||||
if(key == "3d-render/antialiasing")
|
|
||||||
{
|
|
||||||
unsigned int aa = mWindow->getFSAA();
|
|
||||||
unsigned int antialiasing = 0;
|
|
||||||
if(!list.empty())
|
|
||||||
{
|
|
||||||
if(list.at(0) == "MSAA 16") antialiasing = 16;
|
|
||||||
else if(list.at(0) == "MSAA 8") antialiasing = 8;
|
|
||||||
else if(list.at(0) == "MSAA 4") antialiasing = 4;
|
|
||||||
else if(list.at(0) == "MSAA 2") antialiasing = 2;
|
|
||||||
}
|
|
||||||
if(aa != antialiasing)
|
|
||||||
updateOgreWindow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,21 +2,13 @@
|
||||||
#define OPENCS_VIEW_SCENEWIDGET_H
|
#define OPENCS_VIEW_SCENEWIDGET_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QTimer>
|
||||||
#include <OgreColourValue.h>
|
|
||||||
|
|
||||||
#include "lightingday.hpp"
|
#include "lightingday.hpp"
|
||||||
#include "lightingnight.hpp"
|
#include "lightingnight.hpp"
|
||||||
#include "lightingbright.hpp"
|
#include "lightingbright.hpp"
|
||||||
|
|
||||||
namespace Ogre
|
#include <osgViewer/Viewer>
|
||||||
{
|
|
||||||
class Camera;
|
|
||||||
class SceneManager;
|
|
||||||
class RenderWindow;
|
|
||||||
class Viewport;
|
|
||||||
class RenderTargetListener;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace CSVWidget
|
namespace CSVWidget
|
||||||
{
|
{
|
||||||
|
@ -29,110 +21,22 @@ namespace CSVRender
|
||||||
class Navigation;
|
class Navigation;
|
||||||
class Lighting;
|
class Lighting;
|
||||||
|
|
||||||
class SceneWidget : public QWidget
|
class SceneWidget : public QWidget, public osgViewer::Viewer
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
SceneWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
|
||||||
|
|
||||||
SceneWidget(QWidget *parent);
|
virtual void paintEvent( QPaintEvent* event );
|
||||||
virtual ~SceneWidget();
|
|
||||||
|
|
||||||
QPaintEngine* paintEngine() const;
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
virtual void setVisibilityMask (unsigned int mask);
|
|
||||||
|
|
||||||
virtual void updateScene();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
void setNavigation (Navigation *navigation);
|
|
||||||
///< \attention The ownership of \a navigation is not transferred to *this.
|
|
||||||
|
|
||||||
void addRenderTargetListener(Ogre::RenderTargetListener *listener);
|
|
||||||
|
|
||||||
void removeRenderTargetListener(Ogre::RenderTargetListener *listener);
|
|
||||||
|
|
||||||
Ogre::Viewport *getViewport();
|
|
||||||
|
|
||||||
Ogre::SceneManager *getSceneManager();
|
|
||||||
|
|
||||||
Ogre::Camera *getCamera();
|
|
||||||
|
|
||||||
void flagAsModified();
|
void flagAsModified();
|
||||||
|
|
||||||
void setDefaultAmbient (const Ogre::ColourValue& colour);
|
protected:
|
||||||
///< \note The actual ambient colour may differ based on lighting settings.
|
|
||||||
|
|
||||||
virtual void updateOverlay();
|
QTimer mTimer;
|
||||||
|
|
||||||
virtual void mouseReleaseEvent (QMouseEvent *event);
|
|
||||||
|
|
||||||
virtual void mouseMoveEvent (QMouseEvent *event);
|
|
||||||
|
|
||||||
void wheelEvent (QWheelEvent *event);
|
|
||||||
|
|
||||||
void keyPressEvent (QKeyEvent *event);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void paintEvent(QPaintEvent* e);
|
|
||||||
void resizeEvent(QResizeEvent* e);
|
|
||||||
bool event(QEvent* e);
|
|
||||||
|
|
||||||
void keyReleaseEvent (QKeyEvent *event);
|
|
||||||
|
|
||||||
void focusOutEvent (QFocusEvent *event);
|
|
||||||
|
|
||||||
void leaveEvent (QEvent *event);
|
|
||||||
|
|
||||||
void updateOgreWindow();
|
|
||||||
|
|
||||||
void setLighting (Lighting *lighting);
|
|
||||||
///< \attention The ownership of \a lighting is not transferred to *this.
|
|
||||||
|
|
||||||
Ogre::Camera* mCamera;
|
|
||||||
Ogre::SceneManager* mSceneMgr;
|
|
||||||
Ogre::RenderWindow* mWindow;
|
|
||||||
Ogre::Viewport *mViewport;
|
|
||||||
|
|
||||||
Navigation *mNavigation;
|
|
||||||
Lighting *mLighting;
|
|
||||||
bool mUpdate;
|
|
||||||
bool mKeyForward;
|
|
||||||
bool mKeyBackward;
|
|
||||||
bool mKeyLeft;
|
|
||||||
bool mKeyRight;
|
|
||||||
bool mKeyRollLeft;
|
|
||||||
bool mKeyRollRight;
|
|
||||||
bool mFast;
|
|
||||||
bool mDragging;
|
|
||||||
bool mMod1;
|
|
||||||
QPoint mOldPos;
|
|
||||||
int mFastFactor;
|
|
||||||
Ogre::ColourValue mDefaultAmbient;
|
|
||||||
bool mHasDefaultAmbient;
|
|
||||||
LightingDay mLightingDay;
|
|
||||||
LightingNight mLightingNight;
|
|
||||||
LightingBright mLightingBright;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
|
|
||||||
void updateUserSetting (const QString &key, const QStringList &list);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
|
|
||||||
void update();
|
|
||||||
|
|
||||||
void selectLightingMode (const std::string& mode);
|
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
void focusToolbarRequest();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -26,11 +26,11 @@ void CSVRender::UnpagedWorldspaceWidget::update()
|
||||||
|
|
||||||
Ogre::ColourValue colour;
|
Ogre::ColourValue colour;
|
||||||
colour.setAsABGR (record.get().mAmbi.mAmbient);
|
colour.setAsABGR (record.get().mAmbi.mAmbient);
|
||||||
setDefaultAmbient (colour);
|
//setDefaultAmbient (colour);
|
||||||
|
|
||||||
/// \todo deal with mSunlight and mFog/mForDensity
|
/// \todo deal with mSunlight and mFog/mForDensity
|
||||||
|
|
||||||
flagAsModified();
|
//flagAsModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document, QWidget* parent)
|
CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document, QWidget* parent)
|
||||||
|
@ -49,7 +49,7 @@ CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string&
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
||||||
mCell.reset (new Cell (document.getData(), getSceneManager(), mCellId, document.getPhysics()));
|
//mCell.reset (new Cell (document.getData(), getSceneManager(), mCellId, document.getPhysics()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::UnpagedWorldspaceWidget::cellDataChanged (const QModelIndex& topLeft,
|
void CSVRender::UnpagedWorldspaceWidget::cellDataChanged (const QModelIndex& topLeft,
|
||||||
|
@ -91,7 +91,7 @@ bool CSVRender::UnpagedWorldspaceWidget::handleDrop (const std::vector<CSMWorld:
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
mCellId = data.begin()->getId();
|
mCellId = data.begin()->getId();
|
||||||
mCell.reset (new Cell (getDocument().getData(), getSceneManager(), mCellId, getDocument().getPhysics()));
|
//mCell.reset (new Cell (getDocument().getData(), getSceneManager(), mCellId, getDocument().getPhysics()));
|
||||||
|
|
||||||
update();
|
update();
|
||||||
emit cellChanged(*data.begin());
|
emit cellChanged(*data.begin());
|
||||||
|
@ -163,6 +163,7 @@ void CSVRender::UnpagedWorldspaceWidget::addVisibilitySelectorButtons (
|
||||||
|
|
||||||
std::string CSVRender::UnpagedWorldspaceWidget::getStartupInstruction()
|
std::string CSVRender::UnpagedWorldspaceWidget::getStartupInstruction()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
Ogre::Vector3 position = getCamera()->getPosition();
|
Ogre::Vector3 position = getCamera()->getPosition();
|
||||||
|
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
|
@ -173,6 +174,8 @@ std::string CSVRender::UnpagedWorldspaceWidget::getStartupInstruction()
|
||||||
<< ", 0, \"" << mCellId << "\"";
|
<< ", 0, \"" << mCellId << "\"";
|
||||||
|
|
||||||
return stream.str();
|
return stream.str();
|
||||||
|
*/
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVRender::WorldspaceWidget::dropRequirments CSVRender::UnpagedWorldspaceWidget::getDropRequirements (CSVRender::WorldspaceWidget::DropType type) const
|
CSVRender::WorldspaceWidget::dropRequirments CSVRender::UnpagedWorldspaceWidget::getDropRequirements (CSVRender::WorldspaceWidget::DropType type) const
|
||||||
|
|
|
@ -56,31 +56,33 @@ CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidg
|
||||||
this, SLOT (debugProfileAboutToBeRemoved (const QModelIndex&, int, int)));
|
this, SLOT (debugProfileAboutToBeRemoved (const QModelIndex&, int, int)));
|
||||||
|
|
||||||
mPhysics = document.getPhysics(); // create physics if one doesn't exist
|
mPhysics = document.getPhysics(); // create physics if one doesn't exist
|
||||||
mPhysics->addSceneManager(getSceneManager(), this);
|
//mPhysics->addSceneManager(getSceneManager(), this);
|
||||||
mMouse = new MouseState(this);
|
mMouse = new MouseState(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVRender::WorldspaceWidget::~WorldspaceWidget ()
|
CSVRender::WorldspaceWidget::~WorldspaceWidget ()
|
||||||
{
|
{
|
||||||
delete mMouse;
|
delete mMouse;
|
||||||
mPhysics->removeSceneManager(getSceneManager());
|
//mPhysics->removeSceneManager(getSceneManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::WorldspaceWidget::selectNavigationMode (const std::string& mode)
|
void CSVRender::WorldspaceWidget::selectNavigationMode (const std::string& mode)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if (mode=="1st")
|
if (mode=="1st")
|
||||||
setNavigation (&m1st);
|
setNavigation (&m1st);
|
||||||
else if (mode=="free")
|
else if (mode=="free")
|
||||||
setNavigation (&mFree);
|
setNavigation (&mFree);
|
||||||
else if (mode=="orbit")
|
else if (mode=="orbit")
|
||||||
setNavigation (&mOrbit);
|
setNavigation (&mOrbit);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::WorldspaceWidget::useViewHint (const std::string& hint) {}
|
void CSVRender::WorldspaceWidget::useViewHint (const std::string& hint) {}
|
||||||
|
|
||||||
void CSVRender::WorldspaceWidget::selectDefaultNavigationMode()
|
void CSVRender::WorldspaceWidget::selectDefaultNavigationMode()
|
||||||
{
|
{
|
||||||
setNavigation (&m1st);
|
//setNavigation (&m1st);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVWidget::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector (
|
CSVWidget::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector (
|
||||||
|
@ -355,7 +357,7 @@ void CSVRender::WorldspaceWidget::debugProfileAboutToBeRemoved (const QModelInde
|
||||||
|
|
||||||
void CSVRender::WorldspaceWidget::elementSelectionChanged()
|
void CSVRender::WorldspaceWidget::elementSelectionChanged()
|
||||||
{
|
{
|
||||||
setVisibilityMask (getVisibilityMask());
|
//setVisibilityMask (getVisibilityMask());
|
||||||
flagAsModified();
|
flagAsModified();
|
||||||
updateOverlay();
|
updateOverlay();
|
||||||
}
|
}
|
||||||
|
@ -386,11 +388,13 @@ void CSVRender::WorldspaceWidget::mouseReleaseEvent (QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if(event->button() == Qt::RightButton)
|
if(event->button() == Qt::RightButton)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if(!getViewport())
|
if(!getViewport())
|
||||||
{
|
{
|
||||||
SceneWidget::mouseReleaseEvent(event);
|
SceneWidget::mouseReleaseEvent(event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
mMouse->mouseReleaseEvent(event);
|
mMouse->mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
SceneWidget::mouseReleaseEvent(event);
|
SceneWidget::mouseReleaseEvent(event);
|
||||||
|
|
|
@ -30,8 +30,8 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo
|
||||||
|
|
||||||
CSVWidget::SceneToolbar *toolbar = new CSVWidget::SceneToolbar (48+6, this);
|
CSVWidget::SceneToolbar *toolbar = new CSVWidget::SceneToolbar (48+6, this);
|
||||||
|
|
||||||
CSVWidget::SceneToolMode *lightingTool = mScene->makeLightingSelector (toolbar);
|
//CSVWidget::SceneToolMode *lightingTool = mScene->makeLightingSelector (toolbar);
|
||||||
toolbar->addTool (lightingTool);
|
//toolbar->addTool (lightingTool);
|
||||||
|
|
||||||
layout->addWidget (toolbar, 0);
|
layout->addWidget (toolbar, 0);
|
||||||
|
|
||||||
|
|
|
@ -107,8 +107,8 @@ CSVWidget::SceneToolbar* CSVWorld::SceneSubView::makeToolbar (CSVRender::Worldsp
|
||||||
CSVWidget::SceneToolMode *navigationTool = widget->makeNavigationSelector (toolbar);
|
CSVWidget::SceneToolMode *navigationTool = widget->makeNavigationSelector (toolbar);
|
||||||
toolbar->addTool (navigationTool);
|
toolbar->addTool (navigationTool);
|
||||||
|
|
||||||
CSVWidget::SceneToolMode *lightingTool = widget->makeLightingSelector (toolbar);
|
//CSVWidget::SceneToolMode *lightingTool = widget->makeLightingSelector (toolbar);
|
||||||
toolbar->addTool (lightingTool);
|
//toolbar->addTool (lightingTool);
|
||||||
|
|
||||||
CSVWidget::SceneToolToggle2 *sceneVisibilityTool =
|
CSVWidget::SceneToolToggle2 *sceneVisibilityTool =
|
||||||
widget->makeSceneVisibilitySelector (toolbar);
|
widget->makeSceneVisibilitySelector (toolbar);
|
||||||
|
|
Loading…
Reference in a new issue