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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <Graphic3d_Texture2Dplane.ixx>
18 #include <Graphic3d_TypeOfTextureMode.hxx>
19 #include <Graphic3d_TextureParams.hxx>
21 // =======================================================================
22 // function : Graphic3d_Texture2Dplane
24 // =======================================================================
25 Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane (const TCollection_AsciiString& theFileName)
26 : Graphic3d_Texture2D (theFileName, Graphic3d_TOT_2D_MIPMAP)
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));
36 // =======================================================================
37 // function : Graphic3d_Texture2Dplane
39 // =======================================================================
40 Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane (const Graphic3d_NameOfTexture2D theNOT)
41 : Graphic3d_Texture2D (theNOT, Graphic3d_TOT_2D_MIPMAP)
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));
51 // =======================================================================
52 // function : Graphic3d_Texture2Dplane
54 // =======================================================================
55 Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane (const Handle(Image_PixMap)& thePixMap)
56 : Graphic3d_Texture2D (thePixMap, Graphic3d_TOT_2D_MIPMAP)
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));
66 // =======================================================================
67 // function : SetPlaneS
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)
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;
81 // =======================================================================
82 // function : SetPlaneT
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)
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;
96 // =======================================================================
97 // function : SetPlane
99 // =======================================================================
100 void Graphic3d_Texture2Dplane::SetPlane (const Graphic3d_NameOfTexturePlane thePlane)
104 case Graphic3d_NOTP_XY:
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));
111 case Graphic3d_NOTP_YZ:
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));
118 case Graphic3d_NOTP_ZX:
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));
128 myPlaneName = thePlane;
131 // =======================================================================
132 // function : SetScaleS
134 // =======================================================================
135 void Graphic3d_Texture2Dplane::SetScaleS (const Standard_ShortReal theVal)
137 Graphic3d_Vec2 aScale = myParams->Scale();
139 myParams->SetScale (aScale);
142 // =======================================================================
143 // function : SetScaleT
145 // =======================================================================
146 void Graphic3d_Texture2Dplane::SetScaleT (const Standard_ShortReal theVal)
148 Graphic3d_Vec2 aScale = myParams->Scale();
150 myParams->SetScale (aScale);
153 // =======================================================================
154 // function : SetTranslateS
156 // =======================================================================
157 void Graphic3d_Texture2Dplane::SetTranslateS (const Standard_ShortReal theVal)
159 Graphic3d_Vec2 aVec = myParams->Translation();
161 myParams->SetTranslation (aVec);
164 // =======================================================================
165 // function : SetTranslateT
167 // =======================================================================
168 void Graphic3d_Texture2Dplane::SetTranslateT (const Standard_ShortReal theVal)
170 Graphic3d_Vec2 aVec = myParams->Translation();
172 myParams->SetTranslation (aVec);
175 // =======================================================================
176 // function : SetRotation
178 // =======================================================================
179 void Graphic3d_Texture2Dplane::SetRotation (const Standard_ShortReal theAngleDegrees)
181 myParams->SetRotation (theAngleDegrees);
184 // =======================================================================
187 // =======================================================================
188 void Graphic3d_Texture2Dplane::PlaneS (Standard_ShortReal& theA,
189 Standard_ShortReal& theB,
190 Standard_ShortReal& theC,
191 Standard_ShortReal& theD) const
193 const Graphic3d_Vec4& aPlaneS = myParams->GenPlaneS();
200 // =======================================================================
203 // =======================================================================
204 void Graphic3d_Texture2Dplane::PlaneT (Standard_ShortReal& theA,
205 Standard_ShortReal& theB,
206 Standard_ShortReal& theC,
207 Standard_ShortReal& theD) const
209 const Graphic3d_Vec4& aPlaneT = myParams->GenPlaneT();
216 // =======================================================================
217 // function : TranslateS
219 // =======================================================================
220 void Graphic3d_Texture2Dplane::TranslateS (Standard_ShortReal& theVal) const
222 theVal = myParams->Translation().x();
225 // =======================================================================
226 // function : TranslateT
228 // =======================================================================
229 void Graphic3d_Texture2Dplane::TranslateT (Standard_ShortReal& theVal) const
231 theVal = myParams->Translation().y();
234 // =======================================================================
235 // function : Rotation
237 // =======================================================================
238 void Graphic3d_Texture2Dplane::Rotation (Standard_ShortReal& theVal) const
240 theVal = myParams->Rotation();
243 // =======================================================================
246 // =======================================================================
247 Graphic3d_NameOfTexturePlane Graphic3d_Texture2Dplane::Plane() const
252 // =======================================================================
255 // =======================================================================
256 void Graphic3d_Texture2Dplane::ScaleS (Standard_ShortReal& theVal) const
258 theVal = myParams->Scale().x();
261 // =======================================================================
264 // =======================================================================
265 void Graphic3d_Texture2Dplane::ScaleT (Standard_ShortReal& theVal) const
267 theVal = myParams->Scale().y();