Open3D (C++ API)
Scene.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2019 www.open3d.org
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // ----------------------------------------------------------------------------
26 
27 #pragma once
28 
29 #include <Eigen/Geometry>
30 
33 
34 namespace open3d {
35 
36 namespace geometry {
37 class Geometry3D;
38 class AxisAlignedBoundingBox;
39 } // namespace geometry
40 
41 namespace visualization {
42 
43 class View;
44 
45 // Contains renderable objects like geometry and lights
46 // Can have multiple views
47 class Scene {
48 public:
49  using Transform = Eigen::Transform<float, 3, Eigen::Affine>;
50 
51  virtual ~Scene() = default;
52 
53  virtual ViewHandle AddView(std::int32_t x,
54  std::int32_t y,
55  std::uint32_t w,
56  std::uint32_t h) = 0;
57  virtual View* GetView(const ViewHandle& view_id) const = 0;
58  virtual void SetViewActive(const ViewHandle& view_id, bool is_active) = 0;
59  virtual void RemoveView(const ViewHandle& view_id) = 0;
60 
61  // 'All defaults' way:
62  // * Will use geometry name as entity name
63  // * Will use apropriate default material for rendering
64  // * For geometries with textures, will try load and assign a texture
65  virtual GeometryHandle AddGeometry(
66  const geometry::Geometry3D& geometry) = 0;
67  // Will use geometry name as entity name
68  virtual GeometryHandle AddGeometry(
69  const geometry::Geometry3D& geometry,
70  const MaterialInstanceHandle& material_id) = 0;
71  virtual GeometryHandle AddGeometry(
72  const geometry::Geometry3D& geometry,
73  const MaterialInstanceHandle& material_id,
74  const std::string& name) = 0;
75  virtual void AssignMaterial(const GeometryHandle& geometry_id,
76  const MaterialInstanceHandle& material_id) = 0;
77  virtual MaterialInstanceHandle GetMaterial(
78  const GeometryHandle& geometry_id) const = 0;
79  virtual void SetGeometryShadows(const GeometryHandle& geometry_id,
80  bool casts_shadows,
81  bool receives_shadows) = 0;
82  virtual std::vector<GeometryHandle> FindGeometryByName(
83  const std::string& name) = 0;
84  virtual void RemoveGeometry(const GeometryHandle& geometry_id) = 0;
85 
86  virtual LightHandle AddLight(const LightDescription& descr) = 0;
87  // TODO: If possible, add getters
88  virtual void SetLightIntensity(const LightHandle& id, float intensity) = 0;
89  virtual void SetLightColor(const LightHandle& id,
90  const Eigen::Vector3f& color) = 0;
91  virtual Eigen::Vector3f GetLightDirection(const LightHandle& id) const = 0;
92  virtual void SetLightDirection(const LightHandle& id,
93  const Eigen::Vector3f& dir) = 0;
94  virtual void SetLightPosition(const LightHandle& id,
95  const Eigen::Vector3f& pos) = 0;
96  virtual void SetLightFalloff(const LightHandle& id, float falloff) = 0;
97  virtual void RemoveLight(const LightHandle& id) = 0;
98 
99  // Passing empty id disables indirect lightning
100  virtual void SetIndirectLight(const IndirectLightHandle& id) = 0;
101  virtual void SetIndirectLightIntensity(float intensity) = 0;
102  virtual float GetIndirectLightIntensity() const = 0;
103  virtual void SetIndirectLightRotation(const Transform& rotation) = 0;
104  virtual Transform GetIndirectLightRotation() const = 0;
105 
106  // Passing empty id removes skybox
107  virtual void SetSkybox(const SkyboxHandle& id) = 0;
108 
109  virtual void SetEntityEnabled(const REHandle_abstract& entity_id,
110  bool enabled) = 0;
111  virtual bool GetEntityEnabled(const REHandle_abstract& entity_id) = 0;
112  virtual void SetEntityTransform(const REHandle_abstract& entity_id,
113  const Transform& transform) = 0;
114  virtual Transform GetEntityTransform(
115  const REHandle_abstract& entity_id) = 0;
116 
117  // Returns world space AABB
118  virtual geometry::AxisAlignedBoundingBox GetEntityBoundingBox(
119  const REHandle_abstract& entity_id) = 0;
120 };
121 
122 } // namespace visualization
123 } // namespace open3d
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t timeout_in_ms capture_handle capture_handle capture_handle image_handle temperature_c k4a_image_t image_handle uint8_t image_handle image_handle image_handle image_handle uint32_t
Definition: K4aPlugin.cpp:553
A bounding box that is aligned along the coordinate axes.
Definition: BoundingVolume.h:164
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t int32_t
Definition: K4aPlugin.cpp:394
math::float4 color
Definition: LineSetBuffers.cpp:46
The base geometry class for 3D geometries.
Definition: Geometry3D.h:46
Definition: RendererStructs.h:42
Definition: View.h:37
Eigen::Transform< float, 3, Eigen::Affine > Transform
Definition: Scene.h:49
Definition: Open3DViewer.h:29
std::string name
Definition: FilePCD.cpp:56
Definition: RendererHandle.h:71
Definition: Scene.h:47