OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
objects.hpp
Go to the documentation of this file.
1 #ifndef GAME_RENDER_OBJECTS_H
2 #define GAME_RENDER_OBJECTS_H
3 
4 #include <map>
5 #include <memory>
6 #include <string>
7 
8 #include <osg/ref_ptr>
9 #include <osg/Object>
10 
11 #include "../mwworld/ptr.hpp"
12 
13 namespace osg
14 {
15  class Group;
16 }
17 
18 namespace osgUtil
19 {
20  class IncrementalCompileOperation;
21 }
22 
23 namespace Resource
24 {
25  class ResourceSystem;
26 }
27 
28 namespace MWWorld
29 {
30  class CellStore;
31 }
32 
33 namespace SceneUtil
34 {
35  class UnrefQueue;
36 }
37 
38 namespace MWRender{
39 
40 class Animation;
41 
42 class PtrHolder : public osg::Object
43 {
44 public:
46  : mPtr(ptr)
47  {
48  }
49 
51  {
52  }
53 
54  PtrHolder(const PtrHolder& copy, const osg::CopyOp& copyop)
55  : mPtr(copy.mPtr)
56  {
57  }
58 
59  META_Object(MWRender, PtrHolder)
60 
61  MWWorld::Ptr mPtr;
62 };
63 
64 class Objects{
65  typedef std::map<MWWorld::ConstPtr,Animation*> PtrAnimationMap;
66 
67  typedef std::map<const MWWorld::CellStore*, osg::ref_ptr<osg::Group> > CellMap;
68  CellMap mCellSceneNodes;
69  PtrAnimationMap mObjects;
70 
71  osg::ref_ptr<osg::Group> mRootNode;
72 
74 
75  osg::ref_ptr<SceneUtil::UnrefQueue> mUnrefQueue;
76 
77  void insertBegin(const MWWorld::Ptr& ptr);
78 
79 public:
80  Objects(Resource::ResourceSystem* resourceSystem, osg::ref_ptr<osg::Group> rootNode, SceneUtil::UnrefQueue* unrefQueue);
81  ~Objects();
82 
85  void insertModel(const MWWorld::Ptr& ptr, const std::string &model, bool animated=false, bool allowLight=true);
86 
87  void insertNPC(const MWWorld::Ptr& ptr);
88  void insertCreature (const MWWorld::Ptr& ptr, const std::string& model, bool weaponsShields);
89 
90  Animation* getAnimation(const MWWorld::Ptr &ptr);
91  const Animation* getAnimation(const MWWorld::ConstPtr &ptr) const;
92 
93  bool removeObject (const MWWorld::Ptr& ptr);
95 
96  void removeCell(const MWWorld::CellStore* store);
97 
99  void updatePtr(const MWWorld::Ptr &old, const MWWorld::Ptr &cur);
100 
101 private:
102  void operator = (const Objects&);
103  Objects(const Objects&);
104 };
105 }
106 #endif
Definition: objects.hpp:42
Wrapper class that constructs and provides access to the most commonly used resource subsystems...
Definition: resourcesystem.hpp:24
Definition: animation.hpp:77
PtrHolder(const PtrHolder &copy, const osg::CopyOp &copyop)
Definition: objects.hpp:54
PtrHolder(MWWorld::Ptr ptr)
Definition: objects.hpp:45
std::map< MWWorld::ConstPtr, Animation * > PtrAnimationMap
Definition: objects.hpp:65
PtrAnimationMap mObjects
Definition: objects.hpp:69
osg::ref_ptr< osg::Group > mRootNode
Definition: objects.hpp:71
Mutable state of a cell.
Definition: cellstore.hpp:53
Pointer to a const LiveCellRef.
Definition: ptr.hpp:90
CellMap mCellSceneNodes
Definition: objects.hpp:68
PtrHolder()
Definition: objects.hpp:50
std::map< const MWWorld::CellStore *, osg::ref_ptr< osg::Group > > CellMap
Definition: objects.hpp:67
Handles unreferencing of objects through the WorkQueue. Typical use scenario would be the main thread...
Definition: unrefqueue.hpp:19
Resource::ResourceSystem * mResourceSystem
Definition: objects.hpp:73
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
osg::ref_ptr< SceneUtil::UnrefQueue > mUnrefQueue
Definition: objects.hpp:75
Definition: objects.hpp:64