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 Resource
19 {
20  class ResourceSystem;
21 }
22 
23 namespace MWWorld
24 {
25  class CellStore;
26 }
27 
28 namespace SceneUtil
29 {
30  class UnrefQueue;
31 }
32 
33 namespace MWRender{
34 
35 class Animation;
36 
37 class PtrHolder : public osg::Object
38 {
39 public:
40  PtrHolder(const MWWorld::Ptr& ptr)
41  : mPtr(ptr)
42  {
43  }
44 
46  {
47  }
48 
49  PtrHolder(const PtrHolder& copy, const osg::CopyOp& copyop)
50  : mPtr(copy.mPtr)
51  {
52  }
53 
54  META_Object(MWRender, PtrHolder)
55 
56  MWWorld::Ptr mPtr;
57 };
58 
59 class Objects{
60  typedef std::map<MWWorld::ConstPtr,osg::ref_ptr<Animation> > PtrAnimationMap;
61 
62  typedef std::map<const MWWorld::CellStore*, osg::ref_ptr<osg::Group> > CellMap;
63  CellMap mCellSceneNodes;
64  PtrAnimationMap mObjects;
65 
66  osg::ref_ptr<osg::Group> mRootNode;
67 
69 
70  osg::ref_ptr<SceneUtil::UnrefQueue> mUnrefQueue;
71 
72  void insertBegin(const MWWorld::Ptr& ptr);
73 
74 public:
75  Objects(Resource::ResourceSystem* resourceSystem, osg::ref_ptr<osg::Group> rootNode, SceneUtil::UnrefQueue* unrefQueue);
76  ~Objects();
77 
80  void insertModel(const MWWorld::Ptr& ptr, const std::string &model, bool animated=false, bool allowLight=true);
81 
82  void insertNPC(const MWWorld::Ptr& ptr);
83  void insertCreature (const MWWorld::Ptr& ptr, const std::string& model, bool weaponsShields);
84 
85  Animation* getAnimation(const MWWorld::Ptr &ptr);
86  const Animation* getAnimation(const MWWorld::ConstPtr &ptr) const;
87 
88  bool removeObject (const MWWorld::Ptr& ptr);
90 
91  void removeCell(const MWWorld::CellStore* store);
92 
94  void updatePtr(const MWWorld::Ptr &old, const MWWorld::Ptr &cur);
95 
96 private:
97  void operator = (const Objects&);
98  Objects(const Objects&);
99 };
100 }
101 #endif
Definition: objects.hpp:37
Wrapper class that constructs and provides access to the most commonly used resource subsystems...
Definition: resourcesystem.hpp:30
void copy(const btTransform &src, Nif::Transformation &dst)
Definition: testbulletnifloader.cpp:269
Definition: animation.hpp:85
PtrHolder(const PtrHolder &copy, const osg::CopyOp &copyop)
Definition: objects.hpp:49
std::map< MWWorld::ConstPtr, osg::ref_ptr< Animation > > PtrAnimationMap
Definition: objects.hpp:60
PtrAnimationMap mObjects
Definition: objects.hpp:64
osg::ref_ptr< osg::Group > mRootNode
Definition: objects.hpp:66
Mutable state of a cell.
Definition: cellstore.hpp:51
Pointer to a const LiveCellRef.
Definition: ptr.hpp:90
CellMap mCellSceneNodes
Definition: objects.hpp:63
PtrHolder()
Definition: objects.hpp:45
PtrHolder(const MWWorld::Ptr &ptr)
Definition: objects.hpp:40
std::map< const MWWorld::CellStore *, osg::ref_ptr< osg::Group > > CellMap
Definition: objects.hpp:62
Handles unreferencing of objects through the WorkQueue. Typical use scenario would be the main thread...
Definition: unrefqueue.hpp:24
Resource::ResourceSystem * mResourceSystem
Definition: objects.hpp:68
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
osg::ref_ptr< SceneUtil::UnrefQueue > mUnrefQueue
Definition: objects.hpp:70
Definition: objects.hpp:59