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 : SetPlaneS
54 // =======================================================================
55 void Graphic3d_Texture2Dplane::SetPlaneS (const Standard_ShortReal theA,
56 const Standard_ShortReal theB,
57 const Standard_ShortReal theC,
58 const Standard_ShortReal theD)
60 const Graphic3d_Vec4 aPlaneS (theA, theB, theC, theD);
61 const Graphic3d_Vec4 aPlaneT = myParams->GenPlaneT();
62 myParams->SetGenMode (Graphic3d_TOTM_OBJECT, aPlaneS, aPlaneT);
63 myPlaneName = Graphic3d_NOTP_UNKNOWN;
66 // =======================================================================
67 // function : SetPlaneT
69 // =======================================================================
70 void Graphic3d_Texture2Dplane::SetPlaneT (const Standard_ShortReal theA,
71 const Standard_ShortReal theB,
72 const Standard_ShortReal theC,
73 const Standard_ShortReal theD)
75 const Graphic3d_Vec4 aPlaneS = myParams->GenPlaneS();
76 const Graphic3d_Vec4 aPlaneT (theA, theB, theC, theD);
77 myParams->SetGenMode (Graphic3d_TOTM_OBJECT, aPlaneS, aPlaneT);
78 myPlaneName = Graphic3d_NOTP_UNKNOWN;
81 // =======================================================================
82 // function : SetPlane
84 // =======================================================================
85 void Graphic3d_Texture2Dplane::SetPlane (const Graphic3d_NameOfTexturePlane thePlane)
89 case Graphic3d_NOTP_XY:
91 myParams->SetGenMode (Graphic3d_TOTM_OBJECT,
92 Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f),
93 Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f));
96 case Graphic3d_NOTP_YZ:
98 myParams->SetGenMode (Graphic3d_TOTM_OBJECT,
99 Graphic3d_Vec4 (0.0f, 1.0f, 0.0f, 0.0f),
100 Graphic3d_Vec4 (0.0f, 0.0f, 1.0f, 0.0f));
103 case Graphic3d_NOTP_ZX:
105 myParams->SetGenMode (Graphic3d_TOTM_OBJECT,
106 Graphic3d_Vec4 (0.0f, 0.0f, 1.0f, 0.0f),
107 Graphic3d_Vec4 (1.0f, 0.0f, 0.0f, 0.0f));
113 myPlaneName = thePlane;
116 // =======================================================================
117 // function : SetScaleS
119 // =======================================================================
120 void Graphic3d_Texture2Dplane::SetScaleS (const Standard_ShortReal theVal)
122 Graphic3d_Vec2 aScale = myParams->Scale();
124 myParams->SetScale (aScale);
127 // =======================================================================
128 // function : SetScaleT
130 // =======================================================================
131 void Graphic3d_Texture2Dplane::SetScaleT (const Standard_ShortReal theVal)
133 Graphic3d_Vec2 aScale = myParams->Scale();
135 myParams->SetScale (aScale);
138 // =======================================================================
139 // function : SetTranslateS
141 // =======================================================================
142 void Graphic3d_Texture2Dplane::SetTranslateS (const Standard_ShortReal theVal)
144 Graphic3d_Vec2 aVec = myParams->Translation();
146 myParams->SetTranslation (aVec);
149 // =======================================================================
150 // function : SetTranslateT
152 // =======================================================================
153 void Graphic3d_Texture2Dplane::SetTranslateT (const Standard_ShortReal theVal)
155 Graphic3d_Vec2 aVec = myParams->Translation();
157 myParams->SetTranslation (aVec);
160 // =======================================================================
161 // function : SetRotation
163 // =======================================================================
164 void Graphic3d_Texture2Dplane::SetRotation (const Standard_ShortReal theAngleDegrees)
166 myParams->SetRotation (theAngleDegrees);
169 // =======================================================================
172 // =======================================================================
173 void Graphic3d_Texture2Dplane::PlaneS (Standard_ShortReal& theA,
174 Standard_ShortReal& theB,
175 Standard_ShortReal& theC,
176 Standard_ShortReal& theD) const
178 const Graphic3d_Vec4& aPlaneS = myParams->GenPlaneS();
185 // =======================================================================
188 // =======================================================================
189 void Graphic3d_Texture2Dplane::PlaneT (Standard_ShortReal& theA,
190 Standard_ShortReal& theB,
191 Standard_ShortReal& theC,
192 Standard_ShortReal& theD) const
194 const Graphic3d_Vec4& aPlaneT = myParams->GenPlaneT();
201 // =======================================================================
202 // function : TranslateS
204 // =======================================================================
205 void Graphic3d_Texture2Dplane::TranslateS (Standard_ShortReal& theVal) const
207 theVal = myParams->Translation().x();
210 // =======================================================================
211 // function : TranslateT
213 // =======================================================================
214 void Graphic3d_Texture2Dplane::TranslateT (Standard_ShortReal& theVal) const
216 theVal = myParams->Translation().y();
219 // =======================================================================
220 // function : Rotation
222 // =======================================================================
223 void Graphic3d_Texture2Dplane::Rotation (Standard_ShortReal& theVal) const
225 theVal = myParams->Rotation();
228 // =======================================================================
231 // =======================================================================
232 Graphic3d_NameOfTexturePlane Graphic3d_Texture2Dplane::Plane() const
237 // =======================================================================
240 // =======================================================================
241 void Graphic3d_Texture2Dplane::ScaleS (Standard_ShortReal& theVal) const
243 theVal = myParams->Scale().x();
246 // =======================================================================
249 // =======================================================================
250 void Graphic3d_Texture2Dplane::ScaleT (Standard_ShortReal& theVal) const
252 theVal = myParams->Scale().y();