Gazebo Rendering

API Reference

9.0.0
Scene.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 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_SCENE_HH_
18#define GZ_RENDERING_SCENE_HH_
19
20#include <array>
21#include <string>
22#include <limits>
23
24#include <gz/common/Material.hh>
25#include <gz/common/Mesh.hh>
26
27#include <gz/math/Color.hh>
28
30
31#include "gz/rendering/config.hh"
36#include "gz/rendering/Export.hh"
37#include "gz/rendering/Light.hh"
38
39namespace gz
40{
41 namespace rendering
42 {
43 inline namespace GZ_RENDERING_VERSION_NAMESPACE {
44 //
45 class RenderEngine;
46 class SceneExt;
47
52 class GZ_RENDERING_VISIBLE Scene
53 {
55 public: virtual ~Scene();
56
58 public: virtual void Load() = 0;
59
61 public: virtual void Init() = 0;
62
63 // TODO(anyone): merge with Destroy
64 public: virtual void Fini() = 0;
65
68 public: virtual bool IsInitialized() const = 0;
69
72 public: virtual unsigned int Id() const = 0;
73
76 public: virtual std::string Name() const = 0;
77
80 public: virtual RenderEngine *Engine() const = 0;
81
84 public: virtual std::chrono::steady_clock::duration
85 Time() const = 0;
86
89 public: virtual void SetTime(
90 const std::chrono::steady_clock::duration &_time) = 0;
91
97 public: virtual VisualPtr RootVisual() const = 0;
98
103 public: virtual VisualPtr VisualAt(const CameraPtr &_camera,
104 const math::Vector2i &_mousePos) = 0;
105
108 public: virtual math::Color AmbientLight() const = 0;
109
115 public: virtual void SetAmbientLight(double _r, double _g, double _b,
116 double _a = 1.0) = 0;
117
120 public: virtual void SetAmbientLight(const math::Color &_color) = 0;
121
124 public: virtual math::Color BackgroundColor() const = 0;
125
131 public: virtual void SetBackgroundColor(double _r, double _g, double _b,
132 double _a = 1.0) = 0;
133
136 public: virtual void SetBackgroundColor(const math::Color &_color) = 0;
137
140 public: virtual bool IsGradientBackgroundColor() const = 0;
141
145 public: virtual std::array<math::Color, 4>
147
161 public: virtual void SetGradientBackgroundColor(
162 const std::array<math::Color, 4> &_colors) = 0;
163
167 public: virtual void RemoveGradientBackgroundColor() = 0;
168
172 public: virtual MaterialPtr BackgroundMaterial() const = 0;
173
177 public: virtual void SetBackgroundMaterial(MaterialPtr _material) = 0;
178
182 public: virtual unsigned int NodeCount() const = 0;
183
187 public: virtual bool HasNode(ConstNodePtr _node) const = 0;
188
193 public: virtual bool HasNodeId(unsigned int _id) const = 0;
194
199 public: virtual bool HasNodeName(const std::string &_name) const = 0;
200
205 public: virtual NodePtr NodeById(unsigned int _id) const = 0;
206
211 public: virtual NodePtr NodeByName(const std::string &_name) const = 0;
212
217 public: virtual NodePtr NodeByIndex(unsigned int _index) const = 0;
218
226 public: virtual void DestroyNode(NodePtr _node,
227 bool _recursive = false) = 0;
228
233 public: virtual void DestroyNodeById(unsigned int _id) = 0;
234
239 public: virtual void DestroyNodeByName(const std::string &_name) = 0;
240
245 public: virtual void DestroyNodeByIndex(unsigned int _index) = 0;
246
248 public: virtual void DestroyNodes() = 0;
249
253 public: virtual unsigned int LightCount() const = 0;
254
258 public: virtual bool HasLight(ConstLightPtr _light) const = 0;
259
264 public: virtual bool HasLightId(unsigned int _id) const = 0;
265
270 public: virtual bool HasLightName(const std::string &_name) const = 0;
271
276 public: virtual LightPtr LightById(unsigned int _id) const = 0;
277
282 public: virtual LightPtr LightByName(
283 const std::string &_name) const = 0;
284
289 public: virtual LightPtr LightByIndex(unsigned int _index) const = 0;
290
298 public: virtual void DestroyLight(LightPtr _light,
299 bool _recursive = false) = 0;
300
305 public: virtual void DestroyLightById(unsigned int _id) = 0;
306
311 public: virtual void DestroyLightByName(const std::string &_name) = 0;
312
317 public: virtual void DestroyLightByIndex(unsigned int _index) = 0;
318
320 public: virtual void DestroyLights() = 0;
321
325 public: virtual unsigned int SensorCount() const = 0;
326
330 public: virtual bool HasSensor(ConstSensorPtr _sensor) const = 0;
331
336 public: virtual bool HasSensorId(unsigned int _id) const = 0;
337
342 public: virtual bool HasSensorName(const std::string &_name) const = 0;
343
348 public: virtual SensorPtr SensorById(unsigned int _id) const = 0;
349
354 public: virtual SensorPtr SensorByName(
355 const std::string &_name) const = 0;
356
361 public: virtual SensorPtr SensorByIndex(unsigned int _index) const = 0;
362
370 public: virtual void DestroySensor(SensorPtr _sensor,
371 bool _recursive = false) = 0;
372
377 public: virtual void DestroySensorById(unsigned int _id) = 0;
378
383 public: virtual void DestroySensorByName(const std::string &_name) = 0;
384
389 public: virtual void DestroySensorByIndex(unsigned int _index) = 0;
390
392 public: virtual void DestroySensors() = 0;
393
397 public: virtual unsigned int VisualCount() const = 0;
398
402 public: virtual bool HasVisual(ConstVisualPtr _node) const = 0;
403
408 public: virtual bool HasVisualId(unsigned int _id) const = 0;
409
414 public: virtual bool HasVisualName(const std::string &_name) const = 0;
415
420 public: virtual VisualPtr VisualById(unsigned int _id) const = 0;
421
426 public: virtual VisualPtr VisualByName(
427 const std::string &_name) const = 0;
428
433 public: virtual VisualPtr VisualByIndex(unsigned int _index) const = 0;
434
443 public: virtual void DestroyVisual(VisualPtr _node,
444 bool _recursive = false) = 0;
445
450 public: virtual void DestroyVisualById(unsigned int _id) = 0;
451
456 public: virtual void DestroyVisualByName(const std::string &_name) = 0;
457
462 public: virtual void DestroyVisualByIndex(unsigned int _index) = 0;
463
465 public: virtual void DestroyVisuals() = 0;
466
470 public: virtual bool MaterialRegistered(
471 const std::string &_name) const = 0;
472
477 public: virtual MaterialPtr Material(
478 const std::string &_name) const = 0;
479
484 public: virtual void RegisterMaterial(const std::string &_name,
485 MaterialPtr _material) = 0;
486
490 public: virtual void UnregisterMaterial(const std::string &_name) = 0;
491
493 public: virtual void UnregisterMaterials() = 0;
494
497 public: virtual void DestroyMaterial(MaterialPtr _material) = 0;
498
500 public: virtual void DestroyMaterials() = 0;
501
506
513 unsigned int _id) = 0;
514
521 const std::string &_name) = 0;
522
529 unsigned int _id, const std::string &_name) = 0;
530
534 public: virtual PointLightPtr CreatePointLight() = 0;
535
542 unsigned int _id) = 0;
543
550 const std::string &_name) = 0;
551
558 unsigned int _id, const std::string &_name) = 0;
559
563 public: virtual SpotLightPtr CreateSpotLight() = 0;
564
571 unsigned int _id) = 0;
572
579 const std::string &_name) = 0;
580
587 unsigned int _id, const std::string &_name) = 0;
588
592 public: virtual CameraPtr CreateCamera() = 0;
593
599 public: virtual CameraPtr CreateCamera(
600 unsigned int _id) = 0;
601
607 public: virtual CameraPtr CreateCamera(
608 const std::string &_name) = 0;
609
615 public: virtual CameraPtr CreateCamera(
616 unsigned int _id, const std::string &_name) = 0;
617
621 public: virtual DepthCameraPtr CreateDepthCamera() = 0;
622
629 unsigned int _id) = 0;
630
637 const std::string &_name) = 0;
638
645 unsigned int _id, const std::string &_name) = 0;
646
651
658 unsigned int _id) = 0;
659
666 const std::string &_name) = 0;
667
674 unsigned int _id, const std::string &_name) = 0;
675
680
687 unsigned int _id) = 0;
688
695 const std::string &_name) = 0;
696
703 unsigned int _id, const std::string &_name) = 0;
704
709
716 unsigned int _id) = 0;
717
724 const std::string &_name) = 0;
725
732 unsigned int _id, const std::string &_name) = 0;
733
738
745 unsigned int _id) = 0;
746
753 const std::string &_name) = 0;
754
761 unsigned int _id, const std::string &_name) = 0;
762
766 public: virtual GpuRaysPtr CreateGpuRays() = 0;
767
773 public: virtual GpuRaysPtr CreateGpuRays(unsigned int _id) = 0;
774
780 public: virtual GpuRaysPtr CreateGpuRays(
781 const std::string &_name) = 0;
782
788 public: virtual GpuRaysPtr CreateGpuRays(
789 unsigned int _id, const std::string &_name) = 0;
790
794 public: virtual VisualPtr CreateVisual() = 0;
795
801 public: virtual VisualPtr CreateVisual(
802 unsigned int _id) = 0;
803
809 public: virtual VisualPtr CreateVisual(
810 const std::string &_name) = 0;
811
817 public: virtual VisualPtr CreateVisual(
818 unsigned int _id, const std::string &_name) = 0;
819
823 public: virtual ArrowVisualPtr CreateArrowVisual() = 0;
824
831 unsigned int _id) = 0;
832
839 const std::string &_name) = 0;
840
847 unsigned int _id, const std::string &_name) = 0;
848
852 public: virtual AxisVisualPtr CreateAxisVisual() = 0;
853
860 unsigned int _id) = 0;
861
868 const std::string &_name) = 0;
869
876 unsigned int _id, const std::string &_name) = 0;
877
881 public: virtual GizmoVisualPtr CreateGizmoVisual() = 0;
882
889 unsigned int _id) = 0;
890
897 const std::string &_name) = 0;
898
905 unsigned int _id, const std::string &_name) = 0;
906
910 public: virtual COMVisualPtr CreateCOMVisual() = 0;
911
918 unsigned int _id) = 0;
919
926 const std::string &_name) = 0;
927
934 unsigned int _id, const std::string &_name) = 0;
935
940
947 unsigned int _id) = 0;
948
955 const std::string &_name) = 0;
956
963 unsigned int _id, const std::string &_name) = 0;
964
968 public: virtual JointVisualPtr CreateJointVisual() = 0;
969
976 unsigned int _id) = 0;
977
984 const std::string &_name) = 0;
985
992 unsigned int _id, const std::string &_name) = 0;
993
997 public: virtual LightVisualPtr CreateLightVisual() = 0;
998
1005 unsigned int _id) = 0;
1006
1013 const std::string &_name) = 0;
1014
1021 unsigned int _id, const std::string &_name) = 0;
1022
1025 public: virtual GeometryPtr CreateBox() = 0;
1026
1029 public: virtual CapsulePtr CreateCapsule() = 0;
1030
1033 public: virtual GeometryPtr CreateCone() = 0;
1034
1037 public: virtual GeometryPtr CreateCylinder() = 0;
1038
1041 public: virtual GeometryPtr CreatePlane() = 0;
1042
1047 public: virtual GeometryPtr CreateSphere() = 0;
1048
1055 public: virtual MeshPtr CreateMesh(const std::string &_meshName) = 0;
1056
1062 public: virtual MeshPtr CreateMesh(const common::Mesh *_mesh) = 0;
1063
1069 public: virtual MeshPtr CreateMesh(const MeshDescriptor &_desc) = 0;
1070
1073 public: virtual GridPtr CreateGrid() = 0;
1074
1077 public: virtual WireBoxPtr CreateWireBox() = 0;
1078
1081 public: virtual MarkerPtr CreateMarker() = 0;
1082
1086 public: virtual LidarVisualPtr CreateLidarVisual() = 0;
1087
1093 public: virtual LidarVisualPtr CreateLidarVisual(unsigned int _id) = 0;
1094
1101 const std::string &_name) = 0;
1102
1109 unsigned int _id, const std::string &_name) = 0;
1110
1116 const HeightmapDescriptor &_desc) = 0;
1117
1120 public: virtual TextPtr CreateText() = 0;
1121
1126 public: virtual MaterialPtr CreateMaterial(const std::string &_name = "")
1127 = 0;
1128
1133 const common::Material &_material) = 0;
1134
1138
1144
1147 public: virtual RayQueryPtr CreateRayQuery() = 0;
1148
1153
1160 unsigned int _id) = 0;
1161
1168 const std::string &_name) = 0;
1169
1176 unsigned int _id, const std::string &_name) = 0;
1177
1181 public: virtual ProjectorPtr CreateProjector() = 0;
1182
1189 unsigned int _id) = 0;
1190
1196 const std::string &_name) = 0;
1197
1204 unsigned int _id, const std::string &_name) = 0;
1205
1209 public: virtual GlobalIlluminationVctPtr
1211
1218 unsigned int _id) = 0;
1219
1226 const std::string &_name) = 0;
1227
1234 unsigned int _id, const std::string &_name) = 0;
1235
1239 public: virtual GlobalIlluminationCiVctPtr
1241
1248 unsigned int _id) = 0;
1249
1256 const std::string &_name) = 0;
1257
1264 unsigned int _id, const std::string &_name) = 0;
1265
1268 public: virtual void SetSkyEnabled(bool _enabled) = 0;
1269
1272 public: virtual bool SkyEnabled() const = 0;
1273
1277 public: virtual bool SetShadowTextureSize(LightType _lightType,
1278 unsigned int _textureSize) = 0;
1279
1282 public: virtual unsigned int ShadowTextureSize(LightType _lightType)
1283 const = 0;
1284
1287 public: virtual void SetActiveGlobalIllumination(
1289
1292 public: virtual void PreRender() = 0;
1293
1299 public: virtual void PostRender() = 0;
1300
1394 public: virtual void SetCameraPassCountPerGpuFlush(uint8_t _numPass) = 0;
1395
1400 public: virtual uint8_t CameraPassCountPerGpuFlush() const = 0;
1401
1406 public: virtual bool LegacyAutoGpuFlush() const = 0;
1407
1411 public: virtual void Clear() = 0;
1412
1416 public: virtual void Destroy() = 0;
1417
1420 public: SceneExt *Extension() const;
1421
1424 protected: void SetExtension(SceneExt *_ext);
1425 };
1426 }
1427 }
1428}
1429#endif