diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index e1e467889..62747c9b0 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -69,7 +69,7 @@ opencs_units_noqt (view/world ) opencs_units (view/widget - scenetoolbar scenetool scenetoolmode pushbutton + scenetoolbar scenetool scenetoolmode pushbutton scenetooltoggle ) opencs_units (view/render @@ -82,6 +82,10 @@ opencs_units_noqt (view/render lightingbright object cell ) +opencs_hdrs_noqt (view/render + elements + ) + opencs_units (view/tools reportsubview diff --git a/apps/opencs/view/render/elements.hpp b/apps/opencs/view/render/elements.hpp new file mode 100644 index 000000000..784e41212 --- /dev/null +++ b/apps/opencs/view/render/elements.hpp @@ -0,0 +1,23 @@ +#ifndef CSV_RENDER_ELEMENTS_H +#define CSV_RENDER_ELEMENTS_H + +namespace CSVRender +{ + /// Visual elements in a scene + enum Elements + { + // elements that are part of the actual scene + Element_Reference = 0x1, + Element_Terrain = 0x2, + Element_Water = 0x4, + Element_Pathgrid = 0x8, + Element_Fog = 0x10, + + // control elements + Element_CellMarker = 0x10000, + Element_CellArrow = 0x20000, + Element_CellBorder = 0x40000 + }; +} + +#endif diff --git a/apps/opencs/view/render/object.cpp b/apps/opencs/view/render/object.cpp index bb7c2f386..359392d81 100644 --- a/apps/opencs/view/render/object.cpp +++ b/apps/opencs/view/render/object.cpp @@ -9,6 +9,8 @@ #include "../../model/world/ref.hpp" #include "../../model/world/refidcollection.hpp" +#include "elements.hpp" + void CSVRender::Object::clearSceneNode (Ogre::SceneNode *node) { for (Ogre::SceneNode::ObjectIterator iter = node->getAttachedObjectIterator(); @@ -63,12 +65,14 @@ void CSVRender::Object::update() { Ogre::Entity* entity = mBase->getCreator()->createEntity (Ogre::SceneManager::PT_CUBE); entity->setMaterialName("BaseWhite"); /// \todo adjust material according to error + entity->setVisibilityFlags (Element_Reference); mBase->attachObject (entity); } else { mObject = NifOgre::Loader::createObjects (mBase, "Meshes\\" + model); + mObject->setVisibilityFlags (Element_Reference); } } diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index 1ee32fa97..21d88fb89 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -10,6 +10,10 @@ #include "../../model/world/tablemimedata.hpp" #include "../../model/world/idtable.hpp" +#include "../widget/scenetooltoggle.hpp" + +#include "elements.hpp" + bool CSVRender::PagedWorldspaceWidget::adjustCells() { bool modified = false; @@ -237,6 +241,31 @@ CSVRender::WorldspaceWidget::dropRequirments CSVRender::PagedWorldspaceWidget::g } } + +unsigned int CSVRender::PagedWorldspaceWidget::getElementMask() const +{ + return WorldspaceWidget::getElementMask() | mControlElements->getSelection(); +} + +CSVWidget::SceneToolToggle *CSVRender::PagedWorldspaceWidget::makeControlVisibilitySelector ( + CSVWidget::SceneToolbar *parent) +{ + mControlElements = new CSVWidget::SceneToolToggle (parent, + "Controls & Guides Visibility", ":door.png"); + + mControlElements->addButton (":activator.png", Element_CellMarker, ":activator.png", + "Cell marker"); + mControlElements->addButton (":armor.png", Element_CellArrow, ":armor.png", "Cell arrows"); + mControlElements->addButton (":armor.png", Element_CellBorder, ":armor.png", "Cell border"); + + mControlElements->setSelection (0xffffffff); + + connect (mControlElements, SIGNAL (selectionChanged()), + this, SLOT (elementSelectionChanged())); + + return mControlElements; +} + void CSVRender::PagedWorldspaceWidget::cellDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight) { diff --git a/apps/opencs/view/render/pagedworldspacewidget.hpp b/apps/opencs/view/render/pagedworldspacewidget.hpp index c4fb789ee..ec4485697 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.hpp +++ b/apps/opencs/view/render/pagedworldspacewidget.hpp @@ -18,6 +18,7 @@ namespace CSVRender CSMWorld::CellSelection mSelection; std::map mCells; std::string mWorldspace; + CSVWidget::SceneToolToggle *mControlElements; private: @@ -58,6 +59,13 @@ namespace CSVRender virtual dropRequirments getDropRequirements(dropType type) const; + /// \attention The created tool is not added to the toolbar (via addTool). Doing + /// that is the responsibility of the calling function. + virtual CSVWidget::SceneToolToggle *makeControlVisibilitySelector ( + CSVWidget::SceneToolbar *parent); + + virtual unsigned int getElementMask() const; + signals: void cellSelectionChanged (const CSMWorld::CellSelection& selection); diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 494229600..1a720ff33 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -126,7 +126,9 @@ namespace CSVRender #endif mWindow = Ogre::Root::getSingleton().createRenderWindow(windowTitle.str(), this->width(), this->height(), false, ¶ms); - mWindow->addViewport(mCamera)->setBackgroundColour(Ogre::ColourValue(0.3,0.3,0.3,1)); + + mViewport = mWindow->addViewport (mCamera); + mViewport->setBackgroundColour (Ogre::ColourValue (0.3,0.3,0.3,1)); Ogre::Real aspectRatio = Ogre::Real(width()) / Ogre::Real(height()); mCamera->setAspectRatio(aspectRatio); @@ -141,6 +143,11 @@ namespace CSVRender Ogre::Root::getSingleton().destroySceneManager (mSceneMgr); } + void SceneWidget::setVisibilityMask (unsigned int mask) + { + mViewport->setVisibilityMask (mask); + } + void SceneWidget::setNavigation (Navigation *navigation) { if ((mNavigation = navigation)) diff --git a/apps/opencs/view/render/scenewidget.hpp b/apps/opencs/view/render/scenewidget.hpp index 8f548f483..9f79aee17 100644 --- a/apps/opencs/view/render/scenewidget.hpp +++ b/apps/opencs/view/render/scenewidget.hpp @@ -14,6 +14,7 @@ namespace Ogre class Camera; class SceneManager; class RenderWindow; + class Viewport; } namespace CSVWidget @@ -42,6 +43,8 @@ namespace CSVRender ///< \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); + protected: void setNavigation (Navigation *navigation); @@ -85,6 +88,7 @@ namespace CSVRender Ogre::Camera* mCamera; Ogre::SceneManager* mSceneMgr; Ogre::RenderWindow* mWindow; + Ogre::Viewport *mViewport; Navigation *mNavigation; Lighting *mLighting; diff --git a/apps/opencs/view/render/unpagedworldspacewidget.cpp b/apps/opencs/view/render/unpagedworldspacewidget.cpp index 0b656ddc6..5175eba6e 100644 --- a/apps/opencs/view/render/unpagedworldspacewidget.cpp +++ b/apps/opencs/view/render/unpagedworldspacewidget.cpp @@ -11,6 +11,10 @@ #include "../../model/world/idtable.hpp" #include "../../model/world/tablemimedata.hpp" +#include "../widget/scenetooltoggle.hpp" + +#include "elements.hpp" + void CSVRender::UnpagedWorldspaceWidget::update() { const CSMWorld::Record& record = @@ -25,6 +29,14 @@ void CSVRender::UnpagedWorldspaceWidget::update() flagAsModified(); } +void CSVRender::UnpagedWorldspaceWidget::addVisibilitySelectorButtons ( + CSVWidget::SceneToolToggle *tool) +{ + WorldspaceWidget::addVisibilitySelectorButtons (tool); + + tool->addButton (":armor.png", Element_Fog, ":armor.png", "Fog"); +} + CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document, QWidget* parent) : WorldspaceWidget (document, parent), mCellId (cellId) { diff --git a/apps/opencs/view/render/unpagedworldspacewidget.hpp b/apps/opencs/view/render/unpagedworldspacewidget.hpp index ee8377fae..505d60735 100644 --- a/apps/opencs/view/render/unpagedworldspacewidget.hpp +++ b/apps/opencs/view/render/unpagedworldspacewidget.hpp @@ -32,6 +32,10 @@ namespace CSVRender void update(); + protected: + + virtual void addVisibilitySelectorButtons (CSVWidget::SceneToolToggle *tool); + public: UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document, diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index 57ed06212..4d3c7f666 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -10,6 +10,9 @@ #include "../../model/world/universalid.hpp" #include "../widget/scenetoolmode.hpp" +#include "../widget/scenetooltoggle.hpp" + +#include "elements.hpp" CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent) : SceneWidget (parent), mDocument(document) @@ -94,6 +97,21 @@ CSVWidget::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector ( return tool; } +CSVWidget::SceneToolToggle *CSVRender::WorldspaceWidget::makeSceneVisibilitySelector (CSVWidget::SceneToolbar *parent) +{ + mSceneElements= new CSVWidget::SceneToolToggle (parent, + "Scene Element Visibility", ":door.png"); + + addVisibilitySelectorButtons (mSceneElements); + + mSceneElements->setSelection (0xffffffff); + + connect (mSceneElements, SIGNAL (selectionChanged()), + this, SLOT (elementSelectionChanged())); + + return mSceneElements; +} + CSVRender::WorldspaceWidget::dropType CSVRender::WorldspaceWidget::getDropType ( const std::vector< CSMWorld::UniversalId >& data) { @@ -147,6 +165,20 @@ CSVRender::WorldspaceWidget::dropType CSVRender::WorldspaceWidget::getDropType ( return output; } +unsigned int CSVRender::WorldspaceWidget::getElementMask() const +{ + return mSceneElements->getSelection(); +} + +void CSVRender::WorldspaceWidget::addVisibilitySelectorButtons ( + CSVWidget::SceneToolToggle *tool) +{ + tool->addButton (":activator.png", Element_Reference, ":activator.png", "References"); + tool->addButton (":armor.png", Element_Terrain, ":armor.png", "Terrain"); + tool->addButton (":armor.png", Element_Water, ":armor.png", "Water"); + tool->addButton (":armor.png", Element_Pathgrid, ":armor.png", "Pathgrid"); +} + void CSVRender::WorldspaceWidget::dragEnterEvent (QDragEnterEvent* event) { event->accept(); @@ -157,7 +189,6 @@ void CSVRender::WorldspaceWidget::dragMoveEvent(QDragMoveEvent *event) event->accept(); } - void CSVRender::WorldspaceWidget::dropEvent (QDropEvent* event) { const CSMWorld::TableMimeData* mime = dynamic_cast (event->mimeData()); @@ -169,3 +200,9 @@ void CSVRender::WorldspaceWidget::dropEvent (QDropEvent* event) emit dataDropped(mime->getData()); } //not handling drops from different documents at the moment } + +void CSVRender::WorldspaceWidget::elementSelectionChanged() +{ + setVisibilityMask (getElementMask()); + flagAsModified(); +} diff --git a/apps/opencs/view/render/worldspacewidget.hpp b/apps/opencs/view/render/worldspacewidget.hpp index 3b96779a8..e21ad5ec2 100644 --- a/apps/opencs/view/render/worldspacewidget.hpp +++ b/apps/opencs/view/render/worldspacewidget.hpp @@ -16,6 +16,7 @@ namespace CSMWorld namespace CSVWidget { class SceneToolMode; + class SceneToolToggle; class SceneToolbar; } @@ -28,6 +29,7 @@ namespace CSVRender CSVRender::Navigation1st m1st; CSVRender::NavigationFree mFree; CSVRender::NavigationOrbit mOrbit; + CSVWidget::SceneToolToggle *mSceneElements; public: @@ -53,6 +55,11 @@ namespace CSVRender ///< \attention The created tool is not added to the toolbar (via addTool). Doing that /// is the responsibility of the calling function. + /// \attention The created tool is not added to the toolbar (via addTool). Doing + /// that is the responsibility of the calling function. + CSVWidget::SceneToolToggle *makeSceneVisibilitySelector ( + CSVWidget::SceneToolbar *parent); + void selectDefaultNavigationMode(); static dropType getDropType(const std::vector& data); @@ -64,8 +71,13 @@ namespace CSVRender virtual void handleDrop(const std::vector& data) = 0; + virtual unsigned int getElementMask() const; + protected: - const CSMDoc::Document& mDocument; //for checking if drop comes from same document + + virtual void addVisibilitySelectorButtons (CSVWidget::SceneToolToggle *tool); + + const CSMDoc::Document& mDocument; private: @@ -92,6 +104,10 @@ namespace CSVRender virtual void referenceAdded (const QModelIndex& index, int start, int end) = 0; + protected slots: + + void elementSelectionChanged(); + signals: void closeRequest(); diff --git a/apps/opencs/view/widget/pushbutton.cpp b/apps/opencs/view/widget/pushbutton.cpp index 056e548fb..ccf89e18a 100644 --- a/apps/opencs/view/widget/pushbutton.cpp +++ b/apps/opencs/view/widget/pushbutton.cpp @@ -26,6 +26,14 @@ void CSVWidget::PushButton::setExtendedToolTip (const QString& text) "

(left click to activate," "
shift-left click to activate and keep panel open)"; + case Type_Toggle: + + tooltip += "

(left click to "; + tooltip += isChecked() ? "disable" : "enable"; + tooltip += "

shift-left click to "; + tooltip += isChecked() ? "disable" : "enable"; + tooltip += " and keep panel open)"; + break; } @@ -45,6 +53,9 @@ void CSVWidget::PushButton::keyReleaseEvent (QKeyEvent *event) if (event->key()==Qt::Key_Return || event->key()==Qt::Key_Enter) { mKeepOpen = event->modifiers() & Qt::ShiftModifier; + + setChecked (!isChecked()); + emit clicked(); } @@ -61,14 +72,14 @@ CSVWidget::PushButton::PushButton (const QIcon& icon, Type type, const QString& QWidget *parent) : QPushButton (icon, "", parent), mKeepOpen (false), mType (type), mToolTip (tooltip) { - setCheckable (type==Type_Mode); + setCheckable (type==Type_Mode || type==Type_Toggle); setExtendedToolTip (tooltip); } CSVWidget::PushButton::PushButton (Type type, const QString& tooltip, QWidget *parent) : QPushButton (parent), mKeepOpen (false), mType (type), mToolTip (tooltip) { - setCheckable (type==Type_Mode); + setCheckable (type==Type_Mode || type==Type_Toggle); setExtendedToolTip (tooltip); } diff --git a/apps/opencs/view/widget/pushbutton.hpp b/apps/opencs/view/widget/pushbutton.hpp index 9b90bd0c6..eae0f0a24 100644 --- a/apps/opencs/view/widget/pushbutton.hpp +++ b/apps/opencs/view/widget/pushbutton.hpp @@ -14,7 +14,8 @@ namespace CSVWidget enum Type { Type_TopMode, // top level button for mode selector panel - Type_Mode // mode button + Type_Mode, // mode button + Type_Toggle }; private: diff --git a/apps/opencs/view/widget/scenetooltoggle.cpp b/apps/opencs/view/widget/scenetooltoggle.cpp new file mode 100644 index 000000000..07c448e45 --- /dev/null +++ b/apps/opencs/view/widget/scenetooltoggle.cpp @@ -0,0 +1,205 @@ + +#include "scenetooltoggle.hpp" + +#include + +#include +#include +#include +#include + +#include "scenetoolbar.hpp" +#include "pushbutton.hpp" + +void CSVWidget::SceneToolToggle::adjustToolTip() +{ + QString toolTip = mToolTip; + + toolTip += "

Currently enabled: "; + + bool first = true; + + for (std::map::const_iterator iter (mButtons.begin()); + iter!=mButtons.end(); ++iter) + if (iter->first->isChecked()) + { + if (!first) + toolTip += ", "; + else + first = false; + + toolTip += iter->second.mName; + } + + if (first) + toolTip += "none"; + + toolTip += "

(left click to alter selection)"; + + setToolTip (toolTip); +} + +void CSVWidget::SceneToolToggle::adjustIcon() +{ + unsigned int selection = getSelection(); + if (!selection) + setIcon (QIcon (QString::fromUtf8 (mEmptyIcon.c_str()))); + else + { + QPixmap pixmap (48, 48); + pixmap.fill (QColor (0, 0, 0, 0)); + + { + QPainter painter (&pixmap); + + for (std::map::const_iterator iter (mButtons.begin()); + iter!=mButtons.end(); ++iter) + if (iter->first->isChecked()) + { + painter.drawImage (getIconBox (iter->second.mIndex), + QImage (QString::fromUtf8 (iter->second.mSmallIcon.c_str()))); + } + } + + setIcon (pixmap); + } +} + +QRect CSVWidget::SceneToolToggle::getIconBox (int index) const +{ + // layout for a 3x3 grid + int xMax = 3; + int yMax = 3; + + // icon size + int xBorder = 1; + int yBorder = 1; + + int iconXSize = (mIconSize-xBorder*(xMax+1))/xMax; + int iconYSize = (mIconSize-yBorder*(yMax+1))/yMax; + + int y = index / xMax; + int x = index % xMax; + + int total = mButtons.size(); + + int actualYIcons = total/xMax; + + if (total % xMax) + ++actualYIcons; + + if (actualYIcons!=yMax) + { + // space out icons vertically, if there aren't enough to populate all rows + int diff = yMax - actualYIcons; + yBorder += (diff*(yBorder+iconXSize)) / (actualYIcons+1); + } + + if (y==actualYIcons-1) + { + // generating the last row of icons + int actualXIcons = total % xMax; + + if (actualXIcons) + { + // space out icons horizontally, if there aren't enough to fill the last row + int diff = xMax - actualXIcons; + + xBorder += (diff*(xBorder+iconXSize)) / (actualXIcons+1); + } + } + + return QRect ((iconXSize+xBorder)*x+xBorder, (iconYSize+yBorder)*y+yBorder, + iconXSize, iconYSize); +} + +CSVWidget::SceneToolToggle::SceneToolToggle (SceneToolbar *parent, const QString& toolTip, + const std::string& emptyIcon) +: SceneTool (parent), mEmptyIcon (emptyIcon), mButtonSize (parent->getButtonSize()), + mIconSize (parent->getIconSize()), mToolTip (toolTip), mFirst (0) +{ + mPanel = new QFrame (this, Qt::Popup); + + mLayout = new QHBoxLayout (mPanel); + + mLayout->setContentsMargins (QMargins (0, 0, 0, 0)); + + mPanel->setLayout (mLayout); +} + +void CSVWidget::SceneToolToggle::showPanel (const QPoint& position) +{ + mPanel->move (position); + mPanel->show(); + + if (mFirst) + mFirst->setFocus (Qt::OtherFocusReason); +} + +void CSVWidget::SceneToolToggle::addButton (const std::string& icon, unsigned int id, + const std::string& smallIcon, const QString& name, const QString& tooltip) +{ + if (mButtons.size()>=9) + throw std::runtime_error ("Exceeded number of buttons in toggle type tool"); + + PushButton *button = new PushButton (QIcon (QPixmap (icon.c_str())), + PushButton::Type_Toggle, tooltip.isEmpty() ? name: tooltip, mPanel); + + button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed)); + button->setIconSize (QSize (mIconSize, mIconSize)); + button->setFixedSize (mButtonSize, mButtonSize); + + mLayout->addWidget (button); + + ButtonDesc desc; + desc.mId = id; + desc.mSmallIcon = smallIcon; + desc.mName = name; + desc.mIndex = mButtons.size(); + + mButtons.insert (std::make_pair (button, desc)); + + connect (button, SIGNAL (clicked()), this, SLOT (selected())); + + if (mButtons.size()==1) + mFirst = button; +} + +unsigned int CSVWidget::SceneToolToggle::getSelection() const +{ + unsigned int selection = 0; + + for (std::map::const_iterator iter (mButtons.begin()); + iter!=mButtons.end(); ++iter) + if (iter->first->isChecked()) + selection |= iter->second.mId; + + return selection; +} + +void CSVWidget::SceneToolToggle::setSelection (unsigned int selection) +{ + for (std::map::iterator iter (mButtons.begin()); + iter!=mButtons.end(); ++iter) + iter->first->setChecked (selection & iter->second.mId); + + adjustToolTip(); + adjustIcon(); +} + +void CSVWidget::SceneToolToggle::selected() +{ + std::map::const_iterator iter = + mButtons.find (dynamic_cast (sender())); + + if (iter!=mButtons.end()) + { + if (!iter->first->hasKeepOpen()) + mPanel->hide(); + + adjustToolTip(); + adjustIcon(); + + emit selectionChanged(); + } +} diff --git a/apps/opencs/view/widget/scenetooltoggle.hpp b/apps/opencs/view/widget/scenetooltoggle.hpp new file mode 100644 index 000000000..55e697524 --- /dev/null +++ b/apps/opencs/view/widget/scenetooltoggle.hpp @@ -0,0 +1,75 @@ +#ifndef CSV_WIDGET_SCENETOOL_TOGGLE_H +#define CSV_WIDGET_SCENETOOL_TOGGLE_H + +#include "scenetool.hpp" + +#include + +class QHBoxLayout; +class QRect; + +namespace CSVWidget +{ + class SceneToolbar; + class PushButton; + + ///< \brief Multi-Toggle tool + class SceneToolToggle : public SceneTool + { + Q_OBJECT + + struct ButtonDesc + { + unsigned int mId; + std::string mSmallIcon; + QString mName; + int mIndex; + }; + + std::string mEmptyIcon; + QWidget *mPanel; + QHBoxLayout *mLayout; + std::map mButtons; // widget, id + int mButtonSize; + int mIconSize; + QString mToolTip; + PushButton *mFirst; + + void adjustToolTip(); + + void adjustIcon(); + + QRect getIconBox (int index) const; + + public: + + SceneToolToggle (SceneToolbar *parent, const QString& toolTip, + const std::string& emptyIcon); + + virtual void showPanel (const QPoint& position); + + /// \attention After the last button has been added, setSelection must be called at + /// least once to finalise the layout. + /// + /// \note The layout algorithm can not handle more than 9 buttons. To prevent this An + /// attempt to add more will result in an exception being thrown. + /// The small icons will be sized at (x-4)/3 (where x is the main icon size). + void addButton (const std::string& icon, unsigned int id, + const std::string& smallIcon, const QString& name, const QString& tooltip = ""); + + unsigned int getSelection() const; + + /// \param or'ed button IDs. IDs that do not exist will be ignored. + void setSelection (unsigned int selection); + + signals: + + void selectionChanged(); + + private slots: + + void selected(); + }; +} + +#endif diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index dc1525b05..3c5b38a22 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -19,6 +19,7 @@ #include "../widget/scenetoolbar.hpp" #include "../widget/scenetoolmode.hpp" +#include "../widget/scenetooltoggle.hpp" #include "tablebottombox.hpp" #include "creator.hpp" @@ -107,18 +108,19 @@ CSVWidget::SceneToolbar* CSVWorld::SceneSubView::makeToolbar (CSVRender::Worldsp CSVWidget::SceneToolMode *lightingTool = widget->makeLightingSelector (toolbar); toolbar->addTool (lightingTool); -/* Add buttons specific to the type. For now no need for it. - * - switch (type) + CSVWidget::SceneToolToggle *sceneVisibilityTool = + widget->makeSceneVisibilitySelector (toolbar); + toolbar->addTool (sceneVisibilityTool); + + if (type==widget_Paged) { - case widget_Paged: - break; - - case widget_Unpaged: - break; + CSVWidget::SceneToolToggle *controlVisibilityTool = + dynamic_cast (*widget). + makeControlVisibilitySelector (toolbar); + toolbar->addTool (controlVisibilityTool); } -*/ + return toolbar; } diff --git a/components/nifogre/ogrenifloader.cpp b/components/nifogre/ogrenifloader.cpp index c39c62b67..750fa8167 100644 --- a/components/nifogre/ogrenifloader.cpp +++ b/components/nifogre/ogrenifloader.cpp @@ -115,6 +115,24 @@ ObjectScene::~ObjectScene() mSkelBase = NULL; } +void ObjectScene::setVisibilityFlags (unsigned int flags) +{ + if (mSkelBase) + mSkelBase->setVisibilityFlags (flags); + + for (std::vector::iterator iter (mEntities.begin()); iter!=mEntities.end(); + ++iter) + (*iter)->setVisibilityFlags (flags); + + for (std::vector::iterator iter (mParticles.begin()); + iter!=mParticles.end(); ++iter) + (*iter)->setVisibilityFlags (flags); + + for (std::vector::iterator iter (mLights.begin()); iter!=mLights.end(); + ++iter) + (*iter)->setVisibilityFlags (flags); +} + void ObjectScene::rotateBillboardNodes(Ogre::Camera *camera) { for (std::vector::iterator it = mBillboardNodes.begin(); it != mBillboardNodes.end(); ++it) diff --git a/components/nifogre/ogrenifloader.hpp b/components/nifogre/ogrenifloader.hpp index 011245bea..abadd38de 100644 --- a/components/nifogre/ogrenifloader.hpp +++ b/components/nifogre/ogrenifloader.hpp @@ -82,6 +82,8 @@ struct ObjectScene { // Rotate nodes in mBillboardNodes so they face the given camera void rotateBillboardNodes(Ogre::Camera* camera); + + void setVisibilityFlags (unsigned int flags); }; typedef Ogre::SharedPtr ObjectScenePtr;