1 -- Created on: 2001-07-02
2 -- Created by: Mathias BOSSHARD
3 -- Copyright (c) 2001-2012 OPEN CASCADE SAS
5 -- The content of this file is subject to the Open CASCADE Technology Public
6 -- License Version 6.5 (the "License"). You may not use the content of this file
7 -- except in compliance with the License. Please obtain a copy of the License
8 -- at http://www.opencascade.org and read it completely before using this file.
10 -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 -- The Original Code and all software distributed under the License is
14 -- distributed on an "AS IS" basis, without warranty of any kind, and the
15 -- Initial Developer hereby disclaims all such warranties, including without
16 -- limitation, any warranties of merchantability, fitness for a particular
17 -- purpose or non-infringement. Please see the License for the specific terms
18 -- and conditions governing the rights and limitations under the License.
22 class TexturedShape from AIS inherits Shape from AIS
24 ---Purpose: This class allows to map textures on shapes
25 -- Textures are image files.
26 -- The texture itself is parametrized in (0,1)x(0,1).
27 -- Each face of a shape located in
28 -- UV space is provided with these parameters:
29 -- - Umin - starting position in U
30 -- - Umax - ending position in U
31 -- - Vmin - starting position in V
32 -- - Vmax - ending position in V
33 -- Each face is triangulated and a texel is assigned to each
34 -- node. Facets are then filled using a linear interpolation
35 -- of texture between each 'three texels'
37 -- - the number of occurences of the texture on the face
38 -- - the position of the origin of the texture
39 -- - the scale factor of the texture
46 NameOfTexture2D from Graphic3d,
47 AspectFillArea3d from Graphic3d,
48 Texture2Dmanual from Graphic3d,
49 PresentationManager3d from PrsMgr,
50 Presentation from Prs3d,
51 AsciiString from TCollection
55 Create (shap: Shape from TopoDS)
56 returns mutable TexturedShape from AIS;
57 ---Purpose: Initializes the textured shape ashape.
60 ------------------------------------------------------------
61 SetTextureFileName( me: mutable;
62 TextureFileName: AsciiString from TCollection)
66 ---Purpose : Sets the name of the texture file to map. The accepted
67 -- file types are those used in AlienImage with extensions
68 -- such as xwd, bmp, gif, rgb, ras, rs and more.
71 ------------------------------------------------------------
72 SetTextureRepeat( me: mutable;
73 RepeatYN: Boolean from Standard;
74 URepeat: Real from Standard = 1.0;
75 VRepeat: Real from Standard = 1.0)
79 ---Purpose : Sets the number of occurrences of
80 -- the texture on each face. The texture itself is parameterized
81 -- in (0,1) by (0,1) . Each face of the shape to be textured is
82 -- parameterized in UV space (Umin,Umax) by (Vmin,Vmax). If
83 -- RepeatYN is set to false, texture coordinates are clamped in the
84 -- range (0,1)x(0,1) of the face.
87 ------------------------------------------------------------
88 SetTextureOrigin( me: mutable;
89 SetTextureOriginYN: Boolean from Standard;
90 UOrigin: Real from Standard = 0.0;
91 VOrigin: Real from Standard = 0.0)
94 ---Purpose : Use this method to change the origin of the
95 -- texture. The texel (0,0) will be mapped to the
96 -- surfel (UOrigin,VOrigin)
97 ------------------------------------------------------------
101 ------------------------------------------------------------
102 SetTextureScale( me: mutable;
103 SetTextureScaleYN: Boolean from Standard;
104 ScaleU: Real from Standard = 1.0;
105 ScaleV: Real from Standard = 1.0)
109 ---Purpose : Use this method to scale the texture (percent of
111 -- You can specify a scale factor for both U and V.
113 -- example : if you set ScaleU and ScaleV to 0.5 and
114 -- you enable texture repeat, the texture will appear
115 -- twice on the face in each direction.
116 ------------------------------------------------------------
120 ------------------------------------------------------------
121 ShowTriangles( me : mutable;
122 ShowTrianglesYN: Boolean from Standard = Standard_False)
126 ---Purpose : Use this method to show the triangulation of
127 -- the shape. This is not very esthetic but can be
128 -- usefull for debug ...
129 ------------------------------------------------------------
133 ------------------------------------------------------------
134 SetTextureMapOn(me: mutable);
136 ---Purpose : Enables texture mapping
137 ------------------------------------------------------------
141 ------------------------------------------------------------
142 SetTextureMapOff(me: mutable);
144 ---Purpose : Disables texture mapping
145 ------------------------------------------------------------
149 ------------------------------------------------------------
150 EnableTextureModulate(me: mutable);
152 ---Purpose : Enables texture modulation
153 ------------------------------------------------------------
157 ------------------------------------------------------------
158 DisableTextureModulate(me: mutable);
160 ---Purpose : Disables texture modulation
161 ------------------------------------------------------------
165 ------------------------------------------------------------
166 UpdateAttributes(me: mutable);
168 ---Purpose : Use this method to display the textured shape
169 -- without recomputing the whole presentation.
170 -- Use this method when ONLY the texture has been changed.
171 -- ie : myTShape->UpdateAttributes()
173 -- If other parameters (ie: scale factors,
174 -- texture origin, texture repeat ...) have changed,
175 -- the whole presentation has to be recomputed.
176 -- ie : if (myShape->DisplayMode() == 3)
177 -- myAISContext->RecomputePrsOnly(myShape);
180 -- myAISContext->SetDisplayMode(myShape,3,Standard_False);
181 -- myAISContext->Display(myShape, Standard_True);
183 ------------------------------------------------------------
187 ------------------------------------------------------------
188 Compute(me : mutable;
189 aPresentationManager : PresentationManager3d from PrsMgr;
190 aPresentation : mutable Presentation from Prs3d;
191 aMode : Integer from Standard = 0)
192 is redefined virtual protected;
194 ------------------------------------------------------------
196 ------------------------------------------------------------
200 ------------------------------------------------------------
203 TextureMapState(me) returns Boolean from Standard;
206 URepeat(me) returns Real from Standard;
209 TextureRepeat(me) returns Boolean from Standard;
212 Deflection(me) returns Real from Standard;
215 TextureFile(me) returns CString from Standard;
218 VRepeat(me) returns Real from Standard;
221 ShowTriangles(me) returns Boolean from Standard;
224 TextureUOrigin(me) returns Real from Standard;
227 TextureVOrigin(me) returns Real from Standard;
230 TextureScaleU(me) returns Real from Standard;
233 TextureScaleV(me) returns Real from Standard;
236 TextureScale(me) returns Boolean from Standard;
239 TextureOrigin(me) returns Boolean from Standard;
242 TextureModulate(me) returns Boolean from Standard;
246 myPredefTexture : NameOfTexture2D from Graphic3d;
247 myTextureFile : AsciiString from TCollection;
248 DoRepeat : Boolean from Standard;
249 myURepeat : Real from Standard;
250 myVRepeat : Real from Standard;
251 DoMapTexture : Boolean from Standard;
252 DoSetTextureOrigin : Boolean from Standard;
253 myUOrigin : Real from Standard;
254 myVOrigin : Real from Standard;
255 DoSetTextureScale : Boolean from Standard;
256 myScaleU : Real from Standard;
257 myScaleV : Real from Standard;
258 DoShowTriangles : Boolean from Standard;
259 myDeflection : Real from Standard;
260 myAspect : AspectFillArea3d from Graphic3d;
261 mytexture : Texture2Dmanual from Graphic3d;
262 Umin : Real from Standard;
263 Umax : Real from Standard;
264 Vmin : Real from Standard;
265 Vmax : Real from Standard;
266 dUmax : Real from Standard;
267 dVmax : Real from Standard;
268 myModulate : Boolean from Standard;