1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-07 12:54:00 +00:00
OpenMW/apps/openmw/mwrender/objects.hpp

101 lines
2.6 KiB
C++
Raw Normal View History

2011-11-12 20:58:22 +00:00
#ifndef _GAME_RENDER_OBJECTS_H
#define _GAME_RENDER_OBJECTS_H
#include <OgreColourValue.h>
#include <openengine/ogre/renderer.hpp>
namespace MWWorld
{
class Ptr;
class CellStore;
}
2011-11-01 03:59:16 +00:00
namespace MWRender{
2012-04-19 18:59:57 +00:00
/// information about light needed for rendering
2012-04-28 18:42:53 +00:00
enum LightType
{
// These are all mutually exclusive
LT_Normal=0,
LT_Flicker=1,
LT_FlickerSlow=2,
LT_Pulse=3,
LT_PulseSlow=4
};
2012-04-19 18:59:57 +00:00
struct LightInfo
{
2012-04-28 18:42:53 +00:00
// Constants
2012-04-19 18:59:57 +00:00
std::string name; // ogre handle
Ogre::ColourValue colour;
float radius;
2012-04-28 18:42:53 +00:00
bool interior; // Does this light belong to an interior or exterior cell
LightType type;
// Runtime variables
float flickerVariation; // 25% flicker variation, reset once every 0.5 seconds
float flickerSlowVariation; // 25% flicker variation, reset once every 1.0 seconds
float resetTime;
long double time;
LightInfo() :
flickerVariation(0), resetTime(0.5),
2012-06-06 18:29:30 +00:00
flickerSlowVariation(0), time(0), interior(true),
type(LT_Normal), radius(1.0)
2012-04-28 18:42:53 +00:00
{
}
2012-04-19 18:59:57 +00:00
};
2011-11-01 03:59:16 +00:00
class Objects{
2012-02-06 09:41:13 +00:00
OEngine::Render::OgreRenderer &mRenderer;
std::map<MWWorld::CellStore *, Ogre::SceneNode *> mCellSceneNodes;
std::map<MWWorld::CellStore *, Ogre::StaticGeometry*> mStaticGeometry;
std::map<MWWorld::CellStore *, Ogre::StaticGeometry*> mStaticGeometrySmall;
std::map<MWWorld::CellStore *, Ogre::AxisAlignedBox> mBounds;
2012-04-19 18:59:57 +00:00
std::vector<LightInfo> mLights;
2011-11-22 07:39:28 +00:00
Ogre::SceneNode* mMwRoot;
2012-02-06 09:41:13 +00:00
bool mIsStatic;
2011-11-05 01:57:39 +00:00
static int uniqueID;
static float lightLinearValue;
static float lightLinearRadiusMult;
static bool lightQuadratic;
static float lightQuadraticValue;
static float lightQuadraticRadiusMult;
static bool lightOutQuadInLin;
void clearSceneNode (Ogre::SceneNode *node);
///< Remove all movable objects from \a node.
2011-11-01 03:59:16 +00:00
public:
2012-06-06 18:29:30 +00:00
Objects(OEngine::Render::OgreRenderer& renderer): mRenderer (renderer), mIsStatic(false) {}
2011-11-01 03:59:16 +00:00
~Objects(){}
2011-11-05 01:57:39 +00:00
void insertBegin (const MWWorld::Ptr& ptr, bool enabled, bool static_);
2011-11-01 17:46:57 +00:00
void insertMesh (const MWWorld::Ptr& ptr, const std::string& mesh);
2011-11-05 01:57:39 +00:00
void insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, float radius);
2012-04-02 17:37:24 +00:00
void enableLights();
void disableLights();
2012-04-19 18:59:57 +00:00
void update (const float dt);
///< per-frame update
Ogre::AxisAlignedBox getDimensions(MWWorld::CellStore*);
///< get a bounding box that encloses all objects in the specified cell
bool deleteObject (const MWWorld::Ptr& ptr);
///< \return found?
void removeCell(MWWorld::CellStore* store);
void buildStaticGeometry(MWWorld::CellStore &cell);
2011-11-17 22:10:27 +00:00
void setMwRoot(Ogre::SceneNode* root);
2012-07-11 00:31:03 +00:00
void rebuildStaticGeometry();
2011-11-01 03:59:16 +00:00
};
2011-11-12 20:58:22 +00:00
}
#endif