opensurgsim
OsgScreenSpaceQuadRepresentation.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_GRAPHICS_OSGSCREENSPACEQUADREPRESENTATION_H
17 #define SURGSIM_GRAPHICS_OSGSCREENSPACEQUADREPRESENTATION_H
18 
19 #include "SurgSim/DataStructures/OptionalValue.h"
20 #include "SurgSim/Graphics/OsgRepresentation.h"
21 #include "SurgSim/Graphics/OsgUniform.h"
22 #include "SurgSim/Graphics/Representation.h"
23 #include "SurgSim/Graphics/ScreenSpaceQuadRepresentation.h"
24 
25 #include <array>
26 #include <osg/Vec3>
27 
28 #if defined(_MSC_VER)
29 #pragma warning(push)
30 #pragma warning(disable:4250)
31 #endif
32 
33 namespace osg
34 {
35 class Projection;
36 class Geode;
37 class Geometry;
38 }
39 
40 namespace SurgSim
41 {
42 namespace Graphics
43 {
44 
45 class UniformBase;
46 class Texture;
47 class OsgTexture2d;
48 class OsgTextureRectangle;
49 
50 
54 {
55 public:
56 
58  explicit OsgScreenSpaceQuadRepresentation(const std::string& name);
60 
63  virtual void setLocation(double x, double y);
64 
67  virtual void getLocation(double* x, double* y);
68 
72  void setSize(double width, double height) override;
73 
77  void getSize(double* width, double* height) const override;
78 
84  bool setTexture(std::shared_ptr<Texture> texture) override;
85 
91  bool setTexture(std::shared_ptr<OsgTexture2d> texture);
92 
98  bool setTexture(std::shared_ptr<OsgTextureRectangle> texture);
99 
102  void setTransparent(bool value);
103 
106  bool isTransparent();
107 
108 protected:
109  void doUpdate(double dt) override;
110 
111  bool doInitialize() override;
112 
113 private:
114 
116  osg::ref_ptr<osg::Geode> m_geode;
117 
119  osg::ref_ptr<osg::Geometry> m_geometry;
120 
122  osg::ref_ptr<osg::Projection> m_projection;
123 
125  osg::Vec3 m_scale;
126 
129  void setTextureCoordinates(float left, float bottom, float right, float top);
130 
135  bool replaceUniform(const std::string& name, std::shared_ptr<SurgSim::Graphics::UniformBase> newUniform);
136 
138  std::shared_ptr<OsgUniform<std::shared_ptr<OsgTexture2d>>> m_textureUniform;
139 
141  std::shared_ptr<OsgUniform<std::shared_ptr<OsgTextureRectangle>>> m_rectangleTextureUniform;
142 
145 };
146 
147 }; // Graphics
148 }; // SurgSim
149 
150 #if defined(_MSC_VER)
151 #pragma warning(pop)
152 #endif
153 
154 #endif
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
A quad to display on the screen in screen space coordinates, use setPose() to set the position but x...
Definition: ScreenSpaceQuadRepresentation.h:36
Definition: OsgImGuiHandler.h:8
Base OSG implementation of a graphics representation.
Definition: OsgRepresentation.h:55
Implements the ScreenSpaceQuadRepresentation, provides the uniform &#39;texture&#39; for the texture that it ...
Definition: OsgScreenSpaceQuadRepresentation.h:53