ufe 7.0
Universal Front End is a DCC-agnostic component that will allow a DCC to browse and edit data in multiple data models
light.h
Go to the documentation of this file.
1#line 1 "D:/Jenkins/workspace/EMS/ECG/ufe/full/ufe-full-python3.13-windows/ufe/include/light.h"
2#ifndef UFE_LIGHT_H
3#define UFE_LIGHT_H
4
5// ===========================================================================
6// Copyright 2025 Autodesk, Inc. All rights reserved.
7//
8// The use of this software is subject to the Autodesk Terms of Use or other
9// license agreement provided at the time of installation or download, or
10// which otherwise accompanies this software.
11// ===========================================================================
12
13#include "common/ufeExport.h"
14#include "sceneItem.h"
15#include "observer.h"
17#include "types.h"
18
19#include <memory>
20#include <array>
21
23{
24
26
65 {
66 public:
67 typedef std::shared_ptr<Light> Ptr;
68
69 enum Type
70 {
79 Dome
80 };
81
83 {
84 float radius = 0;
85 bool asPoint = true;
86 };
87
88 struct ConeProps
89 {
90 // Higher focus values pull light towards the center and narrow the spread
91 float focus = 0;
92 // Angular limit off the primary axis to restrict the light spread
93 float angle = 40;
94 // Controls the cutoff softness for cone angle
95 float softness = 0;
96 };
97
99 {
100 float radius = 0;
101 float length = 0;
102 };
103
115
124 static Ptr light(const SceneItem::Ptr &item);
125
133 static bool addObserver(
134 const SceneItem::Ptr &item, const Observer::Ptr &obs);
142 static bool removeObserver(
143 const SceneItem::Ptr &item, const Observer::Ptr &obs);
144
150 static std::size_t nbObservers(const SceneItem::Ptr &item);
151
159 static bool hasObserver(
160 const SceneItem::Ptr &item, const Observer::Ptr &obs);
161
164 static bool hasObservers(const Path &path);
165
170 static bool hasObservers(Rtid runTimeId);
171
175 static void notify(const Path &path);
176
180 Light(const Light &) = default;
182 virtual ~Light();
183
185 virtual const Path &path() const = 0;
186
188 virtual SceneItem::Ptr sceneItem() const = 0;
189
191 virtual Type type() const = 0;
192
193 /*************************************************
194 Light intensity attribute.
195 Valid for the following light types: [all]
196 *************************************************/
197
202
205 virtual void intensity(float li) {
206 if (auto cmd = intensityCmd(li)) {
207 cmd->execute();
208 }
209 }
210
213 virtual float intensity() const = 0;
214
215 /*************************************************
216 Light color attribute, defined in energy-linear terms
217 Valid for the following light types: [all]
218 *************************************************/
219
225 virtual ColorUndoableCommand::Ptr colorCmd(float r, float g, float b) = 0;
226
229 virtual void color(float r, float g, float b) {
230 if (auto cmd = colorCmd(r, g, b)) {
231 cmd->execute();
232 }
233 }
234
237 virtual Color3f color() const = 0;
238
239 /*************************************************
240 Light shadow enable attribute.
241 Valid for the following light types: [all]
242 *************************************************/
243
248
251 virtual void shadowEnable(bool se) {
252 if (auto cmd = shadowEnableCmd(se)) {
253 cmd->execute();
254 }
255 }
256
259 virtual bool shadowEnable() const = 0;
260
261 /*************************************************
262 Shadow color attribute.
263 Valid for the following light types: [all]
264 *************************************************/
265
271 virtual ShadowColorUndoableCommand::Ptr shadowColorCmd(float r, float g, float b) = 0;
272
275 virtual void shadowColor(float r, float g, float b) {
276 if (auto cmd = shadowColorCmd(r, g, b)) {
277 cmd->execute();
278 }
279 }
280
283 virtual Color3f shadowColor() const = 0;
284
285 /*************************************************
286 Light diffuse attribute, a multiplier for the effect
287 of this light on the diffuse response of materials.
288 Valid for the following light types: [all]
289 *************************************************/
290
295
298 virtual void diffuse(float ld) {
299 if (auto cmd = diffuseCmd(ld)) {
300 cmd->execute();
301 }
302 }
303
306 virtual float diffuse() const = 0;
307
308 /*************************************************
309 Light specular attribute, a multiplier for the effect
310 of this light on the specular response of materials.
311 Valid for the following light types: [all]
312 *************************************************/
313
318
321 virtual void specular(float ls) {
322 if (auto cmd = specularCmd(ls)) {
323 cmd->execute();
324 }
325 }
326
329 virtual float specular() const = 0;
330
331 /*************************************************
332 Directional interface.
333 Valid for the following light types: [Directional]
334 *************************************************/
335
337 {
338 public:
340
344 virtual AngleUndoableCommand::Ptr angleCmd(float la) = 0;
345
348 virtual void angle(float la) {
349 if (auto cmd = angleCmd(la)) {
350 cmd->execute();
351 }
352 }
353
356 virtual float angle() const = 0;
357 };
358
361 std::shared_ptr<DirectionalInterface> directionalInterface();
362
363 /*************************************************
364 Sphere interface.
365 Valid for the following light types: [Point, Spot]
366 *************************************************/
367
369 {
370 public:
372
377 virtual SpherePropsUndoableCommand::Ptr spherePropsCmd(float radius, bool asPoint) = 0;
378
382 virtual void sphereProps(float radius, bool asPoint) {
383 if (auto cmd = spherePropsCmd(radius, asPoint)) {
384 cmd->execute();
385 }
386 }
387
390 virtual SphereProps sphereProps() const = 0;
391 };
392
395 std::shared_ptr<SphereInterface> sphereInterface();
396
397 /*************************************************
398 Cone interface.
399 Valid for the following light types: [Spot]
400 *************************************************/
401
403 {
404 public:
405 virtual ~ConeInterface();
406
412 virtual ConePropsUndoableCommand::Ptr conePropsCmd(float focus, float angle, float softness) = 0;
413
418 virtual void coneProps(float focus, float angle, float softness) {
419 if (auto cmd = conePropsCmd(focus, angle, softness)) {
420 cmd->execute();
421 }
422 }
423
426 virtual ConeProps coneProps() const = 0;
427 };
428
431 std::shared_ptr<ConeInterface> coneInterface();
432
433 /*************************************************
434 Area interface.
435 Valid for the following light types: [Area]
436 *************************************************/
437
439 {
440 public:
441 virtual ~AreaInterface();
442
444
449
452 virtual void normalize(bool nl) {
453 if (auto cmd = normalizeCmd(nl)) {
454 cmd->execute();
455 }
456 }
457
460 virtual bool normalize() const = 0;
461 };
462
465 std::shared_ptr<AreaInterface> areaInterface();
466
468 {
469 public:
471
476 virtual VolumePropsUndoableCommand::Ptr volumePropsCmd(float radius, float length) = 0;
477
481 virtual void volumeProps(float radius, float length) {
482 if (auto cmd = volumePropsCmd(radius, length)) {
483 cmd->execute();
484 }
485 }
486
489 virtual VolumeProps volumeProps() const = 0;
490 };
491
494 std::shared_ptr<CylinderInterface> cylinderInterface();
495
496 /*************************************************
497 Disk interface.
498 Valid for the following light types: [Disk]
499 *************************************************/
500
502 {
503 public:
504 virtual ~DiskInterface();
505
510
513 virtual void volumeProps(float radius) {
514 if (auto cmd = volumePropsCmd(radius)) {
515 cmd->execute();
516 }
517 }
518
521 virtual VolumeProps volumeProps() const = 0;
522 };
523
526 std::shared_ptr<DiskInterface> diskInterface();
527
528 /*************************************************
529 Dome interface.
530 Valid for the following light types: [Dome]
531 *************************************************/
532
534 {
535 public:
536 virtual ~DomeInterface();
537
542
545 virtual void volumeProps(float radius) {
546 if (auto cmd = volumePropsCmd(radius)) {
547 cmd->execute();
548 }
549 }
550
553 virtual VolumeProps volumeProps() const = 0;
554 };
555
558 std::shared_ptr<DomeInterface> domeInterface();
559
560 protected:
561 virtual std::shared_ptr<DirectionalInterface> directionalInterfaceImpl() = 0;
562 virtual std::shared_ptr<SphereInterface> sphereInterfaceImpl() = 0;
563 virtual std::shared_ptr<ConeInterface> coneInterfaceImpl() = 0;
564 virtual std::shared_ptr<AreaInterface> areaInterfaceImpl() = 0;
565 virtual std::shared_ptr<CylinderInterface> cylinderInterfaceImpl() = 0;
566 virtual std::shared_ptr<DiskInterface> diskInterfaceImpl() = 0;
567 virtual std::shared_ptr<DomeInterface> domeInterfaceImpl() = 0;
568 };
569}
570
571#endif /* UFE_LIGHT_H */
virtual NormalizeUndoableCommand::Ptr normalizeCmd(bool nl)=0
Normalize attribute. Normalizes power by the surface area of the light.
virtual void normalize(bool nl)
Definition: light.h:452
virtual bool normalize() const =0
virtual void coneProps(float focus, float angle, float softness)
Definition: light.h:418
virtual ConePropsUndoableCommand::Ptr conePropsCmd(float focus, float angle, float softness)=0
virtual ConeProps coneProps() const =0
virtual VolumeProps volumeProps() const =0
virtual void volumeProps(float radius, float length)
Definition: light.h:481
virtual VolumePropsUndoableCommand::Ptr volumePropsCmd(float radius, float length)=0
virtual void angle(float la)
Definition: light.h:348
virtual AngleUndoableCommand::Ptr angleCmd(float la)=0
virtual float angle() const =0
virtual void volumeProps(float radius)
Definition: light.h:513
virtual VolumePropsUndoableCommand::Ptr volumePropsCmd(float radius)=0
virtual VolumeProps volumeProps() const =0
virtual VolumeProps volumeProps() const =0
virtual void volumeProps(float radius)
Definition: light.h:545
virtual VolumePropsUndoableCommand::Ptr volumePropsCmd(float radius)=0
virtual void sphereProps(float radius, bool asPoint)
Definition: light.h:382
virtual SpherePropsUndoableCommand::Ptr spherePropsCmd(float radius, bool asPoint)=0
virtual SphereProps sphereProps() const =0
Abstract base class for light interface.
Definition: light.h:65
virtual void shadowColor(float r, float g, float b)
Definition: light.h:275
Light()
Constructor.
virtual Color3f color() const =0
static bool hasObservers(const Path &path)
virtual bool shadowEnable() const =0
virtual float diffuse() const =0
virtual ShadowColorUndoableCommand::Ptr shadowColorCmd(float r, float g, float b)=0
virtual ColorUndoableCommand::Ptr colorCmd(float r, float g, float b)=0
std::shared_ptr< SphereInterface > sphereInterface()
virtual ~Light()
Destructor.
static bool removeObserver(const SceneItem::Ptr &item, const Observer::Ptr &obs)
virtual void specular(float ls)
Definition: light.h:321
virtual void intensity(float li)
Definition: light.h:205
std::shared_ptr< DirectionalInterface > directionalInterface()
static void notify(const Path &path)
virtual void diffuse(float ld)
Definition: light.h:298
virtual ShadowEnableUndoableCommand::Ptr shadowEnableCmd(bool se)=0
virtual std::shared_ptr< CylinderInterface > cylinderInterfaceImpl()=0
@ Disk
Definition: light.h:78
@ Area
Definition: light.h:75
@ Cylinder
Definition: light.h:77
@ Sphere
Definition: light.h:76
@ Invalid
Definition: light.h:71
@ Point
Definition: light.h:73
@ Spot
Definition: light.h:74
@ Directional
Definition: light.h:72
virtual const Path & path() const =0
std::shared_ptr< CylinderInterface > cylinderInterface()
virtual float specular() const =0
virtual DiffuseUndoableCommand::Ptr diffuseCmd(float ld)=0
virtual SpecularUndoableCommand::Ptr specularCmd(float ls)=0
virtual IntensityUndoableCommand::Ptr intensityCmd(float li)=0
std::shared_ptr< AreaInterface > areaInterface()
std::shared_ptr< ConeInterface > coneInterface()
virtual std::shared_ptr< DiskInterface > diskInterfaceImpl()=0
virtual Color3f shadowColor() const =0
static Ptr light(const SceneItem::Ptr &item)
virtual std::shared_ptr< SphereInterface > sphereInterfaceImpl()=0
static bool hasObserver(const SceneItem::Ptr &item, const Observer::Ptr &obs)
virtual void shadowEnable(bool se)
Definition: light.h:251
virtual Type type() const =0
std::shared_ptr< Light > Ptr
Definition: light.h:67
Light(const Light &)=default
Default copy constructor.
virtual SceneItem::Ptr sceneItem() const =0
virtual std::shared_ptr< DirectionalInterface > directionalInterfaceImpl()=0
virtual void color(float r, float g, float b)
Definition: light.h:229
static std::size_t nbObservers(const SceneItem::Ptr &item)
std::shared_ptr< DomeInterface > domeInterface()
virtual std::shared_ptr< ConeInterface > coneInterfaceImpl()=0
virtual std::shared_ptr< DomeInterface > domeInterfaceImpl()=0
static bool hasObservers(Rtid runTimeId)
std::shared_ptr< DiskInterface > diskInterface()
virtual std::shared_ptr< AreaInterface > areaInterfaceImpl()=0
virtual float intensity() const =0
static bool addObserver(const SceneItem::Ptr &item, const Observer::Ptr &obs)
std::shared_ptr< Observer > Ptr
Definition: observer.h:37
Identify an object or 3D path in the scene.
Definition: path.h:40
std::shared_ptr< SceneItem > Ptr
Definition: sceneItem.h:45
Abstract class for set value command.
std::shared_ptr< SetValueUndoableCommand > Ptr
Path path(const std::string &pathString)
SetValueUndoableCommand< bool > SetBoolUndoableCommand
SetValueUndoableCommand< const Color3f & > SetColor3fUndoableCommand
SetValueUndoableCommand< float > SetFloatUndoableCommand
uint32_t Rtid
Definition: rtid.h:27
#define UFE_NS_DEF
Definition: ufe.h:36
Definition of macros for symbol visibility.
#define UFE_SDK_DECL
Definition: ufeExport.h:35