Gazebo Rendering

API Reference

6.6.3
gz/rendering/ogre2/Ogre2Scene.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 #ifndef GZ_RENDERING_OGRE2_OGRE2SCENE_HH_
18 #define GZ_RENDERING_OGRE2_OGRE2SCENE_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include "gz/rendering/Storage.hh"
27 
28 #include "gz/rendering/ogre2/Export.hh"
29 
30 // This disables warning messages for OGRE
31 #ifndef _MSC_VER
32  #pragma GCC system_header
33 #else
34  #pragma warning(push, 0)
35 #endif
36 #include <Compositor/OgreCompositorShadowNode.h>
37 #ifdef _MSC_VER
38  #pragma warning(pop)
39 #endif
40 
41 namespace Ogre
42 {
43  class Root;
44  class SceneManager;
45 }
46 
47 namespace ignition
48 {
49  namespace rendering
50  {
51  inline namespace IGNITION_RENDERING_VERSION_NAMESPACE {
52  //
53  // forward declaration
54  class Ogre2ScenePrivate;
55  //
57  class IGNITION_RENDERING_OGRE2_VISIBLE Ogre2Scene :
58  public BaseScene
59  {
63  protected: Ogre2Scene(unsigned int _id, const std::string &_name);
64 
66  public: virtual ~Ogre2Scene();
67 
68  // Documentation inherited.
69  public: virtual void Fini() override;
70 
71  // Documentation inherited.
72  public: virtual RenderEngine *Engine() const override;
73 
74  // Documentation inherited.
75  public: virtual VisualPtr RootVisual() const override;
76 
77  // Documentation inherited.
78  public: virtual void SetTime(
79  const std::chrono::steady_clock::duration &_time) override;
80 
81  // Documentation inherited.
82  public: virtual math::Color AmbientLight() const override;
83 
84  // Documentation inherited.
85  public: virtual void SetAmbientLight(const math::Color &_color) override;
86 
87  // Documentation inherited
88  public: virtual void PreRender() override;
89 
90  // Documentation inherited
91  public: virtual void Clear() override;
92 
93  // Documentation inherited
94  public: virtual void Destroy() override;
95 
96  // Documentation inherited
97  public: virtual void SetSkyEnabled(bool _enabled) override;
98 
99  // Documentation inherited
100  public: virtual bool SkyEnabled() const override;
101 
102  // Documentation inherited.
103  public: virtual void SetCameraPassCountPerGpuFlush(
104  uint8_t _numPass) override;
105 
106  // Documentation inherited.
107  public: virtual uint8_t CameraPassCountPerGpuFlush() const override;
108 
109  // Documentation inherited.
110  public: virtual bool LegacyAutoGpuFlush() const override;
111 
114  public: virtual Ogre::SceneManager *OgreSceneManager() const;
115 
116  // Documentation inherited
117  public: virtual void PostRender() override;
118 
131  public: void StartForcedRender();
132 
137  public: void EndForcedRender();
138 
148  public: void StartRendering(Ogre::Camera *_camera);
149 
161  public: void FlushGpuCommandsAndStartNewFrame(uint8_t _numPasses,
162  bool _startNewFrame);
163 
166  protected: void FlushGpuCommandsOnly();
167 
180  protected: void EndFrame();
181 
187  public: void SetShadowsDirty(bool _dirty);
188 
193  public: bool ShadowsDirty() const;
195 
196  // Documentation inherited
197  protected: virtual bool LoadImpl() override;
198 
199  // Documentation inherited
200  protected: virtual bool InitImpl() override;
201 
202  // Documentation inherited
203  protected: virtual COMVisualPtr CreateCOMVisualImpl(unsigned int _id,
204  const std::string &_name) override;
205 
206  // Documentation inherited
207  protected: virtual InertiaVisualPtr CreateInertiaVisualImpl(
208  unsigned int _id, const std::string &_name) override;
209 
210  // Documentation inherited
211  protected: virtual JointVisualPtr CreateJointVisualImpl(unsigned int _id,
212  const std::string &_name) override;
213 
214  // Documentation inherited
215  protected: virtual LightVisualPtr CreateLightVisualImpl(unsigned int _id,
216  const std::string &_name) override;
217 
218  // Documentation inherited
219  protected: virtual DirectionalLightPtr CreateDirectionalLightImpl(
220  unsigned int _id, const std::string &_name) override;
221 
222  // Documentation inherited
223  protected: virtual PointLightPtr CreatePointLightImpl(unsigned int _id,
224  const std::string &_name) override;
225 
226  // Documentation inherited
227  protected: virtual SpotLightPtr CreateSpotLightImpl(unsigned int _id,
228  const std::string &_name) override;
229 
230  // Documentation inherited
231  protected: virtual CameraPtr CreateCameraImpl(unsigned int _id,
232  const std::string &_name) override;
233 
234  // Documentation inherited
235  protected: virtual DepthCameraPtr CreateDepthCameraImpl(unsigned int _id,
236  const std::string &_name) override;
237 
238  // Documentation inherited
239  protected: virtual ThermalCameraPtr CreateThermalCameraImpl(
240  unsigned int _id, const std::string &_name) override;
241 
242  // Documentation inherited
243  protected: virtual BoundingBoxCameraPtr CreateBoundingBoxCameraImpl(
244  unsigned int _id, const std::string &_name) override;
245 
246  // Documentation inherited
247  protected: virtual SegmentationCameraPtr CreateSegmentationCameraImpl(
248  unsigned int _id, const std::string &_name) override;
249 
250  // Documentation inherited
251  protected: virtual GpuRaysPtr CreateGpuRaysImpl(unsigned int _id,
252  const std::string &_name) override;
253 
254  // Documentation inherited
255  protected: virtual VisualPtr CreateVisualImpl(unsigned int _id,
256  const std::string &_name) override;
257 
258  // Documentation inherited
259  protected: virtual ArrowVisualPtr CreateArrowVisualImpl(unsigned int _id,
260  const std::string &_name) override;
261 
262  // Documentation inherited
263  protected: virtual AxisVisualPtr CreateAxisVisualImpl(unsigned int _id,
264  const std::string &_name) override;
265 
266  // Documentation inherited
267  protected: virtual GizmoVisualPtr CreateGizmoVisualImpl(unsigned int _id,
268  const std::string &_name) override;
269 
270  // Documentation inherited
271  protected: virtual GeometryPtr CreateBoxImpl(unsigned int _id,
272  const std::string &_name) override;
273 
274  // Documentation inherited
275  protected: virtual GeometryPtr CreateConeImpl(unsigned int _id,
276  const std::string &_name) override;
277 
278  // Documentation inherited
279  protected: virtual GeometryPtr CreateCylinderImpl(unsigned int _id,
280  const std::string &_name) override;
281 
282  // Documentation inherited
283  protected: virtual GeometryPtr CreatePlaneImpl(unsigned int _id,
284  const std::string &_name) override;
285 
286  // Documentation inherited
287  protected: virtual GeometryPtr CreateSphereImpl(unsigned int _id,
288  const std::string &_name) override;
289 
294  protected: virtual MeshPtr CreateMeshImpl(unsigned int _id,
295  const std::string &_name, const std::string &_meshName);
296 
297  // Documentation inherited
298  protected: virtual MeshPtr CreateMeshImpl(unsigned int _id,
299  const std::string &_name, const MeshDescriptor &_desc)
300  override;
301 
302  // Documentation inherited
303  protected: virtual CapsulePtr CreateCapsuleImpl(unsigned int _id,
304  const std::string &_name) override;
305 
306  protected: virtual HeightmapPtr CreateHeightmapImpl(unsigned int _id,
307  const std::string &_name, const HeightmapDescriptor &_desc)
308  override;
309 
310  // Documentation inherited
311  protected: virtual GridPtr CreateGridImpl(unsigned int _id,
312  const std::string &_name) override;
313 
314  // Documentation inherited
315  protected: virtual MarkerPtr CreateMarkerImpl(unsigned int _id,
316  const std::string &_name) override;
317 
318  // Documentation inherited
319  protected: virtual LidarVisualPtr CreateLidarVisualImpl(unsigned int _id,
320  const std::string &_name) override;
321 
322  // Documentation inherited
323  protected: virtual WireBoxPtr CreateWireBoxImpl(unsigned int _id,
324  const std::string &_name) override;
325 
326  // Documentation inherited
327  protected: virtual TextPtr CreateTextImpl(unsigned int _id,
328  const std::string &_name) override;
329 
330  protected: virtual MaterialPtr CreateMaterialImpl(unsigned int _id,
331  const std::string &_name) override;
332 
333  protected: virtual RenderTexturePtr CreateRenderTextureImpl(
334  unsigned int _id, const std::string &_name) override;
335 
336  // Documentation inherited.
337  protected: virtual RenderWindowPtr CreateRenderWindowImpl(
338  unsigned int _id, const std::string &_name) override;
339 
340  // Documentation inherited
341  protected: virtual RayQueryPtr CreateRayQueryImpl(
342  unsigned int _id, const std::string &_name) override;
343 
344  // Documentation inherited
345  protected: virtual ParticleEmitterPtr CreateParticleEmitterImpl(
346  unsigned int _id, const std::string &_name) override;
347 
352  protected: virtual bool InitObject(Ogre2ObjectPtr _object,
353  unsigned int _id, const std::string &_name);
354 
359  public: void UpdateAllHeightmaps(Ogre::Camera *_camera);
360 
363  public: const std::vector<std::weak_ptr<Ogre2Heightmap>> &Heightmaps()
364  const;
365 
368  protected: void UpdateShadowNode();
369 
383  private: void CreateShadowNodeWithSettings(
384  Ogre::CompositorManager2 *_compositorManager,
385  const std::string &_shadowNodeName,
386  const Ogre::ShadowNodeHelper::ShadowParamVec &_shadowParams);
387 
388  // Documentation inherited
389  protected: virtual LightStorePtr Lights() const override;
390 
391  // Documentation inherited
392  protected: virtual SensorStorePtr Sensors() const override;
393 
394  // Documentation inherited
395  protected: virtual VisualStorePtr Visuals() const override;
396 
397  // Documentation inherited
398  protected: virtual MaterialMapPtr Materials() const override;
399 
401  private: void CreateContext();
402 
404  private: void CreateRootVisual();
405 
407  private: void CreateMeshFactory();
408 
410  private: void CreateStores();
411 
414  public: void ClearMaterialsCache(const std::string &_name);
415 
417  private: Ogre2ScenePtr SharedThis();
418 
421 
424 
427 
430 
433 
436 
439 
441  protected: Ogre::SceneManager *ogreSceneManager = nullptr;
442 
444  private: std::unique_ptr<Ogre2ScenePrivate> dataPtr;
445 
447  private: friend class Ogre2RenderEngine;
448  };
449  }
450  }
451 }
452 #endif
Definition: gz/rendering/ogre/OgreCamera.hh:27
STL class.
STL class.
Describes how a Heightmap should be loaded.
Definition: gz/rendering/HeightmapDescriptor.hh:146
Describes how a Mesh should be loaded.
Definition: gz/rendering/MeshDescriptor.hh:44
Ogre2LightStorePtr lights
A list of ogre lights.
Definition: gz/rendering/ogre2/Ogre2Scene.hh:432
STL class.
std::vector< std::weak_ptr< Ogre2Heightmap > > heightmaps
A list of ogre heightmaps.
Definition: gz/rendering/ogre2/Ogre2Scene.hh:438
Ogre2VisualStorePtr visuals
A list of ogre visuals.
Definition: gz/rendering/ogre2/Ogre2Scene.hh:429
Ogre2 render engine class. A singleton class that manages the underlying ogre2 render engine,...
Definition: gz/rendering/ogre2/Ogre2RenderEngine.hh:80
Ogre2SensorStorePtr sensors
A list of ogre sensors, e.g. cameras.
Definition: gz/rendering/ogre2/Ogre2Scene.hh:426
Ogre2.x implementation of the scene class.
Definition: gz/rendering/ogre2/Ogre2Scene.hh:57
Ogre2MeshFactoryPtr meshFactory
Mesh factory for generating ogre meshes.
Definition: gz/rendering/ogre2/Ogre2Scene.hh:423
Ogre2VisualPtr rootVisual
Root visual in the scene.
Definition: gz/rendering/ogre2/Ogre2Scene.hh:420
Definition: gz/rendering/base/BaseScene.hh:37
An abstract interface to a concrete render-engine. A RenderEngine is responsible for initializing a r...
Definition: gz/rendering/RenderEngine.hh:36
Ogre2MaterialMapPtr materials
A list of ogre materials.
Definition: gz/rendering/ogre2/Ogre2Scene.hh:435