Blender  V2.93
NodeLight.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
22 #include "NodeLight.h"
23 
24 namespace Freestyle {
25 
26 int NodeLight::numberOfLights = 0;
27 
29 {
30  if (numberOfLights > 7) {
31  _number = 7;
32  }
33  else {
34  _number = numberOfLights;
35  numberOfLights++;
36  }
37 
38  Ambient[0] = Ambient[1] = Ambient[2] = 0.0f;
39  Ambient[3] = 1.0f;
40 
41  for (int i = 0; i < 4; i++) {
42  Diffuse[i] = 1.0f;
43  Specular[i] = 1.0f;
44  }
45 
46  Position[0] = Position[1] = Position[3] = 0.0f;
47  Position[2] = 1.0f;
48 
49  on = true;
50 }
51 
52 NodeLight::NodeLight(NodeLight &iBrother) : Node(iBrother)
53 {
54  if (numberOfLights > 7) {
55  _number = 7;
56  }
57  else {
58  _number = numberOfLights;
59  numberOfLights++;
60  }
61 
62  for (int i = 0; i < 4; i++) {
63  Ambient[i] = iBrother.ambient()[i];
64  Diffuse[i] = iBrother.diffuse()[i];
65  Specular[i] = iBrother.specular()[i];
66  Position[i] = iBrother.position()[i];
67  }
68 
69  on = iBrother.isOn();
70 }
71 
73 {
74  v.visitNodeLight(*this);
75 }
76 
77 } /* namespace Freestyle */
Class to represent a light node.
ATTR_WARN_UNUSED_RESULT const BMVert * v
const float * position() const
Definition: NodeLight.h:62
virtual void accept(SceneVisitor &v)
Definition: NodeLight.cpp:72
const float * diffuse() const
Definition: NodeLight.h:52
const float * ambient() const
Definition: NodeLight.h:47
const float * specular() const
Definition: NodeLight.h:57
bool isOn() const
Definition: NodeLight.h:67
inherits from class Rep
Definition: AppCanvas.cpp:32