Ignition Rendering

API Reference

6.0.1
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 IGNITION_RENDERING_OGRE2_OGRE2SCENE_HH_
18 #define IGNITION_RENDERING_OGRE2_OGRE2SCENE_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
27 
28 #include "ignition/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 math::Color AmbientLight() const override;
79 
80  // Documentation inherited.
81  public: virtual void SetAmbientLight(const math::Color &_color) override;
82 
83  // Documentation inherited
84  public: virtual void PreRender() override;
85 
86  // Documentation inherited
87  public: virtual void Clear() override;
88 
89  // Documentation inherited
90  public: virtual void Destroy() override;
91 
92  // Documentation inherited
93  public: virtual void SetSkyEnabled(bool _enabled) override;
94 
95  // Documentation inherited
96  public: virtual bool SkyEnabled() const override;
97 
98  // Documentation inherited.
99  public: virtual void SetCameraPassCountPerGpuFlush(
100  uint8_t _numPass) override;
101 
102  // Documentation inherited.
103  public: virtual uint8_t CameraPassCountPerGpuFlush() const override;
104 
105  // Documentation inherited.
106  public: virtual bool LegacyAutoGpuFlush() const override;
107 
110  public: virtual Ogre::SceneManager *OgreSceneManager() const;
111 
112  // Documentation inherited
113  public: virtual void PostRender() override;
114 
127  public: void StartForcedRender();
128 
133  public: void EndForcedRender();
134 
144  public: void StartRendering(Ogre::Camera *_camera);
145 
157  public: void FlushGpuCommandsAndStartNewFrame(uint8_t _numPasses,
158  bool _startNewFrame);
159 
162  protected: void FlushGpuCommandsOnly();
163 
176  protected: void EndFrame();
177 
183  public: void SetShadowsDirty(bool _dirty);
184 
189  public: bool ShadowsDirty() const;
191 
192  // Documentation inherited
193  protected: virtual bool LoadImpl() override;
194 
195  // Documentation inherited
196  protected: virtual bool InitImpl() override;
197 
198  // Documentation inherited
199  protected: virtual COMVisualPtr CreateCOMVisualImpl(unsigned int _id,
200  const std::string &_name) override;
201 
202  // Documentation inherited
203  protected: virtual InertiaVisualPtr CreateInertiaVisualImpl(
204  unsigned int _id, const std::string &_name) override;
205 
206  // Documentation inherited
207  protected: virtual JointVisualPtr CreateJointVisualImpl(unsigned int _id,
208  const std::string &_name) override;
209 
210  // Documentation inherited
211  protected: virtual LightVisualPtr CreateLightVisualImpl(unsigned int _id,
212  const std::string &_name) override;
213 
214  // Documentation inherited
215  protected: virtual DirectionalLightPtr CreateDirectionalLightImpl(
216  unsigned int _id, const std::string &_name) override;
217 
218  // Documentation inherited
219  protected: virtual PointLightPtr CreatePointLightImpl(unsigned int _id,
220  const std::string &_name) override;
221 
222  // Documentation inherited
223  protected: virtual SpotLightPtr CreateSpotLightImpl(unsigned int _id,
224  const std::string &_name) override;
225 
226  // Documentation inherited
227  protected: virtual CameraPtr CreateCameraImpl(unsigned int _id,
228  const std::string &_name) override;
229 
230  // Documentation inherited
231  protected: virtual DepthCameraPtr CreateDepthCameraImpl(unsigned int _id,
232  const std::string &_name) override;
233 
234  // Documentation inherited
235  protected: virtual ThermalCameraPtr CreateThermalCameraImpl(
236  unsigned int _id, const std::string &_name) override;
237 
238  // Documentation inherited
239  protected: virtual SegmentationCameraPtr CreateSegmentationCameraImpl(
240  unsigned int _id, const std::string &_name) override;
241 
242  // Documentation inherited
243  protected: virtual GpuRaysPtr CreateGpuRaysImpl(unsigned int _id,
244  const std::string &_name) override;
245 
246  // Documentation inherited
247  protected: virtual VisualPtr CreateVisualImpl(unsigned int _id,
248  const std::string &_name) override;
249 
250  // Documentation inherited
251  protected: virtual ArrowVisualPtr CreateArrowVisualImpl(unsigned int _id,
252  const std::string &_name) override;
253 
254  // Documentation inherited
255  protected: virtual AxisVisualPtr CreateAxisVisualImpl(unsigned int _id,
256  const std::string &_name) override;
257 
258  // Documentation inherited
259  protected: virtual GizmoVisualPtr CreateGizmoVisualImpl(unsigned int _id,
260  const std::string &_name) override;
261 
262  // Documentation inherited
263  protected: virtual GeometryPtr CreateBoxImpl(unsigned int _id,
264  const std::string &_name) override;
265 
266  // Documentation inherited
267  protected: virtual GeometryPtr CreateConeImpl(unsigned int _id,
268  const std::string &_name) override;
269 
270  // Documentation inherited
271  protected: virtual GeometryPtr CreateCylinderImpl(unsigned int _id,
272  const std::string &_name) override;
273 
274  // Documentation inherited
275  protected: virtual GeometryPtr CreatePlaneImpl(unsigned int _id,
276  const std::string &_name) override;
277 
278  // Documentation inherited
279  protected: virtual GeometryPtr CreateSphereImpl(unsigned int _id,
280  const std::string &_name) override;
281 
286  protected: virtual MeshPtr CreateMeshImpl(unsigned int _id,
287  const std::string &_name, const std::string &_meshName);
288 
289  // Documentation inherited
290  protected: virtual MeshPtr CreateMeshImpl(unsigned int _id,
291  const std::string &_name, const MeshDescriptor &_desc)
292  override;
293 
294  // Documentation inherited
295  protected: virtual CapsulePtr CreateCapsuleImpl(unsigned int _id,
296  const std::string &_name) override;
297 
298  protected: virtual HeightmapPtr CreateHeightmapImpl(unsigned int _id,
299  const std::string &_name, const HeightmapDescriptor &_desc)
300  override;
301 
302  // Documentation inherited
303  protected: virtual GridPtr CreateGridImpl(unsigned int _id,
304  const std::string &_name) override;
305 
306  // Documentation inherited
307  protected: virtual MarkerPtr CreateMarkerImpl(unsigned int _id,
308  const std::string &_name) override;
309 
310  // Documentation inherited
311  protected: virtual LidarVisualPtr CreateLidarVisualImpl(unsigned int _id,
312  const std::string &_name) override;
313 
314  // Documentation inherited
315  protected: virtual WireBoxPtr CreateWireBoxImpl(unsigned int _id,
316  const std::string &_name) override;
317 
318  // Documentation inherited
319  protected: virtual TextPtr CreateTextImpl(unsigned int _id,
320  const std::string &_name) override;
321 
322  protected: virtual MaterialPtr CreateMaterialImpl(unsigned int _id,
323  const std::string &_name) override;
324 
325  protected: virtual RenderTexturePtr CreateRenderTextureImpl(
326  unsigned int _id, const std::string &_name) override;
327 
328  // Documentation inherited.
329  protected: virtual RenderWindowPtr CreateRenderWindowImpl(
330  unsigned int _id, const std::string &_name) override;
331 
332  // Documentation inherited
333  protected: virtual RayQueryPtr CreateRayQueryImpl(
334  unsigned int _id, const std::string &_name) override;
335 
336  // Documentation inherited
337  protected: virtual ParticleEmitterPtr CreateParticleEmitterImpl(
338  unsigned int _id, const std::string &_name) override;
339 
344  protected: virtual bool InitObject(Ogre2ObjectPtr _object,
345  unsigned int _id, const std::string &_name);
346 
351  public: void UpdateAllHeightmaps(Ogre::Camera *_camera);
352 
355  public: const std::vector<std::weak_ptr<Ogre2Heightmap>> &Heightmaps()
356  const;
357 
360  protected: void UpdateShadowNode();
361 
375  private: void CreateShadowNodeWithSettings(
376  Ogre::CompositorManager2 *_compositorManager,
377  const std::string &_shadowNodeName,
378  const Ogre::ShadowNodeHelper::ShadowParamVec &_shadowParams);
379 
380  // Documentation inherited
381  protected: virtual LightStorePtr Lights() const override;
382 
383  // Documentation inherited
384  protected: virtual SensorStorePtr Sensors() const override;
385 
386  // Documentation inherited
387  protected: virtual VisualStorePtr Visuals() const override;
388 
389  // Documentation inherited
390  protected: virtual MaterialMapPtr Materials() const override;
391 
393  private: void CreateContext();
394 
396  private: void CreateRootVisual();
397 
399  private: void CreateMeshFactory();
400 
402  private: void CreateStores();
403 
406  public: void ClearMaterialsCache(const std::string &_name);
407 
409  private: Ogre2ScenePtr SharedThis();
410 
413 
416 
419 
422 
425 
428 
431 
433  protected: Ogre::SceneManager *ogreSceneManager = nullptr;
434 
436  private: std::unique_ptr<Ogre2ScenePrivate> dataPtr;
437 
439  private: friend class Ogre2RenderEngine;
440  };
441  }
442  }
443 }
444 #endif
Ogre2LightStorePtr lights
A list of ogre lights.
Definition: Ogre2Scene.hh:424
Describes how a Mesh should be loaded.
Definition: MeshDescriptor.hh:44
std::vector< std::weak_ptr< Ogre2Heightmap > > heightmaps
A list of ogre heightmaps.
Definition: Ogre2Scene.hh:430
Ogre2.x implementation of the scene class.
Definition: Ogre2Scene.hh:57
Ogre2VisualStorePtr visuals
A list of ogre visuals.
Definition: Ogre2Scene.hh:421
STL class.
Ogre2SensorStorePtr sensors
A list of ogre sensors, e.g. cameras.
Definition: Ogre2Scene.hh:418
Ogre2 render engine class. A singleton class that manages the underlying ogre2 render engine...
Definition: Ogre2RenderEngine.hh:79
Definition: BaseScene.hh:37
Ogre2VisualPtr rootVisual
Root visual in the scene.
Definition: Ogre2Scene.hh:412
Ogre2MeshFactoryPtr meshFactory
Mesh factory for generating ogre meshes.
Definition: Ogre2Scene.hh:415
Describes how a Heightmap should be loaded.
Definition: HeightmapDescriptor.hh:146
STL class.
Definition: OgreCamera.hh:27
An abstract interface to a concrete render-engine. A RenderEngine is responsible for initializing a r...
Definition: RenderEngine.hh:36
Ogre2MaterialMapPtr materials
A list of ogre materials.
Definition: Ogre2Scene.hh:427