Panda3DRGBRenderer

class Panda3DRGBRenderer(*args, **kwargs)

Bases: Panda3DBaseRenderer, Panda3DLightableScene

Implementation of a traditional RGB renderer in Panda3D.

The lighting model follows a Cook-torrance BRDF.

For each object, a specific Version of the cook-torrance shader is compiled: diffuse textures are supported, but normal/bump/roughness maps are not. This class will try to automatically detect whether an object has RGB textures.

Specular highlights and reflections can be ignored, depending on the value of isShowingSpeculars.

Warning

if an object is detected as having image textures but it actually doesn’t have any, the object may appear washed out.

Note

Most of the tested objects were in BAM format, Panda3D’s own format. The following pipeline was used:

  • Export to GLTF with Blender

  • In a Python environment, install gltf2bam with pip install panda3d-gltf

  • run gltf2bam path/to/yourObject.gltf path/to/yourObject.bam

  • then, in the code, use renderer.addNodeToScene(“/path/to/yourObject.bam”);

Overloaded function.

  1. __init__(self: visp._visp.ar.Panda3DRGBRenderer) -> None

Default constructor. Initialize an RGB renderer with the normal rendering behavior showing speculars.

  1. __init__(self: visp._visp.ar.Panda3DRGBRenderer, showSpeculars: bool) -> None

RGB renderer constructor allowing to specify whether specular highlights should be rendered or if only ambient/diffuse lighting should be considered.

Parameters:
showSpeculars

whether to render speculars

Methods

__init__

Overloaded function.

addNodeToScene

Overloaded function.

getRender

Store the render resulting from calling renderFrame() into a vpImage .

isShowingSpeculars

setBackgroundImage

Inherited Methods

setNodePose

Overloaded function.

addLight

loadObject

Load a 3D object.

getNodePose

Overloaded function.

afterFrameRendered

initFramework

Initialize the whole Panda3D framework.

setAbortOnPandaError

Set the behaviour when a Panda3D assertion fails.

computeNearAndFarPlanesFromNode

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

setName

vispVectorToPanda

printStructure

isRendering3DScene

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

beforeFrameRendered

setRenderParameters

Set new rendering parameters.

setRenderOrder

renderFrame

enableDebugLog

getCameraPose

Retrieve the camera's pose, in the world frame.

getName

Get the name of the renderer.

initFromParent

Overloaded function.

getRenderRoot

Get the scene root.

setVerticalSyncEnabled

set whether vertical sync is enabled.

enableSharedDepthBuffer

vispPointToPanda

getRenderOrder

Get the rendering order of this renderer.

setCameraPose

Set the camera's pose.

Operators

__doc__

__init__

Overloaded function.

__module__

Attributes

__annotations__

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: visp._visp.ar.Panda3DRGBRenderer) -> None

Default constructor. Initialize an RGB renderer with the normal rendering behavior showing speculars.

  1. __init__(self: visp._visp.ar.Panda3DRGBRenderer, showSpeculars: bool) -> None

RGB renderer constructor allowing to specify whether specular highlights should be rendered or if only ambient/diffuse lighting should be considered.

Parameters:
showSpeculars

whether to render speculars

addLight(self, light: visp._visp.ar.Panda3DLight) None
addNodeToScene(*args, **kwargs)

Overloaded function.

  1. addNodeToScene(self: visp._visp.ar.Panda3DRGBRenderer, object: NodePath) -> None

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

Parameters:
object

  1. addNodeToScene(self: visp._visp.ar.Panda3DBaseRenderer, object: NodePath) -> None

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

Parameters:
object

afterFrameRendered(self) None
beforeFrameRendered(self) None
computeNearAndFarPlanesFromNode(self, name: str, near: float, far: float, fast: bool) tuple[float, float]

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.

Warning

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:
name: str

name of the node that should be used to compute near and far values.

near: float

resulting near clipping plane distance

far: float

resulting far clipping plane distance

fast: bool

Whether to use the axis align bounding box to compute the clipping planes. This is faster than reprojecting the full geometry in the camera frame

Returns:

A tuple containing:

  • near: resulting near clipping plane distance

  • far: resulting far clipping plane distance

enableDebugLog(self) None
enableSharedDepthBuffer(self, sourceBuffer: visp._visp.ar.Panda3DBaseRenderer) None
getCameraPose(self) visp._visp.core.HomogeneousMatrix

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

getName(self) str

Get the name of the renderer.

Returns:

const std::string&

getNodePose(*args, **kwargs)

Overloaded function.

  1. getNodePose(self: visp._visp.ar.Panda3DBaseRenderer, name: str) -> visp._visp.core.HomogeneousMatrix

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

Parameters:
name

Node path to search for.

Returns:

wTo, the pose of the object in world frame

  1. getNodePose(self: visp._visp.ar.Panda3DBaseRenderer, object: NodePath) -> visp._visp.core.HomogeneousMatrix

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.

getRender(self, I: visp._visp.core.ImageRGBa) None

Store the render resulting from calling renderFrame() into a vpImage .

If the image does not have the correct dimensions, it is resized.

Parameters:
I: visp._visp.core.ImageRGBa

The image in which to store the render.

getRenderOrder(self) int

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

getRenderRoot(self) NodePath

Get the scene root.

initFramework(self) None

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)

initFromParent(*args, **kwargs)

Overloaded function.

  1. initFromParent(self: visp._visp.ar.Panda3DBaseRenderer, framework: PandaFramework, window: PointerTo<WindowFramework>) -> None

  2. initFromParent(self: visp._visp.ar.Panda3DBaseRenderer, renderer: visp._visp.ar.Panda3DBaseRenderer) -> None

isRendering3DScene(self) bool

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.

isShowingSpeculars(self) bool
loadObject(self, nodeName: str, modelPath: str) NodePath

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:
nodeName: str

the name that will be used when inserting the node in the scene graph

modelPath: str

Path to the model file

Returns:

NodePath The NodePath containing the 3D model, which can now be added to the scene graph.

printStructure(self) None
renderFrame(self) None
setAbortOnPandaError(self, abort: bool) None

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:
abort: bool

whether to abort (true) or display a message when an assertion fails.

setBackgroundImage(self, background: visp._visp.core.ImageRGBa) None
setCameraPose(self, wTc: visp._visp.core.HomogeneousMatrix) None

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

Parameters:
wTc: visp._visp.core.HomogeneousMatrix

the new pose of the camera, in world frame

setName(self, name: str) None
setNodePose(*args, **kwargs)

Overloaded function.

  1. setNodePose(self: visp._visp.ar.Panda3DBaseRenderer, name: str, wTo: visp._visp.core.HomogeneousMatrix) -> None

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:
name

Node 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

wTo

Pose of the object in the world frame

  1. setNodePose(self: visp._visp.ar.Panda3DBaseRenderer, object: NodePath, wTo: visp._visp.core.HomogeneousMatrix) -> None

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:
object

The object for which to set the pose

wTo

Pose of the object in the world frame

setRenderOrder(self, order: int) None
setRenderParameters(self, params: visp._visp.ar.Panda3DRenderParameters) None

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

Parameters:
params: visp._visp.ar.Panda3DRenderParameters

the new rendering parameters

setVerticalSyncEnabled(self, useVsync: bool) None

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

Parameters:
useVsync: bool

Whether to use vsync or not

static vispPointToPanda(point: visp._visp.core.ColVector) visp._visp.core.ColVector
static vispVectorToPanda(vec: visp._visp.core.ColVector) visp._visp.core.ColVector