0024855: Revision of parameters of standard materials
[occt.git] / src / Graphic3d / Graphic3d_Texture2Dplane.cxx
1 // Created on: 1997-07-28
2 // Created by: Pierre CHALAMET
3 // Copyright (c) 1997-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 #include <Graphic3d_Texture2Dplane.ixx>
18 #include <Graphic3d_TypeOfTextureMode.hxx>
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 }
35
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 }
50
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
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);
78   myPlaneName = Graphic3d_NOTP_UNKNOWN;
79 }
80
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)
89 {
90   const Graphic3d_Vec4 aPlaneS = myParams->GenPlaneS();
91   const Graphic3d_Vec4 aPlaneT (theA, theB, theC, theD);
92   myParams->SetGenMode (Graphic3d_TOTM_OBJECT, aPlaneS, aPlaneT);
93   myPlaneName = Graphic3d_NOTP_UNKNOWN;
94 }
95
96 // =======================================================================
97 // function : SetPlane
98 // purpose  :
99 // =======================================================================
100 void Graphic3d_Texture2Dplane::SetPlane (const Graphic3d_NameOfTexturePlane thePlane)
101 {
102   switch (thePlane)
103   {
104     case Graphic3d_NOTP_XY:
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));
109       break;
110     }
111     case Graphic3d_NOTP_YZ:
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));
116       break;
117     }
118     case Graphic3d_NOTP_ZX:
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));
123       break;
124     }
125     default: break;
126   }
127
128   myPlaneName = thePlane;
129 }
130
131 // =======================================================================
132 // function : SetScaleS
133 // purpose  :
134 // =======================================================================
135 void Graphic3d_Texture2Dplane::SetScaleS (const Standard_ShortReal theVal)
136 {
137   Graphic3d_Vec2 aScale = myParams->Scale();
138   aScale.x() = theVal;
139   myParams->SetScale (aScale);
140 }
141
142 // =======================================================================
143 // function : SetScaleT
144 // purpose  :
145 // =======================================================================
146 void Graphic3d_Texture2Dplane::SetScaleT (const Standard_ShortReal theVal)
147 {
148   Graphic3d_Vec2 aScale = myParams->Scale();
149   aScale.y() = theVal;
150   myParams->SetScale (aScale);
151 }
152
153 // =======================================================================
154 // function : SetTranslateS
155 // purpose  :
156 // =======================================================================
157 void Graphic3d_Texture2Dplane::SetTranslateS (const Standard_ShortReal theVal)
158 {
159   Graphic3d_Vec2 aVec = myParams->Translation();
160   aVec.x() = theVal;
161   myParams->SetTranslation (aVec);
162 }
163
164 // =======================================================================
165 // function : SetTranslateT
166 // purpose  :
167 // =======================================================================
168 void Graphic3d_Texture2Dplane::SetTranslateT (const Standard_ShortReal theVal)
169 {
170   Graphic3d_Vec2 aVec = myParams->Translation();
171   aVec.y() = theVal;
172   myParams->SetTranslation (aVec);
173 }
174
175 // =======================================================================
176 // function : SetRotation
177 // purpose  :
178 // =======================================================================
179 void Graphic3d_Texture2Dplane::SetRotation (const Standard_ShortReal theAngleDegrees)
180 {
181   myParams->SetRotation (theAngleDegrees);
182 }
183
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
192 {
193   const Graphic3d_Vec4& aPlaneS = myParams->GenPlaneS();
194   theA = aPlaneS.x();
195   theB = aPlaneS.y();
196   theC = aPlaneS.z();
197   theD = aPlaneS.w();
198 }
199
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
208 {
209   const Graphic3d_Vec4& aPlaneT = myParams->GenPlaneT();
210   theA = aPlaneT.x();
211   theB = aPlaneT.y();
212   theC = aPlaneT.z();
213   theD = aPlaneT.w();
214 }
215
216 // =======================================================================
217 // function : TranslateS
218 // purpose  :
219 // =======================================================================
220 void Graphic3d_Texture2Dplane::TranslateS (Standard_ShortReal& theVal) const
221 {
222   theVal = myParams->Translation().x();
223 }
224
225 // =======================================================================
226 // function : TranslateT
227 // purpose  :
228 // =======================================================================
229 void Graphic3d_Texture2Dplane::TranslateT (Standard_ShortReal& theVal) const
230 {
231   theVal = myParams->Translation().y();
232 }
233
234 // =======================================================================
235 // function : Rotation
236 // purpose  :
237 // =======================================================================
238 void Graphic3d_Texture2Dplane::Rotation (Standard_ShortReal& theVal) const
239 {
240   theVal = myParams->Rotation();
241 }
242
243 // =======================================================================
244 // function : Plane
245 // purpose  :
246 // =======================================================================
247 Graphic3d_NameOfTexturePlane Graphic3d_Texture2Dplane::Plane() const
248 {
249   return myPlaneName;
250 }
251
252 // =======================================================================
253 // function : ScaleS
254 // purpose  :
255 // =======================================================================
256 void Graphic3d_Texture2Dplane::ScaleS (Standard_ShortReal& theVal) const
257 {
258   theVal = myParams->Scale().x();
259 }
260
261 // =======================================================================
262 // function : ScaleT
263 // purpose  :
264 // =======================================================================
265 void Graphic3d_Texture2Dplane::ScaleT (Standard_ShortReal& theVal) const
266 {
267   theVal = myParams->Scale().y();
268 }