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.
18 #include <Graphic3d_Texture2Dplane.hxx>
19 #include <Graphic3d_TextureParams.hxx>
20 #include <Graphic3d_TypeOfTextureMode.hxx>
21 #include <Standard_Type.hxx>
22 #include <TCollection_AsciiString.hxx>
24 IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Texture2Dplane,Graphic3d_Texture2D)
26 // =======================================================================
27 // function : Graphic3d_Texture2Dplane
29 // =======================================================================
30 Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane (const TCollection_AsciiString& theFileName)
31 : Graphic3d_Texture2D (theFileName, Graphic3d_TOT_2D_MIPMAP)
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));
41 // =======================================================================
42 // function : Graphic3d_Texture2Dplane
44 // =======================================================================
45 Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane (const Graphic3d_NameOfTexture2D theNOT)
46 : Graphic3d_Texture2D (theNOT, Graphic3d_TOT_2D_MIPMAP)
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));
56 // =======================================================================
57 // function : Graphic3d_Texture2Dplane
59 // =======================================================================
60 Graphic3d_Texture2Dplane::Graphic3d_Texture2Dplane (const Handle(Image_PixMap)& thePixMap)
61 : Graphic3d_Texture2D (thePixMap, Graphic3d_TOT_2D_MIPMAP)
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));
71 // =======================================================================
72 // function : SetPlaneS
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)
80 const Graphic3d_Vec4 aPlaneS (theA, theB, theC, theD);
81 const Graphic3d_Vec4 aPlaneT = myParams->GenPlaneT();
82 myParams->SetGenMode (Graphic3d_TOTM_OBJECT, aPlaneS, aPlaneT);
83 myPlaneName = Graphic3d_NOTP_UNKNOWN;
86 // =======================================================================
87 // function : SetPlaneT
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)
95 const Graphic3d_Vec4 aPlaneS = myParams->GenPlaneS();
96 const Graphic3d_Vec4 aPlaneT (theA, theB, theC, theD);
97 myParams->SetGenMode (Graphic3d_TOTM_OBJECT, aPlaneS, aPlaneT);
98 myPlaneName = Graphic3d_NOTP_UNKNOWN;
101 // =======================================================================
102 // function : SetPlane
104 // =======================================================================
105 void Graphic3d_Texture2Dplane::SetPlane (const Graphic3d_NameOfTexturePlane thePlane)
109 case Graphic3d_NOTP_XY:
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));
116 case Graphic3d_NOTP_YZ:
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));
123 case Graphic3d_NOTP_ZX:
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));
133 myPlaneName = thePlane;
136 // =======================================================================
137 // function : SetScaleS
139 // =======================================================================
140 void Graphic3d_Texture2Dplane::SetScaleS (const Standard_ShortReal theVal)
142 Graphic3d_Vec2 aScale = myParams->Scale();
144 myParams->SetScale (aScale);
147 // =======================================================================
148 // function : SetScaleT
150 // =======================================================================
151 void Graphic3d_Texture2Dplane::SetScaleT (const Standard_ShortReal theVal)
153 Graphic3d_Vec2 aScale = myParams->Scale();
155 myParams->SetScale (aScale);
158 // =======================================================================
159 // function : SetTranslateS
161 // =======================================================================
162 void Graphic3d_Texture2Dplane::SetTranslateS (const Standard_ShortReal theVal)
164 Graphic3d_Vec2 aVec = myParams->Translation();
166 myParams->SetTranslation (aVec);
169 // =======================================================================
170 // function : SetTranslateT
172 // =======================================================================
173 void Graphic3d_Texture2Dplane::SetTranslateT (const Standard_ShortReal theVal)
175 Graphic3d_Vec2 aVec = myParams->Translation();
177 myParams->SetTranslation (aVec);
180 // =======================================================================
181 // function : SetRotation
183 // =======================================================================
184 void Graphic3d_Texture2Dplane::SetRotation (const Standard_ShortReal theAngleDegrees)
186 myParams->SetRotation (theAngleDegrees);
189 // =======================================================================
192 // =======================================================================
193 void Graphic3d_Texture2Dplane::PlaneS (Standard_ShortReal& theA,
194 Standard_ShortReal& theB,
195 Standard_ShortReal& theC,
196 Standard_ShortReal& theD) const
198 const Graphic3d_Vec4& aPlaneS = myParams->GenPlaneS();
205 // =======================================================================
208 // =======================================================================
209 void Graphic3d_Texture2Dplane::PlaneT (Standard_ShortReal& theA,
210 Standard_ShortReal& theB,
211 Standard_ShortReal& theC,
212 Standard_ShortReal& theD) const
214 const Graphic3d_Vec4& aPlaneT = myParams->GenPlaneT();
221 // =======================================================================
222 // function : TranslateS
224 // =======================================================================
225 void Graphic3d_Texture2Dplane::TranslateS (Standard_ShortReal& theVal) const
227 theVal = myParams->Translation().x();
230 // =======================================================================
231 // function : TranslateT
233 // =======================================================================
234 void Graphic3d_Texture2Dplane::TranslateT (Standard_ShortReal& theVal) const
236 theVal = myParams->Translation().y();
239 // =======================================================================
240 // function : Rotation
242 // =======================================================================
243 void Graphic3d_Texture2Dplane::Rotation (Standard_ShortReal& theVal) const
245 theVal = myParams->Rotation();
248 // =======================================================================
251 // =======================================================================
252 Graphic3d_NameOfTexturePlane Graphic3d_Texture2Dplane::Plane() const
257 // =======================================================================
260 // =======================================================================
261 void Graphic3d_Texture2Dplane::ScaleS (Standard_ShortReal& theVal) const
263 theVal = myParams->Scale().x();
266 // =======================================================================
269 // =======================================================================
270 void Graphic3d_Texture2Dplane::ScaleT (Standard_ShortReal& theVal) const
272 theVal = myParams->Scale().y();