forked from mirror/openmw-tes3mp
Add pathgrid rendering to opencs
This commit is contained in:
parent
5cac882123
commit
8d95b63180
2 changed files with 58 additions and 0 deletions
|
@ -1,10 +1,14 @@
|
|||
#include "cell.hpp"
|
||||
|
||||
#include <osg/PositionAttitudeTransform>
|
||||
#include <osg/Geode>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Group>
|
||||
|
||||
#include <components/misc/stringops.hpp>
|
||||
#include <components/esm/loadcell.hpp>
|
||||
#include <components/esm/loadland.hpp>
|
||||
#include <components/sceneutil/pathgridutil.hpp>
|
||||
|
||||
#include "../../model/world/idtable.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;
|
||||
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();
|
||||
|
||||
if (!mDeleted)
|
||||
|
@ -104,6 +118,15 @@ CSVRender::Cell::Cell (CSMWorld::Data& data, osg::Group* rootNode, const std::st
|
|||
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)
|
||||
{
|
||||
mPathgridGeode->removeDrawable(mPathgridGeometry);
|
||||
mPathgridGeometry = SceneUtil::PathgridGeometryFactory::get().create(pathgrid);
|
||||
mPathgridGeode->addDrawable(mPathgridGeometry);
|
||||
}
|
||||
|
||||
void CSVRender::Cell::pathgridRemoved()
|
||||
{
|
||||
mPathgridGeode->removeDrawable(mPathgridGeometry);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
|
|
|
@ -23,6 +23,8 @@ class QModelIndex;
|
|||
namespace osg
|
||||
{
|
||||
class Group;
|
||||
class Geometry;
|
||||
class Geode;
|
||||
}
|
||||
|
||||
namespace CSMWorld
|
||||
|
@ -41,6 +43,8 @@ namespace CSVRender
|
|||
CSMWorld::Data& mData;
|
||||
std::string mId;
|
||||
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::auto_ptr<Terrain::TerrainGrid> mTerrain;
|
||||
CSMWorld::CellCoordinates mCoordinates;
|
||||
|
|
Loading…
Reference in a new issue