1 -- Created on: 2001-07-02
2 -- Created by: Mathias BOSSHARD
3 -- Copyright (c) 2001-2014 OPEN CASCADE SAS
5 -- This file is part of Open CASCADE Technology software library.
7 -- This library is free software; you can redistribute it and/or modify it under
8 -- the terms of the GNU Lesser General Public License version 2.1 as published
9 -- by the Free Software Foundation, with special exception defined in the file
10 -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 -- distribution for complete text of the license and disclaimer of any warranty.
13 -- Alternatively, this file may be used under the terms of Open CASCADE
14 -- commercial license or contractual agreement.
16 class TexturedShape from AIS inherits Shape from AIS
18 ---Purpose: This class allows to map textures on shapes
19 -- Textures are image files.
20 -- The texture itself is parametrized in (0,1)x(0,1).
21 -- Each face of a shape located in
22 -- UV space is provided with these parameters:
23 -- - Umin - starting position in U
24 -- - Umax - ending position in U
25 -- - Vmin - starting position in V
26 -- - Vmax - ending position in V
27 -- Each face is triangulated and a texel is assigned to each
28 -- node. Facets are then filled using a linear interpolation
29 -- of texture between each 'three texels'
31 -- - the number of occurences of the texture on the face
32 -- - the position of the origin of the texture
33 -- - the scale factor of the texture
40 NameOfTexture2D from Graphic3d,
41 AspectFillArea3d from Graphic3d,
42 Texture2Dmanual from Graphic3d,
43 PresentationManager3d from PrsMgr,
44 Presentation from Prs3d,
45 AsciiString from TCollection
49 Create (shap: Shape from TopoDS)
50 returns mutable TexturedShape from AIS;
51 ---Purpose: Initializes the textured shape ashape.
54 ------------------------------------------------------------
55 SetTextureFileName( me: mutable;
56 TextureFileName: AsciiString from TCollection)
58 ---Purpose : Sets the name of the texture file to map. The accepted
59 -- file types are those used in Image_AlienPixMap with extensions
60 -- such as rgb, png, jpg and more.
63 ------------------------------------------------------------
64 SetTextureRepeat( me: mutable;
65 RepeatYN: Boolean from Standard;
66 URepeat: Real from Standard = 1.0;
67 VRepeat: Real from Standard = 1.0)
71 ---Purpose : Sets the number of occurrences of
72 -- the texture on each face. The texture itself is parameterized
73 -- in (0,1) by (0,1) . Each face of the shape to be textured is
74 -- parameterized in UV space (Umin,Umax) by (Vmin,Vmax). If
75 -- RepeatYN is set to false, texture coordinates are clamped in the
76 -- range (0,1)x(0,1) of the face.
79 ------------------------------------------------------------
80 SetTextureOrigin( me: mutable;
81 SetTextureOriginYN: Boolean from Standard;
82 UOrigin: Real from Standard = 0.0;
83 VOrigin: Real from Standard = 0.0)
86 ---Purpose : Use this method to change the origin of the
87 -- texture. The texel (0,0) will be mapped to the
88 -- surfel (UOrigin,VOrigin)
89 ------------------------------------------------------------
93 ------------------------------------------------------------
94 SetTextureScale( me: mutable;
95 SetTextureScaleYN: Boolean from Standard;
96 ScaleU: Real from Standard = 1.0;
97 ScaleV: Real from Standard = 1.0)
101 ---Purpose : Use this method to scale the texture (percent of
103 -- You can specify a scale factor for both U and V.
105 -- example : if you set ScaleU and ScaleV to 0.5 and
106 -- you enable texture repeat, the texture will appear
107 -- twice on the face in each direction.
108 ------------------------------------------------------------
112 ------------------------------------------------------------
113 ShowTriangles( me : mutable;
114 ShowTrianglesYN: Boolean from Standard = Standard_False)
118 ---Purpose : Use this method to show the triangulation of
119 -- the shape. This is not very esthetic but can be
120 -- usefull for debug ...
121 ------------------------------------------------------------
125 ------------------------------------------------------------
126 SetTextureMapOn(me: mutable);
128 ---Purpose : Enables texture mapping
129 ------------------------------------------------------------
133 ------------------------------------------------------------
134 SetTextureMapOff(me: mutable);
136 ---Purpose : Disables texture mapping
137 ------------------------------------------------------------
141 ------------------------------------------------------------
142 EnableTextureModulate(me: mutable);
144 ---Purpose : Enables texture modulation
145 ------------------------------------------------------------
149 ------------------------------------------------------------
150 DisableTextureModulate(me: mutable);
152 ---Purpose : Disables texture modulation
153 ------------------------------------------------------------
157 ------------------------------------------------------------
158 UpdateAttributes(me: mutable);
160 ---Purpose : Use this method to display the textured shape
161 -- without recomputing the whole presentation.
162 -- Use this method when ONLY the texture has been changed.
163 -- ie : myTShape->UpdateAttributes()
165 -- If other parameters (ie: scale factors,
166 -- texture origin, texture repeat ...) have changed,
167 -- the whole presentation has to be recomputed.
168 -- ie : if (myShape->DisplayMode() == 3)
169 -- myAISContext->RecomputePrsOnly(myShape);
172 -- myAISContext->SetDisplayMode(myShape,3,Standard_False);
173 -- myAISContext->Display(myShape, Standard_True);
175 ------------------------------------------------------------
179 ------------------------------------------------------------
180 Compute(me : mutable;
181 aPresentationManager : PresentationManager3d from PrsMgr;
182 aPresentation : mutable Presentation from Prs3d;
183 aMode : Integer from Standard = 0)
184 is redefined virtual protected;
186 ------------------------------------------------------------
188 ------------------------------------------------------------
192 ------------------------------------------------------------
195 TextureMapState(me) returns Boolean from Standard;
198 URepeat(me) returns Real from Standard;
201 TextureRepeat(me) returns Boolean from Standard;
204 Deflection(me) returns Real from Standard;
207 TextureFile(me) returns CString from Standard;
210 VRepeat(me) returns Real from Standard;
213 ShowTriangles(me) returns Boolean from Standard;
216 TextureUOrigin(me) returns Real from Standard;
219 TextureVOrigin(me) returns Real from Standard;
222 TextureScaleU(me) returns Real from Standard;
225 TextureScaleV(me) returns Real from Standard;
228 TextureScale(me) returns Boolean from Standard;
231 TextureOrigin(me) returns Boolean from Standard;
234 TextureModulate(me) returns Boolean from Standard;
238 myPredefTexture : NameOfTexture2D from Graphic3d;
239 myTextureFile : AsciiString from TCollection;
240 DoRepeat : Boolean from Standard;
241 myURepeat : Real from Standard;
242 myVRepeat : Real from Standard;
243 DoMapTexture : Boolean from Standard;
244 DoSetTextureOrigin : Boolean from Standard;
245 myUOrigin : Real from Standard;
246 myVOrigin : Real from Standard;
247 DoSetTextureScale : Boolean from Standard;
248 myScaleU : Real from Standard;
249 myScaleV : Real from Standard;
250 DoShowTriangles : Boolean from Standard;
251 myDeflection : Real from Standard;
252 myAspect : AspectFillArea3d from Graphic3d;
253 mytexture : Texture2Dmanual from Graphic3d;
254 myModulate : Boolean from Standard;