39 #pragma warning(disable : 4068 4146 4293 4305) 42 #include <filament/LightManager.h> 43 #include <filament/RenderableManager.h> 44 #include <utils/Entity.h> 50 #include <Eigen/Geometry> 51 #include <unordered_map> 69 class TransformManager;
75 namespace visualization {
79 class GeometryBuffersBuilder;
87 using Transform = Eigen::Transform<float, 3, Eigen::Affine>;
101 void SetViewActive(
const ViewHandle& view_id,
bool is_active)
override;
102 void SetRenderOnce(
const ViewHandle& view_id)
override;
103 void RemoveView(
const ViewHandle& view_id)
override;
106 void AddCamera(
const std::string& camera_name,
107 std::shared_ptr<Camera> cam)
override;
108 void RemoveCamera(
const std::string& camera_name)
override;
112 bool AddGeometry(
const std::string& object_name,
115 const std::string& downsampled_name =
"",
116 size_t downsample_threshold = SIZE_MAX)
override;
117 bool AddGeometry(
const std::string& object_name,
120 const std::string& downsampled_name =
"",
121 size_t downsample_threshold = SIZE_MAX)
override;
122 bool AddGeometry(
const std::string& object_name,
124 bool HasGeometry(
const std::string& object_name)
const override;
125 void UpdateGeometry(
const std::string& object_name,
128 void RemoveGeometry(
const std::string& object_name)
override;
129 void ShowGeometry(
const std::string& object_name,
bool show)
override;
130 bool GeometryIsVisible(
const std::string& object_name)
override;
131 void SetGeometryTransform(
const std::string& object_name,
133 Transform GetGeometryTransform(
const std::string& object_name)
override;
135 const std::string& object_name)
override;
136 void GeometryShadows(
const std::string& object_name,
138 bool receive_shadows)
override;
139 void OverrideMaterial(
const std::string& object_name,
141 void QueryGeometry(std::vector<std::string>& geometry)
override;
142 void OverrideMaterialAll(
const Material& material,
143 bool shader_only =
true)
override;
146 bool AddPointLight(
const std::string& light_name,
147 const Eigen::Vector3f&
color,
151 bool cast_shadows)
override;
152 bool AddSpotLight(
const std::string& light_name,
153 const Eigen::Vector3f&
color,
155 const Eigen::Vector3f& direction,
158 float inner_cone_angle,
159 float outer_cone_angle,
160 bool cast_shadows)
override;
161 Light& GetLight(
const std::string& light_name)
override;
162 void RemoveLight(
const std::string& light_name)
override;
163 void UpdateLight(
const std::string& light_name,
164 const Light& light)
override;
165 void UpdateLightColor(
const std::string& light_name,
166 const Eigen::Vector3f&
color)
override;
167 void UpdateLightPosition(
const std::string& light_name,
168 const Eigen::Vector3f&
position)
override;
169 void UpdateLightDirection(
const std::string& light_name,
170 const Eigen::Vector3f& direction)
override;
171 void UpdateLightIntensity(
const std::string& light_name,
172 float intensity)
override;
173 void UpdateLightFalloff(
const std::string& light_name,
174 float falloff)
override;
175 void UpdateLightConeAngles(
const std::string& light_name,
176 float inner_cone_angle,
177 float outer_cone_angle)
override;
178 void EnableLightShadow(
const std::string& light_name,
179 bool cast_shadows)
override;
181 void SetDirectionalLight(
const Eigen::Vector3f& direction,
182 const Eigen::Vector3f&
color,
183 float intensity)
override;
184 void EnableDirectionalLight(
bool enable)
override;
185 void EnableDirectionalLightShadows(
bool enable)
override;
186 void SetDirectionalLightDirection(
187 const Eigen::Vector3f& direction)
override;
188 Eigen::Vector3f GetDirectionalLightDirection()
override;
190 bool SetIndirectLight(
const std::string& ibl_name)
override;
191 const std::string& GetIndirectLight()
override;
192 void EnableIndirectLight(
bool enable)
override;
193 void SetIndirectLightIntensity(
float intensity)
override;
194 float GetIndirectLightIntensity()
override;
195 void SetIndirectLightRotation(
const Transform& rotation)
override;
196 Transform GetIndirectLightRotation()
override;
197 void ShowSkybox(
bool show)
override;
198 void SetBackgroundColor(
const Eigen::Vector4f&
color)
override;
200 void RenderToImage(std::function<
void(std::shared_ptr<geometry::Image>)>
203 void Draw(filament::Renderer& renderer);
209 filament::RenderableManager::Builder& builder,
211 enum BufferReuse { kNo, kYes };
212 bool CreateAndAddFilamentEntity(
213 const std::string& object_name,
219 BufferReuse reusing_vertex_buffer = BufferReuse::kNo);
221 filament::Engine& engine_;
223 filament::Scene* scene_ =
nullptr;
227 rendering::FilamentResourceManager::kDefaultTexture;
229 rendering::FilamentResourceManager::kDefaultNormalMap;
231 rendering::FilamentResourceManager::kDefaultTexture;
233 rendering::FilamentResourceManager::kDefaultTexture;
235 rendering::FilamentResourceManager::kDefaultTexture;
237 rendering::FilamentResourceManager::kDefaultTexture;
239 rendering::FilamentResourceManager::kDefaultTexture;
241 rendering::FilamentResourceManager::kDefaultTexture;
244 struct GeometryMaterialInstance {
250 struct RenderableGeometry {
253 bool cast_shadows =
true;
254 bool receive_shadow =
true;
256 GeometryMaterialInstance mat;
259 utils::Entity filament_entity;
262 void ReleaseResources(filament::Engine& engine,
268 utils::Entity filament_entity;
272 struct ViewContainer {
273 std::unique_ptr<FilamentView> view;
274 bool is_active =
true;
275 int render_count = -1;
277 std::unordered_map<REHandle_abstract, ViewContainer> views_;
279 std::vector<RenderableGeometry*> GetGeometry(
const std::string& object_name,
280 bool warn_if_not_found =
true);
281 bool GeometryIsModel(
const std::string& object_name)
const;
282 LightEntity* GetLightInternal(
const std::string& light_name,
283 bool warn_if_not_found =
true);
284 void OverrideMaterialInternal(RenderableGeometry* geom,
286 bool shader_only =
false);
287 void UpdateMaterialProperties(RenderableGeometry& geom);
288 void UpdateDefaultLit(GeometryMaterialInstance& geom_mi);
289 void UpdateDefaultUnlit(GeometryMaterialInstance& geom_mi);
290 void UpdateNormalShader(GeometryMaterialInstance& geom_mi);
291 void UpdateDepthShader(GeometryMaterialInstance& geom_mi);
292 void UpdateGradientShader(GeometryMaterialInstance& geom_mi);
293 void UpdateSolidColorShader(GeometryMaterialInstance& geom_mi);
294 utils::EntityInstance<filament::TransformManager>
295 GetGeometryTransformInstance(RenderableGeometry* geom);
296 void CreateSunDirectionalLight();
298 std::unordered_map<std::string, RenderableGeometry> geometries_;
299 std::unordered_map<std::string, LightEntity> lights_;
300 std::unordered_map<std::string, std::vector<std::string>> model_geometries_;
302 std::string ibl_name_;
303 bool ibl_enabled_ =
false;
304 bool skybox_enabled_ =
false;
305 std::weak_ptr<filament::IndirectLight> indirect_light_;
306 std::weak_ptr<filament::Skybox> skybox_;
307 std::weak_ptr<filament::Skybox> color_skybox_;
Eigen::Transform< float, 3, Eigen::Affine > Transform
Definition: FilamentScene.h:87
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:554
A bounding box that is aligned along the coordinate axes.
Definition: BoundingVolume.h:149
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:395
Definition: FilamentResourceManager.h:62
math::float4 color
Definition: LineSetBuffers.cpp:63
Definition: Renderer.h:65
The base geometry class for 3D geometries.
Definition: Geometry3D.h:46
math::float3 position
Definition: LineSetBuffers.cpp:62
A pointcloud contains a set of 3D points.
Definition: PointCloud.h:93
Definition: Material.h:40
Definition: FilamentScene.h:85
Definition: FilamentGeometryBuffersBuilder.h:75
Definition: PinholeCameraIntrinsic.cpp:35
std::string name
Definition: FilePCD.cpp:58
Definition: FilamentEngine.h:31
bool SetActiveCamera(const std::string &path, std::shared_ptr< ConnectionBase > connection)
Definition: RemoteFunctions.cpp:394
filament::Scene * GetNativeScene() const
Definition: FilamentScene.h:205