Visual Servoing Platform  version 3.6.1 under development (2024-11-15)
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
61 {
62 public:
63  vpPanda3DRendererSet(const vpPanda3DRenderParameters &renderParameters);
64 
65  virtual ~vpPanda3DRendererSet() = default;
66 
73  void initFramework() VP_OVERRIDE;
74  void initFromParent(std::shared_ptr<PandaFramework> framework, PointerTo<WindowFramework> window) VP_OVERRIDE;
75  void initFromParent(const vpPanda3DBaseRenderer &renderer) VP_OVERRIDE;
76 
82  void setCameraPose(const vpHomogeneousMatrix &wTc) VP_OVERRIDE;
83 
92  vpHomogeneousMatrix getCameraPose() VP_OVERRIDE;
93 
103  void setNodePose(const std::string &name, const vpHomogeneousMatrix &wTo) VP_OVERRIDE;
104 
112  void setNodePose(NodePath &object, const vpHomogeneousMatrix &wTo) VP_OVERRIDE;
113 
124  vpHomogeneousMatrix getNodePose(const std::string &name) VP_OVERRIDE;
125 
132  vpHomogeneousMatrix getNodePose(NodePath &object) VP_OVERRIDE;
133 
137  void addNodeToScene(const NodePath &object) VP_OVERRIDE;
138 
139  virtual void setRenderParameters(const vpPanda3DRenderParameters &params) VP_OVERRIDE;
140 
141  void addLight(const vpPanda3DLight &light) VP_OVERRIDE;
142 
150  void addSubRenderer(std::shared_ptr<vpPanda3DBaseRenderer> renderer);
151 
152  void enableSharedDepthBuffer(vpPanda3DBaseRenderer &sourceBuffer) VP_OVERRIDE;
153 
160  template<typename RendererType>
161  std::shared_ptr<RendererType> getRenderer()
162  {
163  for (std::shared_ptr<vpPanda3DBaseRenderer> &renderer: m_subRenderers) {
164  std::shared_ptr<RendererType> rendererCast = std::dynamic_pointer_cast<RendererType>(renderer);
165  if (rendererCast != nullptr) {
166  return rendererCast;
167  }
168  }
169  return nullptr;
170  }
171 
179  template<typename RendererType>
180  std::shared_ptr<RendererType> getRenderer(const std::string &name)
181  {
182  for (std::shared_ptr<vpPanda3DBaseRenderer> &renderer: m_subRenderers) {
183  if (renderer->getName() == name) {
184  std::shared_ptr<RendererType> rendererCast = std::dynamic_pointer_cast<RendererType>(renderer);
185  if (rendererCast != nullptr) {
186  return rendererCast;
187  }
188  }
189  }
190  return nullptr;
191  }
192 
193  void beforeFrameRendered() VP_OVERRIDE
194  {
195  for (std::shared_ptr<vpPanda3DBaseRenderer> &renderer: m_subRenderers) {
196  renderer->beforeFrameRendered();
197  }
198  }
199 
200  void afterFrameRendered() VP_OVERRIDE
201  {
202  for (std::shared_ptr<vpPanda3DBaseRenderer> &renderer: m_subRenderers) {
203  renderer->afterFrameRendered();
204  }
205  }
206 
207 protected:
208  void setupScene() VP_OVERRIDE { }
209 
210  void setupCamera() VP_OVERRIDE { }
211 
212  std::vector<std::shared_ptr<vpPanda3DBaseRenderer>> m_subRenderers;
213 };
214 END_VISP_NAMESPACE
215 #endif
216 #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 rendering multiple datatypes, in a single pass. A RendererSet contains multiple subrendere...
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.