ufe 6.2
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.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
64 {
65 public:
66 typedef std::shared_ptr<Light> Ptr;
67
68 enum Type
69 {
78 Dome
79 };
80
82 {
83 float radius = 0;
84 bool asPoint = true;
85 };
86
87 struct ConeProps
88 {
89 // Higher focus values pull light towards the center and narrow the spread
90 float focus = 0;
91 // Angular limit off the primary axis to restrict the light spread
92 float angle = 40;
93 // Controls the cutoff softness for cone angle
94 float softness = 0;
95 };
96
98 {
99 float radius = 0;
100 float length = 0;
101 };
102
114
123 static Ptr light(const SceneItem::Ptr &item);
124
132 static bool addObserver(
133 const SceneItem::Ptr &item, const Observer::Ptr &obs);
141 static bool removeObserver(
142 const SceneItem::Ptr &item, const Observer::Ptr &obs);
143
149 static std::size_t nbObservers(const SceneItem::Ptr &item);
150
158 static bool hasObserver(
159 const SceneItem::Ptr &item, const Observer::Ptr &obs);
160
163 static bool hasObservers(const Path &path);
164
169 static bool hasObservers(Rtid runTimeId);
170
174 static void notify(const Path &path);
175
179 Light(const Light &) = default;
181 virtual ~Light();
182
184 virtual const Path &path() const = 0;
185
187 virtual SceneItem::Ptr sceneItem() const = 0;
188
190 virtual Type type() const = 0;
191
192 /*************************************************
193 Light intensity attribute.
194 Valid for the following light types: [all]
195 *************************************************/
196
201
204 virtual void intensity(float li) {
205 if (auto cmd = intensityCmd(li)) {
206 cmd->execute();
207 }
208 }
209
212 virtual float intensity() const = 0;
213
214 /*************************************************
215 Light color attribute, defined in energy-linear terms
216 Valid for the following light types: [all]
217 *************************************************/
218
224 virtual ColorUndoableCommand::Ptr colorCmd(float r, float g, float b) = 0;
225
228 virtual void color(float r, float g, float b) {
229 if (auto cmd = colorCmd(r, g, b)) {
230 cmd->execute();
231 }
232 }
233
236 virtual Color3f color() const = 0;
237
238 /*************************************************
239 Light shadow enable attribute.
240 Valid for the following light types: [all]
241 *************************************************/
242
247
250 virtual void shadowEnable(bool se) {
251 if (auto cmd = shadowEnableCmd(se)) {
252 cmd->execute();
253 }
254 }
255
258 virtual bool shadowEnable() const = 0;
259
260 /*************************************************
261 Shadow color attribute.
262 Valid for the following light types: [all]
263 *************************************************/
264
270 virtual ShadowColorUndoableCommand::Ptr shadowColorCmd(float r, float g, float b) = 0;
271
274 virtual void shadowColor(float r, float g, float b) {
275 if (auto cmd = shadowColorCmd(r, g, b)) {
276 cmd->execute();
277 }
278 }
279
282 virtual Color3f shadowColor() const = 0;
283
284 /*************************************************
285 Light diffuse attribute, a multiplier for the effect
286 of this light on the diffuse response of materials.
287 Valid for the following light types: [all]
288 *************************************************/
289
294
297 virtual void diffuse(float ld) {
298 if (auto cmd = diffuseCmd(ld)) {
299 cmd->execute();
300 }
301 }
302
305 virtual float diffuse() const = 0;
306
307 /*************************************************
308 Light specular attribute, a multiplier for the effect
309 of this light on the specular response of materials.
310 Valid for the following light types: [all]
311 *************************************************/
312
317
320 virtual void specular(float ls) {
321 if (auto cmd = specularCmd(ls)) {
322 cmd->execute();
323 }
324 }
325
328 virtual float specular() const = 0;
329
330 /*************************************************
331 Directional interface.
332 Valid for the following light types: [Directional]
333 *************************************************/
334
336 {
337 public:
339
343 virtual AngleUndoableCommand::Ptr angleCmd(float la) = 0;
344
347 virtual void angle(float la) {
348 if (auto cmd = angleCmd(la)) {
349 cmd->execute();
350 }
351 }
352
355 virtual float angle() const = 0;
356 };
357
360 std::shared_ptr<DirectionalInterface> directionalInterface();
361
362 /*************************************************
363 Sphere interface.
364 Valid for the following light types: [Point, Spot]
365 *************************************************/
366
368 {
369 public:
371
376 virtual SpherePropsUndoableCommand::Ptr spherePropsCmd(float radius, bool asPoint) = 0;
377
381 virtual void sphereProps(float radius, bool asPoint) {
382 if (auto cmd = spherePropsCmd(radius, asPoint)) {
383 cmd->execute();
384 }
385 }
386
389 virtual SphereProps sphereProps() const = 0;
390 };
391
394 std::shared_ptr<SphereInterface> sphereInterface();
395
396 /*************************************************
397 Cone interface.
398 Valid for the following light types: [Spot]
399 *************************************************/
400
402 {
403 public:
404 virtual ~ConeInterface();
405
411 virtual ConePropsUndoableCommand::Ptr conePropsCmd(float focus, float angle, float softness) = 0;
412
417 virtual void coneProps(float focus, float angle, float softness) {
418 if (auto cmd = conePropsCmd(focus, angle, softness)) {
419 cmd->execute();
420 }
421 }
422
425 virtual ConeProps coneProps() const = 0;
426 };
427
430 std::shared_ptr<ConeInterface> coneInterface();
431
432 /*************************************************
433 Area interface.
434 Valid for the following light types: [Area]
435 *************************************************/
436
438 {
439 public:
440 virtual ~AreaInterface();
441
443
448
451 virtual void normalize(bool nl) {
452 if (auto cmd = normalizeCmd(nl)) {
453 cmd->execute();
454 }
455 }
456
459 virtual bool normalize() const = 0;
460 };
461
464 std::shared_ptr<AreaInterface> areaInterface();
465
467 {
468 public:
470
475 virtual VolumePropsUndoableCommand::Ptr volumePropsCmd(float radius, float length) = 0;
476
480 virtual void volumeProps(float radius, float length) {
481 if (auto cmd = volumePropsCmd(radius, length)) {
482 cmd->execute();
483 }
484 }
485
488 virtual VolumeProps volumeProps() const = 0;
489 };
490
493 std::shared_ptr<CylinderInterface> cylinderInterface();
494
495 /*************************************************
496 Disk interface.
497 Valid for the following light types: [Disk]
498 *************************************************/
499
501 {
502 public:
503 virtual ~DiskInterface();
504
509
512 virtual void volumeProps(float radius) {
513 if (auto cmd = volumePropsCmd(radius)) {
514 cmd->execute();
515 }
516 }
517
520 virtual VolumeProps volumeProps() const = 0;
521 };
522
525 std::shared_ptr<DiskInterface> diskInterface();
526
527 /*************************************************
528 Dome interface.
529 Valid for the following light types: [Dome]
530 *************************************************/
531
533 {
534 public:
535 virtual ~DomeInterface();
536
541
544 virtual void volumeProps(float radius) {
545 if (auto cmd = volumePropsCmd(radius)) {
546 cmd->execute();
547 }
548 }
549
552 virtual VolumeProps volumeProps() const = 0;
553 };
554
557 std::shared_ptr<DomeInterface> domeInterface();
558
559 protected:
560 virtual std::shared_ptr<DirectionalInterface> directionalInterfaceImpl() = 0;
561 virtual std::shared_ptr<SphereInterface> sphereInterfaceImpl() = 0;
562 virtual std::shared_ptr<ConeInterface> coneInterfaceImpl() = 0;
563 virtual std::shared_ptr<AreaInterface> areaInterfaceImpl() = 0;
564 virtual std::shared_ptr<CylinderInterface> cylinderInterfaceImpl() = 0;
565 virtual std::shared_ptr<DiskInterface> diskInterfaceImpl() = 0;
566 virtual std::shared_ptr<DomeInterface> domeInterfaceImpl() = 0;
567 };
568}
569
570#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:451
virtual bool normalize() const =0
virtual void coneProps(float focus, float angle, float softness)
Definition: light.h:417
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:480
virtual VolumePropsUndoableCommand::Ptr volumePropsCmd(float radius, float length)=0
virtual void angle(float la)
Definition: light.h:347
virtual AngleUndoableCommand::Ptr angleCmd(float la)=0
virtual float angle() const =0
virtual void volumeProps(float radius)
Definition: light.h:512
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:544
virtual VolumePropsUndoableCommand::Ptr volumePropsCmd(float radius)=0
virtual void sphereProps(float radius, bool asPoint)
Definition: light.h:381
virtual SpherePropsUndoableCommand::Ptr spherePropsCmd(float radius, bool asPoint)=0
virtual SphereProps sphereProps() const =0
Abstract base class for light interface.
Definition: light.h:64
virtual void shadowColor(float r, float g, float b)
Definition: light.h:274
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:320
virtual void intensity(float li)
Definition: light.h:204
std::shared_ptr< DirectionalInterface > directionalInterface()
static void notify(const Path &path)
virtual void diffuse(float ld)
Definition: light.h:297
virtual ShadowEnableUndoableCommand::Ptr shadowEnableCmd(bool se)=0
virtual std::shared_ptr< CylinderInterface > cylinderInterfaceImpl()=0
@ Disk
Definition: light.h:77
@ Area
Definition: light.h:74
@ Cylinder
Definition: light.h:76
@ Sphere
Definition: light.h:75
@ Invalid
Definition: light.h:70
@ Point
Definition: light.h:72
@ Spot
Definition: light.h:73
@ Directional
Definition: light.h:71
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:250
virtual Type type() const =0
std::shared_ptr< Light > Ptr
Definition: light.h:66
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:228
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: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