summaryrefslogtreecommitdiff
path: root/src/Vrml/Vrml_SpotLight.cxx
blob: 38ace49b6070fe6041cd2a860671e4eded02821f (plain)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#include <Vrml_SpotLight.ixx>

Vrml_SpotLight::Vrml_SpotLight():
  myOnOff(Standard_True),
  myIntensity(1),
  myDropOffRate(0), 
  myCutOffAngle(0.785398) 
{
  gp_Vec tmpVec(0,0,1);
  myLocation = tmpVec;

  tmpVec.SetCoord(0,0,-1);
  myDirection = tmpVec;

  Quantity_Color tmpColor(1,1,1,Quantity_TOC_RGB);
  myColor = tmpColor;
}

 Vrml_SpotLight::Vrml_SpotLight( const Standard_Boolean aOnOff, 
				 const Standard_Real aIntensity, 
			         const Quantity_Color& aColor, 
			         const gp_Vec& aLocation,
			         const gp_Vec& aDirection,
				 const Standard_Real aDropOffRate, 
				 const Standard_Real aCutOffAngle) 
{
  myOnOff = aOnOff;
  if (aIntensity < 0. || aIntensity > 1.)
    {
      Standard_Failure::Raise("Error : Light intensity must be in the range 0.0 to 1.0, inclusive.");
    }
  myIntensity = aIntensity;
  myColor = aColor;
  myLocation = aLocation;
  myDirection = aDirection;
  myDropOffRate = aDropOffRate;
  myCutOffAngle = aCutOffAngle;
}

void Vrml_SpotLight::SetOnOff(const Standard_Boolean aOnOff)
{
  myOnOff = aOnOff;
}

Standard_Boolean Vrml_SpotLight::OnOff() const 
{
  return myOnOff;
}

void Vrml_SpotLight::SetIntensity(const Standard_Real aIntensity)
{
  if (aIntensity < 0. || aIntensity > 1.)
    {
      Standard_Failure::Raise("Error : Light intensity must be in the range 0.0 to 1.0, inclusive.");
    }
  myIntensity = aIntensity;
}

Standard_Real Vrml_SpotLight::Intensity() const 
{
  return myIntensity;
}

void Vrml_SpotLight::SetColor(const Quantity_Color& aColor)
{
  myColor = aColor;
}

Quantity_Color Vrml_SpotLight::Color() const 
{
  return  myColor;
}

void Vrml_SpotLight::SetLocation(const gp_Vec& aLocation)
{
  myLocation = aLocation;
}

gp_Vec Vrml_SpotLight::Location() const 
{
  return myLocation;
}

void Vrml_SpotLight::SetDirection(const gp_Vec& aDirection)
{
  myDirection = aDirection;
}

gp_Vec Vrml_SpotLight::Direction() const 
{
  return myDirection;
}

void Vrml_SpotLight::SetDropOffRate(const Standard_Real aDropOffRate)
{
  myDropOffRate = aDropOffRate;
}

Standard_Real Vrml_SpotLight::DropOffRate() const 
{
  return myDropOffRate;
}

void Vrml_SpotLight::SetCutOffAngle(const Standard_Real aCutOffAngle)
{
  myCutOffAngle = aCutOffAngle;
}

Standard_Real Vrml_SpotLight::CutOffAngle() const 
{
  return myCutOffAngle;
}

Standard_OStream& Vrml_SpotLight::Print(Standard_OStream& anOStream) const 
{
 anOStream  << "SpotLight {" << endl;

 if ( myOnOff != Standard_True )
   {
    anOStream  << "    on" << "\t\t" << "FALSE" << endl;
//    anOStream << myOnOff << endl;
   }

 if ( Abs(myIntensity - 1) > 0.0001 )
   {
    anOStream  << "    intensity" << '\t';
    anOStream << myIntensity << endl;
   }

 if ( Abs(myColor.Red() - 1) > 0.0001 || 
     Abs(myColor.Green() - 1) > 0.0001 || 
     Abs(myColor.Blue() - 1) > 0.0001 )
   {
    anOStream  << "    color" << '\t';
    anOStream << myColor.Red() << ' ' << myColor.Green() << ' ' << myColor.Blue() << endl;
   }

 if ( Abs(myLocation.X() - 0) > 0.0001 || 
     Abs(myLocation.Y() - 0) > 0.0001 || 
     Abs(myLocation.Z() - 1) > 0.0001 ) 
   {
    anOStream  << "    location" << '\t';
    anOStream << myLocation.X() << ' ' << myLocation.Y() << ' ' << myLocation.Z() << endl;
   }

 if ( Abs(myDirection.X() - 0) > 0.0001 || 
     Abs(myDirection.Y() - 0) > 0.0001 || 
     Abs(myDirection.Z() + 1) > 0.0001 ) 
   {
    anOStream  << "    direction" << '\t';
    anOStream << myDirection.X() << ' ' << myDirection.Y() << ' ' << myDirection.Z() << endl;
   }

 if ( Abs(myDropOffRate - 0) > 0.0001 )
   {
    anOStream  << "    dropOffRate" << '\t';
    anOStream << myDropOffRate << endl;
   }

 if ( Abs(myCutOffAngle - 0.785398) > 0.0000001 )
   {
    anOStream  << "    cutOffAngle" << '\t';
    anOStream << myCutOffAngle << endl;
   }

 anOStream  << '}' << endl;
 return anOStream;
}