Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
ImageSprite.h
1 //
2 // ImageSprite.h
3 //
4 // Copyright (c) 2001-2011 Virtual Terrain Project
5 // Free for all uses, see license.txt for details.
6 //
7 
8 #ifndef VTLIB_IMAGESPRITE
9 #define VTLIB_IMAGESPRITE
10 
16 class vtImageSprite : public osg::Referenced
17 {
18 public:
19  vtImageSprite();
20  ~vtImageSprite();
21  bool Create(const char *szTextureName, bool bBlending = false);
22  bool Create(osg::Image *pImage, bool bBlending = false);
23  IPoint2 GetSize() const { return m_Size; }
24  void SetPosition(float l, float t, float r, float b, float rot = 0.0f);
25  void SetImage(osg::Image *image);
26  vtGeode *GetGeode() const { return m_pGeode; }
27 
28 protected:
29  vtMaterialArrayPtr m_pMats;
30  vtGeode *m_pGeode;
31  vtMesh *m_pMesh;
32  IPoint2 m_Size;
33 };
34 
39 class vtSpriteSizer : public vtEngine
40 {
41 public:
42  vtSpriteSizer(vtImageSprite *pSprite, float l, float t, float r, float b);
43 
44  void SetRect(const FRECT &rect) { m_rect = rect; }
45  FRECT GetRect() { return m_rect; }
46  FRECT GetWindowRect() { return m_window_rect; }
47  FPoint2 GetWindowCenter();
48 
49  void SetRotation(float rot) { m_fRotation = rot; }
50  float GetRotation() { return m_fRotation; }
51 
52  void OnWindowSize(int width, int height);
53 
54 protected:
55  FRECT m_rect;
56  FRECT m_window_rect;
57  float m_fRotation;
58  osg::ref_ptr<vtImageSprite> m_pSprite;
59 };
60 
61 #endif // VTLIB_IMAGESPRITE