2 -- File: Visual3d_Light.cdl
3 -- Created: Jeudi 22 Aout 1991
6 ---Copyright: MatraDatavision 1991,1992,1993,1994
9 class Light from Visual3d inherits TShared
13 ---Purpose: This class defines and updates light sources.
14 -- There is no limit to the number of light sources defined.
15 -- Only the number of active sources is limited.
17 -- TypeOfLightSource = TOLS_AMBIENT
22 -- Angle is a radian value.
23 -- Concentration, Attenuation are in the [0,1] interval.
26 ---Keywords: Light, View, Context, Ambient, Directional, Positional,
27 -- Spot, Angle, Concentration, Attenuation, Color, Shading
36 CLight from Graphic3d,
37 Vector from Graphic3d,
38 Vertex from Graphic3d,
40 TypeOfLightSource from Visual3d
44 LightDefinitionError from Visual3d
49 returns mutable Light from Visual3d;
51 ---Purpose: Creates a light from default values.
52 -- Light sources are created in a visualiser
53 -- and are activated in one of its views.
55 -- Type = TOLS_AMBIENT
58 Create ( Color : Color from Quantity )
59 returns mutable Light from Visual3d;
61 ---Purpose: Creates an AMBIENT light source.
62 -- Light sources are created in a visualiser
63 -- and are activated in one of its views.
65 Create ( Color : Color from Quantity;
66 Direction : Vector from Graphic3d;
67 Headlight : Boolean from Standard = Standard_False )
68 returns mutable Light from Visual3d
70 ---Purpose: Creates a DIRECTIONAL light source.
71 -- Light sources are created in a visualiser
72 -- and are activated in one of its views.
73 -- Warning: Raises LightDefinitionError if <Direction> is null.
74 raises LightDefinitionError;
76 Create ( Color : Color from Quantity;
77 Position : Vertex from Graphic3d;
78 Fact1, Fact2 : Real from Standard )
79 returns mutable Light from Visual3d
81 ---Purpose: Creates a POSITIONAL light source.
82 -- Light sources are created in a visualiser
83 -- and are activated in one of its views.
84 -- Warning: Raises LightDefinitionError
85 -- if <Fact1> and <Fact2> are null.
86 -- if <Fact1> is a negative value or greater than 1.0.
87 -- if <Fact2> is a negative value or greater than 1.0.
88 raises LightDefinitionError;
90 Create ( Color : Color from Quantity;
91 Position : Vertex from Graphic3d;
92 Direction : Vector from Graphic3d;
93 Concentration : Real from Standard;
94 Fact1, Fact2 : Real from Standard;
95 AngleCone : Real from Standard )
96 returns mutable Light from Visual3d
98 ---Purpose: Creates a SPOT light source.
99 -- Light sources are created in a visualiser
100 -- and are activated in one of its views.
101 -- <Concentration> specifies the intensity distribution of
103 -- <AngleCone> specifies the angle (radians) of the cone
104 -- created by the spot.
105 -- the global attenuation is equal :
106 -- 1 / (Fact1 + Fact2 * (norm(ObjectPosition - LightPosition)))
107 -- Warning: Raises LightDefinitionError
108 -- if <Direction> is null.
109 -- if <Concentration> is a negative value or greater than 1.0.
110 -- if <Fact1> and <Fact2> are null.
111 -- if <Fact1> is a negative value or greater than 1.0.
112 -- if <Fact2> is a negative value or greater than 1.0.
113 -- if <AngleCone> is a negative value or greater than PI/2.
114 raises LightDefinitionError;
116 ---------------------------------------------------
117 -- Category: Methods to modify the class definition
118 ---------------------------------------------------
120 SetAngle ( me : mutable;
121 AngleCone : Real from Standard )
123 ---Purpose: Modifies the angle (radians) of the cone created by the spot.
124 -- Works only on TOLS_SPOT lights.
125 -- Category: Methods to modify the class definition
126 -- Warning: Raises LightDefinitionError
127 -- if the type of the light is not TOLS_SPOT.
128 -- if <AngleCone> is a negative value or greater than PI/2.
129 raises LightDefinitionError is static;
131 SetAttenuation1 ( me : mutable;
132 Fact1 : Real from Standard )
134 ---Purpose: Modifies the attenuation factor of the light.
135 -- Works only on the TOLS_POSITIONAL and TOLS_SPOT lights.
136 -- Category: Methods to modify the class definition
137 -- Warning: Raises LightDefinitionError
138 -- if the type of the light is not TOLS_SPOT or TOLS_POSITIONAL.
139 -- if <Fact1> is a negative value or greater than 1.0.
140 raises LightDefinitionError is static;
142 SetAttenuation2 ( me : mutable;
143 Fact2 : Real from Standard )
145 ---Purpose: Modifies the attenuation factor of the light.
146 -- Works only on the TOLS_POSITIONAL and TOLS_SPOT lights.
147 -- Category: Methods to modify the class definition
148 -- Warning: Raises LightDefinitionError
149 -- if the type of the light is not TOLS_POSITIONAL or TOLS_SPOT.
150 -- if <Fact2> is a negative value or greater than 1.0..
151 raises LightDefinitionError is static;
153 SetColor ( me : mutable;
154 Color : Color from Quantity )
157 ---Purpose: Modifies the colour of the light.
158 ---Category: Methods to modify the class definition
160 SetConcentration ( me : mutable;
161 Concentration : Real from Standard )
163 ---Purpose: Modifies the intensity distribution of the light.
164 -- Works only on the TOLS_SPOT lights.
165 -- Category: Methods to modify the class definition
166 -- Warning: Raises LightDefinitionError
167 -- if the type of the light is not TOLS_SPOT.
168 -- if <Concentration> is a negative value or greater than 1.0.
169 raises LightDefinitionError is static;
171 SetDirection ( me : mutable;
172 Direction : Vector from Graphic3d )
174 ---Purpose: Modifies the light direction.
175 -- Works only on the TOLS_DIRECTIONAL and TOLS_SPOT lights.
177 -- Category: Methods to modify the class definition
178 -- Warning: Raises LightDefinitionError
179 -- if the type of the light is not TOLS_DIRECTIONAL
181 -- if <Direction> is null.
182 raises LightDefinitionError is static;
184 SetPosition ( me : mutable;
185 Position : Vertex from Graphic3d )
187 ---Purpose: Modifies the position of the light.
188 -- Works only on the TOLS_POSITIONAL and TOLS_SPOT lights.
189 -- Category: Methods to modify the class definition
190 -- Warning: Raises LightDefinitionError
191 -- if the type of the light is not TOLS_POSITIONAL or TOLS_SPOT.
192 raises LightDefinitionError is static;
194 ----------------------------
195 -- Category: Inquire methods
196 ----------------------------
199 returns Boolean from Standard is static;
201 ---Purpose: Returns the headlight state of the light <me>
202 ---Category: Inquire methods
205 returns Color from Quantity is static;
207 ---Purpose: Returns the colour of the light <me>.
208 ---Category: Inquire methods
211 returns TypeOfLightSource from Visual3d is static;
213 ---Purpose: Returns the light type of <me>.
215 -- TypeOfLightSource = TOLS_AMBIENT
220 ---Category: Inquire methods
223 Color : out Color from Quantity )
225 ---Purpose: Returns the definition of <me> if <me> is
226 -- a light source of the TOLS_AMBIENT type.
227 -- Category: Inquire methods
228 -- Warning: Raises LightDefinitionError
229 -- if the type of the light is not TOLS_AMBIENT.
230 raises LightDefinitionError is static;
233 Color : out Color from Quantity;
234 Direction : out Vector from Graphic3d )
236 ---Purpose: Returns the definition of <me> if <me> is
237 -- a light source of the TOLS_DIRECTIONAL type.
238 -- Category: Inquire methods
239 -- Warning: Raises LightDefinitionError
240 -- if the type of the light is not TOLS_DIRECTIONAL.
241 raises LightDefinitionError is static;
244 Color : out Color from Quantity;
245 Position : out Vertex from Graphic3d;
246 Fact1,Fact2 : out Real from Standard )
248 ---Purpose: Returns the definition of <me> if <me> is
249 -- a light source of the TOLS_POSITIONAL type.
250 -- Category: Inquire methods
251 -- Warning: Raises LightDefinitionError
252 -- if the type of the light is not TOLS_POSITIONAL.
253 raises LightDefinitionError is static;
256 Color : out Color from Quantity;
257 Position : out Vertex from Graphic3d;
258 Direction : out Vector from Graphic3d;
259 Concentration : out Real from Standard;
260 Fact1,Fact2 : out Real from Standard;
261 AngleCone : out Real from Standard )
263 ---Purpose: Returns the definition of <me> if <me> is
264 -- a light source of the TOLS_SPOT type.
265 -- Category: Inquire methods
266 -- Warning: Raises LightDefinitionError
267 -- if the type of the light is not TOLS_SPOT.
268 raises LightDefinitionError is static;
270 --------------------------
271 -- Category: Class methods
272 --------------------------
275 returns Integer from Standard;
277 ---Purpose: Maximum number of activatable light sources.
278 ---Category: Class methods
280 ----------------------------
281 -- Category: Private methods
282 ----------------------------
284 Identification ( me )
285 returns Integer from Standard
288 ---Purpose: Returns the light identification.
289 ---Category: Private methods
292 AAngle : Real from Standard )
293 returns Boolean from Standard
296 ---Purpose: Returns True if <AAngle> is a valid
297 -- spot light spread angle.
298 ---Category: Private methods
305 -- Class : Visual3d_Light
307 -- Purpose : Declaration of variables specific to light sources
309 -- Reminder : A light source is defined by:
312 -- - the attenuation factor ( positional and spot only)
313 -- - its angle ( spot only )
314 -- - its concentration ( spot only )
315 -- - its direction ( directional and spot only )
316 -- - its position ( positional and spot only )
318 -- It is actived in a context of view.
322 MyType : TypeOfLightSource from Visual3d;
324 -- the associated C structure
325 MyCLight : CLight from Graphic3d;
329 class View from Visual3d