7fd59977 |
1 | -- File: AIS_TexturedShape.cdl |
2 | -- Created: Mon Jul 2 11:32:59 2001 |
3 | -- Author: Mathias BOSSHARD |
4 | -- <mbd@pomalox.paris1.matra-dtv.fr> |
5 | ---Copyright: Matra Datavision 2001 |
6 | |
7 | |
8 | class TexturedShape from AIS inherits Shape from AIS |
9 | |
10 | ---Purpose: This class allows to map textures on shapes |
11 | -- Textures are image files. |
12 | -- The texture itself is parametrized in (0,1)x(0,1). |
13 | -- Each face of a shape located in |
14 | -- UV space is provided with these parameters: |
15 | -- - Umin - starting position in U |
16 | -- - Umax - ending position in U |
17 | -- - Vmin - starting position in V |
18 | -- - Vmax - ending position in V |
19 | -- Each face is triangulated and a texel is assigned to each |
20 | -- node. Facets are then filled using a linear interpolation |
21 | -- of texture between each 'three texels' |
22 | -- User can act on : |
23 | -- - the number of occurences of the texture on the face |
24 | -- - the position of the origin of the texture |
25 | -- - the scale factor of the texture |
26 | |
27 | |
28 | |
29 | uses |
30 | Pnt from gp, |
31 | Shape from TopoDS, |
32 | NameOfTexture2D from Graphic3d, |
33 | AspectFillArea3d from Graphic3d, |
34 | Texture2Dmanual from Graphic3d, |
35 | PresentationManager3d from PrsMgr, |
36 | Presentation from Prs3d, |
37 | AsciiString from TCollection |
38 | |
39 | is |
40 | |
41 | Create (shap: Shape from TopoDS) |
42 | returns mutable TexturedShape from AIS; |
43 | ---Purpose: Initializes the textured shape ashape. |
44 | |
45 | |
46 | ------------------------------------------------------------ |
47 | SetTextureFileName( me: mutable; |
48 | TextureFileName: AsciiString from TCollection) |
49 | is virtual; |
50 | |
51 | |
52 | ---Purpose : Sets the name of the texture file to map. The accepted |
53 | -- file types are those used in AlienImage with extensions |
54 | -- such as xwd, bmp, gif, rgb, ras, rs and more. |
55 | |
56 | |
57 | ------------------------------------------------------------ |
58 | SetTextureRepeat( me: mutable; |
59 | RepeatYN: Boolean from Standard; |
60 | URepeat: Real from Standard = 1.0; |
61 | VRepeat: Real from Standard = 1.0) |
62 | is virtual; |
63 | |
64 | |
65 | ---Purpose : Sets the number of occurrences of |
66 | -- the texture on each face. The texture itself is parameterized |
67 | -- in (0,1) by (0,1) . Each face of the shape to be textured is |
68 | -- parameterized in UV space (Umin,Umax) by (Vmin,Vmax). If |
69 | -- RepeatYN is set to false, texture coordinates are clamped in the |
70 | -- range (0,1)x(0,1) of the face. |
71 | |
72 | |
73 | ------------------------------------------------------------ |
74 | SetTextureOrigin( me: mutable; |
75 | SetTextureOriginYN: Boolean from Standard; |
76 | UOrigin: Real from Standard = 0.0; |
77 | VOrigin: Real from Standard = 0.0) |
78 | is virtual; |
79 | |
80 | ---Purpose : Use this method to change the origin of the |
81 | -- texture. The texel (0,0) will be mapped to the |
82 | -- surfel (UOrigin,VOrigin) |
83 | ------------------------------------------------------------ |
84 | |
85 | |
86 | |
87 | ------------------------------------------------------------ |
88 | SetTextureScale( me: mutable; |
89 | SetTextureScaleYN: Boolean from Standard; |
90 | ScaleU: Real from Standard = 1.0; |
91 | ScaleV: Real from Standard = 1.0) |
92 | is virtual; |
93 | |
94 | |
95 | ---Purpose : Use this method to scale the texture (percent of |
96 | -- the face). |
97 | -- You can specify a scale factor for both U and V. |
98 | -- |
99 | -- example : if you set ScaleU and ScaleV to 0.5 and |
100 | -- you enable texture repeat, the texture will appear |
101 | -- twice on the face in each direction. |
102 | ------------------------------------------------------------ |
103 | |
104 | |
105 | |
106 | ------------------------------------------------------------ |
107 | ShowTriangles( me : mutable; |
108 | ShowTrianglesYN: Boolean from Standard = Standard_False) |
109 | is virtual; |
110 | |
111 | |
112 | ---Purpose : Use this method to show the triangulation of |
113 | -- the shape. This is not very esthetic but can be |
114 | -- usefull for debug ... |
115 | ------------------------------------------------------------ |
116 | |
117 | |
118 | |
119 | ------------------------------------------------------------ |
120 | SetTextureMapOn(me: mutable); |
121 | |
122 | ---Purpose : Enables texture mapping |
123 | ------------------------------------------------------------ |
124 | |
125 | |
126 | |
127 | ------------------------------------------------------------ |
128 | SetTextureMapOff(me: mutable); |
129 | |
130 | ---Purpose : Disables texture mapping |
131 | ------------------------------------------------------------ |
132 | |
133 | |
134 | |
135 | ------------------------------------------------------------ |
136 | EnableTextureModulate(me: mutable); |
137 | |
138 | ---Purpose : Enables texture modulation |
139 | ------------------------------------------------------------ |
140 | |
141 | |
142 | |
143 | ------------------------------------------------------------ |
144 | DisableTextureModulate(me: mutable); |
145 | |
146 | ---Purpose : Disables texture modulation |
147 | ------------------------------------------------------------ |
148 | |
149 | |
150 | |
151 | ------------------------------------------------------------ |
152 | UpdateAttributes(me: mutable); |
153 | |
154 | ---Purpose : Use this method to display the textured shape |
155 | -- without recomputing the whole presentation. |
156 | -- Use this method when ONLY the texture has been changed. |
157 | -- ie : myTShape->UpdateAttributes() |
158 | -- |
159 | -- If other parameters (ie: scale factors, |
160 | -- texture origin, texture repeat ...) have changed, |
161 | -- the whole presentation has to be recomputed. |
162 | -- ie : if (myShape->DisplayMode() == 3) |
163 | -- myAISContext->RecomputePrsOnly(myShape); |
164 | -- else |
165 | -- { |
166 | -- myAISContext->SetDisplayMode(myShape,3,Standard_False); |
167 | -- myAISContext->Display(myShape, Standard_True); |
168 | -- } |
169 | ------------------------------------------------------------ |
170 | |
171 | |
172 | |
173 | ------------------------------------------------------------ |
174 | Compute(me : mutable; |
175 | aPresentationManager : PresentationManager3d from PrsMgr; |
176 | aPresentation : mutable Presentation from Prs3d; |
177 | aMode : Integer from Standard = 0) |
178 | is redefined virtual protected; |
179 | |
180 | ------------------------------------------------------------ |
181 | |
182 | |
183 | |
184 | ------------------------------------------------------------ |
185 | TriangleIsValid(me; |
186 | P1: Pnt from gp; |
187 | P2: Pnt from gp; |
188 | P3: Pnt from gp) |
189 | returns Boolean from Standard is private; |
190 | |
191 | ------------------------------------------------------------ |
192 | |
193 | |
194 | |
195 | ------------------------------------------------------------ |
196 | -- |
197 | -- QUERY METHODS |
198 | -- |
199 | ------------------------------------------------------------ |
200 | |
201 | |
202 | TextureMapState(me) returns Boolean from Standard; |
203 | |
204 | |
205 | URepeat(me) returns Real from Standard; |
206 | |
207 | |
208 | TextureRepeat(me) returns Boolean from Standard; |
209 | |
210 | |
211 | Deflection(me) returns Real from Standard; |
212 | |
213 | |
214 | TextureFile(me) returns CString from Standard; |
215 | |
216 | |
217 | VRepeat(me) returns Real from Standard; |
218 | |
219 | |
220 | ShowTriangles(me) returns Boolean from Standard; |
221 | |
222 | |
223 | TextureUOrigin(me) returns Real from Standard; |
224 | |
225 | |
226 | TextureVOrigin(me) returns Real from Standard; |
227 | |
228 | |
229 | TextureScaleU(me) returns Real from Standard; |
230 | |
231 | |
232 | TextureScaleV(me) returns Real from Standard; |
233 | |
234 | |
235 | TextureScale(me) returns Boolean from Standard; |
236 | |
237 | |
238 | TextureOrigin(me) returns Boolean from Standard; |
239 | |
240 | |
241 | TextureModulate(me) returns Boolean from Standard; |
242 | |
243 | |
244 | fields |
245 | myPredefTexture : NameOfTexture2D from Graphic3d; |
246 | myTextureFile : AsciiString from TCollection; |
247 | DoRepeat : Boolean from Standard; |
248 | myURepeat : Real from Standard; |
249 | myVRepeat : Real from Standard; |
250 | DoMapTexture : Boolean from Standard; |
251 | DoSetTextureOrigin : Boolean from Standard; |
252 | myUOrigin : Real from Standard; |
253 | myVOrigin : Real from Standard; |
254 | DoSetTextureScale : Boolean from Standard; |
255 | myScaleU : Real from Standard; |
256 | myScaleV : Real from Standard; |
257 | DoShowTriangles : Boolean from Standard; |
258 | myDeflection : Real from Standard; |
259 | myAspect : AspectFillArea3d from Graphic3d; |
260 | mytexture : Texture2Dmanual from Graphic3d; |
261 | Umin : Real from Standard; |
262 | Umax : Real from Standard; |
263 | Vmin : Real from Standard; |
264 | Vmax : Real from Standard; |
265 | dUmax : Real from Standard; |
266 | dVmax : Real from Standard; |
267 | myModulate : Boolean from Standard; |
268 | end TexturedShape; |