AGX Dynamics 2.42.1.1
Loading...
Searching...
No Matches
agxOSG::RenderTarget Class Reference

Render target is used for rendering camera content to a buffer, either a DEPTH or COLOR target. More...

#include <RenderTarget.h>

+ Inheritance diagram for agxOSG::RenderTarget:

Public Types

enum  BufferComponent { COLOR_BUFFER =osg::Camera::COLOR_BUFFER , DEPTH_BUFFER =osg::Camera::DEPTH_BUFFER }
 Specifies which type of buffer to render. More...
 
enum  ComputeNearFarMode { DO_NOT_COMPUTE_NEAR_FAR =osg::Camera::DO_NOT_COMPUTE_NEAR_FAR , COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES =osg::Camera::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES , COMPUTE_NEAR_FAR_USING_PRIMITIVES =osg::Camera::COMPUTE_NEAR_FAR_USING_PRIMITIVES , COMPUTE_NEAR_USING_PRIMITIVES =osg::Camera::COMPUTE_NEAR_USING_PRIMITIVES }
 
enum  TextureFormat { RGBA =GL_RGBA , RGB = GL_RGB , DEPTH_COMPONENT = GL_DEPTH_COMPONENT }
 Specifies target texture format. More...
 
- Public Types inherited from agx::Object
typedef agx::observer_ptr< const EventEventConstObserver
 
typedef agx::ref_ptr< const EventEventConstRef
 
typedef agx::observer_ptr< EventEventObserver
 
typedef agx::Vector< EventObserverEventObserverVector
 
typedef agx::VectorPOD< Event * > EventPtrVector
 
typedef agx::ref_ptr< EventEventRef
 
typedef agx::Vector< EventRefEventRefVector
 

Public Member Functions

 RenderTarget (agx::UInt width, agx::UInt height)
 Constructor.
 
void addPreRenderCallback (osg::Camera::DrawCallback *callback)
 Add a pre-render callback to this RenderTarget.
 
agx::Vec2 calculateScreenCoords (agx::Vec3 &worldPos)
 Transform the position into screen coordinates using the camera associated to this RenderTarget.
 
osg::Camera * getCamera ()
 
int getCameraCullMask () const
 
agxOSG::ImageCaptureBasegetImageCapture ()
 
agx::Vec2u getSize () const
 
void setCameraCullMask (int cullMask)
 
void setComputeNearFarMode (agxOSG::RenderTarget::ComputeNearFarMode mode)
 Specifies whether the near far should be automatically updated or not.
 
void setImageCapture (agxOSG::ImageCaptureBase *imageCapture)
 By attaching an ImageCaptureBase you can automatically store the image data to disk given a specific format, fps, path etc.
 
void setProjectionMatrixAsOrtho (double left, double right, double bottom, double top, double zNear, double zFar)
 Update the orthographic projection matrix given the arguments.
 
void setProjectionMatrixAsPerspective (double fovy, double aspectRatio, double zNear, double zFar)
 Update the perspective projection matrix given the arguments.
 
void setProjectionMatrixFromOtherCamera (const osg::Camera *camera)
 Update the perspective projection matrix from another camera.
 
void setReferenceCamera (const osg::Camera *referenceCamera)
 By using a reference camera, the render target camera will get the same view/projection/viewpoint as the reference.
 
void setSize (agx::UInt width, agx::UInt height)
 Update the size of the render target buffer size.
 
void setSize (agx::Vec2u size)
 Update the size of the render target buffer size.
 
void setViewMatrixAsLookAt (const agx::Vec3 &eye, const agx::Vec3 &center, const agx::Vec3 &up)
 Update the view matrix given the arguments.
 
void setViewMatrixFromOtherCamera (const osg::Camera *camera)
 Update the view matrix given the arguments.
 
- Public Member Functions inherited from agx::Object
 Object (const Name &name=Name(), Model *model=Object::ClassModel())
 
void addListener (EventListener *listener)
 
virtual void buildNavigationTree (agxJson::Value &eNode) const
 
virtual void configure (TiXmlElement *)
 
agx::String fullName () const
 
agx::String fullPath () const
 
agx::String fullPath (const agx::Object *root) const
 
template<typename T >
T * getAutoScopedResource (const agx::Path &path)
 
template<typename T >
const T * getAutoScopedResource (const agx::Path &path) const
 
agx::ObjectgetAutoScopedResource (const agx::Path &path, agx::Model *model=nullptr)
 
const agx::ObjectgetAutoScopedResource (const agx::Path &path, agx::Model *model=nullptr) const
 
agx::ObjectgetContext ()
 
template<typename T >
T * getContext ()
 
const agx::ObjectgetContext () const
 
template<typename T >
const T * getContext () const
 
agx::UInt32 getId () const
 
const agx::NamegetImplementationName () const
 
agx::ModelgetModel ()
 
const agx::ModelgetModel () const
 
const agx::NamegetName () const
 
agx::ObjectgetNextSibling ()
 
const agx::ObjectgetNextSibling () const
 
agx::Path getPath () const
 
agx::Path getPath (const agx::Object *root) const
 
template<typename T >
T * getResource (const agx::Path &path)
 
template<typename T >
const T * getResource (const agx::Path &path) const
 
agx::ObjectgetResource (const agx::Path &path, agx::Model *model=nullptr)
 
const agx::ObjectgetResource (const agx::Path &path, agx::Model *model=nullptr) const
 
virtual agx::ObjectgetResourceImpl (const agx::Path &path, agx::Model *model)
 
agx::ObjectgetRootContext ()
 
const agx::ObjectgetRootContext () const
 
bool hasListener (EventListener *listener)
 
bool hasParent (const agx::Object *node) const
 
bool isUnique () const
 
virtual void printSubtree () const
 
virtual void rebind ()
 
void removeListener (EventListener *listener)
 
virtual void save (TiXmlElement *) const
 
virtual void setContext (agx::Object *context)
 
void setId (UInt32 id)
 
void setModel (agx::Model *model)
 Set the object model (handled automatically).
 
void setName (const agx::Name &name)
 Set the name of the object.
 
virtual void snapshot (TiXmlNode *, const String &) const
 
- Public Member Functions inherited from agx::Referenced
 Referenced ()
 Default constructor.
 
 Referenced (const Referenced &)
 
template<typename T >
T * as ()
 Subclass casting.
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match.
 
template<typename T >
const T * asSafe () const
 
int getReferenceCount () const
 
template<typename T >
bool is () const
 Subclass test.
 
Referencedoperator= (const Referenced &)
 Assignment operator. Will increment the number of references to the referenced object.
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it.
 

Protected Member Functions

virtual ~RenderTarget ()
 
- Protected Member Functions inherited from agx::Object
virtual ~Object ()
 
- Protected Member Functions inherited from agx::Referenced
virtual ~Referenced ()
 Destructor.
 
void allocateObserverVector () const
 
void deleteUsingDeleteHandler () const
 

Protected Attributes

osg::ref_ptr< osg::Camera > m_camera
 
osg::ref_ptr< CameraSynchronizeCallback > m_cameraSynchronizeCallback
 
agx::UInt m_height
 
ImageCaptureBaseRef m_imageCapture
 
agx::UInt m_width
 
- Protected Attributes inherited from agx::Referenced
Mutex m_mutex
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 

Additional Inherited Members

- Static Public Member Functions inherited from agx::Object
static agx::ModelClassModel ()
 
static agx::String generateName (const agx::String &bindPath)
 
static const HashSet< Object * > & getActiveObjects ()
 
static bool getEnableRebind ()
 Should rebinding be allowed? Right now a global setting.
 
static Objectload (const String &path, Device *device, const String &type, const String &attribute, const String &value)
 
template<typename T >
static T * load (const String &path, Device *device, const String &type, const String &attribute, const String &value)
 
static Objectload (const String &path, Device *device, const String &type="", size_t instance=0)
 
template<typename T >
static T * load (const String &path, Device *device, const String &type="", size_t instance=0)
 
static void load (const String &path, Device *device, ObjectPtrVector &loadedObjects)
 
static Objectload (TiXmlElement *eObject, Device *device)
 
template<typename T >
static T * load (TiXmlElement *eObject, Device *device)
 
static TiXmlDocument openDocument (const String &path)
 
static void setEnableRebind (bool flag)
 Sets if rebinding of objects should be allowed (Right now a global setting).
 
- Static Public Member Functions inherited from agx::Referenced
template<typename T >
static bool ValidateCast (const Referenced *object)
 
- Static Protected Member Functions inherited from agx::Referenced
static DeleteHandlergetDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.
 

Detailed Description

Render target is used for rendering camera content to a buffer, either a DEPTH or COLOR target.

Definition at line 40 of file RenderTarget.h.

Member Enumeration Documentation

◆ BufferComponent

Specifies which type of buffer to render.

Enumerator
COLOR_BUFFER 
DEPTH_BUFFER 

Definition at line 46 of file RenderTarget.h.

◆ ComputeNearFarMode

Enumerator
DO_NOT_COMPUTE_NEAR_FAR 
COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES 
COMPUTE_NEAR_FAR_USING_PRIMITIVES 
COMPUTE_NEAR_USING_PRIMITIVES 

Definition at line 60 of file RenderTarget.h.

◆ TextureFormat

Specifies target texture format.

Enumerator
RGBA 
RGB 
DEPTH_COMPONENT 

Definition at line 53 of file RenderTarget.h.

Constructor & Destructor Documentation

◆ RenderTarget()

agxOSG::RenderTarget::RenderTarget ( agx::UInt  width,
agx::UInt  height 
)

Constructor.

Create a new RenderTarget

Parameters
width- Width of target buffer
height- Height of target buffer

◆ ~RenderTarget()

virtual agxOSG::RenderTarget::~RenderTarget ( )
protectedvirtual

Member Function Documentation

◆ addPreRenderCallback()

void agxOSG::RenderTarget::addPreRenderCallback ( osg::Camera::DrawCallback *  callback)

Add a pre-render callback to this RenderTarget.

Parameters
callback- DrawCallback object to add

◆ calculateScreenCoords()

agx::Vec2 agxOSG::RenderTarget::calculateScreenCoords ( agx::Vec3 worldPos)

Transform the position into screen coordinates using the camera associated to this RenderTarget.

Parameters
worldPos- Position in world coordinate system
Returns
position (x,y) in screen coordinates

◆ getCamera()

osg::Camera * agxOSG::RenderTarget::getCamera ( )
Returns
the camera that is used for this RenderTarget

◆ getCameraCullMask()

int agxOSG::RenderTarget::getCameraCullMask ( ) const
Returns
current cullmask for the camera node

◆ getImageCapture()

agxOSG::ImageCaptureBase * agxOSG::RenderTarget::getImageCapture ( )
Returns
a pointer to the image capture object that this RenderTarget is using (nullptr if none)

◆ getSize()

agx::Vec2u agxOSG::RenderTarget::getSize ( ) const
Returns
the size of the render target

◆ setCameraCullMask()

void agxOSG::RenderTarget::setCameraCullMask ( int  cullMask)
Set the cull node mask to specify what part of the scenegraph that should be rendered.
This maps directly to OSG:s setCullMask.
Typical use for this mask is:

Disable mask: cullMask &= ~agxOSGExampleApplication::HUD_MASK; setCameraCullMask(cullMask);

Enable mask cullMask |= agxOSG::ExampleApplication::HUD_MASK; setCameraCullMask(cullMask);

◆ setComputeNearFarMode()

void agxOSG::RenderTarget::setComputeNearFarMode ( agxOSG::RenderTarget::ComputeNearFarMode  mode)

Specifies whether the near far should be automatically updated or not.

◆ setImageCapture()

void agxOSG::RenderTarget::setImageCapture ( agxOSG::ImageCaptureBase imageCapture)

By attaching an ImageCaptureBase you can automatically store the image data to disk given a specific format, fps, path etc.

Parameters
imageCapture- Pointer to a ImageCaptureBase object that manages storing of images to disk

◆ setProjectionMatrixAsOrtho()

void agxOSG::RenderTarget::setProjectionMatrixAsOrtho ( double  left,
double  right,
double  bottom,
double  top,
double  zNear,
double  zFar 
)

Update the orthographic projection matrix given the arguments.

Parameters
left,right,bottom,top- defines the size of the orthographic view frustum
zNear- Near clipping plane
zFar- Far clipping plane

◆ setProjectionMatrixAsPerspective()

void agxOSG::RenderTarget::setProjectionMatrixAsPerspective ( double  fovy,
double  aspectRatio,
double  zNear,
double  zFar 
)

Update the perspective projection matrix given the arguments.

Parameters
fovy- field of view in y
aspectRatio- width/height ratio
zNear- Near clipping plane
zFar- Far clipping plane

◆ setProjectionMatrixFromOtherCamera()

void agxOSG::RenderTarget::setProjectionMatrixFromOtherCamera ( const osg::Camera *  camera)

Update the perspective projection matrix from another camera.

Parameters
camera- camera to copy view matrix from

◆ setReferenceCamera()

void agxOSG::RenderTarget::setReferenceCamera ( const osg::Camera *  referenceCamera)

By using a reference camera, the render target camera will get the same view/projection/viewpoint as the reference.

Parameters
referenceCamera- The camera to mimic

◆ setSize() [1/2]

void agxOSG::RenderTarget::setSize ( agx::UInt  width,
agx::UInt  height 
)

Update the size of the render target buffer size.

Parameters
width- Width of render target
height- Height of render target

◆ setSize() [2/2]

void agxOSG::RenderTarget::setSize ( agx::Vec2u  size)

Update the size of the render target buffer size.

Parameters
size- Width, height of render target

◆ setViewMatrixAsLookAt()

void agxOSG::RenderTarget::setViewMatrixAsLookAt ( const agx::Vec3 eye,
const agx::Vec3 center,
const agx::Vec3 up 
)

Update the view matrix given the arguments.

Parameters
eye- position of eye
center- point towards the camera is aimed
up- up vector

◆ setViewMatrixFromOtherCamera()

void agxOSG::RenderTarget::setViewMatrixFromOtherCamera ( const osg::Camera *  camera)

Update the view matrix given the arguments.

Parameters
camera- camera to copy view matrix from

Member Data Documentation

◆ m_camera

osg::ref_ptr<osg::Camera> agxOSG::RenderTarget::m_camera
protected

Definition at line 197 of file RenderTarget.h.

◆ m_cameraSynchronizeCallback

osg::ref_ptr<CameraSynchronizeCallback> agxOSG::RenderTarget::m_cameraSynchronizeCallback
protected

Definition at line 198 of file RenderTarget.h.

◆ m_height

agx::UInt agxOSG::RenderTarget::m_height
protected

Definition at line 195 of file RenderTarget.h.

◆ m_imageCapture

ImageCaptureBaseRef agxOSG::RenderTarget::m_imageCapture
protected

Definition at line 196 of file RenderTarget.h.

◆ m_width

agx::UInt agxOSG::RenderTarget::m_width
protected

Definition at line 194 of file RenderTarget.h.


The documentation for this class was generated from the following file: