ufe  4.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 "S:/jenkins/workspace/ECP/ufe/ufe-full-python3.10-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"
15 #include "baseUndoableCommands.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  {
71  Area
72  };
73 
74  struct SphereProps
75  {
76  float radius = 0;
77  bool asPoint = true;
78  };
79 
80  struct ConeProps
81  {
82  // Higher focus values pull light towards the center and narrow the spread
83  float focus = 0;
84  // Angular limit off the primary axis to restrict the light spread
85  float angle = 40;
86  // Controls the cutoff softness for cone angle
87  float softness = 0;
88  };
89 
100 
109  static Ptr light(const SceneItem::Ptr &item);
110 
118  static bool addObserver(
119  const SceneItem::Ptr &item, const Observer::Ptr &obs);
127  static bool removeObserver(
128  const SceneItem::Ptr &item, const Observer::Ptr &obs);
129 
135  static std::size_t nbObservers(const SceneItem::Ptr &item);
136 
144  static bool hasObserver(
145  const SceneItem::Ptr &item, const Observer::Ptr &obs);
146 
149  static bool hasObservers(const Path &path);
150 
155  static bool hasObservers(Rtid runTimeId);
156 
160  static void notify(const Path &path);
161 
163  Light();
165  Light(const Light &) = default;
167  virtual ~Light();
168 
170  virtual const Path &path() const = 0;
171 
173  virtual SceneItem::Ptr sceneItem() const = 0;
174 
176  virtual Type type() const = 0;
177 
178  /*************************************************
179  Light intensity attribute.
180  Valid for the following light types: [all]
181  *************************************************/
182 
186  virtual IntensityUndoableCommand::Ptr intensityCmd(float li) = 0;
187 
190  virtual void intensity(float li) {
191  if (auto cmd = intensityCmd(li)) {
192  cmd->execute();
193  }
194  }
195 
198  virtual float intensity() const = 0;
199 
200  /*************************************************
201  Light color attribute, defined in energy-linear terms
202  Valid for the following light types: [all]
203  *************************************************/
204 
210  virtual ColorUndoableCommand::Ptr colorCmd(float r, float g, float b) = 0;
211 
214  virtual void color(float r, float g, float b) {
215  if (auto cmd = colorCmd(r, g, b)) {
216  cmd->execute();
217  }
218  }
219 
222  virtual Color3f color() const = 0;
223 
224  /*************************************************
225  Light shadow enable attribute.
226  Valid for the following light types: [all]
227  *************************************************/
228 
232  virtual ShadowEnableUndoableCommand::Ptr shadowEnableCmd(bool se) = 0;
233 
236  virtual void shadowEnable(bool se) {
237  if (auto cmd = shadowEnableCmd(se)) {
238  cmd->execute();
239  }
240  }
241 
244  virtual bool shadowEnable() const = 0;
245 
246  /*************************************************
247  Shadow color attribute.
248  Valid for the following light types: [all]
249  *************************************************/
250 
256  virtual ShadowColorUndoableCommand::Ptr shadowColorCmd(float r, float g, float b) = 0;
257 
260  virtual void shadowColor(float r, float g, float b) {
261  if (auto cmd = shadowColorCmd(r, g, b)) {
262  cmd->execute();
263  }
264  }
265 
268  virtual Color3f shadowColor() const = 0;
269 
270  /*************************************************
271  Light diffuse attribute, a multiplier for the effect
272  of this light on the diffuse response of materials.
273  Valid for the following light types: [all]
274  *************************************************/
275 
279  virtual DiffuseUndoableCommand::Ptr diffuseCmd(float ld) = 0;
280 
283  virtual void diffuse(float ld) {
284  if (auto cmd = diffuseCmd(ld)) {
285  cmd->execute();
286  }
287  }
288 
291  virtual float diffuse() const = 0;
292 
293  /*************************************************
294  Light specular attribute, a multiplier for the effect
295  of this light on the specular response of materials.
296  Valid for the following light types: [all]
297  *************************************************/
298 
302  virtual SpecularUndoableCommand::Ptr specularCmd(float ls) = 0;
303 
306  virtual void specular(float ls) {
307  if (auto cmd = specularCmd(ls)) {
308  cmd->execute();
309  }
310  }
311 
314  virtual float specular() const = 0;
315 
316  /*************************************************
317  Directional interface.
318  Valid for the following light types: [Directional]
319  *************************************************/
320 
322  {
323  public:
324  virtual ~DirectionalInterface();
325 
329  virtual AngleUndoableCommand::Ptr angleCmd(float la) = 0;
330 
333  virtual void angle(float la) {
334  if (auto cmd = angleCmd(la)) {
335  cmd->execute();
336  }
337  }
338 
341  virtual float angle() const = 0;
342  };
343 
346  std::shared_ptr<DirectionalInterface> directionalInterface();
347 
348  /*************************************************
349  Sphere interface.
350  Valid for the following light types: [Point, Spot]
351  *************************************************/
352 
354  {
355  public:
356  virtual ~SphereInterface();
357 
362  virtual SpherePropsUndoableCommand::Ptr spherePropsCmd(float radius, bool asPoint) = 0;
363 
367  virtual void sphereProps(float radius, bool asPoint) {
368  if (auto cmd = spherePropsCmd(radius, asPoint)) {
369  cmd->execute();
370  }
371  }
372 
375  virtual SphereProps sphereProps() const = 0;
376  };
377 
380  std::shared_ptr<SphereInterface> sphereInterface();
381 
382  /*************************************************
383  Cone interface.
384  Valid for the following light types: [Spot]
385  *************************************************/
386 
388  {
389  public:
390  virtual ~ConeInterface();
391 
397  virtual ConePropsUndoableCommand::Ptr conePropsCmd(float focus, float angle, float softness) = 0;
398 
403  virtual void coneProps(float focus, float angle, float softness) {
404  if (auto cmd = conePropsCmd(focus, angle, softness)) {
405  cmd->execute();
406  }
407  }
408 
411  virtual ConeProps coneProps() const = 0;
412  };
413 
416  std::shared_ptr<ConeInterface> coneInterface();
417 
418  /*************************************************
419  Area interface.
420  Valid for the following light types: [Area]
421  *************************************************/
422 
424  {
425  public:
426  virtual ~AreaInterface();
427 
429 
433  virtual NormalizeUndoableCommand::Ptr normalizeCmd(bool nl) = 0;
434 
437  virtual void normalize(bool nl) {
438  if (auto cmd = normalizeCmd(nl)) {
439  cmd->execute();
440  }
441  }
442 
445  virtual bool normalize() const = 0;
446  };
447 
450  std::shared_ptr<AreaInterface> areaInterface();
451 
452  protected:
453  virtual std::shared_ptr<DirectionalInterface> directionalInterfaceImpl() = 0;
454  virtual std::shared_ptr<SphereInterface> sphereInterfaceImpl() = 0;
455  virtual std::shared_ptr<ConeInterface> coneInterfaceImpl() = 0;
456  virtual std::shared_ptr<AreaInterface> areaInterfaceImpl() = 0;
457  };
458 }
459 
460 #endif /* _light */
virtual void diffuse(float ld)
Definition: light.h:283
virtual void specular(float ls)
Definition: light.h:306
virtual void coneProps(float focus, float angle, float softness)
Definition: light.h:403
std::shared_ptr< Observer > Ptr
Definition: observer.h:36
Definition of macros for symbol visibility.
std::shared_ptr< ObservableSelection > Ptr
virtual void color(float r, float g, float b)
Definition: light.h:214
virtual void shadowColor(float r, float g, float b)
Definition: light.h:260
std::shared_ptr< SetValueUndoableCommand > Ptr
Identify an object or 3D path in the scene.
Definition: path.h:37
uint32_t Rtid
Definition: rtid.h:26
SetValueUndoableCommand< bool > SetBoolUndoableCommand
std::shared_ptr< Light > Ptr
Definition: light.h:63
Abstract class for set value command.
virtual void shadowEnable(bool se)
Definition: light.h:236
virtual void angle(float la)
Definition: light.h:333
#define UFE_NS_DEF
Definition: ufe.h:35
SetValueUndoableCommand< float > SetFloatUndoableCommand
std::shared_ptr< SceneItem > Ptr
Definition: sceneItem.h:40
Abstract base class for light interface.
Definition: light.h:60
SetValueUndoableCommand< const Color3f & > SetColor3fUndoableCommand
virtual void sphereProps(float radius, bool asPoint)
Definition: light.h:367
Path path(const std::string &pathString)
virtual void normalize(bool nl)
Definition: light.h:437
virtual void intensity(float li)
Definition: light.h:190
#define UFE_SDK_DECL
Definition: ufeExport.h:36