File: Light.h

package info (click to toggle)
pinball 0.3.20201218-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 8,452 kB
  • sloc: cpp: 15,230; makefile: 840; sh: 381; xml: 24
file content (75 lines) | stat: -rw-r--r-- 1,895 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/***************************************************************************
                          Light.h  -  description
                             -------------------
    begin                : Sun Jan 30 2000
    copyright            : (C) 2000 by 
    email                : 
 ***************************************************************************/

#ifndef LIGHT_H
#define LIGHT_H

#define EM_IGNORE_ANGLE_HALF 1
#define EM_IGNORE_ANGLE_FULL 2
#define EM_IGNORE_DISTANCE 4
#define EM_USE_BOUNDS 8
#define EM_USE_SPECULAR 16
#define EM_USE_DIFFUSE 32

class Group;

#include "Node.h"
/** Example:
 * <pre>
 * Group* groupL = new group;
 * Light* l = new Light(1.0, 10.0);
 * 
 * groupL->setLight(l);
 * engine->add(groupL);
 * 
 * engine->addLight(l);
 * </pre> */
class Light {
 public:
  /** Light(constant, linear, quadratic, r, g, b). */
  Light(float c, float l, float q, float r=1.0, float g=1.0, float b=1.0);
  ~Light();
  void setOn(bool on=true) { m_bOn = on;};
  bool getOn() { return m_bOn;};
  // TODO fast clamp
  inline void setColor(float r, float g, float b) {
    m_fR = EM_MAX(EM_MIN(1.0, r), 0.0);
    m_fG = EM_MAX(EM_MIN(1.0, g), 0.0);	
    m_fB = EM_MAX(EM_MIN(1.0, b), 0.0);	
  };
  void getColor(float & r, float & g, float & b) { r = m_fR; g = m_fG; b = m_fB; };
  void setProperty(int);
  void unsetProperty(int);
  void setBounds(float b) { m_fBounds = b; };
  void setIndex(int i);
  inline Group * getParent() {
    return p_Parent;
  };
  
  Vertex3D m_vtxSrc;
  Vertex3D m_vtxTrans;
  Vertex3D m_vtxAlign;
 private:
  friend class AmbientLightVisitor;
  friend class TransformVisitor;
  friend class Group;
  
  void setParent(Group * p) {
    p_Parent = p;
  };
  Group * p_Parent;
  float m_fConstant;
  float m_fLinear;
  float m_fQuadratic;
  float m_fR, m_fG, m_fB;
  float m_fBounds;
  bool m_bOn;
  int m_iProperties;
};

#endif // LIGHT_H