16 #ifndef SURGSIM_GRAPHICS_OSGCAMERA_H 17 #define SURGSIM_GRAPHICS_OSGCAMERA_H 19 #include <unordered_map> 21 #include "SurgSim/Framework/Macros.h" 22 #include "SurgSim/Framework/ObjectFactory.h" 23 #include "SurgSim/Graphics/Camera.h" 24 #include "SurgSim/Graphics/OsgRepresentation.h" 25 #include "SurgSim/Graphics/Texture.h" 33 #pragma warning(disable:4250) 62 explicit OsgCamera(
const std::string& name);
68 bool setRenderGroups(
const std::vector<std::shared_ptr<Group>>& groups)
override;
82 void update(
double dt)
override;
90 bool setRenderTarget(std::shared_ptr<RenderTarget> renderTarget)
override;
94 bool setMaterial(std::shared_ptr<SurgSim::Framework::Component> material)
override;
96 std::shared_ptr<Material>
getMaterial()
const override;
111 double left,
double right,
112 double bottom,
double top,
113 double near,
double far)
override;
116 void setViewport(
int x,
int y,
int width,
int height)
override;
118 void getViewport(
int* x,
int* y,
int* width,
int* height)
const override;
130 osg::ref_ptr<osg::Camera> m_camera;
135 std::unordered_map<int, std::shared_ptr<Texture>> m_textureMap;
136 std::shared_ptr<RenderTarget> m_renderTarget;
141 void attachRenderTargetTexture(osg::Camera::BufferComponent buffer, std::shared_ptr<Texture> texture);
144 void detachCurrentRenderTarget();
147 std::shared_ptr<OsgUniform<SurgSim::Math::Matrix44f>> m_viewMatrixUniform;
150 std::shared_ptr<OsgUniform<SurgSim::Math::Matrix44f>> m_inverseViewMatrixUniform;
153 std::shared_ptr<OsgUniform<SurgSim::Math::Vector4f>> m_ambientColorUniform;
164 #if defined(_MSC_VER) 168 #endif // SURGSIM_GRAPHICS_OSGCAMERA_H void setMainCamera(bool val) override
Marks the camera as a main view camera, this means that view dependent passes should follow this came...
Definition: OsgCamera.cpp:411
void setViewportSize(std::array< double, 2 > dimensions) override
Sets the width and height of the viewport.
Definition: OsgCamera.cpp:383
bool setMaterial(std::shared_ptr< SurgSim::Framework::Component > material) override
Sets the material that defines the visual appearance of the representation.
Definition: OsgCamera.cpp:324
void setProjectionMatrix(const SurgSim::Math::Matrix44d &matrix) override
Sets the projection matrix of the camera.
Definition: OsgCamera.cpp:240
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
void setPerspectiveProjection(double fovy, double aspect, double near, double far) override
Set the projection matrix with the appropriate perspective projection parameters. ...
Definition: OsgCamera.cpp:445
Eigen::Matrix< double, 4, 1 > Vector4d
A 4D vector of doubles.
Definition: Vector.h:61
std::shared_ptr< RenderTarget > getRenderTarget() const override
Gets RenderTarget that is currently being used by the camera.
Definition: OsgCamera.cpp:318
void clearMaterial() override
Removes the material from the representation.
Definition: OsgCamera.cpp:342
SurgSim::Math::Matrix44d getInverseProjectionMatrix() const override
Gets the inverse projection matrix of the camera.
Definition: OsgCamera.cpp:251
osg::ref_ptr< osg::Node > getOsgNode() const
Definition: OsgCamera.cpp:489
Eigen::Matrix< double, 4, 4, Eigen::RowMajor > Matrix44d
A 4x4 matrix of doubles.
Definition: Matrix.h:55
osg::ref_ptr< osg::Camera > getOsgCamera() const
Definition: OsgCamera.cpp:484
void setRenderOrder(RenderOrder order, int value) override
Determine when this camera will render.
Definition: OsgCamera.cpp:476
OSG implementation of a graphics camera.
Definition: OsgCamera.h:54
Base graphics camera class, which defines the basic interface for all graphics cameras.
Definition: Camera.h:51
void setViewport(int x, int y, int width, int height) override
Sets the viewport size for this camera.
Definition: OsgCamera.cpp:363
void setGenerateTangents(bool value) override
Enable or disable the generation of tangents.
Definition: OsgCamera.cpp:510
bool setRenderTarget(std::shared_ptr< RenderTarget > renderTarget) override
Sets RenderTarget for the current camera, enables the camera to render to off-screen textures...
Definition: OsgCamera.cpp:276
std::shared_ptr< Material > getMaterial() const override
Gets the material that defines the visual appearance of the representation.
Definition: OsgCamera.cpp:337
void getViewport(int *x, int *y, int *width, int *height) const override
collect the viewport values
Definition: OsgCamera.cpp:368
void setLocalActive(bool val) override
Set the component's active state.
Definition: OsgCamera.cpp:229
void update(double dt) override
Updates the representation.
Definition: OsgCamera.cpp:256
std::array< double, 2 > getViewportSize() const override
Gets the dimensions of the viewport.
Definition: OsgCamera.cpp:400
const SurgSim::Math::Matrix44d & getProjectionMatrix() const override
Gets the projection matrix of the camera.
Definition: OsgCamera.cpp:246
bool isMainCamera() override
Definition: OsgCamera.cpp:440
OsgCamera(const std::string &name)
Constructor.
Definition: OsgCamera.cpp:147
virtual SurgSim::Math::Matrix44d getViewMatrix() const
Gets the view matrix of the camera.
Definition: OsgCamera.cpp:235
void setAmbientColor(const SurgSim::Math::Vector4d &color) override
Sets a value for the ambient lighting term, this can add light to the scene when there is no lighting...
Definition: OsgCamera.cpp:499
void setOrthogonalProjection(double left, double right, double bottom, double top, double near, double far) override
Set the projection matrix with the appropriate orthogonal projection parameters.
Definition: OsgCamera.cpp:452
SurgSim::Math::Vector4d getAmbientColor() override
Definition: OsgCamera.cpp:505
virtual SurgSim::Math::Matrix44d getInverseViewMatrix() const
Gets the inverse view matrix of the camera.
Definition: OsgCamera.cpp:494
bool setRenderGroup(std::shared_ptr< Group > group) override
Sets the group of representations that will be seen by this camera.
Definition: OsgCamera.cpp:190
Base OSG implementation of a graphics representation.
Definition: OsgRepresentation.h:55
bool setRenderGroups(const std::vector< std::shared_ptr< Group >> &groups) override
Sets the representation groups that will be seen by this camera.
Definition: OsgCamera.cpp:196