Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpPanda3DBaseRenderer.h
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2024 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * See the file LICENSE.txt at the root directory of this source
10 * distribution for additional information about the GNU GPL.
11 *
12 * For using ViSP with software that can not be combined with the GNU
13 * GPL, please contact Inria about acquiring a ViSP Professional
14 * Edition License.
15 *
16 * See https://visp.inria.fr for more information.
17 *
18 * This software was developed at:
19 * Inria Rennes - Bretagne Atlantique
20 * Campus Universitaire de Beaulieu
21 * 35042 Rennes Cedex
22 * France
23 *
24 * If you have questions regarding the use of this file, please contact
25 * Inria at visp@inria.fr
26 *
27 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29 */
30
31#ifndef VP_PANDA3D_BASE_RENDERER_H
32#define VP_PANDA3D_BASE_RENDERER_H
33
34#include <visp3/core/vpConfig.h>
35
36#if defined(VISP_HAVE_PANDA3D)
37#include <visp3/core/vpPoint.h>
38#include <visp3/core/vpCameraParameters.h>
39#include <visp3/ar/vpPanda3DRenderParameters.h>
40
41#include <windowFramework.h>
42#include <graphicsOutput.h>
43
44#include <nodePath.h>
45#include <pointerTo.h>
46#include <camera.h>
47
48
69class VISP_EXPORT vpPanda3DBaseRenderer
70{
71public:
72 vpPanda3DBaseRenderer(const std::string &rendererName)
73 : m_name(rendererName), m_renderOrder(-100), m_window(nullptr), m_camera(nullptr), m_isWindowOwner(false)
74 {
76 }
77
78 virtual ~vpPanda3DBaseRenderer();
79
85 virtual void initFramework();
86 virtual void initFromParent(PointerTo<WindowFramework> window);
87 virtual void initFromParent(const vpPanda3DBaseRenderer &renderer);
88
89 virtual void beforeFrameRendered() { }
90 virtual void renderFrame();
91 virtual void afterFrameRendered();
92
98 const std::string &getName() const { return m_name; }
99
100 void setName(const std::string &name) { m_name = name; }
101
106 NodePath &getRenderRoot() { return m_renderRoot; }
107
108 virtual void clearScene()
109 {
110 m_renderRoot.node()->remove_all_children();
111 }
112
118 virtual void setRenderParameters(const vpPanda3DRenderParameters &params);
119
125 virtual bool isRendering3DScene() const { return true; }
126
134 int getRenderOrder() const { return m_renderOrder; }
135
136 void setRenderOrder(int order);
137
144 virtual void setCameraPose(const vpHomogeneousMatrix &wTc);
145
150 virtual vpHomogeneousMatrix getCameraPose();
151
161 virtual void setNodePose(const std::string &name, const vpHomogeneousMatrix &wTo);
162
171 virtual void setNodePose(NodePath &object, const vpHomogeneousMatrix &wTo);
172
180 virtual vpHomogeneousMatrix getNodePose(const std::string &name);
181
185 virtual vpHomogeneousMatrix getNodePose(NodePath &object);
186
204 void computeNearAndFarPlanesFromNode(const std::string &name, float &nearV, float &farV, bool fast);
205
215 NodePath loadObject(const std::string &nodeName, const std::string &modelPath);
216
222 virtual void addNodeToScene(const NodePath &object);
223
230 virtual void addObjectToScene(const std::string &name, const std::string &path);
231
238 void setVerticalSyncEnabled(bool useVsync);
245 void setAbortOnPandaError(bool abort);
246 void enableDebugLog();
247
248 static vpColVector vispPointToPanda(const vpColVector &point);
249 static vpColVector vispVectorToPanda(const vpColVector &vec);
250
251 void printStructure();
252
253 virtual PointerTo<GraphicsOutput> getMainOutputBuffer() { return nullptr; }
254
255 virtual void enableSharedDepthBuffer(vpPanda3DBaseRenderer &sourceBuffer);
256
257 static const vpHomogeneousMatrix &pandaToVisp();
258
259 static const vpHomogeneousMatrix &vispToPanda();
260
261 PointerTo<WindowFramework> &getWindowFramework() { return m_window; }
262
263protected:
264
271 virtual void setupScene();
272
277 virtual void setupCamera();
278
283 virtual void setupRenderTarget() { }
284
287
288protected:
289 std::string m_name;
291 PointerTo<WindowFramework> m_window;
293 NodePath m_renderRoot;
294 PointerTo<Camera> m_camera;
295 NodePath m_cameraPath;
296 std::vector<PointerTo<GraphicsOutput>> m_buffers;
297 bool m_isWindowOwner; // Whether this panda subrenderer is the "owner" of the window framework and should close all associated windows when getting destroyed
298};
299
300END_VISP_NAMESPACE
301#endif //VISP_HAVE_PANDA3D
302#endif
Implementation of column vector and the associated operations.
Implementation of an homogeneous matrix and operations on such kind of matrices.
Base class for a panda3D renderer. This class handles basic functionalities, such as loading object,...
vpPanda3DBaseRenderer(const std::string &rendererName)
const std::string & getName() const
Get the name of the renderer.
NodePath m_renderRoot
Rendering parameters.
PointerTo< Camera > m_camera
Node containing all the objects and the camera for this renderer.
virtual bool isRendering3DScene() const
Returns true if this renderer process 3D data and its scene root can be interacted with.
void setVerticalSyncEnabled(bool useVsync)
set whether vertical sync is enabled. When vertical sync is enabled, render speed will be limited by ...
static const vpHomogeneousMatrix PANDA_T_VISP
Homogeneous transformation matrix to convert from the Panda coordinate system (right-handed Z-up) to ...
std::string m_name
Inverse of VISP_T_PANDA.
bool m_isWindowOwner
Set of buffers that this renderer uses. This storage contains weak refs to those buffers and should n...
static const vpHomogeneousMatrix VISP_T_PANDA
std::vector< PointerTo< GraphicsOutput > > m_buffers
NodePath of the camera.
void setName(const std::string &name)
PointerTo< WindowFramework > m_window
Rendering priority for this renderer and its buffers. A lower value will be rendered first....
virtual PointerTo< GraphicsOutput > getMainOutputBuffer()
int getRenderOrder() const
Get the rendering order of this renderer. If a renderer A has a lower order value than B,...
virtual void setupRenderTarget()
Initialize buffers and other objects that are required to save the render.
PointerTo< WindowFramework > & getWindowFramework()
int m_renderOrder
name of the renderer
vpPanda3DRenderParameters m_renderParameters
Pointer to owning window, which can create buffers etc. It is not necessarily visible.
NodePath & getRenderRoot()
Get the scene root.
Rendering parameters for a panda3D simulation.