forked from teamnwah/openmw-tes3coop
OpenCS: preliminary port of PreviewWidget to OSG
This commit is contained in:
parent
34d503017a
commit
af27a10b0c
13 changed files with 92 additions and 79 deletions
|
@ -2245,12 +2245,12 @@ void CSMDoc::Document::createBase()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMDoc::Document::Document (const Files::ConfigurationManager& configuration,
|
CSMDoc::Document::Document (const VFS::Manager* vfs, const Files::ConfigurationManager& configuration,
|
||||||
const std::vector< boost::filesystem::path >& files, bool new_,
|
const std::vector< boost::filesystem::path >& files, bool new_,
|
||||||
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir,
|
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir,
|
||||||
ToUTF8::FromType encoding, const CSMWorld::ResourcesManager& resourcesManager,
|
ToUTF8::FromType encoding, const CSMWorld::ResourcesManager& resourcesManager,
|
||||||
const std::vector<std::string>& blacklistedScripts)
|
const std::vector<std::string>& blacklistedScripts)
|
||||||
: mSavePath (savePath), mContentFiles (files), mNew (new_), mData (encoding, resourcesManager),
|
: mVFS(vfs), mSavePath (savePath), mContentFiles (files), mNew (new_), mData (encoding, resourcesManager),
|
||||||
mTools (*this), mResDir(resDir),
|
mTools (*this), mResDir(resDir),
|
||||||
mProjectPath ((configuration.getUserDataPath() / "projects") /
|
mProjectPath ((configuration.getUserDataPath() / "projects") /
|
||||||
(savePath.filename().string() + ".project")),
|
(savePath.filename().string() + ".project")),
|
||||||
|
@ -2311,6 +2311,11 @@ CSMDoc::Document::~Document()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const VFS::Manager *CSMDoc::Document::getVFS() const
|
||||||
|
{
|
||||||
|
return mVFS;
|
||||||
|
}
|
||||||
|
|
||||||
QUndoStack& CSMDoc::Document::getUndoStack()
|
QUndoStack& CSMDoc::Document::getUndoStack()
|
||||||
{
|
{
|
||||||
return mUndoStack;
|
return mUndoStack;
|
||||||
|
|
|
@ -23,6 +23,12 @@
|
||||||
|
|
||||||
class QAbstractItemModel;
|
class QAbstractItemModel;
|
||||||
|
|
||||||
|
namespace VFS
|
||||||
|
{
|
||||||
|
|
||||||
|
class Manager;
|
||||||
|
}
|
||||||
|
|
||||||
namespace ESM
|
namespace ESM
|
||||||
{
|
{
|
||||||
struct GameSetting;
|
struct GameSetting;
|
||||||
|
@ -53,6 +59,7 @@ namespace CSMDoc
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
const VFS::Manager* mVFS;
|
||||||
boost::filesystem::path mSavePath;
|
boost::filesystem::path mSavePath;
|
||||||
std::vector<boost::filesystem::path> mContentFiles;
|
std::vector<boost::filesystem::path> mContentFiles;
|
||||||
bool mNew;
|
bool mNew;
|
||||||
|
@ -91,7 +98,7 @@ namespace CSMDoc
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Document (const Files::ConfigurationManager& configuration,
|
Document (const VFS::Manager* vfs, const Files::ConfigurationManager& configuration,
|
||||||
const std::vector< boost::filesystem::path >& files, bool new_,
|
const std::vector< boost::filesystem::path >& files, bool new_,
|
||||||
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir,
|
const boost::filesystem::path& savePath, const boost::filesystem::path& resDir,
|
||||||
ToUTF8::FromType encoding, const CSMWorld::ResourcesManager& resourcesManager,
|
ToUTF8::FromType encoding, const CSMWorld::ResourcesManager& resourcesManager,
|
||||||
|
@ -99,6 +106,8 @@ namespace CSMDoc
|
||||||
|
|
||||||
~Document();
|
~Document();
|
||||||
|
|
||||||
|
const VFS::Manager* getVFS() const;
|
||||||
|
|
||||||
QUndoStack& getUndoStack();
|
QUndoStack& getUndoStack();
|
||||||
|
|
||||||
int getState() const;
|
int getState() const;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include "document.hpp"
|
#include "document.hpp"
|
||||||
|
|
||||||
CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& configuration)
|
CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& configuration)
|
||||||
: mConfiguration (configuration), mEncoding (ToUTF8::WINDOWS_1252)
|
: mConfiguration (configuration), mEncoding (ToUTF8::WINDOWS_1252), mVFS(NULL)
|
||||||
{
|
{
|
||||||
boost::filesystem::path projectPath = configuration.getUserDataPath() / "projects";
|
boost::filesystem::path projectPath = configuration.getUserDataPath() / "projects";
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ CSMDoc::DocumentManager::~DocumentManager()
|
||||||
void CSMDoc::DocumentManager::addDocument (const std::vector<boost::filesystem::path>& files, const boost::filesystem::path& savePath,
|
void CSMDoc::DocumentManager::addDocument (const std::vector<boost::filesystem::path>& files, const boost::filesystem::path& savePath,
|
||||||
bool new_)
|
bool new_)
|
||||||
{
|
{
|
||||||
Document *document = new Document (mConfiguration, files, new_, savePath, mResDir, mEncoding, mResourcesManager, mBlacklistedScripts);
|
Document *document = new Document (mVFS, mConfiguration, files, new_, savePath, mResDir, mEncoding, mResourcesManager, mBlacklistedScripts);
|
||||||
|
|
||||||
mDocuments.push_back (document);
|
mDocuments.push_back (document);
|
||||||
|
|
||||||
|
@ -107,4 +107,5 @@ void CSMDoc::DocumentManager::documentNotLoaded (Document *document, const std::
|
||||||
void CSMDoc::DocumentManager::setVFS(const VFS::Manager *vfs)
|
void CSMDoc::DocumentManager::setVFS(const VFS::Manager *vfs)
|
||||||
{
|
{
|
||||||
mResourcesManager.setVFS(vfs);
|
mResourcesManager.setVFS(vfs);
|
||||||
|
mVFS = vfs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace CSMDoc
|
||||||
ToUTF8::FromType mEncoding;
|
ToUTF8::FromType mEncoding;
|
||||||
CSMWorld::ResourcesManager mResourcesManager;
|
CSMWorld::ResourcesManager mResourcesManager;
|
||||||
std::vector<std::string> mBlacklistedScripts;
|
std::vector<std::string> mBlacklistedScripts;
|
||||||
VFS::Manager* mVFS;
|
const VFS::Manager* mVFS;
|
||||||
|
|
||||||
DocumentManager (const DocumentManager&);
|
DocumentManager (const DocumentManager&);
|
||||||
DocumentManager& operator= (const DocumentManager&);
|
DocumentManager& operator= (const DocumentManager&);
|
||||||
|
|
|
@ -51,7 +51,7 @@ bool CSVRender::Cell::addObjects (int start, int end)
|
||||||
std::string id = Misc::StringUtils::lowerCase (references.data (
|
std::string id = Misc::StringUtils::lowerCase (references.data (
|
||||||
references.index (i, idColumn)).toString().toUtf8().constData());
|
references.index (i, idColumn)).toString().toUtf8().constData());
|
||||||
|
|
||||||
mObjects.insert (std::make_pair (id, new Object (mData, mCellNode, id, false, mPhysics)));
|
//mObjects.insert (std::make_pair (id, new Object (mData, mCellNode, id, false, mPhysics)));
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,8 +191,8 @@ bool CSVRender::Cell::referenceDataChanged (const QModelIndex& topLeft,
|
||||||
// add new objects
|
// add new objects
|
||||||
for (std::map<std::string, bool>::iterator iter (ids.begin()); iter!=ids.end(); ++iter)
|
for (std::map<std::string, bool>::iterator iter (ids.begin()); iter!=ids.end(); ++iter)
|
||||||
{
|
{
|
||||||
mObjects.insert (std::make_pair (
|
//mObjects.insert (std::make_pair (
|
||||||
iter->first, new Object (mData, mCellNode, iter->first, false, mPhysics)));
|
// iter->first, new Object (mData, mCellNode, iter->first, false, mPhysics)));
|
||||||
|
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
|
|
||||||
#include "object.hpp"
|
#include "object.hpp"
|
||||||
|
|
||||||
#include <OgreSceneManager.h>
|
#include <osg/Group>
|
||||||
#include <OgreSceneNode.h>
|
|
||||||
#include <OgreEntity.h>
|
|
||||||
|
|
||||||
#include "../../model/world/data.hpp"
|
#include "../../model/world/data.hpp"
|
||||||
#include "../../model/world/ref.hpp"
|
#include "../../model/world/ref.hpp"
|
||||||
|
@ -11,43 +8,20 @@
|
||||||
|
|
||||||
#include "../world/physicssystem.hpp"
|
#include "../world/physicssystem.hpp"
|
||||||
|
|
||||||
|
#include <components/nifosg/nifloader.hpp>
|
||||||
|
|
||||||
#include "elements.hpp"
|
#include "elements.hpp"
|
||||||
|
|
||||||
void CSVRender::Object::clearSceneNode (Ogre::SceneNode *node)
|
|
||||||
{
|
|
||||||
for (Ogre::SceneNode::ObjectIterator iter = node->getAttachedObjectIterator();
|
|
||||||
iter.hasMoreElements(); )
|
|
||||||
{
|
|
||||||
Ogre::MovableObject* object = dynamic_cast<Ogre::MovableObject*> (iter.getNext());
|
|
||||||
node->getCreator()->destroyMovableObject (object);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Ogre::SceneNode::ChildNodeIterator iter = node->getChildIterator();
|
|
||||||
iter.hasMoreElements(); )
|
|
||||||
{
|
|
||||||
Ogre::SceneNode* childNode = dynamic_cast<Ogre::SceneNode*> (iter.getNext());
|
|
||||||
clearSceneNode (childNode);
|
|
||||||
node->getCreator()->destroySceneNode (childNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVRender::Object::clear()
|
void CSVRender::Object::clear()
|
||||||
{
|
{
|
||||||
mObject.setNull();
|
|
||||||
|
|
||||||
if (mBase)
|
|
||||||
clearSceneNode (mBase);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::Object::update()
|
void CSVRender::Object::update()
|
||||||
{
|
{
|
||||||
if(!mObject.isNull())
|
|
||||||
mPhysics->removePhysicsObject(mBase->getName());
|
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
std::string model;
|
std::string model;
|
||||||
int error = 0; // 1 referemceanöe does not exist, 2 referenceable does not specify a mesh
|
int error = 0; // 1 referenceable does not exist, 2 referenceable does not specify a mesh
|
||||||
|
|
||||||
const CSMWorld::RefIdCollection& referenceables = mData.getReferenceables();
|
const CSMWorld::RefIdCollection& referenceables = mData.getReferenceables();
|
||||||
|
|
||||||
|
@ -69,17 +43,28 @@ void CSVRender::Object::update()
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
Ogre::Entity* entity = mBase->getCreator()->createEntity (Ogre::SceneManager::PT_CUBE);
|
Ogre::Entity* entity = mBase->getCreator()->createEntity (Ogre::SceneManager::PT_CUBE);
|
||||||
entity->setMaterialName("BaseWhite"); /// \todo adjust material according to error
|
entity->setMaterialName("BaseWhite"); /// \todo adjust material according to error
|
||||||
entity->setVisibilityFlags (Element_Reference);
|
entity->setVisibilityFlags (Element_Reference);
|
||||||
|
|
||||||
mBase->attachObject (entity);
|
mBase->attachObject (entity);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//mObject = NifOgre::Loader::createObjects (mBase, "Meshes\\" + model);
|
NifOsg::Loader loader;
|
||||||
|
loader.resourceManager = mVFS;
|
||||||
|
|
||||||
|
std::string path = "meshes\\" + model;
|
||||||
|
|
||||||
|
Nif::NIFFilePtr file(new Nif::NIFFile(mVFS->get(path), path));
|
||||||
|
|
||||||
|
loader.load(file, mBaseNode);
|
||||||
|
|
||||||
//mObject->setVisibilityFlags (Element_Reference);
|
//mObject->setVisibilityFlags (Element_Reference);
|
||||||
|
|
||||||
|
/*
|
||||||
if (mPhysics && !mReferenceId.empty())
|
if (mPhysics && !mReferenceId.empty())
|
||||||
{
|
{
|
||||||
const CSMWorld::CellRef& reference = getReference();
|
const CSMWorld::CellRef& reference = getReference();
|
||||||
|
@ -96,11 +81,13 @@ void CSVRender::Object::update()
|
||||||
|
|
||||||
mPhysics->addObject("meshes\\" + model, mBase->getName(), mReferenceId, reference.mScale, position, xr*yr*zr);
|
mPhysics->addObject("meshes\\" + model, mBase->getName(), mReferenceId, reference.mScale, position, xr*yr*zr);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::Object::adjust()
|
void CSVRender::Object::adjust()
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
if (mReferenceId.empty())
|
if (mReferenceId.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -122,6 +109,7 @@ void CSVRender::Object::adjust()
|
||||||
|
|
||||||
// scale
|
// scale
|
||||||
mBase->setScale (reference.mScale, reference.mScale, reference.mScale);
|
mBase->setScale (reference.mScale, reference.mScale, reference.mScale);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
const CSMWorld::CellRef& CSVRender::Object::getReference() const
|
const CSMWorld::CellRef& CSVRender::Object::getReference() const
|
||||||
|
@ -132,12 +120,13 @@ const CSMWorld::CellRef& CSVRender::Object::getReference() const
|
||||||
return mData.getReferences().getRecord (mReferenceId).get();
|
return mData.getReferences().getRecord (mReferenceId).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVRender::Object::Object (const CSMWorld::Data& data, Ogre::SceneNode *cellNode,
|
CSVRender::Object::Object (const VFS::Manager* vfs, const CSMWorld::Data& data, osg::Group* parentNode,
|
||||||
const std::string& id, bool referenceable, boost::shared_ptr<CSVWorld::PhysicsSystem> physics,
|
const std::string& id, bool referenceable, boost::shared_ptr<CSVWorld::PhysicsSystem> physics,
|
||||||
bool forceBaseToZero)
|
bool forceBaseToZero)
|
||||||
: mData (data), mBase (0), mForceBaseToZero (forceBaseToZero), mPhysics(physics)
|
: mVFS(vfs), mData (data), mBaseNode(0), mParentNode(parentNode), mForceBaseToZero (forceBaseToZero), mPhysics(physics)
|
||||||
{
|
{
|
||||||
mBase = cellNode->createChildSceneNode();
|
mBaseNode = new osg::Group;
|
||||||
|
parentNode->addChild(mBaseNode);
|
||||||
|
|
||||||
if (referenceable)
|
if (referenceable)
|
||||||
{
|
{
|
||||||
|
@ -157,13 +146,7 @@ CSVRender::Object::~Object()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
if (mBase)
|
mParentNode->removeChild(mBaseNode);
|
||||||
{
|
|
||||||
if(mPhysics) // preview may not have physics enabled
|
|
||||||
mPhysics->removeObject(mBase->getName());
|
|
||||||
|
|
||||||
mBase->getCreator()->destroySceneNode (mBase);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSVRender::Object::referenceableDataChanged (const QModelIndex& topLeft,
|
bool CSVRender::Object::referenceableDataChanged (const QModelIndex& topLeft,
|
||||||
|
|
|
@ -3,15 +3,19 @@
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#ifndef Q_MOC_RUN
|
#include <osg/ref_ptr>
|
||||||
#include <components/nifogre/ogrenifloader.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
|
|
||||||
namespace Ogre
|
|
||||||
|
namespace osg
|
||||||
{
|
{
|
||||||
class SceneNode;
|
class Group;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace VFS
|
||||||
|
{
|
||||||
|
class Manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace CSMWorld
|
namespace CSMWorld
|
||||||
|
@ -32,8 +36,9 @@ namespace CSVRender
|
||||||
const CSMWorld::Data& mData;
|
const CSMWorld::Data& mData;
|
||||||
std::string mReferenceId;
|
std::string mReferenceId;
|
||||||
std::string mReferenceableId;
|
std::string mReferenceableId;
|
||||||
Ogre::SceneNode *mBase;
|
osg::ref_ptr<osg::Group> mBaseNode;
|
||||||
NifOgre::ObjectScenePtr mObject;
|
osg::Group* mParentNode;
|
||||||
|
const VFS::Manager* mVFS;
|
||||||
bool mForceBaseToZero;
|
bool mForceBaseToZero;
|
||||||
boost::shared_ptr<CSVWorld::PhysicsSystem> mPhysics;
|
boost::shared_ptr<CSVWorld::PhysicsSystem> mPhysics;
|
||||||
|
|
||||||
|
@ -43,9 +48,6 @@ namespace CSVRender
|
||||||
/// Not implemented
|
/// Not implemented
|
||||||
Object& operator= (const Object&);
|
Object& operator= (const Object&);
|
||||||
|
|
||||||
/// Destroy all scene nodes and movable objects attached to node.
|
|
||||||
static void clearSceneNode (Ogre::SceneNode *node);
|
|
||||||
|
|
||||||
/// Remove object from node (includes deleting)
|
/// Remove object from node (includes deleting)
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
|
@ -60,7 +62,7 @@ namespace CSVRender
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Object (const CSMWorld::Data& data, Ogre::SceneNode *cellNode,
|
Object (const VFS::Manager* vfs, const CSMWorld::Data& data, osg::Group *cellNode,
|
||||||
const std::string& id, bool referenceable,
|
const std::string& id, bool referenceable,
|
||||||
boost::shared_ptr<CSVWorld::PhysicsSystem> physics = boost::shared_ptr<CSVWorld::PhysicsSystem> (),
|
boost::shared_ptr<CSVWorld::PhysicsSystem> physics = boost::shared_ptr<CSVWorld::PhysicsSystem> (),
|
||||||
bool forceBaseToZero = false);
|
bool forceBaseToZero = false);
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
#include "../../model/world/data.hpp"
|
#include "../../model/world/data.hpp"
|
||||||
#include "../../model/world/idtable.hpp"
|
#include "../../model/world/idtable.hpp"
|
||||||
|
|
||||||
CSVRender::PreviewWidget::PreviewWidget (CSMWorld::Data& data,
|
CSVRender::PreviewWidget::PreviewWidget (const VFS::Manager* vfs, 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(vfs, data, mRootNode, id, referenceable)
|
||||||
{
|
{
|
||||||
//setNavigation (&mOrbit);
|
//setNavigation (&mOrbit);
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ 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,13 +50,11 @@ 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();
|
||||||
|
|
||||||
|
@ -77,13 +74,11 @@ 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();
|
||||||
|
|
||||||
|
@ -112,13 +107,11 @@ 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;
|
||||||
|
|
||||||
|
@ -129,5 +122,4 @@ 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
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,11 @@
|
||||||
|
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
|
|
||||||
|
namespace VFS
|
||||||
|
{
|
||||||
|
class Manager;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSMWorld
|
namespace CSMWorld
|
||||||
{
|
{
|
||||||
class Data;
|
class Data;
|
||||||
|
@ -21,11 +26,11 @@ namespace CSVRender
|
||||||
|
|
||||||
CSMWorld::Data& mData;
|
CSMWorld::Data& mData;
|
||||||
CSVRender::NavigationOrbit mOrbit;
|
CSVRender::NavigationOrbit mOrbit;
|
||||||
//Object mObject;
|
CSVRender::Object mObject;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
PreviewWidget (CSMWorld::Data& data, const std::string& id, bool referenceable,
|
PreviewWidget (const VFS::Manager* vfs, CSMWorld::Data& data, const std::string& id, bool referenceable,
|
||||||
QWidget *parent = 0);
|
QWidget *parent = 0);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -16,12 +16,14 @@
|
||||||
#include <osg/GraphicsContext>
|
#include <osg/GraphicsContext>
|
||||||
|
|
||||||
#include <osgGA/TrackballManipulator>
|
#include <osgGA/TrackballManipulator>
|
||||||
|
#include <osgViewer/ViewerEventHandlers>
|
||||||
|
|
||||||
namespace CSVRender
|
namespace CSVRender
|
||||||
{
|
{
|
||||||
|
|
||||||
SceneWidget::SceneWidget(QWidget *parent, Qt::WindowFlags f)
|
SceneWidget::SceneWidget(QWidget *parent, Qt::WindowFlags f)
|
||||||
: QWidget(parent, f)
|
: QWidget(parent, f)
|
||||||
|
, mRootNode(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050000
|
#if QT_VERSION >= 0x050000
|
||||||
|
@ -37,6 +39,7 @@ SceneWidget::SceneWidget(QWidget *parent, Qt::WindowFlags f)
|
||||||
setKeyEventSetsDone(0);
|
setKeyEventSetsDone(0);
|
||||||
|
|
||||||
osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
|
osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
|
||||||
|
//ds->setNumMultiSamples(8);
|
||||||
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
|
||||||
traits->windowName = "";
|
traits->windowName = "";
|
||||||
traits->windowDecoration = true;
|
traits->windowDecoration = true;
|
||||||
|
@ -49,6 +52,8 @@ SceneWidget::SceneWidget(QWidget *parent, Qt::WindowFlags f)
|
||||||
traits->stencil = ds->getMinimumNumStencilBits();
|
traits->stencil = ds->getMinimumNumStencilBits();
|
||||||
traits->sampleBuffers = ds->getMultiSamples();
|
traits->sampleBuffers = ds->getMultiSamples();
|
||||||
traits->samples = ds->getNumMultiSamples();
|
traits->samples = ds->getNumMultiSamples();
|
||||||
|
// Doesn't make much sense as we're running on demand updates, and there seems to be a bug with the refresh rate when running multiple QGLWidgets
|
||||||
|
traits->vsync = false;
|
||||||
|
|
||||||
osgQt::GraphicsWindowQt* window = new osgQt::GraphicsWindowQt(traits.get());
|
osgQt::GraphicsWindowQt* window = new osgQt::GraphicsWindowQt(traits.get());
|
||||||
QLayout* layout = new QHBoxLayout(this);
|
QLayout* layout = new QHBoxLayout(this);
|
||||||
|
@ -59,15 +64,19 @@ SceneWidget::SceneWidget(QWidget *parent, Qt::WindowFlags f)
|
||||||
|
|
||||||
getCamera()->setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) );
|
getCamera()->setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) );
|
||||||
getCamera()->setViewport( new osg::Viewport(0, 0, traits->width, traits->height) );
|
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 );
|
getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(traits->width)/static_cast<double>(traits->height), 1.0f, 10000.0f );
|
||||||
|
|
||||||
osg::Node* root = new osg::Node;
|
mRootNode = new osg::Group;
|
||||||
setSceneData(root);
|
setSceneData(mRootNode);
|
||||||
|
|
||||||
|
// Press S to reveal profiling stats
|
||||||
|
addEventHandler(new osgViewer::StatsHandler);
|
||||||
|
|
||||||
setCameraManipulator(new osgGA::TrackballManipulator);
|
setCameraManipulator(new osgGA::TrackballManipulator);
|
||||||
|
|
||||||
// Only render when the camera position changed, or content flagged dirty
|
// Only render when the camera position changed, or content flagged dirty
|
||||||
//setRunFrameScheme(osgViewer::ViewerBase::ON_DEMAND);
|
//setRunFrameScheme(osgViewer::ViewerBase::ON_DEMAND);
|
||||||
|
setRunFrameScheme(osgViewer::ViewerBase::CONTINUOUS);
|
||||||
|
|
||||||
connect( &mTimer, SIGNAL(timeout()), this, SLOT(update()) );
|
connect( &mTimer, SIGNAL(timeout()), this, SLOT(update()) );
|
||||||
mTimer.start( 10 );
|
mTimer.start( 10 );
|
||||||
|
|
|
@ -10,6 +10,11 @@
|
||||||
|
|
||||||
#include <osgViewer/Viewer>
|
#include <osgViewer/Viewer>
|
||||||
|
|
||||||
|
namespace osg
|
||||||
|
{
|
||||||
|
class Group;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSVWidget
|
namespace CSVWidget
|
||||||
{
|
{
|
||||||
class SceneToolMode;
|
class SceneToolMode;
|
||||||
|
@ -34,6 +39,8 @@ namespace CSVRender
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
osg::Group* mRootNode;
|
||||||
|
|
||||||
QTimer mTimer;
|
QTimer mTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,10 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo
|
||||||
referenceableIdChanged (referenceableId);
|
referenceableIdChanged (referenceableId);
|
||||||
|
|
||||||
mScene =
|
mScene =
|
||||||
new CSVRender::PreviewWidget (document.getData(), id.getId(), false, this);
|
new CSVRender::PreviewWidget (document.getVFS(), document.getData(), id.getId(), false, this);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mScene = new CSVRender::PreviewWidget (document.getData(), id.getId(), true, this);
|
mScene = new CSVRender::PreviewWidget (document.getVFS(), document.getData(), id.getId(), true, this);
|
||||||
|
|
||||||
CSVWidget::SceneToolbar *toolbar = new CSVWidget::SceneToolbar (48+6, this);
|
CSVWidget::SceneToolbar *toolbar = new CSVWidget::SceneToolbar (48+6, this);
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace NifOsg
|
||||||
|
|
||||||
void loadAsSkeleton(Nif::NIFFilePtr file, osg::Group* parentNode);
|
void loadAsSkeleton(Nif::NIFFilePtr file, osg::Group* parentNode);
|
||||||
|
|
||||||
VFS::Manager* resourceManager;
|
const VFS::Manager* resourceManager;
|
||||||
|
|
||||||
// FIXME move
|
// FIXME move
|
||||||
std::vector<Controller> mControllers;
|
std::vector<Controller> mControllers;
|
||||||
|
|
Loading…
Reference in a new issue