Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpObjectCentricRenderer Class Reference

#include <vpObjectCentricRenderer.h>

Inheritance diagram for vpObjectCentricRenderer:

Public Member Functions

 vpObjectCentricRenderer (const vpPanda3DRenderParameters &renderParameters)
virtual void setRenderParameters (const vpPanda3DRenderParameters &params) VP_OVERRIDE
vpRect getBoundingBox () const
void setFocusedObject (const std::string &focused)
void beforeFrameRendered () VP_OVERRIDE
void computeBoundingBox3DPoints ()
void computeClipping (float &nearV, float &farV)
std::vector< vpColVectorgetBoundingBox3D ()
void get3DExtents (vpTranslationVector &minValues, vpTranslationVector &maxValues)
vpRect computeBoundingBox ()
template<typename T>
void placeRenderInto (const vpImage< T > &render, vpImage< T > &target, const T &clearValue)
void initFramework () VP_OVERRIDE
void initFromParent (PointerTo< WindowFramework > window) VP_OVERRIDE
void initFromParent (const vpPanda3DBaseRenderer &renderer) VP_OVERRIDE
void clearScene () VP_OVERRIDE
void setCameraPose (const vpHomogeneousMatrix &wTc) VP_OVERRIDE
vpHomogeneousMatrix getCameraPose () VP_OVERRIDE
void setNodePose (const std::string &name, const vpHomogeneousMatrix &wTo) VP_OVERRIDE
void setNodePose (NodePath &object, const vpHomogeneousMatrix &wTo) VP_OVERRIDE
vpHomogeneousMatrix getNodePose (const std::string &name) VP_OVERRIDE
vpHomogeneousMatrix getNodePose (NodePath &object) VP_OVERRIDE
void addNodeToScene (const NodePath &object) VP_OVERRIDE
void addLight (const vpPanda3DLight &light) VP_OVERRIDE
void addSubRenderer (std::shared_ptr< vpPanda3DBaseRenderer > renderer)
void enableSharedDepthBuffer (vpPanda3DBaseRenderer &sourceBuffer) VP_OVERRIDE
template<typename RendererType>
std::shared_ptr< RendererType > getRenderer ()
template<typename RendererType>
std::shared_ptr< RendererType > getRenderer (const std::string &name)
virtual void afterFrameRendered () VP_OVERRIDE
virtual void renderFrame ()
const std::string & getName () const
void setName (const std::string &name)
NodePath & getRenderRoot ()
virtual bool isRendering3DScene () const
int getRenderOrder () const
void setRenderOrder (int order)
void computeNearAndFarPlanesFromNode (const std::string &name, float &nearV, float &farV, bool fast)
NodePath loadObject (const std::string &nodeName, const std::string &modelPath)
virtual void addObjectToScene (const std::string &name, const std::string &path)
void setVerticalSyncEnabled (bool useVsync)
void setAbortOnPandaError (bool abort)
void enableDebugLog ()
void printStructure ()
virtual PointerTo< GraphicsOutput > getMainOutputBuffer ()
PointerTo< WindowFramework > & getWindowFramework ()

Static Public Member Functions

static vpColVector vispPointToPanda (const vpColVector &point)
static vpColVector vispVectorToPanda (const vpColVector &vec)
static const vpHomogeneousMatrixpandaToVisp ()
static const vpHomogeneousMatrixvispToPanda ()

Protected Member Functions

void setupScene () VP_OVERRIDE
void setupCamera () VP_OVERRIDE
virtual void setupRenderTarget ()

Protected Attributes

std::vector< std::shared_ptr< vpPanda3DBaseRenderer > > m_subRenderers
std::string m_name
int m_renderOrder
PointerTo< WindowFramework > m_window
vpPanda3DRenderParameters m_renderParameters
NodePath m_renderRoot
PointerTo< Camera > m_camera
NodePath m_cameraPath
std::vector< PointerTo< GraphicsOutput > > m_buffers
bool m_isWindowOwner

Static Protected Attributes

static const vpHomogeneousMatrix VISP_T_PANDA
static const vpHomogeneousMatrix PANDA_T_VISP

Detailed Description

Single object focused renderer.

Tutorials & Examples

Tutorials
If you want to have an in-depth presentation of the Render-Based Tracker (RBT), you may have a look at:

Examples
catchRBT.cpp.

Definition at line 59 of file vpObjectCentricRenderer.h.

Constructor & Destructor Documentation

◆ vpObjectCentricRenderer()

BEGIN_VISP_NAMESPACE vpObjectCentricRenderer::vpObjectCentricRenderer ( const vpPanda3DRenderParameters & renderParameters)

Member Function Documentation

◆ addLight()

void vpPanda3DRendererSet::addLight ( const vpPanda3DLight & light)
virtualinherited

Light this lightable object with a new light.

Parameters
light

Implements vpPanda3DLightable.

Examples
tutorial-panda3d-renderer.cpp.

Definition at line 163 of file vpPanda3DRendererSet.cpp.

References vpPanda3DLightable::addLight(), and m_subRenderers.

◆ addNodeToScene()

void vpPanda3DRendererSet::addNodeToScene ( const NodePath & object)
virtualinherited
Warning
This method is not supported and will throw

Reimplemented from vpPanda3DBaseRenderer.

Examples
tutorial-panda3d-renderer.cpp.

Definition at line 146 of file vpPanda3DRendererSet.cpp.

References m_subRenderers.

◆ addObjectToScene()

void vpPanda3DBaseRenderer::addObjectToScene ( const std::string & name,
const std::string & path )
virtualinherited

Load and and an object to the scene.

Parameters
name
path

Definition at line 357 of file vpPanda3DBaseRenderer.cpp.

References addNodeToScene(), and loadObject().

◆ addSubRenderer()

void vpPanda3DRendererSet::addSubRenderer ( std::shared_ptr< vpPanda3DBaseRenderer > renderer)
inherited

Add a new subrenderer: This subrenderer should have a unique name, not present in the set.

Exceptions
ifthe subrenderer's name is already present in the set.
Parameters
rendererthe renderer to add
Examples
tutorial-panda3d-renderer.cpp.

Definition at line 173 of file vpPanda3DRendererSet.cpp.

References vpException::badValue, getCameraPose(), vpPanda3DBaseRenderer::m_renderParameters, m_subRenderers, and vpPanda3DBaseRenderer::m_window.

◆ afterFrameRendered()

virtual void vpPanda3DRendererSet::afterFrameRendered ( )
inlinevirtualinherited

Reimplemented from vpPanda3DBaseRenderer.

Definition at line 223 of file vpPanda3DRendererSet.h.

References m_subRenderers.

◆ beforeFrameRendered()

◆ clearScene()

void vpPanda3DRendererSet::clearScene ( )
inlinevirtualinherited

Reimplemented from vpPanda3DBaseRenderer.

Definition at line 93 of file vpPanda3DRendererSet.h.

References clearScene(), and m_subRenderers.

Referenced by clearScene().

◆ computeBoundingBox()

◆ computeBoundingBox3DPoints()

void vpObjectCentricRenderer::computeBoundingBox3DPoints ( )

◆ computeClipping()

◆ computeNearAndFarPlanesFromNode()

void vpPanda3DBaseRenderer::computeNearAndFarPlanesFromNode ( const std::string & name,
float & nearV,
float & farV,
bool fast )
inherited

Compute the near and far planes for the camera at the current pose, given a certain node/part of the graph.

The near clipping value will be set to the distance to the closest point of the object. The far clipping value will be set to the distance to farthest vertex of the object.

Warning
Depending on geometry complexity, this may be an expensive operation.
if the object lies partly behind the camera, the near plane value will be zero. If it fully behind, the far plane will also be zero. If these near/far values are used to update the rendering parameters of the camera, this may result in an invalid projection matrix.
Parameters
namename of the node that should be used to compute near and far values.
nearVresulting near clipping plane distance
farVresulting far clipping plane distance
fastWhether to use the axis align bounding box to compute the clipping planes. This is faster than reprojecting the full geometry in the camera frame

Definition at line 239 of file vpPanda3DBaseRenderer.cpp.

References vpException::badValue, vpException::fatalError, getCameraPose(), getNodePose(), vpHomogeneousMatrix::inverse(), m_camera, m_cameraPath, m_renderRoot, vpMath::maximum(), vpException::notInitialized, and PANDA_T_VISP.

◆ enableDebugLog()

void vpPanda3DBaseRenderer::enableDebugLog ( )
inherited
Examples
tutorial-panda3d-renderer.cpp.

Definition at line 381 of file vpPanda3DBaseRenderer.cpp.

◆ enableSharedDepthBuffer()

void vpPanda3DRendererSet::enableSharedDepthBuffer ( vpPanda3DBaseRenderer & sourceBuffer)
virtualinherited

◆ get3DExtents()

void vpObjectCentricRenderer::get3DExtents ( vpTranslationVector & minValues,
vpTranslationVector & maxValues )
inline

◆ getBoundingBox()

vpRect vpObjectCentricRenderer::getBoundingBox ( ) const
inline

Definition at line 69 of file vpObjectCentricRenderer.h.

◆ getBoundingBox3D()

std::vector< vpColVector > vpObjectCentricRenderer::getBoundingBox3D ( )
inline

Definition at line 82 of file vpObjectCentricRenderer.h.

References computeBoundingBox3DPoints(), and getBoundingBox3D().

Referenced by getBoundingBox3D().

◆ getCameraPose()

vpHomogeneousMatrix vpPanda3DRendererSet::getCameraPose ( )
virtualinherited

Retrieve the pose of the camera. As this renderer contains multiple other renderers.

Warning
It is assumed that all the sub renderers are synchronized (i.e., the setCameraPose of this renderer was called before calling this method). Otherwise, you may get incoherent results.
Returns
the pose of the camera using the ViSP convention

Reimplemented from vpPanda3DBaseRenderer.

Definition at line 105 of file vpPanda3DRendererSet.cpp.

References vpException::fatalError, vpPanda3DBaseRenderer::isRendering3DScene(), and m_subRenderers.

Referenced by addSubRenderer(), vpObjectCentricRenderer::computeBoundingBox(), and vpObjectCentricRenderer::computeClipping().

◆ getMainOutputBuffer()

virtual PointerTo< GraphicsOutput > vpPanda3DBaseRenderer::getMainOutputBuffer ( )
inlinevirtualinherited

◆ getName()

const std::string & vpPanda3DBaseRenderer::getName ( ) const
inlineinherited

Get the name of the renderer.

Returns
const std::string&

Definition at line 98 of file vpPanda3DBaseRenderer.h.

References m_name.

◆ getNodePose() [1/2]

vpHomogeneousMatrix vpPanda3DRendererSet::getNodePose ( const std::string & name)
virtualinherited

Retrieve the pose of a scene node. The pose is in the world frame, using a ViSP convention.

See also
the base method
Warning
It is assumed that all the sub renderers are synchronized (i.e., the setNodePose of this renderer was called before calling this method). Otherwise, you may get incoherent results.
Parameters
namename of the node
Returns
vpHomogeneousMatrix the pose of the node in the world frame

Reimplemented from vpPanda3DBaseRenderer.

Examples
tutorial-panda3d-renderer.cpp.

Definition at line 130 of file vpPanda3DRendererSet.cpp.

References vpException::fatalError, vpPanda3DBaseRenderer::isRendering3DScene(), and m_subRenderers.

Referenced by vpObjectCentricRenderer::computeBoundingBox(), and vpObjectCentricRenderer::computeClipping().

◆ getNodePose() [2/2]

vpHomogeneousMatrix vpPanda3DRendererSet::getNodePose ( NodePath & object)
virtualinherited

This method is not supported for this renderer type. Use the std::string version.

Exceptions
vpException,asthis method is not supported
Parameters
object

Reimplemented from vpPanda3DBaseRenderer.

Definition at line 141 of file vpPanda3DRendererSet.cpp.

References vpException::badValue.

◆ getRenderer() [1/2]

template<typename RendererType>
std::shared_ptr< RendererType > vpPanda3DRendererSet::getRenderer ( )
inlineinherited

Retrieve the first subrenderer with the specified template type.

Template Parameters
RendererTypeThe type of the renderer to find
Returns
std::shared_ptr<RendererType> Pointer to the first renderer match, nullptr if none is found.
Examples
tutorial-panda3d-renderer.cpp.

Definition at line 184 of file vpPanda3DRendererSet.h.

References getRenderer(), and m_subRenderers.

Referenced by getRenderer().

◆ getRenderer() [2/2]

template<typename RendererType>
std::shared_ptr< RendererType > vpPanda3DRendererSet::getRenderer ( const std::string & name)
inlineinherited

Retrieve the subrenderer with the specified template type and the given name.

Parameters
namethe name of the subrenderer to find
Template Parameters
RendererTypeThe type of the renderer to find
Returns
std::shared_ptr<RendererType> Pointer to the renderer, nullptr if none is found.

Definition at line 203 of file vpPanda3DRendererSet.h.

References m_subRenderers.

◆ getRenderOrder()

int vpPanda3DBaseRenderer::getRenderOrder ( ) const
inlineinherited

Get the rendering order of this renderer. If a renderer A has a lower order value than B, it will be rendered before B. This is useful, if for instance, B is a postprocessing filter that depends on the result of B.

Returns
int

Definition at line 134 of file vpPanda3DBaseRenderer.h.

References m_renderOrder.

◆ getRenderRoot()

NodePath & vpPanda3DBaseRenderer::getRenderRoot ( )
inlineinherited

Get the scene root.

Definition at line 106 of file vpPanda3DBaseRenderer.h.

References m_renderRoot.

◆ getWindowFramework()

PointerTo< WindowFramework > & vpPanda3DBaseRenderer::getWindowFramework ( )
inlineinherited

Definition at line 261 of file vpPanda3DBaseRenderer.h.

References m_window.

Referenced by vpPanda3DFrameworkManager::enableSingleRenderer().

◆ initFramework()

void vpPanda3DRendererSet::initFramework ( )
virtualinherited

Initialize the framework and propagate the created panda3D framework to the subrenderers.

The subrenderers will be initialized in the order of their priority as defined by vpPanda3DBaseRenderer::getRenderOrder Thus, if a renderer B depends on A for its render, and if B.getRenderOrder() > A.getRenderOrder() it can rely on A being initialized when B.initFromParent is called (along with the setupCamera, setupRenderTarget).

Reimplemented from vpPanda3DBaseRenderer.

Examples
tutorial-panda3d-renderer.cpp.

Definition at line 49 of file vpPanda3DRendererSet.cpp.

References vpException::badValue, vpException::fatalError, vpPanda3DFrameworkManager::getFramework(), vpPanda3DFrameworkManager::getInstance(), vpPanda3DFrameworkManager::initFramework(), vpPanda3DBaseRenderer::m_isWindowOwner, vpPanda3DBaseRenderer::m_renderParameters, m_subRenderers, and vpPanda3DBaseRenderer::m_window.

◆ initFromParent() [1/2]

void vpPanda3DRendererSet::initFromParent ( const vpPanda3DBaseRenderer & renderer)
virtualinherited

◆ initFromParent() [2/2]

void vpPanda3DRendererSet::initFromParent ( PointerTo< WindowFramework > window)
virtualinherited

◆ isRendering3DScene()

virtual bool vpPanda3DBaseRenderer::isRendering3DScene ( ) const
inlinevirtualinherited

Returns true if this renderer process 3D data and its scene root can be interacted with.

This value could be false, if for instance it is redefined in a subclass that performs postprocessing on a texture.

Reimplemented in vpPanda3DPostProcessFilter.

Definition at line 125 of file vpPanda3DBaseRenderer.h.

Referenced by enableSharedDepthBuffer(), vpPanda3DRendererSet::getCameraPose(), and vpPanda3DRendererSet::getNodePose().

◆ loadObject()

NodePath vpPanda3DBaseRenderer::loadObject ( const std::string & nodeName,
const std::string & modelPath )
inherited

Load a 3D object. To load an .obj file, Panda3D must be compiled with assimp support.

Once loaded, the object will not be visible, it should be added to the scene.

Parameters
nodeNamethe name that will be used when inserting the node in the scene graph
modelPathPath to the model file
Returns
NodePath The NodePath containing the 3D model, which can now be added to the scene graph.
Examples
tutorial-panda3d-renderer.cpp.

Definition at line 331 of file vpPanda3DBaseRenderer.cpp.

References vpPanda3DFrameworkManager::getFramework(), vpPanda3DFrameworkManager::getInstance(), vpException::ioError, and m_window.

Referenced by addObjectToScene().

◆ pandaToVisp()

const vpHomogeneousMatrix & vpPanda3DBaseRenderer::pandaToVisp ( )
staticinherited

Definition at line 56 of file vpPanda3DBaseRenderer.cpp.

References VISP_T_PANDA.

◆ placeRenderInto()

template<typename T>
void vpObjectCentricRenderer::placeRenderInto ( const vpImage< T > & render,
vpImage< T > & target,
const T & clearValue )
inline

◆ printStructure()

void vpPanda3DBaseRenderer::printStructure ( )
inherited

Definition at line 399 of file vpPanda3DBaseRenderer.cpp.

References m_renderRoot.

◆ renderFrame()

◆ setAbortOnPandaError()

void vpPanda3DBaseRenderer::setAbortOnPandaError ( bool abort)
inherited

Set the behaviour when a Panda3D assertion fails. If abort is true, the program will stop. Otherwise, an error will be displayed in the console.

Parameters
abortwhether to abort (true) or display a message when an assertion fails.
Examples
tutorial-panda3d-renderer.cpp.

Definition at line 371 of file vpPanda3DBaseRenderer.cpp.

◆ setCameraPose()

void vpPanda3DRendererSet::setCameraPose ( const vpHomogeneousMatrix & wTc)
virtualinherited

Set the pose of the camera, using the ViSP convention. This change is propagated to all subrenderers.

Parameters
wTcPose of the camera

Reimplemented from vpPanda3DBaseRenderer.

Examples
tutorial-panda3d-renderer.cpp.

Definition at line 96 of file vpPanda3DRendererSet.cpp.

References m_subRenderers.

◆ setFocusedObject()

void vpObjectCentricRenderer::setFocusedObject ( const std::string & focused)
inline

Definition at line 71 of file vpObjectCentricRenderer.h.

◆ setName()

void vpPanda3DBaseRenderer::setName ( const std::string & name)
inlineinherited

Definition at line 100 of file vpPanda3DBaseRenderer.h.

References m_name.

◆ setNodePose() [1/2]

void vpPanda3DRendererSet::setNodePose ( const std::string & name,
const vpHomogeneousMatrix & wTo )
virtualinherited

Set the pose of an object for all the subrenderers. The pose is specified using the ViSP convention This method may fail if a subrenderer does not have a node with the given name.

Warning
This method may fail if a subrenderer does not have a node with the given name. It is assumed that the scenes are synchronized
Parameters
name
wTo

Reimplemented from vpPanda3DBaseRenderer.

Examples
tutorial-panda3d-renderer.cpp.

Definition at line 116 of file vpPanda3DRendererSet.cpp.

References m_subRenderers.

◆ setNodePose() [2/2]

void vpPanda3DRendererSet::setNodePose ( NodePath & object,
const vpHomogeneousMatrix & wTo )
virtualinherited

This method is not supported for this renderer type. Use the std::string version.

Exceptions
vpException,asthis method is not supported
Parameters
object
wTo

Reimplemented from vpPanda3DBaseRenderer.

Definition at line 125 of file vpPanda3DRendererSet.cpp.

References vpException::badValue.

◆ setRenderOrder()

void vpPanda3DBaseRenderer::setRenderOrder ( int order)
inherited

Definition at line 322 of file vpPanda3DBaseRenderer.cpp.

References m_buffers, and m_renderOrder.

◆ setRenderParameters()

virtual void vpObjectCentricRenderer::setRenderParameters ( const vpPanda3DRenderParameters & params)
inlinevirtual

Set new rendering parameters. If the scene has already been initialized, the renderer camera is updated.

Parameters
paramsthe new rendering parameters

Reimplemented from vpPanda3DRendererSet.

Definition at line 64 of file vpObjectCentricRenderer.h.

References vpPanda3DRendererSet::setRenderParameters().

◆ setupCamera()

void vpPanda3DRendererSet::setupCamera ( )
inlineprotectedvirtualinherited

Initialize camera. Should be called when the scene root of this render has already been created.

Reimplemented from vpPanda3DBaseRenderer.

Definition at line 233 of file vpPanda3DRendererSet.h.

◆ setupRenderTarget()

virtual void vpPanda3DBaseRenderer::setupRenderTarget ( )
inlineprotectedvirtualinherited

Initialize buffers and other objects that are required to save the render.

Reimplemented in vpPanda3DGeometryRenderer, vpPanda3DPostProcessFilter, and vpPanda3DRGBRenderer.

Definition at line 283 of file vpPanda3DBaseRenderer.h.

Referenced by initFramework(), and initFromParent().

◆ setupScene()

void vpPanda3DRendererSet::setupScene ( )
inlineprotectedvirtualinherited

Initialize the scene for this specific renderer.

Creates a root scene for this node and applies shaders. that will be used for rendering

Reimplemented from vpPanda3DBaseRenderer.

Definition at line 231 of file vpPanda3DRendererSet.h.

◆ setVerticalSyncEnabled()

void vpPanda3DBaseRenderer::setVerticalSyncEnabled ( bool useVsync)
inherited

set whether vertical sync is enabled. When vertical sync is enabled, render speed will be limited by the display's refresh rate

Parameters
useVsyncWhether to use vsync or not
Examples
tutorial-panda3d-renderer.cpp.

Definition at line 362 of file vpPanda3DBaseRenderer.cpp.

Referenced by vpPanda3DBaseRenderer().

◆ vispPointToPanda()

vpColVector vpPanda3DBaseRenderer::vispPointToPanda ( const vpColVector & point)
staticinherited

Definition at line 387 of file vpPanda3DBaseRenderer.cpp.

References PANDA_T_VISP.

◆ vispToPanda()

const vpHomogeneousMatrix & vpPanda3DBaseRenderer::vispToPanda ( )
staticinherited

◆ vispVectorToPanda()

vpColVector vpPanda3DBaseRenderer::vispVectorToPanda ( const vpColVector & vec)
staticinherited

Definition at line 393 of file vpPanda3DBaseRenderer.cpp.

References PANDA_T_VISP.

Referenced by vpPanda3DDirectionalLight::addToScene().

Member Data Documentation

◆ m_buffers

◆ m_camera

PointerTo<Camera> vpPanda3DBaseRenderer::m_camera
protectedinherited

◆ m_cameraPath

◆ m_isWindowOwner

bool vpPanda3DBaseRenderer::m_isWindowOwner
protectedinherited

Set of buffers that this renderer uses. This storage contains weak refs to those buffers and should not deallocate them.

Definition at line 297 of file vpPanda3DBaseRenderer.h.

Referenced by initFramework(), vpPanda3DRendererSet::initFramework(), initFromParent(), initFromParent(), vpPanda3DBaseRenderer(), and ~vpPanda3DBaseRenderer().

◆ m_name

std::string vpPanda3DBaseRenderer::m_name
protectedinherited

◆ m_renderOrder

◆ m_renderParameters

◆ m_renderRoot

◆ m_subRenderers

◆ m_window

◆ PANDA_T_VISP

const vpHomogeneousMatrix vpPanda3DBaseRenderer::PANDA_T_VISP
staticprotectedinherited

Homogeneous transformation matrix to convert from the Panda coordinate system (right-handed Z-up) to the ViSP coordinate system (right-handed Y-Down).

Definition at line 286 of file vpPanda3DBaseRenderer.h.

Referenced by computeNearAndFarPlanesFromNode(), getNodePose(), vispPointToPanda(), vispToPanda(), and vispVectorToPanda().

◆ VISP_T_PANDA

BEGIN_VISP_NAMESPACE const vpHomogeneousMatrix vpPanda3DBaseRenderer::VISP_T_PANDA
staticprotectedinherited

Definition at line 285 of file vpPanda3DBaseRenderer.h.

Referenced by pandaToVisp(), and setNodePose().