b311480e |
1 | -- Created by: NW,JPB,CAL |
2 | -- Copyright (c) 1991-1999 Matra Datavision |
3 | -- Copyright (c) 1999-2012 OPEN CASCADE SAS |
7fd59977 |
4 | -- |
b311480e |
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. |
7fd59977 |
9 | -- |
b311480e |
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. |
7fd59977 |
12 | -- |
b311480e |
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. |
19 | |
7fd59977 |
20 | -- 28-07-97 : PCT ; support for texture mapping |
21 | -- 08-04-98 : FGU ; support for emission |
22 | -- 26-03-99 : FMN ; Compatibilite ascendante: Ajout methodes SetColor() et Color() |
23 | -- 09-04-99 : GG ; Compatibilite ascendante: |
24 | -- NameOfPhysicalMaterial disparait. |
25 | -- 23-11-99 : GG : GER61351 Add Name() & Reset() methods |
26 | -- IMP150200: GG : Add IsEqual() IsDifferent() methods. |
27 | -- Add NumberOfMaterials() MaterialName() class methods |
28 | -- IMP171201: GG : Add MaterialName(), SetMaterialName() |
29 | -- instance methods and field MyRequestedMaterialName |
30 | |
31 | class MaterialAspect from Graphic3d |
32 | |
33 | ---Version: |
34 | |
35 | ---Purpose: This class allows the definition of the type of a surface. |
36 | -- Keywords: Material, FillArea, Shininess, Ambient, Color, Diffuse, |
37 | -- Specular, Transparency, Emissive, ReflectionMode, |
38 | -- BackFace, FrontFace, Reflection, Absorbtion |
39 | |
40 | ---Warning: |
41 | ---References: |
42 | |
43 | uses |
44 | |
45 | Color from Quantity, |
46 | |
47 | NameOfMaterial from Graphic3d, |
48 | TypeOfReflection from Graphic3d, |
49 | TypeOfMaterial from Graphic3d, |
50 | AsciiString from TCollection |
51 | |
52 | raises |
53 | |
54 | MaterialDefinitionError from Graphic3d, |
55 | OutOfRange from Standard |
56 | |
57 | is |
58 | |
59 | Create |
60 | returns MaterialAspect from Graphic3d; |
61 | ---Level: Public |
62 | ---Purpose: Creates a material from default values. |
63 | ---Material is generic |
64 | |
65 | Create ( AName : NameOfMaterial from Graphic3d ) |
66 | returns MaterialAspect from Graphic3d; |
67 | ---Level: Public |
68 | ---Purpose: Creates a generic material calls <AName> |
69 | |
70 | --------------------------------------------------- |
71 | -- Category: Methods to modify the class definition |
72 | --------------------------------------------------- |
73 | |
74 | IncreaseShine ( me : in out; |
75 | ADelta : Real from Standard ) |
76 | is static; |
77 | ---Level: Public |
78 | ---Purpose: Increases or decreases the luminosity of <me>. |
79 | -- <ADelta> is a signed percentage. |
80 | ---Category: Methods to modify the class definition |
81 | |
82 | SetAmbient ( me : in out; |
83 | AValue : Real from Standard ) |
84 | ---Level: Public |
85 | ---Purpose: Modifies the reflection properties of the surface. |
86 | -- Category: Methods to modify the class definition |
87 | -- Warning: Raises MaterialDefinitionError if <AValue> is |
88 | -- a negative value or greater than 1.0. |
89 | raises MaterialDefinitionError from Graphic3d is static; |
90 | |
91 | SetDiffuse ( me : in out; |
92 | AValue : Real from Standard ) |
93 | ---Level: Public |
94 | ---Purpose: Modifies the reflection properties of the surface. |
95 | -- Category: Methods to modify the class definition |
96 | -- Warning: Raises MaterialDefinitionError if <AValue> is a |
97 | -- negative value or greater than 1.0. |
98 | raises MaterialDefinitionError from Graphic3d is static; |
99 | |
100 | SetEmissive ( me : in out; |
101 | AValue : Real from Standard ) |
102 | ---Level: Public |
103 | ---Purpose: Modifies the reflection properties of the surface. |
104 | -- Category: Methods to modify the class definition |
105 | -- Warning: Raises MaterialDefinitionError if <AValue> is a |
106 | -- negative value or greater than 1.0. |
107 | raises MaterialDefinitionError from Graphic3d is static; |
108 | |
109 | SetShininess ( me : in out; |
110 | AValue : Real from Standard ) |
111 | ---Level: Public |
112 | ---Purpose: Modifies the luminosity of the surface. |
113 | -- Category: Methods to modify the class definition |
114 | -- Warning: Raises MaterialDefinitionError if <AValue> is a |
115 | -- negative value or greater than 1.0. |
116 | raises MaterialDefinitionError from Graphic3d is static; |
117 | |
118 | SetSpecular ( me : in out; |
119 | AValue : Real from Standard ) |
120 | ---Level: Public |
121 | ---Purpose: Modifies the reflection properties of the surface. |
122 | -- Category: Methods to modify the class definition |
123 | -- Warning: Raises MaterialDefinitionError if <AValue> is a |
124 | -- negative value or greater than 1.0. |
125 | raises MaterialDefinitionError from Graphic3d is static; |
126 | |
127 | SetTransparency ( me : in out; |
128 | AValue : Real from Standard ) |
129 | ---Level: Public |
130 | ---Purpose: Modifies the transparency coefficient of the surface. |
131 | -- <AValue> = 0. opaque. (default) |
132 | -- <AValue> = 1. transparent. |
133 | -- Transparency is applicable to materials that have at least |
134 | -- one of reflection modes (ambient, diffuse, specular or emissive) |
135 | -- enabled. See also SetReflectionModeOn() and SetReflectionModeOff() methods. |
136 | -- |
137 | -- NOTE: In order for transparency specified through this method to |
138 | -- take effect, it is necessary to enable transparency |
139 | -- in the viewer. This can be done either directly - |
140 | -- see Visual3d_ViewManager::SetTransparency(Standard_Boolean), |
141 | -- or indirectly - by calling AIS_InteractiveObject::SetTransparency() |
142 | -- before an object is added to an interactive context, or by |
143 | -- calling AIS_InteractiveContext::SetTransparency() for a given |
144 | -- interactive object already displayed. |
145 | -- Category: Methods to modify the class definition |
146 | -- Warning: Raises MaterialDefinitionError if <AValue> is a |
147 | -- negative value or greater than 1.0. |
148 | raises MaterialDefinitionError from Graphic3d is static; |
149 | |
150 | SetColor ( me : in out; |
151 | AColor : Color from Quantity ) |
152 | is static; |
153 | ---Level: Public |
154 | ---Purpose: Modifies the ambient colour of the surface. |
155 | -- Category: Methods to modify the class definition |
156 | |
157 | SetAmbientColor ( me : in out; |
158 | AColor : Color from Quantity ) |
159 | is static; |
160 | ---Level: Public |
161 | ---Purpose: Modifies the ambient colour of the surface. |
162 | ---Category: Methods to modify the class definition |
163 | |
164 | SetDiffuseColor ( me : in out; |
165 | AColor : Color from Quantity ) |
166 | is static; |
167 | ---Level: Public |
168 | ---Purpose: Modifies the difuse colour of the surface. |
169 | ---Category: Methods to modify the class definition |
170 | |
171 | SetSpecularColor ( me : in out; |
172 | AColor : Color from Quantity ) |
173 | is static; |
174 | ---Level: Public |
175 | ---Purpose: Modifies the specular colour of the surface. |
176 | ---Category: Methods to modify the class definition |
177 | |
178 | SetEmissiveColor ( me : in out; |
179 | AColor : Color from Quantity ) |
180 | is static; |
181 | ---Level: Public |
182 | ---Purpose: Modifies the emissive colour of the surface. |
183 | ---Category: Methods to modify the class definition |
184 | |
185 | |
186 | SetReflectionModeOn ( me : in out; |
187 | AType : TypeOfReflection from Graphic3d ) |
188 | is static; |
189 | ---Level: Public |
190 | ---Purpose: Activates the reflective properties of the surface <AType>. |
191 | -- |
192 | -- TypeOfReflection : TOR_AMBIENT |
193 | -- TOR_DIFFUSE |
194 | -- TOR_SPECULAR |
195 | -- TOR_EMISSION |
196 | -- 1, 2, 3 or 4 types of reflection can be set for a given surface. |
197 | ---Category: Methods to modify the class definition |
198 | |
199 | SetReflectionModeOff ( me : in out; |
200 | AType : TypeOfReflection from Graphic3d ) |
201 | is static; |
202 | ---Level: Public |
203 | ---Purpose: Deactivates the reflective properties of |
204 | -- the surface <AType>. |
205 | -- |
206 | -- TypeOfReflection : TOR_AMBIENT |
207 | -- TOR_DIFFUSE |
208 | -- TOR_SPECULAR |
209 | -- TOR_EMISSION |
210 | -- 1, 2, 3 or 4 types of reflection can be set off for a given surface. |
211 | -- Disabling diffuse and specular reflectance is useful for efficient visualization |
212 | -- of large amounts of data as definition of normals for graphic primitives is not needed |
213 | -- when only "all-directional" reflectance is active. |
214 | -- |
215 | -- NOTE: Disabling all four reflection modes also turns off the following effects: |
216 | -- 1. Lighting. Colors of primitives are not affected by the material properties when lighting is off. |
217 | -- 2. Transparency. |
218 | ---Category: Methods to modify the class definition |
219 | |
220 | SetMaterialType ( me : in out; |
221 | AType : TypeOfMaterial from Graphic3d ) |
222 | is static; |
223 | ---Level: Public |
224 | ---Purpose: Set MyMaterialType to the value of parameter <AType> |
225 | -- |
226 | -- TypeOfMaterial : MATERIAL_ASPECT |
227 | -- MATERIAL_PHYSIC |
228 | ---Category: Methods to modify the class definition |
229 | |
230 | SetMaterialName ( me : in out; |
231 | AName : CString from Standard ) |
232 | is static; |
233 | ---Level: Public |
234 | ---Purpose: The current matarial become a "UserDefined" material. |
235 | -- Set the name of the "UserDefined" material. |
236 | ---Category: Methods to modify the class definition |
237 | |
238 | SetEnvReflexion(me : in out; |
239 | AValue : ShortReal from Standard ); |
240 | |
241 | Reset(me : out); |
242 | ---Level: Public |
243 | ---Purpose: Resets the material with the original values according to |
244 | -- the material name but leave the current color values untouched |
245 | -- for the material of type ASPECT. |
246 | ---Category: Methods to modify the class definition |
247 | |
248 | ---------------------------- |
249 | -- Category: Inquire methods |
250 | ---------------------------- |
251 | |
252 | Color ( me ) |
253 | returns Color from Quantity |
254 | is static; |
255 | ---Level: Public |
256 | ---Purpose: Returns the ambient colour of the surface. |
257 | ---Category: Inquire methods |
258 | |
259 | AmbientColor ( me ) |
260 | returns Color from Quantity |
261 | is static; |
262 | ---Level: Public |
263 | ---Purpose: Returns the ambient colour of the surface. |
264 | ---Category: Inquire methods |
265 | |
266 | DiffuseColor ( me ) |
267 | returns Color from Quantity |
268 | is static; |
269 | ---Level: Public |
270 | ---Purpose: Returns the diffuse colour of the surface. |
271 | ---Category: Inquire methods |
272 | |
273 | SpecularColor ( me ) |
274 | returns Color from Quantity |
275 | is static; |
276 | ---Level: Public |
277 | ---Purpose: Returns the specular colour of the surface. |
278 | ---Category: Inquire methods |
279 | |
280 | EmissiveColor ( me ) |
281 | returns Color from Quantity |
282 | is static; |
283 | ---Level: Public |
284 | ---Purpose: Returns the emissive colour of the surface. |
285 | ---Category: Inquire methods |
286 | |
287 | Ambient ( me ) |
288 | returns Real from Standard |
289 | is static; |
290 | ---Level: Public |
291 | ---Purpose: Returns the reflection properties of the surface. |
292 | ---Category: Inquire methods |
293 | |
294 | Diffuse ( me ) |
295 | returns Real from Standard |
296 | is static; |
297 | ---Level: Public |
298 | ---Purpose: Returns the reflection properties of the surface. |
299 | ---Category: Inquire methods |
300 | |
301 | Specular ( me ) |
302 | returns Real from Standard |
303 | is static; |
304 | ---Level: Public |
305 | ---Purpose: Returns the reflection properties of the surface. |
306 | ---Category: Inquire methods |
307 | |
308 | Transparency ( me ) |
309 | returns Real from Standard |
310 | is static; |
311 | ---Level: Public |
312 | ---Purpose: Returns the transparency coefficient of the surface. |
313 | ---Category: Inquire methods |
314 | |
315 | Emissive ( me ) |
316 | returns Real from Standard |
317 | is static; |
318 | ---Level: Public |
319 | ---Purpose: Returns the emissive coefficient of the surface. |
320 | ---Category: Inquire methods |
321 | |
322 | Shininess ( me ) |
323 | returns Real from Standard |
324 | is static; |
325 | ---Level: Public |
326 | ---Purpose: Returns the luminosity of the surface. |
327 | ---Category: Inquire methods |
328 | |
329 | ReflectionMode ( me; |
330 | AType : TypeOfReflection from Graphic3d ) |
331 | returns Boolean from Standard |
332 | is static; |
333 | ---Level: Public |
334 | ---Purpose: Returns Standard_True if the reflection mode is active, |
335 | -- Standard_False otherwise. |
336 | ---Category: Inquire methods |
337 | |
338 | MaterialType ( me; |
339 | AType : TypeOfMaterial from Graphic3d ) |
340 | returns Boolean from Standard |
341 | is static; |
342 | ---Level: Public |
343 | ---Purpose: Returns Standard_True if MyMaterialType equal the parameter AType, |
344 | -- Standard_False otherwise. |
345 | ---Category: Inquire methods |
346 | |
347 | EnvReflexion(me) |
348 | returns ShortReal from Standard; |
349 | |
350 | Name(me) |
351 | returns NameOfMaterial from Graphic3d; |
352 | ---Level: Public |
353 | ---Purpose: Returns the material name. |
354 | ---Category: Inquire methods |
355 | |
356 | IsDifferent ( me; |
357 | Other : MaterialAspect from Graphic3d ) |
358 | returns Boolean from Standard is static; |
359 | ---Purpose: Returns Standard_True if the materials <me> and |
360 | -- <Other> are different. |
361 | ---Category: Inquire methods |
362 | ---C++: alias operator != |
363 | |
364 | IsEqual ( me; |
365 | Other : MaterialAspect from Graphic3d ) |
366 | returns Boolean from Standard is static; |
367 | ---Purpose: Returns Standard_True if the materials <me> and |
368 | -- <Other> are identical. |
369 | ---Category: Inquire methods |
370 | ---C++: alias operator == |
371 | |
372 | NumberOfMaterials(myclass) returns Integer from Standard; |
373 | ---Purpose: |
374 | -- Returns the number of predefined textures. |
375 | ---Level: Public |
376 | |
377 | MaterialName(myclass; aRank: Integer from Standard) |
378 | returns CString from Standard |
379 | raises OutOfRange from Standard; |
380 | ---Purpose: |
381 | -- Returns the name of the predefined material of rank <aRank> |
382 | -- Trigger: when <aRank> is < 1 or > NumberOfMaterials. |
383 | ---Level: Public |
384 | |
385 | MaterialName(me) |
386 | returns CString from Standard; |
387 | ---Purpose: |
388 | -- Returns the name of this material |
389 | ---Level: Public |
390 | |
391 | MaterialType(myclass; aRank: Integer from Standard) |
392 | returns TypeOfMaterial from Graphic3d |
393 | raises OutOfRange from Standard; |
394 | ---Purpose: |
395 | -- Returns the type of the predefined material of rank <aRank> |
396 | -- Trigger: when <aRank> is < 1 or > NumberOfMaterials. |
397 | ---Level: Public |
398 | |
399 | ---------------------------- |
400 | -- Category: Private methods |
401 | ---------------------------- |
402 | |
403 | Init ( me : out; AName : NameOfMaterial from Graphic3d) is private; |
404 | |
405 | --\f |
406 | |
407 | fields |
408 | |
409 | -- |
410 | -- Class : Graphic3d_MaterialAspect |
411 | -- |
412 | -- purpose : Declaration of variables specific to the definition |
413 | -- of materials. |
414 | -- |
415 | -- Reminders : A material is defines by: |
416 | -- - A coefficient of transparency |
417 | -- - A coefficient of diffuse reflection |
418 | -- - A coefficient of ambiant reflection |
419 | -- - A coefficient of specular reflection |
420 | -- - A emissive coefficient |
421 | -- |
422 | -- Two properties define a material : |
423 | -- - its transparency |
424 | -- - its reflection which is to say its properties of |
425 | -- - absorbtion and diffusion of light |
426 | -- |
427 | -- The diffuse reflection is seen as a component |
428 | -- of the colour of the object. |
429 | -- The specular reflection is seen as a component |
430 | -- of the colour of the light source |
431 | -- |
432 | -- To determine the three colours of reflection, |
433 | -- four things are required: |
434 | -- - A coefficient of diffuse reflection |
435 | -- - A coefficient of ambiant reflection |
436 | -- - A coefficient of specular reflection |
437 | -- |
438 | -- ( Under GL, the Silicon graphics interface, |
439 | -- we need to determine 3 colours ) |
440 | -- |
441 | -- References : Getting started with DEC PHIGS, appendix C |
442 | -- Iris Advanced Graphics, unit D |
443 | -- |
444 | -- |
445 | -- the coefficient of diffuse reflection, the colour, and the activity |
446 | MyDiffuseCoef : ShortReal from Standard; |
447 | MyDiffuseColor : Color from Quantity; |
448 | MyDiffuseActivity : Boolean from Standard; |
449 | |
450 | -- the coefficient of ambient reflection, the colour |
451 | -- and the activity |
452 | MyAmbientCoef : ShortReal from Standard; |
453 | MyAmbientColor : Color from Quantity; |
454 | MyAmbientActivity : Boolean from Standard; |
455 | |
456 | -- the coefficient of specular reflection, the colour |
457 | -- and the activity |
458 | MySpecularCoef : ShortReal from Standard; |
459 | MySpecularColor : Color from Quantity; |
460 | MySpecularActivity : Boolean from Standard; |
461 | |
462 | -- the coefficient of emissive reflection |
463 | MyEmissiveCoef : ShortReal from Standard; |
464 | MyEmissiveColor : Color from Quantity; |
465 | MyEmissiveActivity : Boolean from Standard; |
466 | |
467 | -- the coefficient of transparency |
468 | MyTransparencyCoef : ShortReal from Standard; |
469 | |
470 | -- the coefficient of luminosity |
471 | MyShininess : ShortReal from Standard; |
472 | |
473 | |
474 | -- the coeficient of reflexion for the environment texture |
475 | MyEnvReflexion : ShortReal from Standard; |
476 | |
477 | -- the type of material |
478 | --MyMaterialType : Boolean from Standard; |
479 | MyMaterialType : TypeOfMaterial from Graphic3d; |
480 | |
481 | -- the Name of material |
482 | MyMaterialName : NameOfMaterial from Graphic3d; |
483 | MyRequestedMaterialName : NameOfMaterial from Graphic3d; |
484 | |
485 | -- the string name of the material |
486 | MyStringName : AsciiString from TCollection; |
487 | |
488 | end MaterialAspect; |