ufe 5.5
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 "S:/jenkins/workspace/ECP/ufe/ufe-full-python3.11-windows/ufe/include/light.h"
2#ifndef _light
3#define _light
4// ===========================================================================
5// Copyright 2022 Autodesk, Inc. All rights reserved.
6//
7// Use of this software is subject to the terms of the Autodesk license
8// agreement provided at the time of installation or download, or which
9// otherwise accompanies this software in either electronic or hard copy form.
10// ===========================================================================
11
12#include "common/ufeExport.h"
13#include "sceneItem.h"
14#include "observer.h"
16#include "types.h"
17
18#include <memory>
19#include <array>
20
22{
23
25
61 {
62 public:
63 typedef std::shared_ptr<Light> Ptr;
64
65 enum Type
66 {
75 Dome
76 };
77
79 {
80 float radius = 0;
81 bool asPoint = true;
82 };
83
84 struct ConeProps
85 {
86 // Higher focus values pull light towards the center and narrow the spread
87 float focus = 0;
88 // Angular limit off the primary axis to restrict the light spread
89 float angle = 40;
90 // Controls the cutoff softness for cone angle
91 float softness = 0;
92 };
93
104
113 static Ptr light(const SceneItem::Ptr &item);
114
122 static bool addObserver(
123 const SceneItem::Ptr &item, const Observer::Ptr &obs);
131 static bool removeObserver(
132 const SceneItem::Ptr &item, const Observer::Ptr &obs);
133
139 static std::size_t nbObservers(const SceneItem::Ptr &item);
140
148 static bool hasObserver(
149 const SceneItem::Ptr &item, const Observer::Ptr &obs);
150
153 static bool hasObservers(const Path &path);
154
159 static bool hasObservers(Rtid runTimeId);
160
164 static void notify(const Path &path);
165
169 Light(const Light &) = default;
171 virtual ~Light();
172
174 virtual const Path &path() const = 0;
175
177 virtual SceneItem::Ptr sceneItem() const = 0;
178
180 virtual Type type() const = 0;
181
182 /*************************************************
183 Light intensity attribute.
184 Valid for the following light types: [all]
185 *************************************************/
186
191
194 virtual void intensity(float li) {
195 if (auto cmd = intensityCmd(li)) {
196 cmd->execute();
197 }
198 }
199
202 virtual float intensity() const = 0;
203
204 /*************************************************
205 Light color attribute, defined in energy-linear terms
206 Valid for the following light types: [all]
207 *************************************************/
208
214 virtual ColorUndoableCommand::Ptr colorCmd(float r, float g, float b) = 0;
215
218 virtual void color(float r, float g, float b) {
219 if (auto cmd = colorCmd(r, g, b)) {
220 cmd->execute();
221 }
222 }
223
226 virtual Color3f color() const = 0;
227
228 /*************************************************
229 Light shadow enable attribute.
230 Valid for the following light types: [all]
231 *************************************************/
232
237
240 virtual void shadowEnable(bool se) {
241 if (auto cmd = shadowEnableCmd(se)) {
242 cmd->execute();
243 }
244 }
245
248 virtual bool shadowEnable() const = 0;
249
250 /*************************************************
251 Shadow color attribute.
252 Valid for the following light types: [all]
253 *************************************************/
254
260 virtual ShadowColorUndoableCommand::Ptr shadowColorCmd(float r, float g, float b) = 0;
261
264 virtual void shadowColor(float r, float g, float b) {
265 if (auto cmd = shadowColorCmd(r, g, b)) {
266 cmd->execute();
267 }
268 }
269
272 virtual Color3f shadowColor() const = 0;
273
274 /*************************************************
275 Light diffuse attribute, a multiplier for the effect
276 of this light on the diffuse response of materials.
277 Valid for the following light types: [all]
278 *************************************************/
279
284
287 virtual void diffuse(float ld) {
288 if (auto cmd = diffuseCmd(ld)) {
289 cmd->execute();
290 }
291 }
292
295 virtual float diffuse() const = 0;
296
297 /*************************************************
298 Light specular attribute, a multiplier for the effect
299 of this light on the specular response of materials.
300 Valid for the following light types: [all]
301 *************************************************/
302
307
310 virtual void specular(float ls) {
311 if (auto cmd = specularCmd(ls)) {
312 cmd->execute();
313 }
314 }
315
318 virtual float specular() const = 0;
319
320 /*************************************************
321 Directional interface.
322 Valid for the following light types: [Directional]
323 *************************************************/
324
326 {
327 public:
329
333 virtual AngleUndoableCommand::Ptr angleCmd(float la) = 0;
334
337 virtual void angle(float la) {
338 if (auto cmd = angleCmd(la)) {
339 cmd->execute();
340 }
341 }
342
345 virtual float angle() const = 0;
346 };
347
350 std::shared_ptr<DirectionalInterface> directionalInterface();
351
352 /*************************************************
353 Sphere interface.
354 Valid for the following light types: [Point, Spot]
355 *************************************************/
356
358 {
359 public:
361
366 virtual SpherePropsUndoableCommand::Ptr spherePropsCmd(float radius, bool asPoint) = 0;
367
371 virtual void sphereProps(float radius, bool asPoint) {
372 if (auto cmd = spherePropsCmd(radius, asPoint)) {
373 cmd->execute();
374 }
375 }
376
379 virtual SphereProps sphereProps() const = 0;
380 };
381
384 std::shared_ptr<SphereInterface> sphereInterface();
385
386 /*************************************************
387 Cone interface.
388 Valid for the following light types: [Spot]
389 *************************************************/
390
392 {
393 public:
394 virtual ~ConeInterface();
395
401 virtual ConePropsUndoableCommand::Ptr conePropsCmd(float focus, float angle, float softness) = 0;
402
407 virtual void coneProps(float focus, float angle, float softness) {
408 if (auto cmd = conePropsCmd(focus, angle, softness)) {
409 cmd->execute();
410 }
411 }
412
415 virtual ConeProps coneProps() const = 0;
416 };
417
420 std::shared_ptr<ConeInterface> coneInterface();
421
422 /*************************************************
423 Area interface.
424 Valid for the following light types: [Area]
425 *************************************************/
426
428 {
429 public:
430 virtual ~AreaInterface();
431
433
438
441 virtual void normalize(bool nl) {
442 if (auto cmd = normalizeCmd(nl)) {
443 cmd->execute();
444 }
445 }
446
449 virtual bool normalize() const = 0;
450 };
451
454 std::shared_ptr<AreaInterface> areaInterface();
455
456 protected:
457 virtual std::shared_ptr<DirectionalInterface> directionalInterfaceImpl() = 0;
458 virtual std::shared_ptr<SphereInterface> sphereInterfaceImpl() = 0;
459 virtual std::shared_ptr<ConeInterface> coneInterfaceImpl() = 0;
460 virtual std::shared_ptr<AreaInterface> areaInterfaceImpl() = 0;
461 };
462
464
477 {
478 public:
479 typedef std::shared_ptr<Light_v5_5> Ptr;
480
482 {
483 float radius = 0;
484 float length = 0;
485 };
486
488
492 Light_v5_5(const Light_v5_5&) = default;
493
494 virtual ~Light_v5_5() override;
495
496 static Ptr light(const SceneItem::Ptr& item);
497
498 /*************************************************
499 Cylinder interface.
500 Valid for the following light types: [Cylinder]
501 *************************************************/
502
504 {
505 public:
507
512 virtual VolumePropsUndoableCommand::Ptr volumePropsCmd(float radius, float length) = 0;
513
517 virtual void volumeProps(float radius, float length) {
518 if (auto cmd = volumePropsCmd(radius, length)) {
519 cmd->execute();
520 }
521 }
522
525 virtual VolumeProps volumeProps() const = 0;
526 };
527
530 std::shared_ptr<CylinderInterface> cylinderInterface();
531
532 /*************************************************
533 Disk interface.
534 Valid for the following light types: [Disk]
535 *************************************************/
536
538 {
539 public:
540 virtual ~DiskInterface();
541
546
549 virtual void volumeProps(float radius) {
550 if (auto cmd = volumePropsCmd(radius)) {
551 cmd->execute();
552 }
553 }
554
557 virtual VolumeProps volumeProps() const = 0;
558 };
559
562 std::shared_ptr<DiskInterface> diskInterface();
563
564 /*************************************************
565 Dome interface.
566 Valid for the following light types: [Dome]
567 *************************************************/
568
570 {
571 public:
572 virtual ~DomeInterface();
573
578
581 virtual void volumeProps(float radius) {
582 if (auto cmd = volumePropsCmd(radius)) {
583 cmd->execute();
584 }
585 }
586
589 virtual VolumeProps volumeProps() const = 0;
590 };
591
594 std::shared_ptr<DomeInterface> domeInterface();
595
596 protected:
597 virtual std::shared_ptr<CylinderInterface> cylinderInterfaceImpl() = 0;
598 virtual std::shared_ptr<DiskInterface> diskInterfaceImpl() = 0;
599 virtual std::shared_ptr<DomeInterface> domeInterfaceImpl() = 0;
600 };
601}
602
603#endif /* _light */
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:441
virtual bool normalize() const =0
virtual void coneProps(float focus, float angle, float softness)
Definition: light.h:407
virtual ConePropsUndoableCommand::Ptr conePropsCmd(float focus, float angle, float softness)=0
virtual ConeProps coneProps() const =0
virtual void angle(float la)
Definition: light.h:337
virtual AngleUndoableCommand::Ptr angleCmd(float la)=0
virtual float angle() const =0
virtual void sphereProps(float radius, bool asPoint)
Definition: light.h:371
virtual SpherePropsUndoableCommand::Ptr spherePropsCmd(float radius, bool asPoint)=0
virtual SphereProps sphereProps() const =0
virtual void volumeProps(float radius, float length)
Definition: light.h:517
virtual VolumeProps volumeProps() const =0
virtual VolumePropsUndoableCommand::Ptr volumePropsCmd(float radius, float length)=0
virtual void volumeProps(float radius)
Definition: light.h:549
virtual VolumeProps volumeProps() const =0
virtual VolumePropsUndoableCommand::Ptr volumePropsCmd(float radius)=0
virtual VolumeProps volumeProps() const =0
virtual void volumeProps(float radius)
Definition: light.h:581
virtual VolumePropsUndoableCommand::Ptr volumePropsCmd(float radius)=0
Class for new light types.
Definition: light.h:477
std::shared_ptr< DiskInterface > diskInterface()
virtual std::shared_ptr< CylinderInterface > cylinderInterfaceImpl()=0
static Ptr light(const SceneItem::Ptr &item)
Light_v5_5(const Light_v5_5 &)=default
Default copy constructor.
std::shared_ptr< DomeInterface > domeInterface()
virtual ~Light_v5_5() override
virtual std::shared_ptr< DomeInterface > domeInterfaceImpl()=0
Light_v5_5()
Constructor.
std::shared_ptr< CylinderInterface > cylinderInterface()
std::shared_ptr< Light_v5_5 > Ptr
Definition: light.h:479
virtual std::shared_ptr< DiskInterface > diskInterfaceImpl()=0
Abstract base class for light interface.
Definition: light.h:61
virtual void shadowColor(float r, float g, float b)
Definition: light.h:264
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:310
virtual void intensity(float li)
Definition: light.h:194
std::shared_ptr< DirectionalInterface > directionalInterface()
static void notify(const Path &path)
virtual void diffuse(float ld)
Definition: light.h:287
virtual ShadowEnableUndoableCommand::Ptr shadowEnableCmd(bool se)=0
@ Disk
Definition: light.h:74
@ Area
Definition: light.h:71
@ Cylinder
Definition: light.h:73
@ Sphere
Definition: light.h:72
@ Invalid
Definition: light.h:67
@ Point
Definition: light.h:69
@ Spot
Definition: light.h:70
@ Directional
Definition: light.h:68
virtual const Path & path() const =0
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 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:240
virtual Type type() const =0
std::shared_ptr< Light > Ptr
Definition: light.h:63
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:218
static std::size_t nbObservers(const SceneItem::Ptr &item)
virtual std::shared_ptr< ConeInterface > coneInterfaceImpl()=0
static bool hasObservers(Rtid runTimeId)
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:36
Identify an object or 3D path in the scene.
Definition: path.h:38
std::shared_ptr< SceneItem > Ptr
Definition: sceneItem.h:44
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:26
#define UFE_NS_DEF
Definition: ufe.h:35
Definition of macros for symbol visibility.
#define UFE_SDK_DECL
Definition: ufeExport.h:36