Camera.h
Go to the documentation of this file.
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_CAMERA_H
17 #define SURGSIM_GRAPHICS_CAMERA_H
18 
20 
21 #include "SurgSim/Math/Matrix.h"
22 #include "SurgSim/Math/Vector.h"
23 
24 namespace SurgSim
25 {
26 
27 namespace Graphics
28 {
29 
30 class Group;
31 class Texture;
32 class RenderTarget;
33 
49 class Camera : public virtual Representation
50 {
51 public:
52 
54  {
59  };
60 
63  explicit Camera(const std::string& name);
64 
68  void setRenderGroupReference(const std::string& name);
69 
72  std::string getRenderGroupReference() const;
73 
79  virtual bool setRenderGroup(std::shared_ptr<Group> group);
80 
84  std::shared_ptr<Group> getRenderGroup() const;
85 
88  virtual SurgSim::Math::Matrix44d getViewMatrix() const = 0;
89 
93 
96  virtual void setProjectionMatrix(const SurgSim::Math::Matrix44d& matrix) = 0;
97 
100  virtual const SurgSim::Math::Matrix44d& getProjectionMatrix() const = 0;
101 
104  virtual bool setRenderTarget(std::shared_ptr<RenderTarget> renderTarget) = 0;
105 
108  virtual std::shared_ptr<RenderTarget> getRenderTarget() const = 0;
109 
116  virtual void setRenderOrder(RenderOrder order, int value) = 0;
117 
118  virtual bool addGroupReference(const std::string& name) override;
119 
122  virtual void setAmbientColor(const SurgSim::Math::Vector4d& color) = 0;
123 
126 
127 
128 private:
129 
130  virtual bool doInitialize() override;
131 
134  std::shared_ptr<Group> m_group;
135 
139 };
140 
141 }; // namespace Graphics
142 
143 }; // namespace SurgSim
144 
145 #endif // SURGSIM_GRAPHICS_CAMERA_H
Definition: DriveElementFromInputBehavior.cpp:27
std::string m_renderGroupReference
The name of the group that the camera wants to use for rendering, the graphics manager will actually ...
Definition: Camera.h:138
Camera(const std::string &name)
Constructor.
Definition: Camera.cpp:24
virtual const SurgSim::Math::Matrix44d & getProjectionMatrix() const =0
Gets the projection matrix of the camera.
virtual SurgSim::Math::Matrix44d getViewMatrix() const =0
Gets the view matrix of the camera.
virtual SurgSim::Math::Matrix44d getInverseViewMatrix() const =0
Gets the inverse view matrix of the camera.
virtual void setAmbientColor(const SurgSim::Math::Vector4d &color)=0
Sets a value for the ambient lighting term, this can add light to the scene when there is no lighting...
virtual bool setRenderGroup(std::shared_ptr< Group > group)
Sets the group of representations that will be seen by this camera.
Definition: Camera.cpp:50
virtual bool addGroupReference(const std::string &name) override
Add a reference to a group, this will eventual add this representation to the group with the the same...
Definition: Camera.cpp:61
Eigen::Matrix< double, 4, 4, Eigen::RowMajor > Matrix44d
A 4x4 matrix of doubles.
Definition: Matrix.h:55
Base graphics camera class, which defines the basic interface for all graphics cameras.
Definition: Camera.h:49
std::string getRenderGroupReference() const
Gets the name of the rendergroup used for rendering.
Definition: Camera.cpp:45
virtual bool setRenderTarget(std::shared_ptr< RenderTarget > renderTarget)=0
Sets RenderTarget for the current camera, enables the camera to render to off-screen textures...
virtual void setProjectionMatrix(const SurgSim::Math::Matrix44d &matrix)=0
Sets the projection matrix of the camera.
Base graphics representation class, which defines the interface that all graphics representations mus...
Definition: Representation.h:39
std::shared_ptr< Group > getRenderGroup() const
Gets the group of representations that will be seen by this camera.
Definition: Camera.cpp:56
Definitions of small fixed-size square matrix types.
Definitions of small fixed-size vector types.
virtual SurgSim::Math::Vector4d getAmbientColor()=0
virtual void setRenderOrder(RenderOrder order, int value)=0
Determine when this camera will render.
virtual std::shared_ptr< RenderTarget > getRenderTarget() const =0
Gets RenderTarget that is currently being used by the camera.
Eigen::Matrix< double, 4, 1 > Vector4d
A 4D vector of doubles.
Definition: Vector.h:60
RenderOrder
Definition: Camera.h:53
virtual bool doInitialize() override
Interface to be implemented by derived classes.
Definition: Camera.cpp:71
std::shared_ptr< Group > m_group
Group of representations that this camera sees Only the representations in this group will be rendere...
Definition: Camera.h:134
void setRenderGroupReference(const std::string &name)
Set the group reference that this camera wants to use as the group for rendering. ...
Definition: Camera.cpp:39