1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <Vrml_SpotLight.ixx>
16 Vrml_SpotLight::Vrml_SpotLight():
17 myOnOff(Standard_True),
20 myCutOffAngle(0.785398)
25 tmpVec.SetCoord(0,0,-1);
28 Quantity_Color tmpColor(1,1,1,Quantity_TOC_RGB);
32 Vrml_SpotLight::Vrml_SpotLight( const Standard_Boolean aOnOff,
33 const Standard_Real aIntensity,
34 const Quantity_Color& aColor,
35 const gp_Vec& aLocation,
36 const gp_Vec& aDirection,
37 const Standard_Real aDropOffRate,
38 const Standard_Real aCutOffAngle)
41 if (aIntensity < 0. || aIntensity > 1.)
43 Standard_Failure::Raise("Error : Light intensity must be in the range 0.0 to 1.0, inclusive.");
45 myIntensity = aIntensity;
47 myLocation = aLocation;
48 myDirection = aDirection;
49 myDropOffRate = aDropOffRate;
50 myCutOffAngle = aCutOffAngle;
53 void Vrml_SpotLight::SetOnOff(const Standard_Boolean aOnOff)
58 Standard_Boolean Vrml_SpotLight::OnOff() const
63 void Vrml_SpotLight::SetIntensity(const Standard_Real aIntensity)
65 if (aIntensity < 0. || aIntensity > 1.)
67 Standard_Failure::Raise("Error : Light intensity must be in the range 0.0 to 1.0, inclusive.");
69 myIntensity = aIntensity;
72 Standard_Real Vrml_SpotLight::Intensity() const
77 void Vrml_SpotLight::SetColor(const Quantity_Color& aColor)
82 Quantity_Color Vrml_SpotLight::Color() const
87 void Vrml_SpotLight::SetLocation(const gp_Vec& aLocation)
89 myLocation = aLocation;
92 gp_Vec Vrml_SpotLight::Location() const
97 void Vrml_SpotLight::SetDirection(const gp_Vec& aDirection)
99 myDirection = aDirection;
102 gp_Vec Vrml_SpotLight::Direction() const
107 void Vrml_SpotLight::SetDropOffRate(const Standard_Real aDropOffRate)
109 myDropOffRate = aDropOffRate;
112 Standard_Real Vrml_SpotLight::DropOffRate() const
114 return myDropOffRate;
117 void Vrml_SpotLight::SetCutOffAngle(const Standard_Real aCutOffAngle)
119 myCutOffAngle = aCutOffAngle;
122 Standard_Real Vrml_SpotLight::CutOffAngle() const
124 return myCutOffAngle;
127 Standard_OStream& Vrml_SpotLight::Print(Standard_OStream& anOStream) const
129 anOStream << "SpotLight {" << endl;
131 if ( myOnOff != Standard_True )
133 anOStream << " on" << "\t\t" << "FALSE" << endl;
134 // anOStream << myOnOff << endl;
137 if ( Abs(myIntensity - 1) > 0.0001 )
139 anOStream << " intensity" << '\t';
140 anOStream << myIntensity << endl;
143 if ( Abs(myColor.Red() - 1) > 0.0001 ||
144 Abs(myColor.Green() - 1) > 0.0001 ||
145 Abs(myColor.Blue() - 1) > 0.0001 )
147 anOStream << " color" << '\t';
148 anOStream << myColor.Red() << ' ' << myColor.Green() << ' ' << myColor.Blue() << endl;
151 if ( Abs(myLocation.X() - 0) > 0.0001 ||
152 Abs(myLocation.Y() - 0) > 0.0001 ||
153 Abs(myLocation.Z() - 1) > 0.0001 )
155 anOStream << " location" << '\t';
156 anOStream << myLocation.X() << ' ' << myLocation.Y() << ' ' << myLocation.Z() << endl;
159 if ( Abs(myDirection.X() - 0) > 0.0001 ||
160 Abs(myDirection.Y() - 0) > 0.0001 ||
161 Abs(myDirection.Z() + 1) > 0.0001 )
163 anOStream << " direction" << '\t';
164 anOStream << myDirection.X() << ' ' << myDirection.Y() << ' ' << myDirection.Z() << endl;
167 if ( Abs(myDropOffRate - 0) > 0.0001 )
169 anOStream << " dropOffRate" << '\t';
170 anOStream << myDropOffRate << endl;
173 if ( Abs(myCutOffAngle - 0.785398) > 0.0000001 )
175 anOStream << " cutOffAngle" << '\t';
176 anOStream << myCutOffAngle << endl;
179 anOStream << '}' << endl;