cherish
Photo.h
1 /* Photo
2  * for more info on textures, see OpenSceneGraph beginner's guide,
3  * Chapter 6 "The basis of texture mapping"
4  */
5 
6 #ifndef PHOTO
7 #define PHOTO
8 
9 #include "Entity2D.h"
10 
11 #include <osg/Geometry>
12 #include <osg/ref_ptr>
13 #include <osg/Texture2D>
14 #include <osgDB/ObjectWrapper>
15 #include <SVMData.h>
16 
17 namespace entity {
18 
22 class Photo: public entity::Entity2D{
23 public:
25  Photo();
26 
28  Photo(const Photo& photo, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
29 
30  META_Node(entity, Photo)
31 
32  void setTexture(osg::Texture2D* texture);
33  const osg::Texture2D* getTexture() const;
34 
35  void setWidth(float w);
36  float getWidth() const;
37 
38  void setHeight(float h);
39  float getHeight() const;
40 
41  void setCenter(const osg::Vec3f& c);
42  const osg::Vec3f& getCenter() const;
43 
44  void setAngle(float a);
45  float getAngle() const;
46 
47  void loadImage(const std::string& fname);
48  osg::StateAttribute* getTextureAsAttribute() const;
49 
53  void move(const double u, const double v);
54 
58  void moveDelta(double du, double dv);
59 
62  void rotate(double angle);
63 
67  void rotate(double theta, osg::Vec3f center);
68 
70  void flipH();
71 
73  void flipV();
74 
76  void scale(double scale, osg::Vec3f center);
77 
79  void scale(double scaleX, double scaleY, osg::Vec3f center);
80 
85  bool scaleWithinViewport(const osg::Plane& plane, const osg::Vec3f& C, const osg::Matrix& invM);
86 
88  void scaleAndPositionWith(const entity::SVMData* svm, const osg::Vec3d& eye, const osg::Vec3d& center, const osg::Vec3d& up);
89 
91  void setColor(const osg::Vec4f& color);
92 
94  const osg::Vec4f& getColor() const;
95 
96  virtual void setSelected(float alpha);
97 
98  virtual void setUnselected(float alpha);
99 
101  void setTransparency(float alpha);
102 
104  float getTransparency() const;
105 
107  cher::ENTITY_TYPE getEntityType() const;
108 
109 protected:
110  void updateVertices();
111 
112 private:
113  osg::ref_ptr<osg::Texture2D> m_texture;
114  osg::Vec3f m_center;
115  float m_width, m_height;
116  float m_angle;
117  osg::Vec4f m_color;
118 };
119 }
120 
121 #endif // PHOTO
122 
void setTransparency(float alpha)
Definition: Photo.cpp:398
void flipV()
Definition: Photo.cpp:187
Definition: SVMData.h:22
void rotate(double angle)
Definition: Photo.cpp:157
Scene graph entities.
Definition: AddEntityCommand.h:17
void scaleAndPositionWith(const entity::SVMData *svm, const osg::Vec3d &eye, const osg::Vec3d &center, const osg::Vec3d &up)
Definition: Photo.cpp:290
Photo()
Definition: Photo.cpp:18
Definition: Entity2D.h:13
void scale(double scale, osg::Vec3f center)
Definition: Photo.cpp:200
bool scaleWithinViewport(const osg::Plane &plane, const osg::Vec3f &C, const osg::Matrix &invM)
Definition: Photo.cpp:225
float getTransparency() const
Definition: Photo.cpp:416
void move(const double u, const double v)
Definition: Photo.cpp:142
Quad that uses texture to represent a 2D photo in 3D space.
Definition: Photo.h:22
void flipH()
Definition: Photo.cpp:174
void setColor(const osg::Vec4f &color)
Definition: Photo.cpp:352
void moveDelta(double du, double dv)
Definition: Photo.cpp:148
cher::ENTITY_TYPE getEntityType() const
Definition: Photo.cpp:428
const osg::Vec4f & getColor() const
Definition: Photo.cpp:370