b311480e |
1 | // Created on: 1997-07-28 |
2 | // Created by: Pierre CHALAMET |
3 | // Copyright (c) 1997-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | #include <Graphic3d_Texture2Dplane.ixx> |
22 | #include <Graphic3d_TypeOfTextureMode.hxx> |
bf75be98 |
23 | #include <Graphic3d_TextureParams.hxx> |
24 | |
25 | // ======================================================================= |
26 | // function : Graphic3d_Texture2Dplane |
27 | // purpose : |
28 | // ======================================================================= |
29 | Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane (const TCollection_AsciiString& theFileName) |
30 | : Graphic3d_Texture2D (theFileName, Graphic3d_TOT_2D_MIPMAP) |
31 | { |
32 | myParams->SetModulate (Standard_True); |
33 | myParams->SetRepeat (Standard_True); |
34 | myParams->SetFilter (Graphic3d_TOTF_TRILINEAR); |
35 | myParams->SetGenMode (Graphic3d_TOTM_OBJECT, |
36 | Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f), |
37 | Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f)); |
38 | } |
7fd59977 |
39 | |
bf75be98 |
40 | // ======================================================================= |
41 | // function : Graphic3d_Texture2Dplane |
42 | // purpose : |
43 | // ======================================================================= |
44 | Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane (const Graphic3d_NameOfTexture2D theNOT) |
45 | : Graphic3d_Texture2D (theNOT, Graphic3d_TOT_2D_MIPMAP) |
46 | { |
47 | myParams->SetModulate (Standard_True); |
48 | myParams->SetRepeat (Standard_True); |
49 | myParams->SetFilter (Graphic3d_TOTF_TRILINEAR); |
50 | myParams->SetGenMode (Graphic3d_TOTM_OBJECT, |
51 | Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f), |
52 | Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f)); |
53 | } |
7fd59977 |
54 | |
bf75be98 |
55 | // ======================================================================= |
56 | // function : SetPlaneS |
57 | // purpose : |
58 | // ======================================================================= |
59 | void Graphic3d_Texture2Dplane::SetPlaneS (const Standard_ShortReal theA, |
60 | const Standard_ShortReal theB, |
61 | const Standard_ShortReal theC, |
62 | const Standard_ShortReal theD) |
63 | { |
64 | const Graphic3d_Vec4 aPlaneS (theA, theB, theC, theD); |
65 | const Graphic3d_Vec4 aPlaneT = myParams->GenPlaneT(); |
66 | myParams->SetGenMode (Graphic3d_TOTM_OBJECT, aPlaneS, aPlaneT); |
7fd59977 |
67 | myPlaneName = Graphic3d_NOTP_UNKNOWN; |
7fd59977 |
68 | } |
69 | |
bf75be98 |
70 | // ======================================================================= |
71 | // function : SetPlaneT |
72 | // purpose : |
73 | // ======================================================================= |
74 | void Graphic3d_Texture2Dplane::SetPlaneT (const Standard_ShortReal theA, |
75 | const Standard_ShortReal theB, |
76 | const Standard_ShortReal theC, |
77 | const Standard_ShortReal theD) |
7fd59977 |
78 | { |
bf75be98 |
79 | const Graphic3d_Vec4 aPlaneS = myParams->GenPlaneS(); |
80 | const Graphic3d_Vec4 aPlaneT (theA, theB, theC, theD); |
81 | myParams->SetGenMode (Graphic3d_TOTM_OBJECT, aPlaneS, aPlaneT); |
7fd59977 |
82 | myPlaneName = Graphic3d_NOTP_UNKNOWN; |
7fd59977 |
83 | } |
84 | |
bf75be98 |
85 | // ======================================================================= |
86 | // function : SetPlane |
87 | // purpose : |
88 | // ======================================================================= |
89 | void Graphic3d_Texture2Dplane::SetPlane (const Graphic3d_NameOfTexturePlane thePlane) |
7fd59977 |
90 | { |
bf75be98 |
91 | switch (thePlane) |
92 | { |
7fd59977 |
93 | case Graphic3d_NOTP_XY: |
bf75be98 |
94 | { |
95 | myParams->SetGenMode (Graphic3d_TOTM_OBJECT, |
96 | Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f), |
97 | Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f)); |
7fd59977 |
98 | break; |
bf75be98 |
99 | } |
7fd59977 |
100 | case Graphic3d_NOTP_YZ: |
bf75be98 |
101 | { |
102 | myParams->SetGenMode (Graphic3d_TOTM_OBJECT, |
103 | Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f), |
104 | Graphic3d_Vec4 (0.0f, 0.0f, 1.0f, 0.0f)); |
7fd59977 |
105 | break; |
bf75be98 |
106 | } |
7fd59977 |
107 | case Graphic3d_NOTP_ZX: |
bf75be98 |
108 | { |
109 | myParams->SetGenMode (Graphic3d_TOTM_OBJECT, |
110 | Graphic3d_Vec4 (0.0f, 0.0f, 1.0f, 0.0f), |
111 | Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f)); |
7fd59977 |
112 | break; |
113 | } |
bf75be98 |
114 | default: break; |
115 | } |
7fd59977 |
116 | |
bf75be98 |
117 | myPlaneName = thePlane; |
7fd59977 |
118 | } |
119 | |
bf75be98 |
120 | // ======================================================================= |
121 | // function : SetScaleS |
122 | // purpose : |
123 | // ======================================================================= |
124 | void Graphic3d_Texture2Dplane::SetScaleS (const Standard_ShortReal theVal) |
7fd59977 |
125 | { |
bf75be98 |
126 | Graphic3d_Vec2 aScale = myParams->Scale(); |
127 | aScale.x() = theVal; |
128 | myParams->SetScale (aScale); |
7fd59977 |
129 | } |
130 | |
bf75be98 |
131 | // ======================================================================= |
132 | // function : SetScaleT |
133 | // purpose : |
134 | // ======================================================================= |
135 | void Graphic3d_Texture2Dplane::SetScaleT (const Standard_ShortReal theVal) |
7fd59977 |
136 | { |
bf75be98 |
137 | Graphic3d_Vec2 aScale = myParams->Scale(); |
138 | aScale.y() = theVal; |
139 | myParams->SetScale (aScale); |
7fd59977 |
140 | } |
141 | |
bf75be98 |
142 | // ======================================================================= |
143 | // function : SetTranslateS |
144 | // purpose : |
145 | // ======================================================================= |
146 | void Graphic3d_Texture2Dplane::SetTranslateS (const Standard_ShortReal theVal) |
7fd59977 |
147 | { |
bf75be98 |
148 | Graphic3d_Vec2 aVec = myParams->Translation(); |
149 | aVec.x() = theVal; |
150 | myParams->SetTranslation (aVec); |
7fd59977 |
151 | } |
152 | |
bf75be98 |
153 | // ======================================================================= |
154 | // function : SetTranslateT |
155 | // purpose : |
156 | // ======================================================================= |
157 | void Graphic3d_Texture2Dplane::SetTranslateT (const Standard_ShortReal theVal) |
7fd59977 |
158 | { |
bf75be98 |
159 | Graphic3d_Vec2 aVec = myParams->Translation(); |
160 | aVec.y() = theVal; |
161 | myParams->SetTranslation (aVec); |
7fd59977 |
162 | } |
163 | |
bf75be98 |
164 | // ======================================================================= |
165 | // function : SetRotation |
166 | // purpose : |
167 | // ======================================================================= |
168 | void Graphic3d_Texture2Dplane::SetRotation (const Standard_ShortReal theAngleDegrees) |
7fd59977 |
169 | { |
bf75be98 |
170 | myParams->SetRotation (theAngleDegrees); |
7fd59977 |
171 | } |
172 | |
bf75be98 |
173 | // ======================================================================= |
174 | // function : PlaneS |
175 | // purpose : |
176 | // ======================================================================= |
177 | void Graphic3d_Texture2Dplane::PlaneS (Standard_ShortReal& theA, |
178 | Standard_ShortReal& theB, |
179 | Standard_ShortReal& theC, |
180 | Standard_ShortReal& theD) const |
7fd59977 |
181 | { |
bf75be98 |
182 | const Graphic3d_Vec4& aPlaneS = myParams->GenPlaneS(); |
183 | theA = aPlaneS.x(); |
184 | theB = aPlaneS.y(); |
185 | theC = aPlaneS.z(); |
186 | theD = aPlaneS.w(); |
7fd59977 |
187 | } |
188 | |
bf75be98 |
189 | // ======================================================================= |
190 | // function : PlaneT |
191 | // purpose : |
192 | // ======================================================================= |
193 | void Graphic3d_Texture2Dplane::PlaneT (Standard_ShortReal& theA, |
194 | Standard_ShortReal& theB, |
195 | Standard_ShortReal& theC, |
196 | Standard_ShortReal& theD) const |
7fd59977 |
197 | { |
bf75be98 |
198 | const Graphic3d_Vec4& aPlaneT = myParams->GenPlaneT(); |
199 | theA = aPlaneT.x(); |
200 | theB = aPlaneT.y(); |
201 | theC = aPlaneT.z(); |
202 | theD = aPlaneT.w(); |
7fd59977 |
203 | } |
204 | |
bf75be98 |
205 | // ======================================================================= |
206 | // function : TranslateS |
207 | // purpose : |
208 | // ======================================================================= |
209 | void Graphic3d_Texture2Dplane::TranslateS (Standard_ShortReal& theVal) const |
7fd59977 |
210 | { |
bf75be98 |
211 | theVal = myParams->Translation().x(); |
7fd59977 |
212 | } |
213 | |
bf75be98 |
214 | // ======================================================================= |
215 | // function : TranslateT |
216 | // purpose : |
217 | // ======================================================================= |
218 | void Graphic3d_Texture2Dplane::TranslateT (Standard_ShortReal& theVal) const |
7fd59977 |
219 | { |
bf75be98 |
220 | theVal = myParams->Translation().y(); |
7fd59977 |
221 | } |
222 | |
bf75be98 |
223 | // ======================================================================= |
224 | // function : Rotation |
225 | // purpose : |
226 | // ======================================================================= |
227 | void Graphic3d_Texture2Dplane::Rotation (Standard_ShortReal& theVal) const |
7fd59977 |
228 | { |
bf75be98 |
229 | theVal = myParams->Rotation(); |
7fd59977 |
230 | } |
231 | |
bf75be98 |
232 | // ======================================================================= |
233 | // function : Plane |
234 | // purpose : |
235 | // ======================================================================= |
236 | Graphic3d_NameOfTexturePlane Graphic3d_Texture2Dplane::Plane() const |
237 | { |
7fd59977 |
238 | return myPlaneName; |
239 | } |
240 | |
bf75be98 |
241 | // ======================================================================= |
242 | // function : ScaleS |
243 | // purpose : |
244 | // ======================================================================= |
245 | void Graphic3d_Texture2Dplane::ScaleS (Standard_ShortReal& theVal) const |
7fd59977 |
246 | { |
bf75be98 |
247 | theVal = myParams->Scale().x(); |
7fd59977 |
248 | } |
249 | |
bf75be98 |
250 | // ======================================================================= |
251 | // function : ScaleT |
252 | // purpose : |
253 | // ======================================================================= |
254 | void Graphic3d_Texture2Dplane::ScaleT (Standard_ShortReal& theVal) const |
7fd59977 |
255 | { |
bf75be98 |
256 | theVal = myParams->Scale().y(); |
7fd59977 |
257 | } |