Pathgrid rendering

c++11
scrawl 10 years ago
parent 1a5407af98
commit 9cf9c2876e

@ -21,8 +21,8 @@ source_group(game FILES ${GAME} ${GAME_HEADER})
add_openmw_dir (mwrender
actors objects renderingmanager animation sky npcanimation vismask
creatureanimation effectmanager util renderinginterface
# debugging camera activatoranimation
creatureanimation effectmanager util renderinginterface debugging rendermode
# camera activatoranimation
# localmap occlusionquery water shadows
# characterpreview globalmap ripplesimulation refraction
# terrainstorage renderconst weaponanimation

@ -9,6 +9,8 @@
#include "../mwworld/ptr.hpp"
#include "../mwrender/rendermode.hpp"
namespace Ogre
{
class Vector2;
@ -83,14 +85,6 @@ namespace MWBase
public:
enum RenderMode
{
Render_CollisionDebug,
Render_Wireframe,
Render_Pathgrid,
Render_BoundingBoxes
};
struct DoorMarker
{
std::string name;
@ -320,7 +314,7 @@ namespace MWBase
/// collisions and gravity.
/// \return Resulting mode
virtual bool toggleRenderMode (RenderMode mode) = 0;
virtual bool toggleRenderMode (MWRender::RenderMode mode) = 0;
///< Toggle a render mode.
///< \return Resulting mode

@ -88,6 +88,11 @@ namespace MWMechanics
return ESM::Pathgrid::Point(static_cast<int>(p.pos[0]), static_cast<int>(p.pos[1]), static_cast<int>(p.pos[2]));
}
static osg::Vec3f MakeOsgVec3(const ESM::Pathgrid::Point& p)
{
return osg::Vec3f(static_cast<float>(p.mX), static_cast<float>(p.mY), static_cast<float>(p.mZ));
}
/// utility function to convert a Pathgrid::Point to a Ogre::Vector3
static Ogre::Vector3 MakeOgreVector3(const ESM::Pathgrid::Point& p)
{

@ -12,12 +12,9 @@
#include "../mwworld/class.hpp"
#include "renderconst.hpp"
namespace MWRender
{
CreatureAnimation::CreatureAnimation(const MWWorld::Ptr &ptr,
const std::string& model, Resource::ResourceSystem* resourceSystem)
: Animation(ptr, osg::ref_ptr<osg::Group>(ptr.getRefData().getBaseNode()), resourceSystem)

@ -2,13 +2,10 @@
#include <cassert>
#include <OgreNode.h>
#include <OgreSceneManager.h>
#include <OgreMaterial.h>
#include <OgreMaterialManager.h>
#include <OgreManualObject.h>
#include <OgreTechnique.h>
#include <OgreSceneNode.h>
#include <osg/Geometry>
#include <osg/PositionAttitudeTransform>
#include <osg/Geode>
#include <osg/Group>
#include <openengine/bullet/physic.hpp>
@ -23,145 +20,118 @@
#include "../mwworld/esmstore.hpp"
#include "../mwmechanics/pathfinding.hpp"
#include "renderconst.hpp"
using namespace Ogre;
#include "vismask.hpp"
namespace MWRender
{
static const std::string PATHGRID_POINT_MATERIAL = "pathgridPointMaterial";
static const std::string PATHGRID_LINE_MATERIAL = "pathgridLineMaterial";
static const std::string DEBUGGING_GROUP = "debugging";
static const int POINT_MESH_BASE = 35;
void Debugging::createGridMaterials()
{
if (mGridMatsCreated) return;
if (MaterialManager::getSingleton().getByName(PATHGRID_LINE_MATERIAL, DEBUGGING_GROUP).isNull())
{
MaterialPtr lineMatPtr = MaterialManager::getSingleton().create(PATHGRID_LINE_MATERIAL, DEBUGGING_GROUP);
lineMatPtr->setReceiveShadows(false);
lineMatPtr->getTechnique(0)->setLightingEnabled(true);
lineMatPtr->getTechnique(0)->getPass(0)->setDiffuse(1,1,0,0);
lineMatPtr->getTechnique(0)->getPass(0)->setAmbient(1,1,0);
lineMatPtr->getTechnique(0)->getPass(0)->setSelfIllumination(1,1,0);
}
if (MaterialManager::getSingleton().getByName(PATHGRID_POINT_MATERIAL, DEBUGGING_GROUP).isNull())
{
MaterialPtr pointMatPtr = MaterialManager::getSingleton().create(PATHGRID_POINT_MATERIAL, DEBUGGING_GROUP);
pointMatPtr->setReceiveShadows(false);
pointMatPtr->getTechnique(0)->setLightingEnabled(true);
pointMatPtr->getTechnique(0)->getPass(0)->setDiffuse(1,0,0,0);
pointMatPtr->getTechnique(0)->getPass(0)->setAmbient(1,0,0);
pointMatPtr->getTechnique(0)->getPass(0)->setSelfIllumination(1,0,0);
}
mGridMatsCreated = true;
}
void Debugging::destroyGridMaterials()
osg::ref_ptr<osg::Geometry> Debugging::createPathgridLines(const ESM::Pathgrid *pathgrid)
{
if (mGridMatsCreated)
{
MaterialManager::getSingleton().remove(PATHGRID_POINT_MATERIAL);
MaterialManager::getSingleton().remove(PATHGRID_LINE_MATERIAL);
mGridMatsCreated = false;
}
}
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
ManualObject *Debugging::createPathgridLines(const ESM::Pathgrid *pathgrid)
{
ManualObject *result = mSceneMgr->createManualObject();
osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array;
result->begin(PATHGRID_LINE_MATERIAL, RenderOperation::OT_LINE_LIST);
for(ESM::Pathgrid::EdgeList::const_iterator it = pathgrid->mEdges.begin();
it != pathgrid->mEdges.end();
++it)
{
const ESM::Pathgrid::Edge &edge = *it;
const ESM::Pathgrid::Point &p1 = pathgrid->mPoints[edge.mV0], &p2 = pathgrid->mPoints[edge.mV1];
Vector3 direction = (MWMechanics::PathFinder::MakeOgreVector3(p2) - MWMechanics::PathFinder::MakeOgreVector3(p1));
Vector3 lineDisplacement = direction.crossProduct(Vector3::UNIT_Z).normalisedCopy();
osg::Vec3f direction = MWMechanics::PathFinder::MakeOsgVec3(p2) - MWMechanics::PathFinder::MakeOsgVec3(p1);
osg::Vec3f lineDisplacement = (direction^osg::Vec3f(0,0,1));
lineDisplacement.normalize();
lineDisplacement = lineDisplacement * POINT_MESH_BASE +
Vector3(0, 0, 10); // move lines up a little, so they will be less covered by meshes/landscape
result->position(MWMechanics::PathFinder::MakeOgreVector3(p1) + lineDisplacement);
result->position(MWMechanics::PathFinder::MakeOgreVector3(p2) + lineDisplacement);
osg::Vec3f(0, 0, 10); // move lines up a little, so they will be less covered by meshes/landscape
vertices->push_back(MWMechanics::PathFinder::MakeOsgVec3(p1) + lineDisplacement);
vertices->push_back(MWMechanics::PathFinder::MakeOsgVec3(p2) + lineDisplacement);
}
result->end();
result->setVisibilityFlags (RV_Debug);
geom->setVertexArray(vertices);
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES, 0, vertices->size()));
return result;
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array;
colors->push_back(osg::Vec4(1.f, 1.f, 0.f, 1.f));
geom->setColorArray(colors, osg::Array::BIND_OVERALL);
return geom;
}
ManualObject *Debugging::createPathgridPoints(const ESM::Pathgrid *pathgrid)
osg::ref_ptr<osg::Geometry> Debugging::createPathgridPoints(const ESM::Pathgrid *pathgrid)
{
ManualObject *result = mSceneMgr->createManualObject();
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
const float height = POINT_MESH_BASE * sqrtf(2);
result->begin(PATHGRID_POINT_MATERIAL, RenderOperation::OT_TRIANGLE_STRIP);
osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array;
osg::ref_ptr<osg::UShortArray> indices = new osg::UShortArray;
bool first = true;
uint32 startIndex = 0;
unsigned short startIndex = 0;
for(ESM::Pathgrid::PointList::const_iterator it = pathgrid->mPoints.begin();
it != pathgrid->mPoints.end();
++it, startIndex += 6)
{
Vector3 pointPos(MWMechanics::PathFinder::MakeOgreVector3(*it));
osg::Vec3f pointPos(MWMechanics::PathFinder::MakeOsgVec3(*it));
if (!first)
{
// degenerate triangle from previous octahedron
result->index(startIndex - 4); // 2nd point of previous octahedron
result->index(startIndex); // start point of current octahedron
indices->push_back(startIndex - 4); // 2nd point of previous octahedron
indices->push_back(startIndex); // start point of current octahedron
}
Ogre::Real pointMeshBase = static_cast<Ogre::Real>(POINT_MESH_BASE);
result->position(pointPos + Vector3(0, 0, height)); // 0
result->position(pointPos + Vector3(-pointMeshBase, -pointMeshBase, 0)); // 1
result->position(pointPos + Vector3(pointMeshBase, -pointMeshBase, 0)); // 2
result->position(pointPos + Vector3(pointMeshBase, pointMeshBase, 0)); // 3
result->position(pointPos + Vector3(-pointMeshBase, pointMeshBase, 0)); // 4
result->position(pointPos + Vector3(0, 0, -height)); // 5
result->index(startIndex + 0);
result->index(startIndex + 1);
result->index(startIndex + 2);
result->index(startIndex + 5);
result->index(startIndex + 3);
result->index(startIndex + 4);
float pointMeshBase = static_cast<float>(POINT_MESH_BASE);
vertices->push_back(pointPos + osg::Vec3f(0, 0, height)); // 0
vertices->push_back(pointPos + osg::Vec3f(-pointMeshBase, -pointMeshBase, 0)); // 1
vertices->push_back(pointPos + osg::Vec3f(pointMeshBase, -pointMeshBase, 0)); // 2
vertices->push_back(pointPos + osg::Vec3f(pointMeshBase, pointMeshBase, 0)); // 3
vertices->push_back(pointPos + osg::Vec3f(-pointMeshBase, pointMeshBase, 0)); // 4
vertices->push_back(pointPos + osg::Vec3f(0, 0, -height)); // 5
indices->push_back(startIndex + 0);
indices->push_back(startIndex + 1);
indices->push_back(startIndex + 2);
indices->push_back(startIndex + 5);
indices->push_back(startIndex + 3);
indices->push_back(startIndex + 4);
// degenerates
result->index(startIndex + 4);
result->index(startIndex + 5);
result->index(startIndex + 5);
indices->push_back(startIndex + 4);
indices->push_back(startIndex + 5);
indices->push_back(startIndex + 5);
// end degenerates
result->index(startIndex + 1);
result->index(startIndex + 4);
result->index(startIndex + 0);
result->index(startIndex + 3);
result->index(startIndex + 2);
indices->push_back(startIndex + 1);
indices->push_back(startIndex + 4);
indices->push_back(startIndex + 0);
indices->push_back(startIndex + 3);
indices->push_back(startIndex + 2);
first = false;
}
result->end();
geom->setVertexArray(vertices);
result->setVisibilityFlags (RV_Debug);
geom->addPrimitiveSet(new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLE_STRIP, indices->size(), &(*indices)[0]));
return result;
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array;
colors->push_back(osg::Vec4(1.f, 0.f, 0.f, 1.f));
geom->setColorArray(colors, osg::Array::BIND_OVERALL);
return geom;
}
Debugging::Debugging(SceneNode *root, OEngine::Physic::PhysicEngine *engine) :
mRootNode(root), mEngine(engine),
mSceneMgr(root->getCreator()),
mPathgridEnabled(false),
mInteriorPathgridNode(NULL), mPathGridRoot(NULL),
mGridMatsCreated(false)
Debugging::Debugging(osg::ref_ptr<osg::Group> root /*, OEngine::Physic::PhysicEngine *engine*/)
: mRootNode(root)
, mPathgridEnabled(false)
, mInteriorPathgridNode(NULL)
, mPathGridRoot(NULL)
{
ResourceGroupManager::getSingleton().createResourceGroup(DEBUGGING_GROUP);
}
Debugging::~Debugging()
@ -170,34 +140,34 @@ Debugging::~Debugging()
{
togglePathgrid();
}
ResourceGroupManager::getSingleton().destroyResourceGroup(DEBUGGING_GROUP);
}
bool Debugging::toggleRenderMode (int mode){
switch (mode)
{
case MWBase::World::Render_CollisionDebug:
//case Render_CollisionDebug:
return mEngine->toggleDebugRendering();
//return mEngine->toggleDebugRendering();
case MWBase::World::Render_Pathgrid:
case Render_Pathgrid:
togglePathgrid();
return mPathgridEnabled;
default:
return false;
}
return false;
}
void Debugging::cellAdded(MWWorld::CellStore *store)
void Debugging::addCell(const MWWorld::CellStore *store)
{
mActiveCells.push_back(store);
if (mPathgridEnabled)
enableCellPathgrid(store);
}
void Debugging::cellRemoved(MWWorld::CellStore *store)
void Debugging::removeCell(const MWWorld::CellStore *store)
{
mActiveCells.erase(std::remove(mActiveCells.begin(), mActiveCells.end(), store), mActiveCells.end());
if (mPathgridEnabled)
@ -209,10 +179,11 @@ void Debugging::togglePathgrid()
mPathgridEnabled = !mPathgridEnabled;
if (mPathgridEnabled)
{
createGridMaterials();
// add path grid meshes to already loaded cells
mPathGridRoot = mRootNode->createChildSceneNode();
mPathGridRoot = new osg::Group;
mPathGridRoot->setNodeMask(Mask_Debug);
mRootNode->addChild(mPathGridRoot);
for(CellList::iterator it = mActiveCells.begin(); it != mActiveCells.end(); ++it)
{
enableCellPathgrid(*it);
@ -225,29 +196,44 @@ void Debugging::togglePathgrid()
{
disableCellPathgrid(*it);
}
mPathGridRoot->removeAndDestroyAllChildren();
mSceneMgr->destroySceneNode(mPathGridRoot);
mPathGridRoot = NULL;
destroyGridMaterials();
if (mPathGridRoot)
{
mRootNode->removeChild(mPathGridRoot);
mPathGridRoot = NULL;
}
}
}
void Debugging::enableCellPathgrid(MWWorld::CellStore *store)
void Debugging::enableCellPathgrid(const MWWorld::CellStore *store)
{
MWBase::World* world = MWBase::Environment::get().getWorld();
const ESM::Pathgrid *pathgrid =
world->getStore().get<ESM::Pathgrid>().search(*store->getCell());
if (!pathgrid) return;
Vector3 cellPathGridPos(0, 0, 0);
osg::Vec3f cellPathGridPos(0, 0, 0);
if (store->getCell()->isExterior())
{
cellPathGridPos.x = static_cast<Ogre::Real>(store->getCell()->mData.mX * ESM::Land::REAL_SIZE);
cellPathGridPos.y = static_cast<Ogre::Real>(store->getCell()->mData.mY * ESM::Land::REAL_SIZE);
cellPathGridPos.x() = static_cast<float>(store->getCell()->mData.mX * ESM::Land::REAL_SIZE);
cellPathGridPos.y() = static_cast<float>(store->getCell()->mData.mY * ESM::Land::REAL_SIZE);
}
SceneNode *cellPathGrid = mPathGridRoot->createChildSceneNode(cellPathGridPos);
cellPathGrid->attachObject(createPathgridLines(pathgrid));
cellPathGrid->attachObject(createPathgridPoints(pathgrid));
osg::ref_ptr<osg::PositionAttitudeTransform> cellPathGrid = new osg::PositionAttitudeTransform;
cellPathGrid->setPosition(cellPathGridPos);
osg::ref_ptr<osg::Geode> lineGeode = new osg::Geode;
osg::ref_ptr<osg::Geometry> lines = createPathgridLines(pathgrid);
lineGeode->addDrawable(lines);
osg::ref_ptr<osg::Geode> pointGeode = new osg::Geode;
osg::ref_ptr<osg::Geometry> points = createPathgridPoints(pathgrid);
pointGeode->addDrawable(points);
cellPathGrid->addChild(lineGeode);
cellPathGrid->addChild(pointGeode);
mPathGridRoot->addChild(cellPathGrid);
if (store->getCell()->isExterior())
{
@ -260,7 +246,7 @@ void Debugging::enableCellPathgrid(MWWorld::CellStore *store)
}
}
void Debugging::disableCellPathgrid(MWWorld::CellStore *store)
void Debugging::disableCellPathgrid(const MWWorld::CellStore *store)
{
if (store->getCell()->isExterior())
{
@ -268,7 +254,7 @@ void Debugging::disableCellPathgrid(MWWorld::CellStore *store)
mExteriorPathgridNodes.find(std::make_pair(store->getCell()->getGridX(), store->getCell()->getGridY()));
if (it != mExteriorPathgridNodes.end())
{
destroyCellPathgridNode(it->second);
mPathGridRoot->removeChild(it->second);
mExteriorPathgridNodes.erase(it);
}
}
@ -276,27 +262,10 @@ void Debugging::disableCellPathgrid(MWWorld::CellStore *store)
{
if (mInteriorPathgridNode)
{
destroyCellPathgridNode(mInteriorPathgridNode);
mPathGridRoot->removeChild(mInteriorPathgridNode);
mInteriorPathgridNode = NULL;
}
}
}
void Debugging::destroyCellPathgridNode(SceneNode *node)
{
mPathGridRoot->removeChild(node);
destroyAttachedObjects(node);
mSceneMgr->destroySceneNode(node);
}
void Debugging::destroyAttachedObjects(SceneNode *node)
{
SceneNode::ObjectIterator objIt = node->getAttachedObjectIterator();
while (objIt.hasMoreElements())
{
MovableObject *mesh = static_cast<MovableObject *>(objIt.getNext());
mSceneMgr->destroyMovableObject(mesh);
}
}
}

@ -7,6 +7,8 @@
#include <string>
#include <map>
#include <osg/ref_ptr>
namespace ESM
{
struct Pathgrid;
@ -20,16 +22,10 @@ namespace OEngine
}
}
namespace Ogre
namespace osg
{
class Camera;
class Viewport;
class SceneManager;
class SceneNode;
class RaySceneQuery;
class Quaternion;
class Vector3;
class ManualObject;
class Group;
class Geometry;
}
namespace MWWorld
@ -42,47 +38,37 @@ namespace MWRender
{
class Debugging
{
OEngine::Physic::PhysicEngine* mEngine;
Ogre::SceneManager *mSceneMgr;
//OEngine::Physic::PhysicEngine* mEngine;
// Path grid stuff
bool mPathgridEnabled;
void togglePathgrid();
typedef std::vector<MWWorld::CellStore *> CellList;
typedef std::vector<const MWWorld::CellStore *> CellList;
CellList mActiveCells;
Ogre::SceneNode *mRootNode;
osg::ref_ptr<osg::Group> mRootNode;
Ogre::SceneNode *mPathGridRoot;
osg::ref_ptr<osg::Group> mPathGridRoot;
typedef std::map<std::pair<int,int>, Ogre::SceneNode *> ExteriorPathgridNodes;
typedef std::map<std::pair<int,int>, osg::ref_ptr<osg::Group> > ExteriorPathgridNodes;
ExteriorPathgridNodes mExteriorPathgridNodes;
Ogre::SceneNode *mInteriorPathgridNode;
void enableCellPathgrid(MWWorld::CellStore *store);
void disableCellPathgrid(MWWorld::CellStore *store);
// utility
void destroyCellPathgridNode(Ogre::SceneNode *node);
void destroyAttachedObjects(Ogre::SceneNode *node);
osg::ref_ptr<osg::Group> mInteriorPathgridNode;
// materials
bool mGridMatsCreated;
void createGridMaterials();
void destroyGridMaterials();
void enableCellPathgrid(const MWWorld::CellStore *store);
void disableCellPathgrid(const MWWorld::CellStore *store);
// path grid meshes
Ogre::ManualObject *createPathgridLines(const ESM::Pathgrid *pathgrid);
Ogre::ManualObject *createPathgridPoints(const ESM::Pathgrid *pathgrid);
osg::ref_ptr<osg::Geometry> createPathgridLines(const ESM::Pathgrid *pathgrid);
osg::ref_ptr<osg::Geometry> createPathgridPoints(const ESM::Pathgrid *pathgrid);
public:
Debugging(Ogre::SceneNode* root, OEngine::Physic::PhysicEngine *engine);
Debugging(osg::ref_ptr<osg::Group> root /*, OEngine::Physic::PhysicEngine *engine*/);
~Debugging();
bool toggleRenderMode (int mode);
void cellAdded(MWWorld::CellStore* store);
void cellRemoved(MWWorld::CellStore* store);
void addCell(const MWWorld::CellStore* store);
void removeCell(const MWWorld::CellStore* store);
};

@ -23,7 +23,6 @@
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/soundmanager.hpp"
#include "renderconst.hpp"
#include "camera.hpp"
namespace

@ -17,7 +17,6 @@
#include "../mwworld/ptr.hpp"
#include "../mwworld/class.hpp"
#include "renderconst.hpp"
#include "animation.hpp"
#include "npcanimation.hpp"
#include "creatureanimation.hpp"

@ -1,76 +0,0 @@
#ifndef GAME_RENDER_CONST_H
#define GAME_RENDER_CONST_H
#include <OgreRenderQueue.h>
namespace MWRender
{
// Render queue groups
enum RenderQueueGroups
{
// Sky early (atmosphere, clouds, moons)
RQG_SkiesEarly = Ogre::RENDER_QUEUE_SKIES_EARLY,
RQG_Main = Ogre::RENDER_QUEUE_MAIN,
RQG_Alpha = Ogre::RENDER_QUEUE_MAIN+1,
RQG_OcclusionQuery = Ogre::RENDER_QUEUE_6,
RQG_UnderWater = Ogre::RENDER_QUEUE_4,
RQG_Water = RQG_Alpha,
RQG_Ripples = RQG_Water+1,
// Sky late (sun & sun flare)
RQG_SkiesLate = Ogre::RENDER_QUEUE_SKIES_LATE
};
// Visibility flags
enum VisibilityFlags
{
// Terrain
RV_Terrain = (1<<0),
// Statics (e.g. trees, houses)
RV_Statics = (1<<1),
// Small statics
RV_StaticsSmall = (1<<2),
// Water
RV_Water = (1<<3),
// Actors (npcs, creatures)
RV_Actors = (1<<4),
// Misc objects (containers, dynamic objects)
RV_Misc = (1<<5),
// VFX, don't appear on map and don't cast shadows
RV_Effects = (1<<6),
RV_Sky = (1<<7),
// not visible in reflection
RV_NoReflection = (1<<8),
RV_OcclusionQuery = (1<<9),
RV_Debug = (1<<10),
// overlays, we only want these on the main render target
RV_Overlay = (1<<11),
// First person meshes do not cast shadows
RV_FirstPerson = (1<<12),
RV_Map = RV_Terrain + RV_Statics + RV_StaticsSmall + RV_Misc + RV_Water,
RV_Refraction = RV_Actors + RV_Misc + RV_Statics + RV_StaticsSmall + RV_Terrain + RV_Effects + RV_Sky + RV_FirstPerson
};
}
#endif

@ -21,10 +21,13 @@
#include <components/esm/loadcell.hpp>
#include "../mwbase/world.hpp"
#include "sky.hpp"
#include "effectmanager.hpp"
#include "npcanimation.hpp"
#include "vismask.hpp"
#include "debugging.hpp"
namespace MWRender
{
@ -88,6 +91,8 @@ namespace MWRender
mRootNode->addChild(lightRoot);
mDebugging.reset(new Debugging(mRootNode));
mObjects.reset(new Objects(mResourceSystem, lightRoot));
mEffectManager.reset(new EffectManager(mRootNode, mResourceSystem));
@ -182,8 +187,14 @@ namespace MWRender
return eye;
}
void RenderingManager::addCell(const MWWorld::CellStore *store)
{
mDebugging->addCell(store);
}
void RenderingManager::removeCell(const MWWorld::CellStore *store)
{
mDebugging->removeCell(store);
mObjects->removeCell(store);
}
@ -192,6 +203,25 @@ namespace MWRender
mSky->setEnabled(enabled);
}
bool RenderingManager::toggleRenderMode(RenderMode mode)
{
if (mode == Render_CollisionDebug || mode == Render_Pathgrid)
return mDebugging->toggleRenderMode(mode);
else if (mode == Render_Wireframe)
{
return false;
}
/*
else //if (mode == Render_BoundingBoxes)
{
bool show = !mRendering.getScene()->getShowBoundingBoxes();
mRendering.getScene()->showBoundingBoxes(show);
return show;
}
*/
return false;
}
void RenderingManager::configureFog(const ESM::Cell *cell)
{
osg::Vec4f color = SceneUtil::colourFromRGB(cell->mAmbi.mFog);

@ -7,6 +7,7 @@
#include "objects.hpp"
#include "renderinginterface.hpp"
#include "rendermode.hpp"
namespace osg
{
@ -37,6 +38,7 @@ namespace MWRender
class EffectManager;
class SkyManager;
class NpcAnimation;
class Debugging;
class RenderingManager : public MWRender::RenderingInterface
{
@ -57,6 +59,7 @@ namespace MWRender
void configureFog(const ESM::Cell* cell);
void configureFog(float fogDepth, const osg::Vec4f& colour);
void addCell(const MWWorld::CellStore* store);
void removeCell(const MWWorld::CellStore* store);
// TODO rename to setRotation/setPosition/setScale, along with the World equivalents
@ -66,6 +69,8 @@ namespace MWRender
void setSkyEnabled(bool enabled);
bool toggleRenderMode(RenderMode mode);
SkyManager* getSkyManager();
osg::Vec3f getEyePos();
@ -94,6 +99,7 @@ namespace MWRender
osg::ref_ptr<osg::Light> mSunLight;
std::auto_ptr<Debugging> mDebugging;
std::auto_ptr<Objects> mObjects;
std::auto_ptr<SkyManager> mSky;
std::auto_ptr<EffectManager> mEffectManager;

@ -0,0 +1,17 @@
#ifndef OPENMW_MWRENDER_RENDERMODE_H
#define OPENMW_MWRENDER_RENDERMODE_H
namespace MWRender
{
enum RenderMode
{
Render_CollisionDebug,
Render_Wireframe,
Render_Pathgrid,
Render_BoundingBoxes
};
}
#endif

@ -34,7 +34,6 @@
#include "../mwworld/fallback.hpp"
#include "renderconst.hpp"
#include "renderingmanager.hpp"
namespace

@ -11,6 +11,7 @@ namespace MWRender
// child of Scene
Mask_Effect = 0x2,
Mask_Debug = 0x4,
// top level masks
Mask_Scene = 0x10,

@ -213,7 +213,7 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime)
{
bool enabled =
MWBase::Environment::get().getWorld()->toggleRenderMode (MWBase::World::Render_CollisionDebug);
MWBase::Environment::get().getWorld()->toggleRenderMode (MWRender::Render_CollisionDebug);
runtime.getContext().report (enabled ?
"Collision Mesh Rendering -> On" : "Collision Mesh Rendering -> Off");
@ -228,7 +228,7 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime)
{
bool enabled =
MWBase::Environment::get().getWorld()->toggleRenderMode (MWBase::World::Render_BoundingBoxes);
MWBase::Environment::get().getWorld()->toggleRenderMode (MWRender::Render_BoundingBoxes);
runtime.getContext().report (enabled ?
"Bounding Box Rendering -> On" : "Bounding Box Rendering -> Off");
@ -242,7 +242,7 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime)
{
bool enabled =
MWBase::Environment::get().getWorld()->toggleRenderMode (MWBase::World::Render_Wireframe);
MWBase::Environment::get().getWorld()->toggleRenderMode (MWRender::Render_Wireframe);
runtime.getContext().report (enabled ?
"Wireframe Rendering -> On" : "Wireframe Rendering -> Off");
@ -255,7 +255,7 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime)
{
bool enabled =
MWBase::Environment::get().getWorld()->toggleRenderMode (MWBase::World::Render_Pathgrid);
MWBase::Environment::get().getWorld()->toggleRenderMode (MWRender::Render_Pathgrid);
runtime.getContext().report (enabled ?
"Path Grid rendering -> On" : "Path Grid Rendering -> Off");

@ -270,8 +270,8 @@ namespace MWWorld
/// \todo rescale depending on the state of a new GMST
insertCell (*cell, true, loadingListener);
mRendering.addCell(cell);
#if 0
mRendering.cellAdded (cell);
bool waterEnabled = cell->getCell()->hasWater();
mRendering.setWaterEnabled(waterEnabled);
if (waterEnabled)

@ -1501,9 +1501,9 @@ namespace MWWorld
return 0;//mPhysics->toggleCollisionMode();
}
bool World::toggleRenderMode (RenderMode mode)
bool World::toggleRenderMode (MWRender::RenderMode mode)
{
return 0;//mRendering->toggleRenderMode (mode);
return mRendering->toggleRenderMode (mode);
}
const ESM::Potion *World::createRecord (const ESM::Potion& record)

@ -396,7 +396,7 @@ namespace MWWorld
/// collisions and gravity.
///< \return Resulting mode
virtual bool toggleRenderMode (RenderMode mode);
virtual bool toggleRenderMode (MWRender::RenderMode mode);
///< Toggle a render mode.
///< \return Resulting mode

Loading…
Cancel
Save