42cf5bc1 |
1 | // Created on: 1992-01-22 |
2 | // Created by: GG |
3 | // Copyright (c) 1992-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _V3d_SpotLight_HeaderFile |
18 | #define _V3d_SpotLight_HeaderFile |
19 | |
42cf5bc1 |
20 | #include <V3d_PositionLight.hxx> |
42cf5bc1 |
21 | #include <V3d_TypeOfOrientation.hxx> |
42cf5bc1 |
22 | |
c357e426 |
23 | class V3d_Viewer; |
42cf5bc1 |
24 | class V3d_SpotLight; |
25 | DEFINE_STANDARD_HANDLE(V3d_SpotLight, V3d_PositionLight) |
26 | |
27 | //! Creation and modification of a spot. |
28 | class V3d_SpotLight : public V3d_PositionLight |
29 | { |
42cf5bc1 |
30 | public: |
31 | |
42cf5bc1 |
32 | //! Creates a light source of the Spot type in the viewer. |
33 | //! The attenuation factor F which determines |
34 | //! the illumination of a surface depends on the following formula : |
c357e426 |
35 | //! F = 1/(theConstAttenuation + theLinearAttenuation*Length) |
42cf5bc1 |
36 | //! Length is the distance from the source to the surface. |
37 | //! The default values (1.0,0.0) correspond to a minimum |
c357e426 |
38 | //! of attenuation. |
42cf5bc1 |
39 | //! The concentration factor determines the dispersion |
40 | //! of the light on the surface, the default value |
c357e426 |
41 | //! (1.0) corresponds to a minimum of dispersion. |
42cf5bc1 |
42 | //! Warning! raises BadValue from V3d - |
c357e426 |
43 | //! If one of the coefficients is not between 0 and 1. |
44 | //! If the lighting angle is <= 0 or > PI. |
45 | Standard_EXPORT V3d_SpotLight (const Handle(V3d_Viewer)& theViewer, |
ee2be2a8 |
46 | const Standard_Real theX, |
47 | const Standard_Real theY, |
48 | const Standard_Real theZ, |
c357e426 |
49 | const V3d_TypeOfOrientation theDirection = V3d_XnegYnegZpos, |
87432b82 |
50 | const Quantity_Color& theColor = Quantity_NOC_WHITE, |
ee2be2a8 |
51 | const Standard_Real theConstAttenuation = 1.0, |
52 | const Standard_Real theLinearAttenuation = 0.0, |
53 | const Standard_Real theConcentration = 1.0, |
54 | const Standard_Real theAngle = 0.523599); |
42cf5bc1 |
55 | |
56 | //! Creates a light source of the Spot type in the viewer. |
c357e426 |
57 | //! theXt, theYt, theZt : Coordinate of light source Target. |
58 | //! theXp, theYp, theZp : Coordinate of light source Position. |
42cf5bc1 |
59 | //! The others parameters describe before. |
60 | //! Warning! raises BadValue from V3d - |
c357e426 |
61 | //! If one of the coefficients is not between 0 and 1. |
62 | //! If the lighting angle is <= 0 or > PI. |
63 | Standard_EXPORT V3d_SpotLight (const Handle(V3d_Viewer)& theViewer, |
ee2be2a8 |
64 | const Standard_Real theXt, |
65 | const Standard_Real theYt, |
66 | const Standard_Real theZt, |
67 | const Standard_Real theXp, |
68 | const Standard_Real theYp, |
69 | const Standard_Real theZp, |
87432b82 |
70 | const Quantity_Color& theColor = Quantity_NOC_WHITE, |
ee2be2a8 |
71 | const Standard_Real theConstAttenuation = 1.0, |
72 | const Standard_Real theLinearAttenuation = 0.0, |
73 | const Standard_Real theConcentration = 1.0, |
74 | const Standard_Real theAngle = 0.523599); |
c357e426 |
75 | |
42cf5bc1 |
76 | //! Defines the position of the light source. |
ee2be2a8 |
77 | Standard_EXPORT virtual void SetPosition (const Standard_Real theX, |
78 | const Standard_Real theY, |
79 | const Standard_Real theZ) Standard_OVERRIDE; |
c357e426 |
80 | |
42cf5bc1 |
81 | //! Defines the direction of the light source. |
82 | //! If the normal vector is NULL. |
ee2be2a8 |
83 | Standard_EXPORT void SetDirection (const Standard_Real theVx, |
84 | const Standard_Real theVy, |
85 | const Standard_Real theVz); |
c357e426 |
86 | |
42cf5bc1 |
87 | //! Defines the direction of the light source |
88 | //! according to a predefined directional vector. |
c357e426 |
89 | Standard_EXPORT void SetDirection (const V3d_TypeOfOrientation theOrientation); |
90 | |
42cf5bc1 |
91 | //! Defines the coefficients of attenuation. |
92 | //! Warning! raises BadValue from V3d |
c357e426 |
93 | //! if one of the coefficient is < 0 or > 1. |
ee2be2a8 |
94 | Standard_EXPORT void SetAttenuation (const Standard_Real theConstAttenuation, |
95 | const Standard_Real theLinearAttenuation); |
c357e426 |
96 | |
42cf5bc1 |
97 | //! Defines the coefficient of concentration. |
c357e426 |
98 | //! if the coefficient is < 0 or > 1. |
ee2be2a8 |
99 | Standard_EXPORT void SetConcentration (const Standard_Real theConcentration); |
c357e426 |
100 | |
42cf5bc1 |
101 | //! Defines the spot angle in RADIANS. |
102 | //! Warning: raises BadValue from from V3d |
c357e426 |
103 | //! If the angle is <= 0 or > PI. |
ee2be2a8 |
104 | Standard_EXPORT void SetAngle (const Standard_Real theAngle); |
c357e426 |
105 | |
42cf5bc1 |
106 | //! Display the graphic structure of light source |
c357e426 |
107 | //! in the chosen view. We have three type of representation |
42cf5bc1 |
108 | //! - SIMPLE : Only the light source is displayed. |
109 | //! - PARTIAL : The light source and the light space are |
110 | //! displayed. |
111 | //! - COMPLETE : The light source, the light space and the |
112 | //! radius of light space are displayed. |
113 | //! We can choose the "SAMELAST" as parameter of representation |
114 | //! In this case the graphic structure representation will be |
115 | //! the last displayed. |
c357e426 |
116 | Standard_EXPORT void Display (const Handle(V3d_View)& theView, |
117 | const V3d_TypeOfRepresentation theRepresentation) Standard_OVERRIDE; |
118 | |
119 | //! Returns the direction of the light source defined by theVx, theVy, theVz. |
ee2be2a8 |
120 | Standard_EXPORT void Direction (Standard_Real& theVx, |
121 | Standard_Real& theVy, |
122 | Standard_Real& theVz) const; |
c357e426 |
123 | |
42cf5bc1 |
124 | //! Returns the position of the light source. |
ee2be2a8 |
125 | Standard_EXPORT void Position (Standard_Real& theX, |
126 | Standard_Real& theY, |
127 | Standard_Real& theZ) const Standard_OVERRIDE; |
c357e426 |
128 | |
42cf5bc1 |
129 | //! Returns the attenuation factors A1,A2 of the light source. |
ee2be2a8 |
130 | Standard_EXPORT void Attenuation (Standard_Real& theConstAttentuation, |
131 | Standard_Real& theLinearAttentuation) const; |
c357e426 |
132 | |
ee2be2a8 |
133 | Standard_EXPORT Standard_Real Concentration() const; |
c357e426 |
134 | |
42cf5bc1 |
135 | //! Returns the spot angle. |
ee2be2a8 |
136 | Standard_EXPORT Standard_Real Angle() const; |
42cf5bc1 |
137 | |
92efcf78 |
138 | DEFINE_STANDARD_RTTIEXT(V3d_SpotLight,V3d_PositionLight) |
42cf5bc1 |
139 | |
42cf5bc1 |
140 | private: |
141 | |
42cf5bc1 |
142 | //! Defines the representation of the spot light source. |
c357e426 |
143 | Standard_EXPORT void Symbol (const Handle(Graphic3d_Group)& theSymbol, |
144 | const Handle(V3d_View)& theView) const Standard_OVERRIDE; |
42cf5bc1 |
145 | }; |
146 | |
42cf5bc1 |
147 | #endif // _V3d_SpotLight_HeaderFile |