Gazebo Rendering

API Reference

7.4.2
gz/rendering/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"
35 #include "gz/rendering/Storage.hh"
36 #include "gz/rendering/Export.hh"
37 
38 namespace gz
39 {
40  namespace rendering
41  {
42  inline namespace GZ_RENDERING_VERSION_NAMESPACE {
43  //
44  class RenderEngine;
45  class SceneExt;
46 
51  class GZ_RENDERING_VISIBLE Scene
52  {
54  public: virtual ~Scene();
55 
57  public: virtual void Load() = 0;
58 
60  public: virtual void Init() = 0;
61 
62  // TODO(anyone): merge with Destroy
63  public: virtual void Fini() = 0;
64 
67  public: virtual bool IsInitialized() const = 0;
68 
71  public: virtual unsigned int Id() const = 0;
72 
75  public: virtual std::string Name() const = 0;
76 
79  public: virtual RenderEngine *Engine() const = 0;
80 
83  public: virtual std::chrono::steady_clock::duration
84  Time() const = 0;
85 
88  public: virtual void SetTime(
89  const std::chrono::steady_clock::duration &_time) = 0;
90 
96  public: virtual VisualPtr RootVisual() const = 0;
97 
102  public: virtual VisualPtr VisualAt(const CameraPtr &_camera,
103  const math::Vector2i &_mousePos) = 0;
104 
107  public: virtual math::Color AmbientLight() const = 0;
108 
114  public: virtual void SetAmbientLight(double _r, double _g, double _b,
115  double _a = 1.0) = 0;
116 
119  public: virtual void SetAmbientLight(const math::Color &_color) = 0;
120 
123  public: virtual math::Color BackgroundColor() const = 0;
124 
130  public: virtual void SetBackgroundColor(double _r, double _g, double _b,
131  double _a = 1.0) = 0;
132 
135  public: virtual void SetBackgroundColor(const math::Color &_color) = 0;
136 
139  public: virtual bool IsGradientBackgroundColor() const = 0;
140 
144  public: virtual std::array<math::Color, 4>
145  GradientBackgroundColor() const = 0;
146 
160  public: virtual void SetGradientBackgroundColor(
161  const std::array<math::Color, 4> &_colors) = 0;
162 
166  public: virtual void RemoveGradientBackgroundColor() = 0;
167 
171  public: virtual MaterialPtr BackgroundMaterial() const = 0;
172 
176  public: virtual void SetBackgroundMaterial(MaterialPtr _material) = 0;
177 
181  public: virtual unsigned int NodeCount() const = 0;
182 
186  public: virtual bool HasNode(ConstNodePtr _node) const = 0;
187 
192  public: virtual bool HasNodeId(unsigned int _id) const = 0;
193 
198  public: virtual bool HasNodeName(const std::string &_name) const = 0;
199 
204  public: virtual NodePtr NodeById(unsigned int _id) const = 0;
205 
210  public: virtual NodePtr NodeByName(const std::string &_name) const = 0;
211 
216  public: virtual NodePtr NodeByIndex(unsigned int _index) const = 0;
217 
225  public: virtual void DestroyNode(NodePtr _node,
226  bool _recursive = false) = 0;
227 
232  public: virtual void DestroyNodeById(unsigned int _id) = 0;
233 
238  public: virtual void DestroyNodeByName(const std::string &_name) = 0;
239 
244  public: virtual void DestroyNodeByIndex(unsigned int _index) = 0;
245 
247  public: virtual void DestroyNodes() = 0;
248 
252  public: virtual unsigned int LightCount() const = 0;
253 
257  public: virtual bool HasLight(ConstLightPtr _light) const = 0;
258 
263  public: virtual bool HasLightId(unsigned int _id) const = 0;
264 
269  public: virtual bool HasLightName(const std::string &_name) const = 0;
270 
275  public: virtual LightPtr LightById(unsigned int _id) const = 0;
276 
281  public: virtual LightPtr LightByName(
282  const std::string &_name) const = 0;
283 
288  public: virtual LightPtr LightByIndex(unsigned int _index) const = 0;
289 
297  public: virtual void DestroyLight(LightPtr _light,
298  bool _recursive = false) = 0;
299 
304  public: virtual void DestroyLightById(unsigned int _id) = 0;
305 
310  public: virtual void DestroyLightByName(const std::string &_name) = 0;
311 
316  public: virtual void DestroyLightByIndex(unsigned int _index) = 0;
317 
319  public: virtual void DestroyLights() = 0;
320 
324  public: virtual unsigned int SensorCount() const = 0;
325 
329  public: virtual bool HasSensor(ConstSensorPtr _sensor) const = 0;
330 
335  public: virtual bool HasSensorId(unsigned int _id) const = 0;
336 
341  public: virtual bool HasSensorName(const std::string &_name) const = 0;
342 
347  public: virtual SensorPtr SensorById(unsigned int _id) const = 0;
348 
353  public: virtual SensorPtr SensorByName(
354  const std::string &_name) const = 0;
355 
360  public: virtual SensorPtr SensorByIndex(unsigned int _index) const = 0;
361 
369  public: virtual void DestroySensor(SensorPtr _sensor,
370  bool _recursive = false) = 0;
371 
376  public: virtual void DestroySensorById(unsigned int _id) = 0;
377 
382  public: virtual void DestroySensorByName(const std::string &_name) = 0;
383 
388  public: virtual void DestroySensorByIndex(unsigned int _index) = 0;
389 
391  public: virtual void DestroySensors() = 0;
392 
396  public: virtual unsigned int VisualCount() const = 0;
397 
401  public: virtual bool HasVisual(ConstVisualPtr _node) const = 0;
402 
407  public: virtual bool HasVisualId(unsigned int _id) const = 0;
408 
413  public: virtual bool HasVisualName(const std::string &_name) const = 0;
414 
419  public: virtual VisualPtr VisualById(unsigned int _id) const = 0;
420 
425  public: virtual VisualPtr VisualByName(
426  const std::string &_name) const = 0;
427 
432  public: virtual VisualPtr VisualByIndex(unsigned int _index) const = 0;
433 
442  public: virtual void DestroyVisual(VisualPtr _node,
443  bool _recursive = false) = 0;
444 
449  public: virtual void DestroyVisualById(unsigned int _id) = 0;
450 
455  public: virtual void DestroyVisualByName(const std::string &_name) = 0;
456 
461  public: virtual void DestroyVisualByIndex(unsigned int _index) = 0;
462 
464  public: virtual void DestroyVisuals() = 0;
465 
469  public: virtual bool MaterialRegistered(
470  const std::string &_name) const = 0;
471 
476  public: virtual MaterialPtr Material(
477  const std::string &_name) const = 0;
478 
483  public: virtual void RegisterMaterial(const std::string &_name,
484  MaterialPtr _material) = 0;
485 
489  public: virtual void UnregisterMaterial(const std::string &_name) = 0;
490 
492  public: virtual void UnregisterMaterials() = 0;
493 
496  public: virtual void DestroyMaterial(MaterialPtr _material) = 0;
497 
499  public: virtual void DestroyMaterials() = 0;
500 
504  public: virtual DirectionalLightPtr CreateDirectionalLight() = 0;
505 
511  public: virtual DirectionalLightPtr CreateDirectionalLight(
512  unsigned int _id) = 0;
513 
519  public: virtual DirectionalLightPtr CreateDirectionalLight(
520  const std::string &_name) = 0;
521 
527  public: virtual DirectionalLightPtr CreateDirectionalLight(
528  unsigned int _id, const std::string &_name) = 0;
529 
533  public: virtual PointLightPtr CreatePointLight() = 0;
534 
540  public: virtual PointLightPtr CreatePointLight(
541  unsigned int _id) = 0;
542 
548  public: virtual PointLightPtr CreatePointLight(
549  const std::string &_name) = 0;
550 
556  public: virtual PointLightPtr CreatePointLight(
557  unsigned int _id, const std::string &_name) = 0;
558 
562  public: virtual SpotLightPtr CreateSpotLight() = 0;
563 
569  public: virtual SpotLightPtr CreateSpotLight(
570  unsigned int _id) = 0;
571 
577  public: virtual SpotLightPtr CreateSpotLight(
578  const std::string &_name) = 0;
579 
585  public: virtual SpotLightPtr CreateSpotLight(
586  unsigned int _id, const std::string &_name) = 0;
587 
591  public: virtual CameraPtr CreateCamera() = 0;
592 
598  public: virtual CameraPtr CreateCamera(
599  unsigned int _id) = 0;
600 
606  public: virtual CameraPtr CreateCamera(
607  const std::string &_name) = 0;
608 
614  public: virtual CameraPtr CreateCamera(
615  unsigned int _id, const std::string &_name) = 0;
616 
620  public: virtual DepthCameraPtr CreateDepthCamera() = 0;
621 
627  public: virtual DepthCameraPtr CreateDepthCamera(
628  unsigned int _id) = 0;
629 
635  public: virtual DepthCameraPtr CreateDepthCamera(
636  const std::string &_name) = 0;
637 
643  public: virtual DepthCameraPtr CreateDepthCamera(
644  unsigned int _id, const std::string &_name) = 0;
645 
649  public: virtual ThermalCameraPtr CreateThermalCamera() = 0;
650 
656  public: virtual ThermalCameraPtr CreateThermalCamera(
657  unsigned int _id) = 0;
658 
664  public: virtual ThermalCameraPtr CreateThermalCamera(
665  const std::string &_name) = 0;
666 
672  public: virtual ThermalCameraPtr CreateThermalCamera(
673  unsigned int _id, const std::string &_name) = 0;
674 
678  public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera() = 0;
679 
685  public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera(
686  unsigned int _id) = 0;
687 
693  public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera(
694  const std::string &_name) = 0;
695 
701  public: virtual BoundingBoxCameraPtr CreateBoundingBoxCamera(
702  unsigned int _id, const std::string &_name) = 0;
703 
707  public: virtual SegmentationCameraPtr CreateSegmentationCamera() = 0;
708 
714  public: virtual SegmentationCameraPtr CreateSegmentationCamera(
715  unsigned int _id) = 0;
716 
722  public: virtual SegmentationCameraPtr CreateSegmentationCamera(
723  const std::string &_name) = 0;
724 
730  public: virtual SegmentationCameraPtr CreateSegmentationCamera(
731  unsigned int _id, const std::string &_name) = 0;
732 
736  public: virtual WideAngleCameraPtr CreateWideAngleCamera() = 0;
737 
743  public: virtual WideAngleCameraPtr CreateWideAngleCamera(
744  unsigned int _id) = 0;
745 
751  public: virtual WideAngleCameraPtr CreateWideAngleCamera(
752  const std::string &_name) = 0;
753 
759  public: virtual WideAngleCameraPtr CreateWideAngleCamera(
760  unsigned int _id, const std::string &_name) = 0;
761 
765  public: virtual GpuRaysPtr CreateGpuRays() = 0;
766 
772  public: virtual GpuRaysPtr CreateGpuRays(unsigned int _id) = 0;
773 
779  public: virtual GpuRaysPtr CreateGpuRays(
780  const std::string &_name) = 0;
781 
787  public: virtual GpuRaysPtr CreateGpuRays(
788  unsigned int _id, const std::string &_name) = 0;
789 
793  public: virtual VisualPtr CreateVisual() = 0;
794 
800  public: virtual VisualPtr CreateVisual(
801  unsigned int _id) = 0;
802 
808  public: virtual VisualPtr CreateVisual(
809  const std::string &_name) = 0;
810 
816  public: virtual VisualPtr CreateVisual(
817  unsigned int _id, const std::string &_name) = 0;
818 
822  public: virtual ArrowVisualPtr CreateArrowVisual() = 0;
823 
829  public: virtual ArrowVisualPtr CreateArrowVisual(
830  unsigned int _id) = 0;
831 
837  public: virtual ArrowVisualPtr CreateArrowVisual(
838  const std::string &_name) = 0;
839 
845  public: virtual ArrowVisualPtr CreateArrowVisual(
846  unsigned int _id, const std::string &_name) = 0;
847 
851  public: virtual AxisVisualPtr CreateAxisVisual() = 0;
852 
858  public: virtual AxisVisualPtr CreateAxisVisual(
859  unsigned int _id) = 0;
860 
866  public: virtual AxisVisualPtr CreateAxisVisual(
867  const std::string &_name) = 0;
868 
874  public: virtual AxisVisualPtr CreateAxisVisual(
875  unsigned int _id, const std::string &_name) = 0;
876 
880  public: virtual GizmoVisualPtr CreateGizmoVisual() = 0;
881 
887  public: virtual GizmoVisualPtr CreateGizmoVisual(
888  unsigned int _id) = 0;
889 
895  public: virtual GizmoVisualPtr CreateGizmoVisual(
896  const std::string &_name) = 0;
897 
903  public: virtual GizmoVisualPtr CreateGizmoVisual(
904  unsigned int _id, const std::string &_name) = 0;
905 
909  public: virtual COMVisualPtr CreateCOMVisual() = 0;
910 
916  public: virtual COMVisualPtr CreateCOMVisual(
917  unsigned int _id) = 0;
918 
924  public: virtual COMVisualPtr CreateCOMVisual(
925  const std::string &_name) = 0;
926 
932  public: virtual COMVisualPtr CreateCOMVisual(
933  unsigned int _id, const std::string &_name) = 0;
934 
938  public: virtual InertiaVisualPtr CreateInertiaVisual() = 0;
939 
945  public: virtual InertiaVisualPtr CreateInertiaVisual(
946  unsigned int _id) = 0;
947 
953  public: virtual InertiaVisualPtr CreateInertiaVisual(
954  const std::string &_name) = 0;
955 
961  public: virtual InertiaVisualPtr CreateInertiaVisual(
962  unsigned int _id, const std::string &_name) = 0;
963 
967  public: virtual JointVisualPtr CreateJointVisual() = 0;
968 
974  public: virtual JointVisualPtr CreateJointVisual(
975  unsigned int _id) = 0;
976 
982  public: virtual JointVisualPtr CreateJointVisual(
983  const std::string &_name) = 0;
984 
990  public: virtual JointVisualPtr CreateJointVisual(
991  unsigned int _id, const std::string &_name) = 0;
992 
996  public: virtual LightVisualPtr CreateLightVisual() = 0;
997 
1003  public: virtual LightVisualPtr CreateLightVisual(
1004  unsigned int _id) = 0;
1005 
1011  public: virtual LightVisualPtr CreateLightVisual(
1012  const std::string &_name) = 0;
1013 
1019  public: virtual LightVisualPtr CreateLightVisual(
1020  unsigned int _id, const std::string &_name) = 0;
1021 
1024  public: virtual GeometryPtr CreateBox() = 0;
1025 
1028  public: virtual CapsulePtr CreateCapsule() = 0;
1029 
1032  public: virtual GeometryPtr CreateCone() = 0;
1033 
1036  public: virtual GeometryPtr CreateCylinder() = 0;
1037 
1040  public: virtual GeometryPtr CreatePlane() = 0;
1041 
1046  public: virtual GeometryPtr CreateSphere() = 0;
1047 
1054  public: virtual MeshPtr CreateMesh(const std::string &_meshName) = 0;
1055 
1061  public: virtual MeshPtr CreateMesh(const common::Mesh *_mesh) = 0;
1062 
1068  public: virtual MeshPtr CreateMesh(const MeshDescriptor &_desc) = 0;
1069 
1072  public: virtual GridPtr CreateGrid() = 0;
1073 
1076  public: virtual WireBoxPtr CreateWireBox() = 0;
1077 
1080  public: virtual MarkerPtr CreateMarker() = 0;
1081 
1085  public: virtual LidarVisualPtr CreateLidarVisual() = 0;
1086 
1092  public: virtual LidarVisualPtr CreateLidarVisual(unsigned int _id) = 0;
1093 
1099  public: virtual LidarVisualPtr CreateLidarVisual(
1100  const std::string &_name) = 0;
1101 
1107  public: virtual LidarVisualPtr CreateLidarVisual(
1108  unsigned int _id, const std::string &_name) = 0;
1109 
1114  public: virtual HeightmapPtr CreateHeightmap(
1115  const HeightmapDescriptor &_desc) = 0;
1116 
1119  public: virtual TextPtr CreateText() = 0;
1120 
1125  public: virtual MaterialPtr CreateMaterial(const std::string &_name = "")
1126  = 0;
1127 
1131  public: virtual MaterialPtr CreateMaterial(
1132  const common::Material &_material) = 0;
1133 
1136  public: virtual RenderTexturePtr CreateRenderTexture() = 0;
1137 
1142  public: virtual RenderWindowPtr CreateRenderWindow() = 0;
1143 
1146  public: virtual RayQueryPtr CreateRayQuery() = 0;
1147 
1151  public: virtual ParticleEmitterPtr CreateParticleEmitter() = 0;
1152 
1158  public: virtual ParticleEmitterPtr CreateParticleEmitter(
1159  unsigned int _id) = 0;
1160 
1166  public: virtual ParticleEmitterPtr CreateParticleEmitter(
1167  const std::string &_name) = 0;
1168 
1174  public: virtual ParticleEmitterPtr CreateParticleEmitter(
1175  unsigned int _id, const std::string &_name) = 0;
1176 
1183 
1192 
1201 
1211 
1214  public: virtual void SetSkyEnabled(bool _enabled) = 0;
1215 
1218  public: virtual bool SkyEnabled() const = 0;
1219 
1222  public: virtual void PreRender() = 0;
1223 
1229  public: virtual void PostRender() = 0;
1230 
1324  public: virtual void SetCameraPassCountPerGpuFlush(uint8_t _numPass) = 0;
1325 
1330  public: virtual uint8_t CameraPassCountPerGpuFlush() const = 0;
1331 
1336  public: virtual bool LegacyAutoGpuFlush() const = 0;
1337 
1341  public: virtual void Clear() = 0;
1342 
1346  public: virtual void Destroy() = 0;
1347 
1350  public: SceneExt *Extension() const;
1351 
1354  protected: void SetExtension(SceneExt *_ext);
1355  };
1356  }
1357  }
1358 }
1359 #endif