mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 12:39:55 +00:00
Add pathgrid rendering to opencs
This commit is contained in:
parent
5cac882123
commit
8d95b63180
@ -1,10 +1,14 @@
|
|||||||
#include "cell.hpp"
|
#include "cell.hpp"
|
||||||
|
|
||||||
|
#include <osg/PositionAttitudeTransform>
|
||||||
|
#include <osg/Geode>
|
||||||
|
#include <osg/Geometry>
|
||||||
#include <osg/Group>
|
#include <osg/Group>
|
||||||
|
|
||||||
#include <components/misc/stringops.hpp>
|
#include <components/misc/stringops.hpp>
|
||||||
#include <components/esm/loadcell.hpp>
|
#include <components/esm/loadcell.hpp>
|
||||||
#include <components/esm/loadland.hpp>
|
#include <components/esm/loadland.hpp>
|
||||||
|
#include <components/sceneutil/pathgridutil.hpp>
|
||||||
|
|
||||||
#include "../../model/world/idtable.hpp"
|
#include "../../model/world/idtable.hpp"
|
||||||
#include "../../model/world/columns.hpp"
|
#include "../../model/world/columns.hpp"
|
||||||
@ -77,6 +81,16 @@ CSVRender::Cell::Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::st
|
|||||||
mCellNode = new osg::Group;
|
mCellNode = new osg::Group;
|
||||||
rootNode->addChild(mCellNode);
|
rootNode->addChild(mCellNode);
|
||||||
|
|
||||||
|
osg::ref_ptr<osg::PositionAttitudeTransform> pathgridTransform = new osg::PositionAttitudeTransform();
|
||||||
|
pathgridTransform->setPosition(osg::Vec3f(mCoordinates.getX() * ESM::Land::REAL_SIZE,
|
||||||
|
mCoordinates.getY() * ESM::Land::REAL_SIZE, 0));
|
||||||
|
mCellNode->addChild(pathgridTransform);
|
||||||
|
|
||||||
|
mPathgridGeode = new osg::Geode();
|
||||||
|
pathgridTransform->addChild(mPathgridGeode);
|
||||||
|
|
||||||
|
mPathgridGeometry = 0;
|
||||||
|
|
||||||
setCellMarker();
|
setCellMarker();
|
||||||
|
|
||||||
if (!mDeleted)
|
if (!mDeleted)
|
||||||
@ -104,6 +118,15 @@ CSVRender::Cell::Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::st
|
|||||||
mCellBorder->buildShape(esmLand);
|
mCellBorder->buildShape(esmLand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids = mData.getPathgrids();
|
||||||
|
int pathgridIndex = pathgrids.searchId(mId);
|
||||||
|
if (pathgridIndex != -1)
|
||||||
|
{
|
||||||
|
mPathgridGeometry = SceneUtil::PathgridGeometryFactory::get().create(
|
||||||
|
pathgrids.getRecord(pathgridIndex).get());
|
||||||
|
mPathgridGeode->addDrawable(mPathgridGeometry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,22 +279,53 @@ bool CSVRender::Cell::referenceAdded (const QModelIndex& parent, int start, int
|
|||||||
|
|
||||||
void CSVRender::Cell::pathgridAdded(const CSMWorld::Pathgrid& pathgrid)
|
void CSVRender::Cell::pathgridAdded(const CSMWorld::Pathgrid& pathgrid)
|
||||||
{
|
{
|
||||||
|
mPathgridGeode->removeDrawable(mPathgridGeometry);
|
||||||
|
mPathgridGeometry = SceneUtil::PathgridGeometryFactory::get().create(pathgrid);
|
||||||
|
mPathgridGeode->addDrawable(mPathgridGeometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::Cell::pathgridRemoved()
|
void CSVRender::Cell::pathgridRemoved()
|
||||||
{
|
{
|
||||||
|
mPathgridGeode->removeDrawable(mPathgridGeometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::Cell::pathgridDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
|
void CSVRender::Cell::pathgridDataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight)
|
||||||
{
|
{
|
||||||
|
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids = mData.getPathgrids();
|
||||||
|
int pathgridIndex = pathgrids.searchId(mId);
|
||||||
|
if (pathgridIndex != -1)
|
||||||
|
{
|
||||||
|
mPathgridGeode->removeDrawable(mPathgridGeometry);
|
||||||
|
mPathgridGeometry = SceneUtil::PathgridGeometryFactory::get().create(
|
||||||
|
pathgrids.getRecord(pathgridIndex).get());
|
||||||
|
mPathgridGeode->addDrawable(mPathgridGeometry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::Cell::pathgridRowRemoved(const QModelIndex& parent, int start, int end)
|
void CSVRender::Cell::pathgridRowRemoved(const QModelIndex& parent, int start, int end)
|
||||||
{
|
{
|
||||||
|
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids = mData.getPathgrids();
|
||||||
|
int pathgridIndex = pathgrids.searchId(mId);
|
||||||
|
if (pathgridIndex != -1)
|
||||||
|
{
|
||||||
|
mPathgridGeode->removeDrawable(mPathgridGeometry);
|
||||||
|
mPathgridGeometry = SceneUtil::PathgridGeometryFactory::get().create(
|
||||||
|
pathgrids.getRecord(pathgridIndex).get());
|
||||||
|
mPathgridGeode->addDrawable(mPathgridGeometry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::Cell::pathgridRowAdded(const QModelIndex& parent, int start, int end)
|
void CSVRender::Cell::pathgridRowAdded(const QModelIndex& parent, int start, int end)
|
||||||
{
|
{
|
||||||
|
const CSMWorld::SubCellCollection<CSMWorld::Pathgrid>& pathgrids = mData.getPathgrids();
|
||||||
|
int pathgridIndex = pathgrids.searchId(mId);
|
||||||
|
if (pathgridIndex != -1)
|
||||||
|
{
|
||||||
|
mPathgridGeode->removeDrawable(mPathgridGeometry);
|
||||||
|
mPathgridGeometry = SceneUtil::PathgridGeometryFactory::get().create(
|
||||||
|
pathgrids.getRecord(pathgridIndex).get());
|
||||||
|
mPathgridGeode->addDrawable(mPathgridGeometry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::Cell::setSelection (int elementMask, Selection mode)
|
void CSVRender::Cell::setSelection (int elementMask, Selection mode)
|
||||||
|
@ -23,6 +23,8 @@ class QModelIndex;
|
|||||||
namespace osg
|
namespace osg
|
||||||
{
|
{
|
||||||
class Group;
|
class Group;
|
||||||
|
class Geometry;
|
||||||
|
class Geode;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace CSMWorld
|
namespace CSMWorld
|
||||||
@ -41,6 +43,8 @@ namespace CSVRender
|
|||||||
CSMWorld::Data& mData;
|
CSMWorld::Data& mData;
|
||||||
std::string mId;
|
std::string mId;
|
||||||
osg::ref_ptr<osg::Group> mCellNode;
|
osg::ref_ptr<osg::Group> mCellNode;
|
||||||
|
osg::ref_ptr<osg::Geode> mPathgridGeode;
|
||||||
|
osg::ref_ptr<osg::Geometry> mPathgridGeometry;
|
||||||
std::map<std::string, Object *> mObjects;
|
std::map<std::string, Object *> mObjects;
|
||||||
std::auto_ptr<Terrain::TerrainGrid> mTerrain;
|
std::auto_ptr<Terrain::TerrainGrid> mTerrain;
|
||||||
CSMWorld::CellCoordinates mCoordinates;
|
CSMWorld::CellCoordinates mCoordinates;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user