ufe  3.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.9-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 
50  {
51  public:
52  typedef std::shared_ptr<Light> Ptr;
53 
54  enum Type
55  {
60  Area
61  };
62 
63  struct SphereProps
64  {
65  float radius = 0;
66  bool asPoint = true;
67  };
68 
69  struct ConeProps
70  {
71  // Higher focus values pull light towards the center and narrow the spread
72  float focus = 0;
73  // Angular limit off the primary axis to restrict the light spread
74  float angle = 40;
75  // Controls the cutoff softness for cone angle
76  float softness = 0;
77  };
78 
89 
98  static Ptr light(const SceneItem::Ptr &item);
99 
107  static bool addObserver(
108  const SceneItem::Ptr &item, const Observer::Ptr &obs);
116  static bool removeObserver(
117  const SceneItem::Ptr &item, const Observer::Ptr &obs);
118 
124  static std::size_t nbObservers(const SceneItem::Ptr &item);
125 
133  static bool hasObserver(
134  const SceneItem::Ptr &item, const Observer::Ptr &obs);
135 
138  static bool hasObservers(const Path &path);
139 
144  static bool hasObservers(Rtid runTimeId);
145 
149  static void notify(const Path &path);
150 
152  Light();
154  Light(const Light &) = default;
156  virtual ~Light();
157 
159  virtual const Path &path() const = 0;
160 
162  virtual SceneItem::Ptr sceneItem() const = 0;
163 
165  virtual Type type() const = 0;
166 
167  /*************************************************
168  Light intensity attribute.
169  Valid for the following light types: [all]
170  *************************************************/
171 
175  virtual IntensityUndoableCommand::Ptr intensityCmd(float li) = 0;
176 
179  virtual void intensity(float li) {
180  if (auto cmd = intensityCmd(li)) {
181  cmd->execute();
182  }
183  }
184 
187  virtual float intensity() const = 0;
188 
189  /*************************************************
190  Light color attribute, defined in energy-linear terms
191  Valid for the following light types: [all]
192  *************************************************/
193 
197  virtual ColorUndoableCommand::Ptr colorCmd(float r, float g, float b) = 0;
198 
201  virtual void color(float r, float g, float b) {
202  if (auto cmd = colorCmd(r, g, b)) {
203  cmd->execute();
204  }
205  }
206 
209  virtual Color3f color() const = 0;
210 
211  /*************************************************
212  Light shadow enable attribute.
213  Valid for the following light types: [all]
214  *************************************************/
215 
219  virtual ShadowEnableUndoableCommand::Ptr shadowEnableCmd(bool se) = 0;
220 
223  virtual void shadowEnable(bool se) {
224  if (auto cmd = shadowEnableCmd(se)) {
225  cmd->execute();
226  }
227  }
228 
231  virtual bool shadowEnable() const = 0;
232 
233  /*************************************************
234  Shadow color attribute.
235  Valid for the following light types: [all]
236  *************************************************/
237 
241  virtual ShadowColorUndoableCommand::Ptr shadowColorCmd(float r, float g, float b) = 0;
242 
245  virtual void shadowColor(float r, float g, float b) {
246  if (auto cmd = shadowColorCmd(r, g, b)) {
247  cmd->execute();
248  }
249  }
250 
253  virtual Color3f shadowColor() const = 0;
254 
255  /*************************************************
256  Light diffuse attribute, a multiplier for the effect
257  of this light on the diffuse response of materials.
258  Valid for the following light types: [all]
259  *************************************************/
260 
264  virtual DiffuseUndoableCommand::Ptr diffuseCmd(float ld) = 0;
265 
268  virtual void diffuse(float ld) {
269  if (auto cmd = diffuseCmd(ld)) {
270  cmd->execute();
271  }
272  }
273 
276  virtual float diffuse() const = 0;
277 
278  /*************************************************
279  Light specular attribute, a multiplier for the effect
280  of this light on the specular response of materials.
281  Valid for the following light types: [all]
282  *************************************************/
283 
287  virtual SpecularUndoableCommand::Ptr specularCmd(float ls) = 0;
288 
291  virtual void specular(float ls) {
292  if (auto cmd = specularCmd(ls)) {
293  cmd->execute();
294  }
295  }
296 
299  virtual float specular() const = 0;
300 
301  /*************************************************
302  Directional interface.
303  Valid for the following light types: [Directional]
304  *************************************************/
305 
307  {
308  public:
309  virtual ~DirectionalInterface();
310 
314  virtual AngleUndoableCommand::Ptr angleCmd(float la) = 0;
315 
318  virtual void angle(float la) {
319  if (auto cmd = angleCmd(la)) {
320  cmd->execute();
321  }
322  }
323 
326  virtual float angle() const = 0;
327  };
328 
331  std::shared_ptr<DirectionalInterface> directionalInterface();
332 
333  /*************************************************
334  Sphere interface.
335  Valid for the following light types: [Point, Spot]
336  *************************************************/
337 
339  {
340  public:
341  virtual ~SphereInterface();
342 
347  virtual SpherePropsUndoableCommand::Ptr spherePropsCmd(float radius, bool asPoint) = 0;
348 
352  virtual void sphereProps(float radius, bool asPoint) {
353  if (auto cmd = spherePropsCmd(radius, asPoint)) {
354  cmd->execute();
355  }
356  }
357 
360  virtual SphereProps sphereProps() const = 0;
361  };
362 
365  std::shared_ptr<SphereInterface> sphereInterface();
366 
367  /*************************************************
368  Cone interface.
369  Valid for the following light types: [Spot]
370  *************************************************/
371 
373  {
374  public:
375  virtual ~ConeInterface();
376 
382  virtual ConePropsUndoableCommand::Ptr conePropsCmd(float focus, float angle, float softness) = 0;
383 
388  virtual void coneProps(float focus, float angle, float softness) {
389  if (auto cmd = conePropsCmd(focus, angle, softness)) {
390  cmd->execute();
391  }
392  }
393 
396  virtual ConeProps coneProps() const = 0;
397  };
398 
401  std::shared_ptr<ConeInterface> coneInterface();
402 
403  /*************************************************
404  Area interface.
405  Valid for the following light types: [Area]
406  *************************************************/
407 
409  {
410  public:
411  virtual ~AreaInterface();
412 
414 
418  virtual NormalizeUndoableCommand::Ptr normalizeCmd(bool nl) = 0;
419 
422  virtual void normalize(bool nl) {
423  if (auto cmd = normalizeCmd(nl)) {
424  cmd->execute();
425  }
426  }
427 
430  virtual bool normalize() const = 0;
431  };
432 
435  std::shared_ptr<AreaInterface> areaInterface();
436 
437  protected:
438  virtual std::shared_ptr<DirectionalInterface> directionalInterfaceImpl() = 0;
439  virtual std::shared_ptr<SphereInterface> sphereInterfaceImpl() = 0;
440  virtual std::shared_ptr<ConeInterface> coneInterfaceImpl() = 0;
441  virtual std::shared_ptr<AreaInterface> areaInterfaceImpl() = 0;
442  };
443 }
444 
445 #endif /* _light */
virtual void diffuse(float ld)
Definition: light.h:268
virtual void specular(float ls)
Definition: light.h:291
virtual void coneProps(float focus, float angle, float softness)
Definition: light.h:388
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:201
virtual void shadowColor(float r, float g, float b)
Definition: light.h:245
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:52
Abstract class for set value command.
virtual void shadowEnable(bool se)
Definition: light.h:223
virtual void angle(float la)
Definition: light.h:318
#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:49
SetValueUndoableCommand< const Color3f & > SetColor3fUndoableCommand
virtual void sphereProps(float radius, bool asPoint)
Definition: light.h:352
Path path(const std::string &pathString)
virtual void normalize(bool nl)
Definition: light.h:422
virtual void intensity(float li)
Definition: light.h:179
#define UFE_SDK_DECL
Definition: ufeExport.h:36