1 -- Created by: NW,JPB,CAL
2 -- Copyright (c) 1991-1999 Matra Datavision
3 -- Copyright (c) 1999-2012 OPEN CASCADE SAS
5 -- The content of this file is subject to the Open CASCADE Technology Public
6 -- License Version 6.5 (the "License"). You may not use the content of this file
7 -- except in compliance with the License. Please obtain a copy of the License
8 -- at http://www.opencascade.org and read it completely before using this file.
10 -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 -- The Original Code and all software distributed under the License is
14 -- distributed on an "AS IS" basis, without warranty of any kind, and the
15 -- Initial Developer hereby disclaims all such warranties, including without
16 -- limitation, any warranties of merchantability, fitness for a particular
17 -- purpose or non-infringement. Please see the License for the specific terms
18 -- and conditions governing the rights and limitations under the License.
20 class Light from Visual3d inherits TShared
24 ---Purpose: This class defines and updates light sources.
25 -- There is no limit to the number of light sources defined.
26 -- Only the number of active sources is limited.
28 -- TypeOfLightSource = TOLS_AMBIENT
33 -- Angle is a radian value.
34 -- Concentration, Attenuation are in the [0,1] interval.
37 ---Keywords: Light, View, Context, Ambient, Directional, Positional,
38 -- Spot, Angle, Concentration, Attenuation, Color, Shading
46 CLight from Graphic3d,
47 Vector from Graphic3d,
48 Vertex from Graphic3d,
49 TypeOfLightSource from Visual3d
53 LightDefinitionError from Visual3d
58 returns mutable Light from Visual3d;
60 ---Purpose: Creates a light from default values.
61 -- Light sources are created in a visualiser
62 -- and are activated in one of its views.
64 -- Type = TOLS_AMBIENT
67 Create ( Color : Color from Quantity )
68 returns mutable Light from Visual3d;
70 ---Purpose: Creates an AMBIENT light source.
71 -- Light sources are created in a visualiser
72 -- and are activated in one of its views.
74 Create ( Color : Color from Quantity;
75 Direction : Vector from Graphic3d;
76 Headlight : Boolean from Standard = Standard_False )
77 returns mutable Light from Visual3d
79 ---Purpose: Creates a DIRECTIONAL light source.
80 -- Light sources are created in a visualiser
81 -- and are activated in one of its views.
82 -- Warning: Raises LightDefinitionError if <Direction> is null.
83 raises LightDefinitionError;
85 Create ( Color : Color from Quantity;
86 Position : Vertex from Graphic3d;
87 Fact1, Fact2 : Real from Standard )
88 returns mutable Light from Visual3d
90 ---Purpose: Creates a POSITIONAL light source.
91 -- Light sources are created in a visualiser
92 -- and are activated in one of its views.
93 -- Warning: Raises LightDefinitionError
94 -- if <Fact1> and <Fact2> are null.
95 -- if <Fact1> is a negative value or greater than 1.0.
96 -- if <Fact2> is a negative value or greater than 1.0.
97 raises LightDefinitionError;
99 Create ( Color : Color from Quantity;
100 Position : Vertex from Graphic3d;
101 Direction : Vector from Graphic3d;
102 Concentration : Real from Standard;
103 Fact1, Fact2 : Real from Standard;
104 AngleCone : Real from Standard )
105 returns mutable Light from Visual3d
107 ---Purpose: Creates a SPOT light source.
108 -- Light sources are created in a visualiser
109 -- and are activated in one of its views.
110 -- <Concentration> specifies the intensity distribution of
112 -- <AngleCone> specifies the angle (radians) of the cone
113 -- created by the spot.
114 -- the global attenuation is equal :
115 -- 1 / (Fact1 + Fact2 * (norm(ObjectPosition - LightPosition)))
116 -- Warning: Raises LightDefinitionError
117 -- if <Direction> is null.
118 -- if <Concentration> is a negative value or greater than 1.0.
119 -- if <Fact1> and <Fact2> are null.
120 -- if <Fact1> is a negative value or greater than 1.0.
121 -- if <Fact2> is a negative value or greater than 1.0.
122 -- if <AngleCone> is a negative value or greater than PI/2.
123 raises LightDefinitionError;
125 ---------------------------------------------------
126 -- Category: Methods to modify the class definition
127 ---------------------------------------------------
129 SetAngle ( me : mutable;
130 AngleCone : Real from Standard )
132 ---Purpose: Modifies the angle (radians) of the cone created by the spot.
133 -- Works only on TOLS_SPOT lights.
134 -- Category: Methods to modify the class definition
135 -- Warning: Raises LightDefinitionError
136 -- if the type of the light is not TOLS_SPOT.
137 -- if <AngleCone> is a negative value or greater than PI/2.
138 raises LightDefinitionError is static;
140 SetAttenuation1 ( me : mutable;
141 Fact1 : Real from Standard )
143 ---Purpose: Modifies the attenuation factor of the light.
144 -- Works only on the TOLS_POSITIONAL and TOLS_SPOT lights.
145 -- Category: Methods to modify the class definition
146 -- Warning: Raises LightDefinitionError
147 -- if the type of the light is not TOLS_SPOT or TOLS_POSITIONAL.
148 -- if <Fact1> is a negative value or greater than 1.0.
149 raises LightDefinitionError is static;
151 SetAttenuation2 ( me : mutable;
152 Fact2 : Real from Standard )
154 ---Purpose: Modifies the attenuation factor of the light.
155 -- Works only on the TOLS_POSITIONAL and TOLS_SPOT lights.
156 -- Category: Methods to modify the class definition
157 -- Warning: Raises LightDefinitionError
158 -- if the type of the light is not TOLS_POSITIONAL or TOLS_SPOT.
159 -- if <Fact2> is a negative value or greater than 1.0..
160 raises LightDefinitionError is static;
162 SetColor ( me : mutable;
163 Color : Color from Quantity )
166 ---Purpose: Modifies the colour of the light.
167 ---Category: Methods to modify the class definition
169 SetConcentration ( me : mutable;
170 Concentration : Real from Standard )
172 ---Purpose: Modifies the intensity distribution of the light.
173 -- Works only on the TOLS_SPOT lights.
174 -- Category: Methods to modify the class definition
175 -- Warning: Raises LightDefinitionError
176 -- if the type of the light is not TOLS_SPOT.
177 -- if <Concentration> is a negative value or greater than 1.0.
178 raises LightDefinitionError is static;
180 SetDirection ( me : mutable;
181 Direction : Vector from Graphic3d )
183 ---Purpose: Modifies the light direction.
184 -- Works only on the TOLS_DIRECTIONAL and TOLS_SPOT lights.
186 -- Category: Methods to modify the class definition
187 -- Warning: Raises LightDefinitionError
188 -- if the type of the light is not TOLS_DIRECTIONAL
190 -- if <Direction> is null.
191 raises LightDefinitionError is static;
193 SetPosition ( me : mutable;
194 Position : Vertex from Graphic3d )
196 ---Purpose: Modifies the position of the light.
197 -- Works only on the TOLS_POSITIONAL and TOLS_SPOT lights.
198 -- Category: Methods to modify the class definition
199 -- Warning: Raises LightDefinitionError
200 -- if the type of the light is not TOLS_POSITIONAL or TOLS_SPOT.
201 raises LightDefinitionError is static;
203 ----------------------------
204 -- Category: Inquire methods
205 ----------------------------
208 returns Boolean from Standard is static;
210 ---Purpose: Returns the headlight state of the light <me>
211 ---Category: Inquire methods
213 SetHeadlight( me : mutable; theValue : Boolean from Standard ) is static;
215 ---Purpose: Setup headlight flag.
218 returns Color from Quantity is static;
220 ---Purpose: Returns the colour of the light <me>.
221 ---Category: Inquire methods
224 returns TypeOfLightSource from Visual3d is static;
226 ---Purpose: Returns the light type of <me>.
228 -- TypeOfLightSource = TOLS_AMBIENT
233 ---Category: Inquire methods
236 Color : out Color from Quantity )
238 ---Purpose: Returns the definition of <me> if <me> is
239 -- a light source of the TOLS_AMBIENT type.
240 -- Category: Inquire methods
241 -- Warning: Raises LightDefinitionError
242 -- if the type of the light is not TOLS_AMBIENT.
243 raises LightDefinitionError is static;
246 Color : out Color from Quantity;
247 Direction : out Vector from Graphic3d )
249 ---Purpose: Returns the definition of <me> if <me> is
250 -- a light source of the TOLS_DIRECTIONAL type.
251 -- Category: Inquire methods
252 -- Warning: Raises LightDefinitionError
253 -- if the type of the light is not TOLS_DIRECTIONAL.
254 raises LightDefinitionError is static;
257 Color : out Color from Quantity;
258 Position : out Vertex from Graphic3d;
259 Fact1,Fact2 : out Real from Standard )
261 ---Purpose: Returns the definition of <me> if <me> is
262 -- a light source of the TOLS_POSITIONAL type.
263 -- Category: Inquire methods
264 -- Warning: Raises LightDefinitionError
265 -- if the type of the light is not TOLS_POSITIONAL.
266 raises LightDefinitionError is static;
269 Color : out Color from Quantity;
270 Position : out Vertex from Graphic3d;
271 Direction : out Vector from Graphic3d;
272 Concentration : out Real from Standard;
273 Fact1,Fact2 : out Real from Standard;
274 AngleCone : out Real from Standard )
276 ---Purpose: Returns the definition of <me> if <me> is
277 -- a light source of the TOLS_SPOT type.
278 -- Category: Inquire methods
279 -- Warning: Raises LightDefinitionError
280 -- if the type of the light is not TOLS_SPOT.
281 raises LightDefinitionError is static;
284 returns CLight from Graphic3d
286 ---C++: return const &
288 ---Purpose: Returns the light defintion.
289 ---Category: Inquire methods
291 --------------------------
292 -- Category: Class methods
293 --------------------------
296 returns Integer from Standard;
298 ---Purpose: Maximum number of activatable light sources.
299 ---Category: Class methods
301 ----------------------------
302 -- Category: Private methods
303 ----------------------------
305 Identification ( me )
306 returns Integer from Standard
309 ---Purpose: Returns the light identification.
310 ---Category: Private methods
313 AAngle : Real from Standard )
314 returns Boolean from Standard
317 ---Purpose: Returns True if <AAngle> is a valid
318 -- spot light spread angle.
319 ---Category: Private methods
325 -- the associated C structure
326 myCLight : CLight from Graphic3d;
330 class View from Visual3d