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

#include <vpPanda3DBaseRenderer.h>

Inheritance diagram for vpPanda3DBaseRenderer:

Public Member Functions

 vpPanda3DBaseRenderer (const std::string &rendererName)
virtual ~vpPanda3DBaseRenderer ()
virtual void initFramework ()
virtual void initFromParent (PointerTo< WindowFramework > window)
virtual void initFromParent (const vpPanda3DBaseRenderer &renderer)
virtual void beforeFrameRendered ()
virtual void renderFrame ()
virtual void afterFrameRendered ()
const std::string & getName () const
void setName (const std::string &name)
NodePath & getRenderRoot ()
virtual void clearScene ()
virtual void setRenderParameters (const vpPanda3DRenderParameters &params)
virtual bool isRendering3DScene () const
int getRenderOrder () const
void setRenderOrder (int order)
virtual void setCameraPose (const vpHomogeneousMatrix &wTc)
virtual vpHomogeneousMatrix getCameraPose ()
virtual void setNodePose (const std::string &name, const vpHomogeneousMatrix &wTo)
virtual void setNodePose (NodePath &object, const vpHomogeneousMatrix &wTo)
virtual vpHomogeneousMatrix getNodePose (const std::string &name)
virtual vpHomogeneousMatrix getNodePose (NodePath &object)
void computeNearAndFarPlanesFromNode (const std::string &name, float &nearV, float &farV, bool fast)
NodePath loadObject (const std::string &nodeName, const std::string &modelPath)
virtual void addNodeToScene (const NodePath &object)
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 ()
virtual void enableSharedDepthBuffer (vpPanda3DBaseRenderer &sourceBuffer)
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

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

Protected Attributes

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

Base class for a panda3D renderer. This class handles basic functionalities, such as loading object, changing camera parameters.

For a subclass to have a novel behaviour (e.g, display something else) These methods should be overriden:

  • setupScene: This is where you should apply your shaders.
  • setupCamera: This is where cameras are created and intrinsics parameters are applied
  • setupRenderTarget: This is where you should create the texture buffers, where the render results should be stored.

Tutorials & Examples

Tutorials
If you are interested in using Panda3D in Augmented Reality applications, you may have a look at:

Definition at line 69 of file vpPanda3DBaseRenderer.h.

Constructor & Destructor Documentation

◆ vpPanda3DBaseRenderer()

◆ ~vpPanda3DBaseRenderer()

vpPanda3DBaseRenderer::~vpPanda3DBaseRenderer ( )
virtual

Member Function Documentation

◆ addNodeToScene()

void vpPanda3DBaseRenderer::addNodeToScene ( const NodePath & object)
virtual

Add a node to the scene. Its pose is set as the identity matrix.

Parameters
object

Reimplemented in vpPanda3DRendererSet, and vpPanda3DRGBRenderer.

Definition at line 347 of file vpPanda3DBaseRenderer.cpp.

References m_camera, m_renderRoot, vpException::notInitialized, and setNodePose().

Referenced by addObjectToScene().

◆ addObjectToScene()

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

Load and and an object to the scene.

Parameters
name
path

Definition at line 357 of file vpPanda3DBaseRenderer.cpp.

References addNodeToScene(), and loadObject().

◆ afterFrameRendered()

void vpPanda3DBaseRenderer::afterFrameRendered ( )
virtual

◆ beforeFrameRendered()

virtual void vpPanda3DBaseRenderer::beforeFrameRendered ( )
inlinevirtual

Reimplemented in vpObjectCentricRenderer, vpPanda3DGeometryRenderer, and vpPanda3DRendererSet.

Definition at line 89 of file vpPanda3DBaseRenderer.h.

Referenced by renderFrame().

◆ clearScene()

virtual void vpPanda3DBaseRenderer::clearScene ( )
inlinevirtual

Reimplemented in vpPanda3DRendererSet.

Definition at line 108 of file vpPanda3DBaseRenderer.h.

References m_renderRoot.

◆ computeNearAndFarPlanesFromNode()

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

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 ( )
Examples
tutorial-panda3d-renderer.cpp.

Definition at line 381 of file vpPanda3DBaseRenderer.cpp.

◆ enableSharedDepthBuffer()

void vpPanda3DBaseRenderer::enableSharedDepthBuffer ( vpPanda3DBaseRenderer & sourceBuffer)
virtual

◆ getCameraPose()

vpHomogeneousMatrix vpPanda3DBaseRenderer::getCameraPose ( )
virtual

Retrieve the camera's pose, in the world frame. The pose is specified using the ViSP convention (Y-down right handed).

Reimplemented in vpPanda3DRendererSet.

Definition at line 198 of file vpPanda3DBaseRenderer.cpp.

References getNodePose(), m_camera, m_cameraPath, and vpException::notInitialized.

Referenced by computeNearAndFarPlanesFromNode().

◆ getMainOutputBuffer()

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

◆ getName()

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

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 vpPanda3DBaseRenderer::getNodePose ( const std::string & name)
virtual

Get the pose of a Panda node, in world frame in the ViSP convention (Y-down right handed).

Parameters
nameNode path to search for.
See also
setNodePose(const std::string &, const vpHomogeneousMatrix &) for more info
Returns
wTo, the pose of the object in world frame
Exceptions
ifno node can be found from the given path.

Reimplemented in vpPanda3DRendererSet.

Definition at line 221 of file vpPanda3DBaseRenderer.cpp.

References vpException::badValue, getNodePose(), and m_renderRoot.

Referenced by computeNearAndFarPlanesFromNode(), getCameraPose(), and getNodePose().

◆ getNodePose() [2/2]

vpHomogeneousMatrix vpPanda3DBaseRenderer::getNodePose ( NodePath & object)
virtual

Get the pose of a Panda node, in world frame in the ViSP convention (Y-down right handed). This version of the method directly uses the Panda Nodepath.

Reimplemented in vpPanda3DRendererSet.

Definition at line 230 of file vpPanda3DBaseRenderer.cpp.

References PANDA_T_VISP.

◆ getRenderOrder()

int vpPanda3DBaseRenderer::getRenderOrder ( ) const
inline

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 ( )
inline

Get the scene root.

Definition at line 106 of file vpPanda3DBaseRenderer.h.

References m_renderRoot.

◆ getWindowFramework()

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

Definition at line 261 of file vpPanda3DBaseRenderer.h.

References m_window.

Referenced by vpPanda3DFrameworkManager::enableSingleRenderer().

◆ initFramework()

void vpPanda3DBaseRenderer::initFramework ( )
virtual

Initialize the whole Panda3D framework. Create a new PandaFramework object and a new window.

Will also perform the renderer setup (scene, camera and render targets)

Reimplemented in vpPanda3DRendererSet.

Definition at line 81 of file vpPanda3DBaseRenderer.cpp.

References vpException::badValue, vpPanda3DFrameworkManager::getFramework(), vpPanda3DFrameworkManager::getInstance(), vpPanda3DFrameworkManager::initFramework(), m_isWindowOwner, m_renderParameters, m_window, vpException::notInitialized, setupCamera(), setupRenderTarget(), and setupScene().

◆ initFromParent() [1/2]

void vpPanda3DBaseRenderer::initFromParent ( const vpPanda3DBaseRenderer & renderer)
virtual

◆ initFromParent() [2/2]

void vpPanda3DBaseRenderer::initFromParent ( PointerTo< WindowFramework > window)
virtual

◆ isRendering3DScene()

virtual bool vpPanda3DBaseRenderer::isRendering3DScene ( ) const
inlinevirtual

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 )

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 ( )
static

Definition at line 56 of file vpPanda3DBaseRenderer.cpp.

References VISP_T_PANDA.

◆ printStructure()

void vpPanda3DBaseRenderer::printStructure ( )

Definition at line 399 of file vpPanda3DBaseRenderer.cpp.

References m_renderRoot.

◆ renderFrame()

◆ setAbortOnPandaError()

void vpPanda3DBaseRenderer::setAbortOnPandaError ( bool abort)

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 vpPanda3DBaseRenderer::setCameraPose ( const vpHomogeneousMatrix & wTc)
virtual

Set the camera's pose. The pose is specified using the ViSP convention (Y-down right handed).

Parameters
wTcthe new pose of the camera, in world frame

Reimplemented in vpPanda3DRendererSet.

Definition at line 190 of file vpPanda3DBaseRenderer.cpp.

References m_camera, m_cameraPath, vpException::notInitialized, and setNodePose().

◆ setName()

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

Definition at line 100 of file vpPanda3DBaseRenderer.h.

References m_name.

◆ setNodePose() [1/2]

void vpPanda3DBaseRenderer::setNodePose ( const std::string & name,
const vpHomogeneousMatrix & wTo )
virtual

Set the pose of a node. This node can be any Panda object (light, mesh, camera). The pose is specified using the ViSP convention (Y-down right handed).

Parameters
nameNode path to search for, from the render root. This is the object that will be modified See https://docs.panda3d.org/1.10/python/programming/scene-graph/searching-scene-graph
wToPose of the object in the world frame
Exceptions
ifthe corresponding node cannot be found.

Reimplemented in vpPanda3DRendererSet.

Definition at line 206 of file vpPanda3DBaseRenderer.cpp.

References m_renderRoot, and setNodePose().

Referenced by addNodeToScene(), vpPanda3DRGBRenderer::addNodeToScene(), setCameraPose(), and setNodePose().

◆ setNodePose() [2/2]

void vpPanda3DBaseRenderer::setNodePose ( NodePath & object,
const vpHomogeneousMatrix & wTo )
virtual

Set the pose of a node. The pose is specified using the ViSP convention (Y-down right handed). This node can be any Panda object (light, mesh, camera).

Parameters
objectThe object for which to set the pose
wToPose of the object in the world frame

Reimplemented in vpPanda3DRendererSet.

Definition at line 212 of file vpPanda3DBaseRenderer.cpp.

References vpHomogeneousMatrix::getRotationMatrix(), vpHomogeneousMatrix::getTranslationVector(), VISP_T_PANDA, vpQuaternionVector::w(), vpQuaternionVector::x(), vpQuaternionVector::y(), and vpQuaternionVector::z().

◆ setRenderOrder()

void vpPanda3DBaseRenderer::setRenderOrder ( int order)

Definition at line 322 of file vpPanda3DBaseRenderer.cpp.

References m_buffers, and m_renderOrder.

◆ setRenderParameters()

void vpPanda3DBaseRenderer::setRenderParameters ( const vpPanda3DRenderParameters & params)
virtual

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

Parameters
paramsthe new rendering parameters

Reimplemented in vpObjectCentricRenderer, vpPanda3DPostProcessFilter, and vpPanda3DRendererSet.

Definition at line 164 of file vpPanda3DBaseRenderer.cpp.

References vpException::fatalError, vpPanda3DRenderParameters::getImageHeight(), vpPanda3DRenderParameters::getImageWidth(), m_buffers, m_camera, and m_renderParameters.

◆ setupCamera()

void vpPanda3DBaseRenderer::setupCamera ( )
protectedvirtual

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

Reimplemented in vpPanda3DPostProcessFilter, and vpPanda3DRendererSet.

Definition at line 136 of file vpPanda3DBaseRenderer.cpp.

References m_camera, m_cameraPath, m_renderParameters, m_renderRoot, and m_window.

Referenced by initFramework(), and initFromParent().

◆ setupRenderTarget()

virtual void vpPanda3DBaseRenderer::setupRenderTarget ( )
inlineprotectedvirtual

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 vpPanda3DBaseRenderer::setupScene ( )
protectedvirtual

Initialize the scene for this specific renderer.

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

Reimplemented in vpPanda3DCanny, vpPanda3DDepthCannyFilter, vpPanda3DGeometryRenderer, vpPanda3DPostProcessFilter, vpPanda3DRendererSet, and vpPanda3DRGBRenderer.

Definition at line 130 of file vpPanda3DBaseRenderer.cpp.

References m_name, m_renderRoot, and m_window.

Referenced by initFramework(), initFromParent(), and vpPanda3DRGBRenderer::setupScene().

◆ setVerticalSyncEnabled()

void vpPanda3DBaseRenderer::setVerticalSyncEnabled ( bool useVsync)

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)
static

Definition at line 387 of file vpPanda3DBaseRenderer.cpp.

References PANDA_T_VISP.

◆ vispToPanda()

const vpHomogeneousMatrix & vpPanda3DBaseRenderer::vispToPanda ( )
static

◆ vispVectorToPanda()

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

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
protected

◆ m_cameraPath

◆ m_isWindowOwner

bool vpPanda3DBaseRenderer::m_isWindowOwner
protected

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
protected

◆ m_renderOrder

◆ m_renderParameters

◆ m_renderRoot

◆ m_window

◆ PANDA_T_VISP

const vpHomogeneousMatrix vpPanda3DBaseRenderer::PANDA_T_VISP
staticprotected

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
staticprotected

Definition at line 285 of file vpPanda3DBaseRenderer.h.

Referenced by pandaToVisp(), and setNodePose().