Visual Servoing Platform  version 3.6.1 under development (2025-01-24)
vpPanda3DRendererSet.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_RENDERER_SET_H
32 #define VP_PANDA3D_RENDERER_SET_H
33 
34 #include <visp3/core/vpConfig.h>
35 
36 #if defined(VISP_HAVE_PANDA3D)
37 
38 #include <vector>
39 
40 #include <visp3/ar/vpPanda3DBaseRenderer.h>
41 #include <visp3/ar/vpPanda3DLight.h>
42 
43 BEGIN_VISP_NAMESPACE
68 {
69 public:
71  vpPanda3DRendererSet(const vpPanda3DRenderParameters &renderParameters);
72 
73  virtual ~vpPanda3DRendererSet() = default;
74 
81  void initFramework() VP_OVERRIDE;
82  void initFromParent(PointerTo<WindowFramework> window) VP_OVERRIDE;
83  void initFromParent(const vpPanda3DBaseRenderer &renderer) VP_OVERRIDE;
84 
90  void setCameraPose(const vpHomogeneousMatrix &wTc) VP_OVERRIDE;
91 
100  vpHomogeneousMatrix getCameraPose() VP_OVERRIDE;
101 
111  void setNodePose(const std::string &name, const vpHomogeneousMatrix &wTo) VP_OVERRIDE;
112 
120  void setNodePose(NodePath &object, const vpHomogeneousMatrix &wTo) VP_OVERRIDE;
121 
132  vpHomogeneousMatrix getNodePose(const std::string &name) VP_OVERRIDE;
133 
140  vpHomogeneousMatrix getNodePose(NodePath &object) VP_OVERRIDE;
141 
145  void addNodeToScene(const NodePath &object) VP_OVERRIDE;
146 
147  virtual void setRenderParameters(const vpPanda3DRenderParameters &params) VP_OVERRIDE;
148 
149  void addLight(const vpPanda3DLight &light) VP_OVERRIDE;
150 
158  void addSubRenderer(std::shared_ptr<vpPanda3DBaseRenderer> renderer);
159 
160  void enableSharedDepthBuffer(vpPanda3DBaseRenderer &sourceBuffer) VP_OVERRIDE;
161 
168  template<typename RendererType>
169  std::shared_ptr<RendererType> getRenderer()
170  {
171  for (std::shared_ptr<vpPanda3DBaseRenderer> &renderer: m_subRenderers) {
172  std::shared_ptr<RendererType> rendererCast = std::dynamic_pointer_cast<RendererType>(renderer);
173  if (rendererCast != nullptr) {
174  return rendererCast;
175  }
176  }
177  return nullptr;
178  }
179 
187  template<typename RendererType>
188  std::shared_ptr<RendererType> getRenderer(const std::string &name)
189  {
190  for (std::shared_ptr<vpPanda3DBaseRenderer> &renderer: m_subRenderers) {
191  if (renderer->getName() == name) {
192  std::shared_ptr<RendererType> rendererCast = std::dynamic_pointer_cast<RendererType>(renderer);
193  if (rendererCast != nullptr) {
194  return rendererCast;
195  }
196  }
197  }
198  return nullptr;
199  }
200 
201  void beforeFrameRendered() VP_OVERRIDE
202  {
203  for (std::shared_ptr<vpPanda3DBaseRenderer> &renderer: m_subRenderers) {
204  renderer->beforeFrameRendered();
205  }
206  }
207 
208  void afterFrameRendered() VP_OVERRIDE
209  {
210  for (std::shared_ptr<vpPanda3DBaseRenderer> &renderer: m_subRenderers) {
211  renderer->afterFrameRendered();
212  }
213  }
214 
215 protected:
216  void setupScene() VP_OVERRIDE { }
217 
218  void setupCamera() VP_OVERRIDE { }
219 
220  std::vector<std::shared_ptr<vpPanda3DBaseRenderer>> m_subRenderers;
221 };
222 END_VISP_NAMESPACE
223 #endif
224 #endif
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,...
virtual void initFramework()
Initialize the whole Panda3D framework. Create a new PandaFramework object and a new window.
Base class for a Light that can be added to a Panda3D scene.
Interface for objects, scenes or other Panda3D related data that can be lit by a vpPanda3DLight.
Rendering parameters for a panda3D simulation.
Class that renders multiple datatypes, in a single pass. A renderer set contains multiple subrenderer...
std::shared_ptr< RendererType > getRenderer(const std::string &name)
Retrieve the subrenderer with the specified template type and the given name.
virtual ~vpPanda3DRendererSet()=default
void beforeFrameRendered() VP_OVERRIDE
std::vector< std::shared_ptr< vpPanda3DBaseRenderer > > m_subRenderers
void setupScene() VP_OVERRIDE
Initialize the scene for this specific renderer.
void afterFrameRendered() VP_OVERRIDE
void setupCamera() VP_OVERRIDE
Initialize camera. Should be called when the scene root of this render has already been created.