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