OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
characterpreview.hpp
Go to the documentation of this file.
1 #ifndef MWRENDER_CHARACTERPREVIEW_H
2 #define MWRENDER_CHARACTERPREVIEW_H
3 
4 #include <osg/ref_ptr>
5 #include <memory>
6 
7 #include <osg/PositionAttitudeTransform>
8 
10 
12 
13 #include "../mwworld/ptr.hpp"
14 
15 namespace osg
16 {
17  class Texture2D;
18  class Camera;
19  class Group;
20 }
21 
22 namespace MWRender
23 {
24 
25  class NpcAnimation;
26  class DrawOnceCallback;
27 
29  {
30  public:
31  CharacterPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character, int sizeX, int sizeY,
32  const osg::Vec3f& position, const osg::Vec3f& lookAt);
33  virtual ~CharacterPreview();
34 
35  int getTextureWidth() const;
36  int getTextureHeight() const;
37 
38  void redraw();
39 
40  void rebuild();
41 
42  osg::ref_ptr<osg::Texture2D> getTexture();
43 
44  private:
47 
48  protected:
49  virtual bool renderHeadOnly() { return false; }
50  virtual void onSetup();
51 
52  osg::ref_ptr<osg::Group> mParent;
54  osg::ref_ptr<osg::Texture2D> mTexture;
55  osg::ref_ptr<osg::Camera> mCamera;
56  osg::ref_ptr<DrawOnceCallback> mDrawOnceCallback;
57 
58  osg::Vec3f mPosition;
59  osg::Vec3f mLookAt;
60 
62 
63  std::auto_ptr<MWRender::NpcAnimation> mAnimation;
64  osg::ref_ptr<osg::PositionAttitudeTransform> mNode;
65  std::string mCurrentAnimGroup;
66 
67  int mSizeX;
68  int mSizeY;
69  };
70 
72  {
73  public:
74 
75  InventoryPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character);
76 
77  void updatePtr(const MWWorld::Ptr& ptr);
78 
79  void update(); // Render preview again, e.g. after changed equipment
80  void setViewport(int sizeX, int sizeY);
81 
82  int getSlotSelected(int posX, int posY);
83 
84  protected:
85  virtual void onSetup();
86  };
87 
89 
91  {
94 
95  protected:
96 
97  virtual bool renderHeadOnly() { return true; }
98  virtual void onSetup();
99 
100  public:
101  RaceSelectionPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem);
102  virtual ~RaceSelectionPreview();
103 
104  void setAngle(float angleRadians);
105 
106  const ESM::NPC &getPrototype() const {
107  return mBase;
108  }
109 
110  void setPrototype(const ESM::NPC &proto);
111 
112  private:
113 
114  osg::ref_ptr<UpdateCameraCallback> mUpdateCameraCallback;
115 
117  };
118 
119 }
120 
121 #endif
void setAngle(float angleRadians)
Definition: characterpreview.cpp:336
virtual void onSetup()
Definition: characterpreview.cpp:310
Wrapper class that constructs and provides access to the most commonly used resource subsystems...
Definition: resourcesystem.hpp:24
osg::Vec3f mPosition
Definition: characterpreview.hpp:58
void rebuild()
Definition: characterpreview.cpp:172
Definition: characterpreview.hpp:28
float mPitchRadians
Definition: characterpreview.hpp:116
MWWorld::LiveCellRef< ESM::NPC > mRef
Definition: characterpreview.hpp:93
void redraw()
Definition: characterpreview.cpp:184
virtual ~RaceSelectionPreview()
Definition: characterpreview.cpp:332
osg::ref_ptr< osg::PositionAttitudeTransform > mNode
Definition: characterpreview.hpp:64
Definition: characterpreview.hpp:71
void setPrototype(const ESM::NPC &proto)
Definition: characterpreview.cpp:343
ESM::NPC mBase
Definition: characterpreview.hpp:92
InventoryPreview(osg::Group *parent, Resource::ResourceSystem *resourceSystem, MWWorld::Ptr character)
Definition: characterpreview.cpp:193
virtual bool renderHeadOnly()
Definition: characterpreview.hpp:49
osg::ref_ptr< osg::Texture2D > getTexture()
Definition: characterpreview.cpp:167
Definition: characterpreview.hpp:90
int mSizeY
Definition: characterpreview.hpp:68
osg::ref_ptr< UpdateCameraCallback > mUpdateCameraCallback
Definition: characterpreview.hpp:114
Definition: loadnpc.hpp:23
virtual bool renderHeadOnly()
Definition: characterpreview.hpp:97
osg::Vec3f mLookAt
Definition: characterpreview.hpp:59
CharacterPreview & operator=(const CharacterPreview &)
Definition: characterpreview.cpp:350
std::string mCurrentAnimGroup
Definition: characterpreview.hpp:65
int mSizeX
Definition: characterpreview.hpp:67
osg::ref_ptr< osg::Group > mParent
Definition: characterpreview.hpp:52
osg::ref_ptr< DrawOnceCallback > mDrawOnceCallback
Definition: characterpreview.hpp:56
osg::ref_ptr< osg::Texture2D > mTexture
Definition: characterpreview.hpp:54
void setViewport(int sizeX, int sizeY)
Definition: characterpreview.cpp:198
Resource::ResourceSystem * mResourceSystem
Definition: characterpreview.hpp:53
virtual void onSetup()
Definition: characterpreview.cpp:383
int getTextureHeight() const
Definition: characterpreview.cpp:158
CharacterPreview(osg::Group *parent, Resource::ResourceSystem *resourceSystem, MWWorld::Ptr character, int sizeX, int sizeY, const osg::Vec3f &position, const osg::Vec3f &lookAt)
Definition: characterpreview.cpp:68
std::auto_ptr< MWRender::NpcAnimation > mAnimation
Definition: characterpreview.hpp:63
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
virtual ~CharacterPreview()
Definition: characterpreview.cpp:147
const ESM::NPC & getPrototype() const
Definition: characterpreview.hpp:106
osg::ref_ptr< osg::Camera > mCamera
Definition: characterpreview.hpp:55
void updatePtr(const MWWorld::Ptr &ptr)
Definition: characterpreview.cpp:305
MWWorld::Ptr mCharacter
Definition: characterpreview.hpp:61
RaceSelectionPreview(osg::Group *parent, Resource::ResourceSystem *resourceSystem)
Definition: characterpreview.cpp:322
virtual void onSetup()
Definition: characterpreview.cpp:163
void update()
Definition: characterpreview.cpp:208
int getSlotSelected(int posX, int posY)
Definition: characterpreview.cpp:276
int getTextureWidth() const
Definition: characterpreview.cpp:153