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 SetGeometryCulling(
const std::string& object_name,
140 bool enable)
override;
141 void SetGeometryPriority(
const std::string& object_name,
142 uint8_t priority)
override;
143 void OverrideMaterial(
const std::string& object_name,
145 void QueryGeometry(std::vector<std::string>& geometry)
override;
146 void OverrideMaterialAll(
const Material& material,
147 bool shader_only =
true)
override;
150 bool AddPointLight(
const std::string& light_name,
151 const Eigen::Vector3f&
color,
155 bool cast_shadows)
override;
156 bool AddSpotLight(
const std::string& light_name,
157 const Eigen::Vector3f&
color,
159 const Eigen::Vector3f& direction,
162 float inner_cone_angle,
163 float outer_cone_angle,
164 bool cast_shadows)
override;
165 bool AddDirectionalLight(
const std::string& light_name,
166 const Eigen::Vector3f&
color,
167 const Eigen::Vector3f& direction,
169 bool cast_shadows)
override;
170 Light& GetLight(
const std::string& light_name)
override;
171 void RemoveLight(
const std::string& light_name)
override;
172 void UpdateLight(
const std::string& light_name,
173 const Light& light)
override;
174 void UpdateLightColor(
const std::string& light_name,
175 const Eigen::Vector3f&
color)
override;
176 void UpdateLightPosition(
const std::string& light_name,
177 const Eigen::Vector3f&
position)
override;
178 void UpdateLightDirection(
const std::string& light_name,
179 const Eigen::Vector3f& direction)
override;
180 void UpdateLightIntensity(
const std::string& light_name,
181 float intensity)
override;
182 void UpdateLightFalloff(
const std::string& light_name,
183 float falloff)
override;
184 void UpdateLightConeAngles(
const std::string& light_name,
185 float inner_cone_angle,
186 float outer_cone_angle)
override;
187 void EnableLightShadow(
const std::string& light_name,
188 bool cast_shadows)
override;
190 void SetSunLight(
const Eigen::Vector3f& direction,
191 const Eigen::Vector3f&
color,
192 float intensity)
override;
193 void EnableSunLight(
bool enable)
override;
194 void EnableSunLightShadows(
bool enable)
override;
195 float GetSunLightIntensity()
override;
196 void SetSunLightDirection(
const Eigen::Vector3f& direction)
override;
197 Eigen::Vector3f GetSunLightDirection()
override;
198 void SetSunAngularRadius(
float radius)
override;
199 void SetSunHaloSize(
float size)
override;
200 void SetSunHaloFalloff(
float falloff)
override;
202 bool SetIndirectLight(
const std::string& ibl_name)
override;
203 const std::string& GetIndirectLight()
override;
204 void EnableIndirectLight(
bool enable)
override;
205 void SetIndirectLightIntensity(
float intensity)
override;
206 float GetIndirectLightIntensity()
override;
207 void SetIndirectLightRotation(
const Transform& rotation)
override;
208 Transform GetIndirectLightRotation()
override;
209 void ShowSkybox(
bool show)
override;
211 const Eigen::Vector4f&
color,
212 const std::shared_ptr<geometry::Image> image =
nullptr)
override;
214 void RenderToImage(std::function<
void(std::shared_ptr<geometry::Image>)>
217 void Draw(filament::Renderer& renderer);
223 filament::RenderableManager::Builder& builder,
225 enum BufferReuse { kNo, kYes };
226 bool CreateAndAddFilamentEntity(
227 const std::string& object_name,
233 BufferReuse reusing_vertex_buffer = BufferReuse::kNo);
235 filament::Engine& engine_;
237 filament::Scene* scene_ =
nullptr;
241 rendering::FilamentResourceManager::kDefaultTexture;
243 rendering::FilamentResourceManager::kDefaultNormalMap;
245 rendering::FilamentResourceManager::kDefaultTexture;
247 rendering::FilamentResourceManager::kDefaultTexture;
249 rendering::FilamentResourceManager::kDefaultTexture;
251 rendering::FilamentResourceManager::kDefaultTexture;
253 rendering::FilamentResourceManager::kDefaultTexture;
255 rendering::FilamentResourceManager::kDefaultTexture;
258 struct GeometryMaterialInstance {
264 struct RenderableGeometry {
267 bool cast_shadows =
true;
268 bool receive_shadow =
true;
270 GeometryMaterialInstance mat;
273 utils::Entity filament_entity;
276 void ReleaseResources(filament::Engine& engine,
282 utils::Entity filament_entity;
286 struct ViewContainer {
287 std::unique_ptr<FilamentView> view;
288 bool is_active =
true;
289 int render_count = -1;
291 std::unordered_map<REHandle_abstract, ViewContainer> views_;
293 std::vector<RenderableGeometry*> GetGeometry(
const std::string& object_name,
294 bool warn_if_not_found =
true);
295 bool GeometryIsModel(
const std::string& object_name)
const;
296 LightEntity* GetLightInternal(
const std::string& light_name,
297 bool warn_if_not_found =
true);
298 void OverrideMaterialInternal(RenderableGeometry* geom,
300 bool shader_only =
false);
301 void UpdateMaterialProperties(RenderableGeometry& geom);
302 void UpdateDefaultLit(GeometryMaterialInstance& geom_mi);
303 void UpdateDefaultLitSSR(GeometryMaterialInstance& geom_mi);
304 void UpdateDefaultUnlit(GeometryMaterialInstance& geom_mi);
305 void UpdateNormalShader(GeometryMaterialInstance& geom_mi);
306 void UpdateDepthShader(GeometryMaterialInstance& geom_mi);
307 void UpdateGradientShader(GeometryMaterialInstance& geom_mi);
308 void UpdateSolidColorShader(GeometryMaterialInstance& geom_mi);
309 void UpdateBackgroundShader(GeometryMaterialInstance& geom_mi);
310 void UpdateLineShader(GeometryMaterialInstance& geom_mi);
311 void UpdateUnlitPolygonOffsetShader(GeometryMaterialInstance& geom_mi);
312 utils::EntityInstance<filament::TransformManager>
313 GetGeometryTransformInstance(RenderableGeometry* geom);
314 void CreateSunDirectionalLight();
316 std::unordered_map<std::string, RenderableGeometry> geometries_;
317 std::unordered_map<std::string, LightEntity> lights_;
318 std::unordered_map<std::string, std::vector<std::string>> model_geometries_;
320 Eigen::Vector4f background_color_;
321 std::shared_ptr<geometry::Image> background_image_;
322 std::string ibl_name_;
323 bool ibl_enabled_ =
false;
324 bool skybox_enabled_ =
false;
325 std::weak_ptr<filament::IndirectLight> indirect_light_;
326 std::weak_ptr<filament::Skybox> skybox_;
void Draw(const std::vector< std::shared_ptr< geometry::Geometry3D >> &geometries, const std::string &window_name, int width, int height, const std::vector< DrawAction > &actions)
Definition: Draw.cpp:54
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:557
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:398
Definition: FilamentResourceManager.h:62
int size
Definition: FilePCD.cpp:59
math::float4 color
Definition: LineSetBuffers.cpp:64
Definition: Renderer.h:64
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:94
Definition: Material.h:41
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:219