b311480e |
1 | // Created on: 1997-07-28 |
2 | // Created by: Pierre CHALAMET |
3 | // Copyright (c) 1997-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
42cf5bc1 |
17 | |
18 | #include <Graphic3d_Texture2Dplane.hxx> |
bf75be98 |
19 | #include <Graphic3d_TextureParams.hxx> |
42cf5bc1 |
20 | #include <Graphic3d_TypeOfTextureMode.hxx> |
21 | #include <Standard_Type.hxx> |
22 | #include <TCollection_AsciiString.hxx> |
bf75be98 |
23 | |
92efcf78 |
24 | IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Texture2Dplane,Graphic3d_Texture2D) |
25 | |
bf75be98 |
26 | // ======================================================================= |
27 | // function : Graphic3d_Texture2Dplane |
28 | // purpose : |
29 | // ======================================================================= |
30 | Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane (const TCollection_AsciiString& theFileName) |
31 | : Graphic3d_Texture2D (theFileName, Graphic3d_TOT_2D_MIPMAP) |
32 | { |
33 | myParams->SetModulate (Standard_True); |
34 | myParams->SetRepeat (Standard_True); |
35 | myParams->SetFilter (Graphic3d_TOTF_TRILINEAR); |
36 | myParams->SetGenMode (Graphic3d_TOTM_OBJECT, |
37 | Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f), |
38 | Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f)); |
39 | } |
7fd59977 |
40 | |
bf75be98 |
41 | // ======================================================================= |
42 | // function : Graphic3d_Texture2Dplane |
43 | // purpose : |
44 | // ======================================================================= |
45 | Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane (const Graphic3d_NameOfTexture2D theNOT) |
46 | : Graphic3d_Texture2D (theNOT, Graphic3d_TOT_2D_MIPMAP) |
47 | { |
48 | myParams->SetModulate (Standard_True); |
49 | myParams->SetRepeat (Standard_True); |
50 | myParams->SetFilter (Graphic3d_TOTF_TRILINEAR); |
51 | myParams->SetGenMode (Graphic3d_TOTM_OBJECT, |
52 | Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f), |
53 | Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f)); |
54 | } |
7fd59977 |
55 | |
f376ac72 |
56 | // ======================================================================= |
57 | // function : Graphic3d_Texture2Dplane |
58 | // purpose : |
59 | // ======================================================================= |
60 | Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane (const Handle(Image_PixMap)& thePixMap) |
61 | : Graphic3d_Texture2D (thePixMap, Graphic3d_TOT_2D_MIPMAP) |
62 | { |
63 | myParams->SetModulate (Standard_True); |
64 | myParams->SetRepeat (Standard_True); |
65 | myParams->SetFilter (Graphic3d_TOTF_TRILINEAR); |
66 | myParams->SetGenMode (Graphic3d_TOTM_OBJECT, |
67 | Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f), |
68 | Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f)); |
69 | } |
70 | |
bf75be98 |
71 | // ======================================================================= |
72 | // function : SetPlaneS |
73 | // purpose : |
74 | // ======================================================================= |
75 | void Graphic3d_Texture2Dplane::SetPlaneS (const Standard_ShortReal theA, |
76 | const Standard_ShortReal theB, |
77 | const Standard_ShortReal theC, |
78 | const Standard_ShortReal theD) |
79 | { |
80 | const Graphic3d_Vec4 aPlaneS (theA, theB, theC, theD); |
81 | const Graphic3d_Vec4 aPlaneT = myParams->GenPlaneT(); |
82 | myParams->SetGenMode (Graphic3d_TOTM_OBJECT, aPlaneS, aPlaneT); |
7fd59977 |
83 | myPlaneName = Graphic3d_NOTP_UNKNOWN; |
7fd59977 |
84 | } |
85 | |
bf75be98 |
86 | // ======================================================================= |
87 | // function : SetPlaneT |
88 | // purpose : |
89 | // ======================================================================= |
90 | void Graphic3d_Texture2Dplane::SetPlaneT (const Standard_ShortReal theA, |
91 | const Standard_ShortReal theB, |
92 | const Standard_ShortReal theC, |
93 | const Standard_ShortReal theD) |
7fd59977 |
94 | { |
bf75be98 |
95 | const Graphic3d_Vec4 aPlaneS = myParams->GenPlaneS(); |
96 | const Graphic3d_Vec4 aPlaneT (theA, theB, theC, theD); |
97 | myParams->SetGenMode (Graphic3d_TOTM_OBJECT, aPlaneS, aPlaneT); |
7fd59977 |
98 | myPlaneName = Graphic3d_NOTP_UNKNOWN; |
7fd59977 |
99 | } |
100 | |
bf75be98 |
101 | // ======================================================================= |
102 | // function : SetPlane |
103 | // purpose : |
104 | // ======================================================================= |
105 | void Graphic3d_Texture2Dplane::SetPlane (const Graphic3d_NameOfTexturePlane thePlane) |
7fd59977 |
106 | { |
bf75be98 |
107 | switch (thePlane) |
108 | { |
7fd59977 |
109 | case Graphic3d_NOTP_XY: |
bf75be98 |
110 | { |
111 | myParams->SetGenMode (Graphic3d_TOTM_OBJECT, |
112 | Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f), |
113 | Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f)); |
7fd59977 |
114 | break; |
bf75be98 |
115 | } |
7fd59977 |
116 | case Graphic3d_NOTP_YZ: |
bf75be98 |
117 | { |
118 | myParams->SetGenMode (Graphic3d_TOTM_OBJECT, |
119 | Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f), |
120 | Graphic3d_Vec4 (0.0f, 0.0f, 1.0f, 0.0f)); |
7fd59977 |
121 | break; |
bf75be98 |
122 | } |
7fd59977 |
123 | case Graphic3d_NOTP_ZX: |
bf75be98 |
124 | { |
125 | myParams->SetGenMode (Graphic3d_TOTM_OBJECT, |
126 | Graphic3d_Vec4 (0.0f, 0.0f, 1.0f, 0.0f), |
127 | Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f)); |
7fd59977 |
128 | break; |
129 | } |
bf75be98 |
130 | default: break; |
131 | } |
7fd59977 |
132 | |
bf75be98 |
133 | myPlaneName = thePlane; |
7fd59977 |
134 | } |
135 | |
bf75be98 |
136 | // ======================================================================= |
137 | // function : SetScaleS |
138 | // purpose : |
139 | // ======================================================================= |
140 | void Graphic3d_Texture2Dplane::SetScaleS (const Standard_ShortReal theVal) |
7fd59977 |
141 | { |
bf75be98 |
142 | Graphic3d_Vec2 aScale = myParams->Scale(); |
143 | aScale.x() = theVal; |
144 | myParams->SetScale (aScale); |
7fd59977 |
145 | } |
146 | |
bf75be98 |
147 | // ======================================================================= |
148 | // function : SetScaleT |
149 | // purpose : |
150 | // ======================================================================= |
151 | void Graphic3d_Texture2Dplane::SetScaleT (const Standard_ShortReal theVal) |
7fd59977 |
152 | { |
bf75be98 |
153 | Graphic3d_Vec2 aScale = myParams->Scale(); |
154 | aScale.y() = theVal; |
155 | myParams->SetScale (aScale); |
7fd59977 |
156 | } |
157 | |
bf75be98 |
158 | // ======================================================================= |
159 | // function : SetTranslateS |
160 | // purpose : |
161 | // ======================================================================= |
162 | void Graphic3d_Texture2Dplane::SetTranslateS (const Standard_ShortReal theVal) |
7fd59977 |
163 | { |
bf75be98 |
164 | Graphic3d_Vec2 aVec = myParams->Translation(); |
165 | aVec.x() = theVal; |
166 | myParams->SetTranslation (aVec); |
7fd59977 |
167 | } |
168 | |
bf75be98 |
169 | // ======================================================================= |
170 | // function : SetTranslateT |
171 | // purpose : |
172 | // ======================================================================= |
173 | void Graphic3d_Texture2Dplane::SetTranslateT (const Standard_ShortReal theVal) |
7fd59977 |
174 | { |
bf75be98 |
175 | Graphic3d_Vec2 aVec = myParams->Translation(); |
176 | aVec.y() = theVal; |
177 | myParams->SetTranslation (aVec); |
7fd59977 |
178 | } |
179 | |
bf75be98 |
180 | // ======================================================================= |
181 | // function : SetRotation |
182 | // purpose : |
183 | // ======================================================================= |
184 | void Graphic3d_Texture2Dplane::SetRotation (const Standard_ShortReal theAngleDegrees) |
7fd59977 |
185 | { |
bf75be98 |
186 | myParams->SetRotation (theAngleDegrees); |
7fd59977 |
187 | } |
188 | |
bf75be98 |
189 | // ======================================================================= |
190 | // function : PlaneS |
191 | // purpose : |
192 | // ======================================================================= |
193 | void Graphic3d_Texture2Dplane::PlaneS (Standard_ShortReal& theA, |
194 | Standard_ShortReal& theB, |
195 | Standard_ShortReal& theC, |
196 | Standard_ShortReal& theD) const |
7fd59977 |
197 | { |
bf75be98 |
198 | const Graphic3d_Vec4& aPlaneS = myParams->GenPlaneS(); |
199 | theA = aPlaneS.x(); |
200 | theB = aPlaneS.y(); |
201 | theC = aPlaneS.z(); |
202 | theD = aPlaneS.w(); |
7fd59977 |
203 | } |
204 | |
bf75be98 |
205 | // ======================================================================= |
206 | // function : PlaneT |
207 | // purpose : |
208 | // ======================================================================= |
209 | void Graphic3d_Texture2Dplane::PlaneT (Standard_ShortReal& theA, |
210 | Standard_ShortReal& theB, |
211 | Standard_ShortReal& theC, |
212 | Standard_ShortReal& theD) const |
7fd59977 |
213 | { |
bf75be98 |
214 | const Graphic3d_Vec4& aPlaneT = myParams->GenPlaneT(); |
215 | theA = aPlaneT.x(); |
216 | theB = aPlaneT.y(); |
217 | theC = aPlaneT.z(); |
218 | theD = aPlaneT.w(); |
7fd59977 |
219 | } |
220 | |
bf75be98 |
221 | // ======================================================================= |
222 | // function : TranslateS |
223 | // purpose : |
224 | // ======================================================================= |
225 | void Graphic3d_Texture2Dplane::TranslateS (Standard_ShortReal& theVal) const |
7fd59977 |
226 | { |
bf75be98 |
227 | theVal = myParams->Translation().x(); |
7fd59977 |
228 | } |
229 | |
bf75be98 |
230 | // ======================================================================= |
231 | // function : TranslateT |
232 | // purpose : |
233 | // ======================================================================= |
234 | void Graphic3d_Texture2Dplane::TranslateT (Standard_ShortReal& theVal) const |
7fd59977 |
235 | { |
bf75be98 |
236 | theVal = myParams->Translation().y(); |
7fd59977 |
237 | } |
238 | |
bf75be98 |
239 | // ======================================================================= |
240 | // function : Rotation |
241 | // purpose : |
242 | // ======================================================================= |
243 | void Graphic3d_Texture2Dplane::Rotation (Standard_ShortReal& theVal) const |
7fd59977 |
244 | { |
bf75be98 |
245 | theVal = myParams->Rotation(); |
7fd59977 |
246 | } |
247 | |
bf75be98 |
248 | // ======================================================================= |
249 | // function : Plane |
250 | // purpose : |
251 | // ======================================================================= |
252 | Graphic3d_NameOfTexturePlane Graphic3d_Texture2Dplane::Plane() const |
253 | { |
7fd59977 |
254 | return myPlaneName; |
255 | } |
256 | |
bf75be98 |
257 | // ======================================================================= |
258 | // function : ScaleS |
259 | // purpose : |
260 | // ======================================================================= |
261 | void Graphic3d_Texture2Dplane::ScaleS (Standard_ShortReal& theVal) const |
7fd59977 |
262 | { |
bf75be98 |
263 | theVal = myParams->Scale().x(); |
7fd59977 |
264 | } |
265 | |
bf75be98 |
266 | // ======================================================================= |
267 | // function : ScaleT |
268 | // purpose : |
269 | // ======================================================================= |
270 | void Graphic3d_Texture2Dplane::ScaleT (Standard_ShortReal& theVal) const |
7fd59977 |
271 | { |
bf75be98 |
272 | theVal = myParams->Scale().y(); |
7fd59977 |
273 | } |