2014-01-05 17:22:29 +00:00
|
|
|
#ifndef GAME_RENDER_OBJECTS_H
|
|
|
|
#define GAME_RENDER_OBJECTS_H
|
2011-11-12 20:58:22 +00:00
|
|
|
|
2015-04-22 17:08:56 +00:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
2015-04-12 13:34:50 +00:00
|
|
|
|
2015-05-24 01:36:34 +00:00
|
|
|
#include <osg/Object>
|
2015-04-12 13:34:50 +00:00
|
|
|
#include <osg/ref_ptr>
|
2015-05-24 01:36:34 +00:00
|
|
|
|
|
|
|
#include "../mwworld/ptr.hpp"
|
2015-04-12 13:34:50 +00:00
|
|
|
|
|
|
|
namespace osg
|
|
|
|
{
|
|
|
|
class Group;
|
|
|
|
}
|
2012-02-06 09:29:18 +00:00
|
|
|
|
2015-04-22 17:08:56 +00:00
|
|
|
namespace Resource
|
|
|
|
{
|
|
|
|
class ResourceSystem;
|
|
|
|
}
|
|
|
|
|
2012-07-03 11:55:53 +00:00
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
class CellStore;
|
|
|
|
}
|
2011-11-01 03:59:16 +00:00
|
|
|
|
2022-07-24 18:55:03 +00:00
|
|
|
namespace SceneUtil
|
|
|
|
{
|
|
|
|
class UnrefQueue;
|
|
|
|
}
|
|
|
|
|
2011-11-01 03:59:16 +00:00
|
|
|
namespace MWRender
|
|
|
|
{
|
2011-11-08 04:35:39 +00:00
|
|
|
|
2015-04-12 13:34:50 +00:00
|
|
|
class Animation;
|
2013-08-07 02:45:07 +00:00
|
|
|
|
2015-05-24 01:36:34 +00:00
|
|
|
class PtrHolder : public osg::Object
|
|
|
|
{
|
2022-09-22 18:26:05 +00:00
|
|
|
public:
|
2017-04-20 11:36:14 +00:00
|
|
|
PtrHolder(const MWWorld::Ptr& ptr)
|
2015-05-24 01:36:34 +00:00
|
|
|
: mPtr(ptr)
|
2022-09-22 18:26:05 +00:00
|
|
|
{
|
2015-05-24 01:36:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PtrHolder() {}
|
|
|
|
|
|
|
|
PtrHolder(const PtrHolder& copy, const osg::CopyOp& copyop)
|
|
|
|
: mPtr(copy.mPtr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
META_Object(MWRender, PtrHolder)
|
|
|
|
|
|
|
|
MWWorld::Ptr mPtr;
|
|
|
|
};
|
2013-08-07 02:45:07 +00:00
|
|
|
|
2022-05-20 21:07:50 +00:00
|
|
|
class Objects
|
|
|
|
{
|
|
|
|
using PtrAnimationMap = std::map<const MWWorld::LiveCellRefBase*, osg::ref_ptr<Animation>>;
|
2013-08-07 02:45:07 +00:00
|
|
|
|
2015-04-12 13:34:50 +00:00
|
|
|
typedef std::map<const MWWorld::CellStore*, osg::ref_ptr<osg::Group>> CellMap;
|
|
|
|
CellMap mCellSceneNodes;
|
2013-08-07 02:45:07 +00:00
|
|
|
PtrAnimationMap mObjects;
|
2015-04-12 13:34:50 +00:00
|
|
|
osg::ref_ptr<osg::Group> mRootNode;
|
|
|
|
Resource::ResourceSystem* mResourceSystem;
|
2022-07-24 18:55:03 +00:00
|
|
|
SceneUtil::UnrefQueue& mUnrefQueue;
|
2013-11-19 23:07:26 +00:00
|
|
|
|
2016-02-09 14:30:53 +00:00
|
|
|
void insertBegin(const MWWorld::Ptr& ptr);
|
|
|
|
|
2011-11-01 03:59:16 +00:00
|
|
|
public:
|
2022-07-24 18:55:03 +00:00
|
|
|
Objects(Resource::ResourceSystem* resourceSystem, const osg::ref_ptr<osg::Group>& rootNode,
|
|
|
|
SceneUtil::UnrefQueue& unrefQueue);
|
2015-04-12 13:34:50 +00:00
|
|
|
~Objects();
|
|
|
|
|
2015-04-14 13:55:56 +00:00
|
|
|
/// @param allowLight If false, no lights will be created, and particles systems will be removed.
|
2023-01-14 01:36:06 +00:00
|
|
|
void insertModel(const MWWorld::Ptr& ptr, const std::string& model, bool allowLight = true);
|
2011-11-21 11:52:28 +00:00
|
|
|
|
2015-04-12 13:34:50 +00:00
|
|
|
void insertNPC(const MWWorld::Ptr& ptr);
|
|
|
|
void insertCreature(const MWWorld::Ptr& ptr, const std::string& model, bool weaponsShields);
|
|
|
|
|
|
|
|
Animation* getAnimation(const MWWorld::Ptr& ptr);
|
2015-12-18 16:21:51 +00:00
|
|
|
const Animation* getAnimation(const MWWorld::ConstPtr& ptr) const;
|
2013-11-17 22:15:57 +00:00
|
|
|
|
2015-05-21 22:55:43 +00:00
|
|
|
bool removeObject(const MWWorld::Ptr& ptr);
|
2011-11-21 11:52:28 +00:00
|
|
|
///< \return found?
|
|
|
|
|
2015-04-12 13:34:50 +00:00
|
|
|
void removeCell(const MWWorld::CellStore* store);
|
2012-07-30 19:28:14 +00:00
|
|
|
|
2012-07-31 12:52:21 +00:00
|
|
|
/// Updates containing cell for object rendering data
|
2015-05-14 15:34:55 +00:00
|
|
|
void updatePtr(const MWWorld::Ptr& old, const MWWorld::Ptr& cur);
|
2015-04-12 13:34:50 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void operator=(const Objects&);
|
|
|
|
Objects(const Objects&);
|
2011-11-01 03:59:16 +00:00
|
|
|
};
|
2011-11-12 20:58:22 +00:00
|
|
|
}
|
2011-11-21 11:52:28 +00:00
|
|
|
#endif
|