Gazebo Rendering

API Reference

9.0.0~pre2
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
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
41namespace Ogre
42{
43 class Root;
44 class SceneManager;
45}
46
47namespace gz
48{
49 namespace rendering
50 {
51 inline namespace GZ_RENDERING_VERSION_NAMESPACE {
52 //
53 // forward declaration
54 class Ogre2ScenePrivate;
55 //
57 class GZ_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: void SetBackgroundColor(const math::Color &_color) override;
89
90 // Documentation inherited
91 public: virtual void PreRender() override;
92
93 // Documentation inherited
94 public: virtual void Clear() override;
95
96 // Documentation inherited
97 public: virtual void Destroy() override;
98
99 // Documentation inherited
100 public: virtual void SetSkyEnabled(bool _enabled) override;
101
102 // Documentation inherited
103 public: virtual bool SkyEnabled() const override;
104
105 // Documentation inherited
106 public: bool SetShadowTextureSize(LightType _lightType,
107 unsigned int _textureSize);
108
109 // Documentation inherited
110 public: unsigned int ShadowTextureSize(LightType _lightType) const
111 override;
112
113 // Documentation inherited
114 public: virtual void SetActiveGlobalIllumination(
115 GlobalIlluminationBasePtr _gi) override;
116
120 public: void SetLightsGiDirty();
121
122 // Documentation inherited.
123 public: virtual void SetCameraPassCountPerGpuFlush(
124 uint8_t _numPass) override;
125
126 // Documentation inherited.
127 public: virtual uint8_t CameraPassCountPerGpuFlush() const override;
128
129 // Documentation inherited.
130 public: virtual bool LegacyAutoGpuFlush() const override;
131
134 public: virtual Ogre::SceneManager *OgreSceneManager() const;
135
136 // Documentation inherited
137 public: virtual void PostRender() override;
138
151 public: void StartForcedRender();
152
157 public: void EndForcedRender();
158
168 public: void StartRendering(Ogre::Camera *_camera);
169
181 public: void FlushGpuCommandsAndStartNewFrame(uint8_t _numPasses,
182 bool _startNewFrame);
183
186 protected: void FlushGpuCommandsOnly();
187
200 protected: void EndFrame();
201
207 public: void SetShadowsDirty(bool _dirty);
208
213 public: bool ShadowsDirty() const;
215
216 // Documentation inherited
217 protected: virtual bool LoadImpl() override;
218
219 // Documentation inherited
220 protected: virtual bool InitImpl() override;
221
222 // Documentation inherited
223 protected: virtual COMVisualPtr CreateCOMVisualImpl(unsigned int _id,
224 const std::string &_name) override;
225
226 // Documentation inherited
228 unsigned int _id, const std::string &_name) override;
229
230 // Documentation inherited
231 protected: virtual JointVisualPtr CreateJointVisualImpl(unsigned int _id,
232 const std::string &_name) override;
233
234 // Documentation inherited
235 protected: virtual LightVisualPtr CreateLightVisualImpl(unsigned int _id,
236 const std::string &_name) override;
237
238 // Documentation inherited
240 unsigned int _id, const std::string &_name) override;
241
242 // Documentation inherited
243 protected: virtual PointLightPtr CreatePointLightImpl(unsigned int _id,
244 const std::string &_name) override;
245
246 // Documentation inherited
247 protected: virtual SpotLightPtr CreateSpotLightImpl(unsigned int _id,
248 const std::string &_name) override;
249
250 // Documentation inherited
251 protected: virtual CameraPtr CreateCameraImpl(unsigned int _id,
252 const std::string &_name) override;
253
254 // Documentation inherited
255 protected: virtual DepthCameraPtr CreateDepthCameraImpl(unsigned int _id,
256 const std::string &_name) override;
257
258 // Documentation inherited
260 unsigned int _id, const std::string &_name) override;
261
262 // Documentation inherited
264 unsigned int _id, const std::string &_name) override;
265
266 // Documentation inherited
268 unsigned int _id, const std::string &_name) override;
269
270 // Documentation inherited
272 unsigned int _id, const std::string &_name) override;
273
274 // Documentation inherited
275 protected: virtual GpuRaysPtr CreateGpuRaysImpl(unsigned int _id,
276 const std::string &_name) override;
277
278 // Documentation inherited
279 protected: virtual VisualPtr CreateVisualImpl(unsigned int _id,
280 const std::string &_name) override;
281
282 // Documentation inherited
283 protected: virtual ArrowVisualPtr CreateArrowVisualImpl(unsigned int _id,
284 const std::string &_name) override;
285
286 // Documentation inherited
287 protected: virtual AxisVisualPtr CreateAxisVisualImpl(unsigned int _id,
288 const std::string &_name) override;
289
290 // Documentation inherited
291 protected: virtual GizmoVisualPtr CreateGizmoVisualImpl(unsigned int _id,
292 const std::string &_name) override;
293
294 // Documentation inherited
295 protected: virtual GeometryPtr CreateBoxImpl(unsigned int _id,
296 const std::string &_name) override;
297
298 // Documentation inherited
299 protected: virtual GeometryPtr CreateConeImpl(unsigned int _id,
300 const std::string &_name) override;
301
302 // Documentation inherited
303 protected: virtual GeometryPtr CreateCylinderImpl(unsigned int _id,
304 const std::string &_name) override;
305
306 // Documentation inherited
307 protected: virtual GeometryPtr CreatePlaneImpl(unsigned int _id,
308 const std::string &_name) override;
309
310 // Documentation inherited
311 protected: virtual GeometryPtr CreateSphereImpl(unsigned int _id,
312 const std::string &_name) override;
313
318 protected: virtual MeshPtr CreateMeshImpl(unsigned int _id,
319 const std::string &_name, const std::string &_meshName);
320
321 // Documentation inherited
322 protected: virtual MeshPtr CreateMeshImpl(unsigned int _id,
323 const std::string &_name, const MeshDescriptor &_desc)
324 override;
325
326 // Documentation inherited
327 protected: virtual CapsulePtr CreateCapsuleImpl(unsigned int _id,
328 const std::string &_name) override;
329
330 protected: virtual HeightmapPtr CreateHeightmapImpl(unsigned int _id,
331 const std::string &_name, const HeightmapDescriptor &_desc)
332 override;
333
334 // Documentation inherited
335 protected: virtual GridPtr CreateGridImpl(unsigned int _id,
336 const std::string &_name) override;
337
338 // Documentation inherited
339 protected: virtual MarkerPtr CreateMarkerImpl(unsigned int _id,
340 const std::string &_name) override;
341
342 // Documentation inherited
343 protected: virtual LidarVisualPtr CreateLidarVisualImpl(unsigned int _id,
344 const std::string &_name) override;
345
346 // Documentation inherited
347 protected: virtual WireBoxPtr CreateWireBoxImpl(unsigned int _id,
348 const std::string &_name) override;
349
350 // Documentation inherited
351 protected: virtual TextPtr CreateTextImpl(unsigned int _id,
352 const std::string &_name) override;
353
354 protected: virtual MaterialPtr CreateMaterialImpl(unsigned int _id,
355 const std::string &_name) override;
356
358 unsigned int _id, const std::string &_name) override;
359
360 // Documentation inherited.
362 unsigned int _id, const std::string &_name) override;
363
364 // Documentation inherited
365 protected: virtual RayQueryPtr CreateRayQueryImpl(
366 unsigned int _id, const std::string &_name) override;
367
368 // Documentation inherited
370 unsigned int _id, const std::string &_name) override;
371
372 // Documentation inherited
374 unsigned int _id, const std::string &_name) override;
375
376 // Documentation inherited
377 protected: virtual GlobalIlluminationVctPtr
379 unsigned int _id, const std::string &_name) override;
380
381 // Documentation inherited
382 protected: virtual GlobalIlluminationCiVctPtr
384 unsigned int _id, const std::string &_name) override;
385
390 protected: virtual bool InitObject(Ogre2ObjectPtr _object,
391 unsigned int _id, const std::string &_name);
392
397 public: void UpdateAllHeightmaps(Ogre::Camera *_camera);
398
402 const;
403
406 protected: void UpdateShadowNode();
407
421 private: void CreateShadowNodeWithSettings(
422 Ogre::CompositorManager2 *_compositorManager,
423 const std::string &_shadowNodeName,
424 const Ogre::ShadowNodeHelper::ShadowParamVec &_shadowParams);
425
426 // Documentation inherited
427 protected: virtual LightStorePtr Lights() const override;
428
429 // Documentation inherited
430 protected: virtual SensorStorePtr Sensors() const override;
431
432 // Documentation inherited
433 protected: virtual VisualStorePtr Visuals() const override;
434
435 // Documentation inherited
436 protected: virtual MaterialMapPtr Materials() const override;
437
438 // Documentation inherited
439 protected: unsigned int CreateObjectId() override;
440
442 private: void CreateContext();
443
445 private: void CreateRootVisual();
446
448 private: void CreateMeshFactory();
449
451 private: void CreateStores();
452
455 public: void ClearMaterialsCache(const std::string &_name);
456
458 private: Ogre2ScenePtr SharedThis();
459
462
465
468
471
474
477
480
482 protected: Ogre::SceneManager *ogreSceneManager = nullptr;
483
485 private: std::unique_ptr<Ogre2ScenePrivate> dataPtr;
486
488 private: friend class Ogre2RenderEngine;
489
490 private: friend class Ogre2SceneExt;
491 };
492
494 class Ogre2SceneExt : public SceneExt
495 {
498 public: Ogre2SceneExt(Scene *_scene);
499
500 // Documentation inherited
501 public: virtual ObjectPtr CreateExt(const std::string &_type,
502 const std::string &_name = "") override;
503 };
504 }
505 }
506}
507#endif