AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
RenderTarget.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
19#include <agxOSG/export.h>
20#include <agxOSG/ImageCapture.h>
21#include <agx/Object.h>
22#include <agx/Vec2.h>
23
24#include <agx/PushDisableWarnings.h> // Disabling warnings. Include agx/PopDisableWarnings.h below!
25#include <osg/Node>
26#include <osg/Geometry>
27#include <osg/Texture2D>
28#include <osg/Image>
29#include <osg/Camera>
30#include <agx/PopDisableWarnings.h> // End of disabled warnings.
31
32namespace agxOSG
33{
36
41 {
42 public:
43
44
47 {
48 COLOR_BUFFER=osg::Camera::COLOR_BUFFER,
49 DEPTH_BUFFER=osg::Camera::DEPTH_BUFFER
50 };
51
54 {
55 RGBA=GL_RGBA,
56 RGB = GL_RGB,
57 DEPTH_COMPONENT= GL_DEPTH_COMPONENT
58 };
59
61 {
62 DO_NOT_COMPUTE_NEAR_FAR=osg::Camera::DO_NOT_COMPUTE_NEAR_FAR,
63 COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES=osg::Camera::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES,
64 COMPUTE_NEAR_FAR_USING_PRIMITIVES=osg::Camera::COMPUTE_NEAR_FAR_USING_PRIMITIVES,
65 COMPUTE_NEAR_USING_PRIMITIVES=osg::Camera::COMPUTE_NEAR_USING_PRIMITIVES
66 };
67
74
79 void setReferenceCamera(const osg::Camera* referenceCamera);
80
86
91
97 void setSize(agx::UInt width, agx::UInt height);
98
103 void setSize(agx::Vec2u size);
104
107
111 osg::Camera* getCamera();
112
117 void addPreRenderCallback(osg::Camera::DrawCallback* callback);
118
125 void setViewMatrixAsLookAt(const agx::Vec3& eye, const agx::Vec3& center, const agx::Vec3& up);
126
131 void setViewMatrixFromOtherCamera(const osg::Camera *camera);
132
140 void setProjectionMatrixAsPerspective(double fovy, double aspectRatio, double zNear, double zFar);
141
146 void setProjectionMatrixFromOtherCamera(const osg::Camera *camera);
147
154 void setProjectionMatrixAsOrtho(double left, double right, double bottom, double top, double zNear, double zFar);
155
160
167
181 void setCameraCullMask(int cullMask);
182
184 int getCameraCullMask() const;
185
186
187 protected:
188 virtual ~RenderTarget();
189
190 private:
191 class CameraSynchronizeCallback;
192
193 protected:
197 osg::ref_ptr<osg::Camera> m_camera;
198 osg::ref_ptr<CameraSynchronizeCallback> m_cameraSynchronizeCallback;
199 };
200
201
203 class RenderTarget::CameraSynchronizeCallback : public osg::Camera::DrawCallback
204 {
205 public:
206 CameraSynchronizeCallback(const osg::Camera *reference, osg::Camera *target);
207 virtual ~CameraSynchronizeCallback();
208
209 virtual void operator () (osg::RenderInfo& /* renderInfo */) const;
210 using osg::Camera::DrawCallback::operator();
211
212 void addNestedCallback(osg::Camera::DrawCallback *child);
213
214 private:
215 osg::ref_ptr<const osg::Camera> m_reference;
216 osg::ref_ptr<osg::Camera> m_target;
218 };
220}
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
#define AGXOSG_EXPORT
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: agx/Vector.h:34
Render target is used for rendering camera content to a buffer, either a DEPTH or COLOR target.
Definition: RenderTarget.h:41
void setViewMatrixFromOtherCamera(const osg::Camera *camera)
Update the view matrix given the arguments.
TextureFormat
Specifies target texture format.
Definition: RenderTarget.h:54
BufferComponent
Specifies which type of buffer to render.
Definition: RenderTarget.h:47
void setProjectionMatrixAsOrtho(double left, double right, double bottom, double top, double zNear, double zFar)
Update the orthographic projection matrix given the arguments.
void setSize(agx::UInt width, agx::UInt height)
Update the size of the render target buffer size.
osg::Camera * getCamera()
osg::ref_ptr< CameraSynchronizeCallback > m_cameraSynchronizeCallback
Definition: RenderTarget.h:198
ImageCaptureBaseRef m_imageCapture
Definition: RenderTarget.h:196
agx::Vec2 calculateScreenCoords(agx::Vec3 &worldPos)
Transform the position into screen coordinates using the camera associated to this RenderTarget.
void setProjectionMatrixFromOtherCamera(const osg::Camera *camera)
Update the perspective projection matrix from another camera.
void setImageCapture(agxOSG::ImageCaptureBase *imageCapture)
By attaching an ImageCaptureBase you can automatically store the image data to disk given a specific ...
void setComputeNearFarMode(agxOSG::RenderTarget::ComputeNearFarMode mode)
Specifies whether the near far should be automatically updated or not.
void setViewMatrixAsLookAt(const agx::Vec3 &eye, const agx::Vec3 &center, const agx::Vec3 &up)
Update the view matrix given the arguments.
osg::ref_ptr< osg::Camera > m_camera
Definition: RenderTarget.h:197
void setReferenceCamera(const osg::Camera *referenceCamera)
By using a reference camera, the render target camera will get the same view/projection/viewpoint as ...
void addPreRenderCallback(osg::Camera::DrawCallback *callback)
Add a pre-render callback to this RenderTarget.
void setProjectionMatrixAsPerspective(double fovy, double aspectRatio, double zNear, double zFar)
Update the perspective projection matrix given the arguments.
int getCameraCullMask() const
RenderTarget(agx::UInt width, agx::UInt height)
Constructor.
agx::Vec2u getSize() const
void setSize(agx::Vec2u size)
Update the size of the render target buffer size.
void setCameraCullMask(int cullMask)
agxOSG::ImageCaptureBase * getImageCapture()
agx::Object is a refcounted object with a name.
Definition: Object.h:59
Templated vector class.
Definition: agx/Vector.h:53
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition: macros.h:89
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition: macros.h:88
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.
uint64_t UInt
Definition: Integer.h:27