ambient lighting in interior cells

actorid
Marc Zinnschlag 11 years ago
parent 7e0f0c8402
commit 4a119c8f46

@ -59,6 +59,11 @@ namespace CSVRender
timer->start (20); /// \todo make this configurable
}
void SceneWidget::setAmbient (const Ogre::ColourValue& colour)
{
mSceneMgr->setAmbientLight (colour);
}
void SceneWidget::updateOgreWindow()
{
if (mWindow)

@ -8,6 +8,7 @@ namespace Ogre
class Camera;
class SceneManager;
class RenderWindow;
class ColourValue;
}
namespace CSVRender
@ -25,6 +26,9 @@ namespace CSVRender
QPaintEngine* paintEngine() const;
void setAmbient (const Ogre::ColourValue& colour);
///< \note The actual ambient colour may differ based on lighting settings.
protected:
void setNavigation (Navigation *navigation);

@ -1,6 +1,60 @@
#include "unpagedworldspacewidget.hpp"
CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (QWidget *parent)
: WorldspaceWidget (parent)
{}
#include <OgreColourValue.h>
#include "../../model/doc/document.hpp"
#include "../../model/world/data.hpp"
#include "../../model/world/idtable.hpp"
void CSVRender::UnpagedWorldspaceWidget::update()
{
const CSMWorld::Record<CSMWorld::Cell>& record =
dynamic_cast<const CSMWorld::Record<CSMWorld::Cell>&> (mCellsModel->getRecord (mCellId));
Ogre::ColourValue colour;
colour.setAsABGR (record.get().mAmbi.mAmbient);
setAmbient (colour);
/// \todo deal with mSunlight and mFog/mForDensity
}
CSVRender::UnpagedWorldspaceWidget::UnpagedWorldspaceWidget (const std::string& cellId,
CSMDoc::Document& document, QWidget *parent)
: WorldspaceWidget (parent), mCellId (cellId)
{
mCellsModel = &dynamic_cast<CSMWorld::IdTable&> (
*document.getData().getTableModel (CSMWorld::UniversalId::Type_Cells));
connect (mCellsModel, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)),
this, SLOT (cellDataChanged (const QModelIndex&, const QModelIndex&)));
connect (mCellsModel, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
this, SLOT (cellRowsAboutToBeRemoved (const QModelIndex&, int, int)));
update();
}
void CSVRender::UnpagedWorldspaceWidget::cellDataChanged (const QModelIndex& topLeft,
const QModelIndex& bottomRight)
{
QModelIndex cellIndex = mCellsModel->getModelIndex (mCellId, 0);
if (cellIndex.row()>=topLeft.row() && cellIndex.row()<bottomRight.row())
{
/// \todo possible optimisation: check columns and update only if relevant columns have
/// changed
update();
}
}
void CSVRender::UnpagedWorldspaceWidget::cellRowsAboutToBeRemoved (const QModelIndex& parent,
int start, int end)
{
QModelIndex cellIndex = mCellsModel->getModelIndex (mCellId, 0);
if (cellIndex.row()>=start && cellIndex.row()<=end)
{
}
}

@ -1,17 +1,43 @@
#ifndef OPENCS_VIEW_UNPAGEDWORLDSPACEWIDGET_H
#define OPENCS_VIEW_UNPAGEDWORLDSPACEWIDGET_H
#include <string>
#include "worldspacewidget.hpp"
class QModelIndex;
namespace CSMDoc
{
class Document;
}
namespace CSMWorld
{
class IdTable;
}
namespace CSVRender
{
class UnpagedWorldspaceWidget : public WorldspaceWidget
{
Q_OBJECT
std::string mCellId;
CSMWorld::IdTable *mCellsModel;
void update();
public:
UnpagedWorldspaceWidget (QWidget *parent);
UnpagedWorldspaceWidget (const std::string& cellId, CSMDoc::Document& document,
QWidget *parent);
private slots:
void cellDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight);
void cellRowsAboutToBeRemoved (const QModelIndex& parent, int start, int end);
};
}

@ -37,7 +37,7 @@ CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::D
if (id.getId()[0]=='#')
mScene = new CSVRender::PagedWorldspaceWidget (this);
else
mScene = new CSVRender::UnpagedWorldspaceWidget (this);
mScene = new CSVRender::UnpagedWorldspaceWidget (id.getId(), document, this);
SceneToolMode *tool = mScene->makeNavigationSelector (toolbar);
toolbar->addTool (tool);

Loading…
Cancel
Save