Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/pqt/autorib/rib/RIBGlobals.java


1   //AutoRIB
2   // Copyright © 1998 - 2002, P W Quint
3   //
4   // Contact: autorib00@aol.com
5   //
6   // This library is free software; you can redistribute it and/or
7   // modify it under the terms of the GNU General Public
8   // License as published by the Free Software Foundation; either
9   // version 2 of the License, or (at your option) any later version.
10  //
11  // This library is distributed in the hope that it will be useful,
12  // but WITHOUT ANY WARRANTY; without even the implied warranty of
13  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  // General Public License for more details.
15  //
16  // You should have received a copy of the GNU General Public
17  // License along with this library; if not, write to the Free Software
18  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  
20  package org.pqt.autorib.rib;
21  
22  import java.util.Vector;
23  import java.util.HashMap;
24  
25  
26  /**This class contains various globally needed definitions used to parse RIB
27   * in particular various arrays define valid requests, and identify which of
28   * these are options, attributes transforms and objects. To ensure AutoRIB
29   * recognises a new RIB request you must add it to the requests array. You
30   * must also define an integer constant corresponding to its position in the
31   * array. You should also include it in the arrays options, attributes, objects
32   * depending on which category the request is. Doing this will ensure
33   * that the request is recognised. For more sophisticated handling you will need
34   * to create a subclass of RIBRequest and edit the RIBReadRequest to ensure it is
35   * recognised. Note that should you need to define a new transform you will need
36   * to rewrite RIBWReader and Matrix to account for it. 
37   */
38  public class RIBGlobals extends Object {
39      
40      public final static String requests[] =
41      { "AreaLightSource",
42        "Atmosphere",
43        "Attribute",
44        "AttributeBegin",
45        "AttributeEnd",
46        "Basis",
47        "Bound",
48        "Clipping",
49        "Color",
50        "ColorSamples",
51        "ConcatTransform",
52        "Cone",
53        "CoordinateSystem",
54        "CropWindow",
55        "Cylinder",
56        "Declare",
57        "Deformation",
58        "DepthOfField",
59        "Detail",
60        "DetailRange",
61        "Disk",
62        "Displacement",
63        "Display",
64        "Exposure",
65        "Exterior",
66        "Format",
67        "FrameAspectRatio",
68        "FrameBegin",
69        "FrameEnd",
70        "GeneralPolygon",
71        "GeometricApproximation",
72        "Hider",
73        "Hyperboloid",
74        "Identity",
75        "Illuminate",
76        "Imager",
77        "Interior",
78        "LightSource",
79        "MakeBump",
80        "MakeCubeFaceEnvironment",
81        "MakeLatLongEnvironment",
82        "MakeShadow",
83        "MakeTexture",
84        "Matte",
85        "MotionBegin",
86        "MotionEnd",
87        "NuPatch",
88        "ObjectBegin",
89        "ObjectEnd",
90        "ObjectInstance",
91        "Opacity",
92        "Option",
93        "Orientation",
94        "Paraboloid",
95        "Patch",
96        "PatchMesh",
97        "Perspective",
98        "PixelFilter",
99        "PixelSamples",
100       "PixelVariance",
101       "PointsGeneralPolygons",
102       "PointsPolygons",
103       "Polygon",
104       "Procedural",
105       "Projection",
106       "Quantize",
107       "RelativeDetail",
108       "ReverseOrientation",
109       "Rotate",
110       "ScreenWindow",
111       "ShadingInterpolation",
112       "ShadingRate",
113       "Shutter",
114       "Sides",
115       "SolidBegin",
116       "SolidEnd",
117       "Sphere",
118       "Surface",
119       "TextureCoordinates",
120       "Torus",
121       "Transform",
122       "TransformPoints",
123       "Translate",
124       "TrimCurve",
125       "WorldBegin",
126       "WorldEnd",
127       "ReadArchive",
128       "CoordSysTransform",
129       "Curves",
130       "Points",
131       "SubdivisionMesh",
132       "Blobby",
133       "version",
134       "Scale",
135       "Skew",
136       "TransformBegin",
137       "TransformEnd",
138       "ClippingPlane",
139       "DelayedReadArchive"
140     };
141     
142     
143     public static final int AREALIGHTSOURCE= 0;
144     public static final int ATMOSPHERE = 1;
145     public static final int ATTRIBUTE = 2;
146     public static final int ATTRIBUTEBEGIN = 3;
147     public static final int ATTRIBUTEEND = 4;
148     public static final int BASIS = 5;
149     public static final int BOUND = 6;
150     public static final int CLIPPING= 7;
151     public static final int COLOR = 8;
152     public static final int COLORSAMPLES = 9;
153     public static final int CONCATTRANSFORM = 10;
154     public static final int CONE = 11;
155     public static final int COORDINATESYSTEM = 12;
156     public static final int CROPWINDOW = 13;
157     public static final int CYLINDER = 14;
158     public static final int DECLARE = 15;
159     public static final int DEFORMATION = 16;
160     public static final int DEPTHOFFIELD = 17;
161     public static final int DETAIL = 18;
162     public static final int DETAILRANGE = 19;
163     public static final int DISK = 20;
164     public static final int DISPLACEMENT = 21;
165     public static final int DISPLAY = 22;
166     public static final int EXPOSURE = 23;
167     public static final int EXTERIOR = 24;
168     public static final int FORMAT = 25;
169     public static final int FRAMEASPECTRATIO = 26;
170     public static final int FRAMEBEGIN = 27;
171     public static final int FRAMEEND = 28;
172     public static final int GENERALPOLYGON = 29;
173     public static final int GEOMETRICAPPROXIMATION = 30;
174     public static final int HIDER = 31;
175     public static final int HYPERBOLOID = 32;
176     public static final int IDENTITY = 33;
177     public static final int ILLUMINATE = 34;
178     public static final int IMAGER = 35;
179     public static final int INTERIOR = 36;
180     public static final int LIGHTSOURCE = 37;
181     public static final int MAKEBUMP = 38;
182     public static final int MAKECUBEFACEENVIRONMENT = 39;
183     public static final int MAKELATLONGENVIRONMENT = 40;
184     public static final int MAKESHADOW = 41;
185     public static final int MAKETEXTURE = 42;
186     public static final int MATTE = 43;
187     public static final int MOTIONBEGIN = 44;
188     public static final int MOTIONEND = 45;
189     public static final int NUPATCH = 46;
190     public static final int OBJECTBEGIN = 47;
191     public static final int OBJECTEND = 48;
192     public static final int OBJECTINSTANCE = 49;
193     public static final int OPACITY = 50;
194     public static final int OPTION = 51;
195     public static final int ORIENTATION = 52;
196     public static final int PARABOLOID = 53;
197     public static final int PATCH = 54;
198     public static final int PATCHMESH = 55;
199     public static final int PERSPECTIVE = 56;
200     public static final int PIXELFILTER = 57;
201     public static final int PIXELSAMPLES = 58;
202     public static final int PIXELVARIANCE = 59;
203     public static final int POINTSGENERALPOLYGONS = 60;
204     public static final int POINTSPOLYGONS = 61;
205     public static final int POLYGON = 62;
206     public static final int PROCEDURAL = 63;
207     public static final int PROJECTION = 64;
208     public static final int QUANTIZE = 65;
209     public static final int RELATIVEDETAIL = 66;
210     public static final int REVERSEORIENTATION = 67;
211     public static final int ROTATE = 68;
212     public static final int SCREENWINDOW = 69;
213     public static final int SHADINGINTERPOLATION = 70;
214     public static final int SHADINGRATE = 71;
215     public static final int SHUTTER = 72;
216     public static final int SIDES = 73;
217     public static final int SOLIDBEGIN = 74;
218     public static final int SOLIDEND = 75;
219     public static final int SPHERE = 76;
220     public static final int SURFACE = 77;
221     public static final int TEXTURECOORDINATES = 78;
222     public static final int TORUS = 79;
223     public static final int TRANSFORM = 80;
224     public static final int TRANSFORMPOINTS = 81;
225     public static final int TRANSLATE = 82;
226     public static final int TRIMCURVE = 83;
227     public static final int WORLDBEGIN = 84;
228     public static final int WORLDEND = 85;
229     public static final int READARCHIVE = 86;
230     public static final int COORDSYSTRANSFORM = 87;
231     public static final int CURVES = 88;
232     public static final int POINTS = 89;
233     public static final int SUBDIVISIONMESH = 90;
234     public static final int BLOBBY = 91;
235     public static final int VERSION = 92;
236     public static final int SCALE = 93;
237     public static final int SKEW = 94;
238     public static final int TRANSFORMBEGIN = 95;
239     public static final int TRANSFORMEND = 96;
240     public static final int CLIPPINGPLANE = 97;
241     public static final int DELAYEDREADARCHIVE = 98;
242     
243     /** contains an entry for every option*/
244     public static final int[] options = {
245         CLIPPING,
246         CROPWINDOW,
247         DEPTHOFFIELD,
248         DISPLAY,
249         IMAGER,
250         EXPOSURE,
251         FORMAT,
252         FRAMEASPECTRATIO,
253         HIDER,
254         PIXELFILTER,
255         PIXELSAMPLES,
256         PIXELVARIANCE,
257         PROJECTION,
258         QUANTIZE,
259         RELATIVEDETAIL,
260         SCREENWINDOW,
261         SHUTTER
262     };
263     
264     /** This contains an entry for every attribute*/
265     public static int attributes[] = {
266         ATMOSPHERE,
267         COLOR,
268         OPACITY,
269         SURFACE,
270         INTERIOR,
271         EXTERIOR,
272         DISPLACEMENT,
273         TEXTURECOORDINATES,
274         SHADINGRATE,
275         SHADINGINTERPOLATION,
276         MATTE,
277         BOUND,
278         DETAIL,
279         DETAILRANGE,
280         GEOMETRICAPPROXIMATION,
281         ORIENTATION,
282         REVERSEORIENTATION,
283         SIDES,
284         BASIS,
285         TRIMCURVE,
286         DECLARE,
287         ATTRIBUTE
288     };
289     
290     /** contains those requests that need not be output in shadow maps*/
291     public static int excludeinShadows[] = {
292         SURFACE,
293         LIGHTSOURCE,
294         ATMOSPHERE,
295         INTERIOR,
296         EXTERIOR
297     };
298     
299     /** contains all valid transforms*/
300     public static int transforms[] = {
301         IDENTITY,
302         ROTATE,
303         TRANSFORM,
304         CONCATTRANSFORM,
305         PERSPECTIVE,
306         TRANSLATE,
307         SCALE,
308         SKEW,
309         DEFORMATION,
310         COORDINATESYSTEM,
311         TRANSFORMPOINTS,
312         TRANSFORMBEGIN,
313         TRANSFORMEND
314     };
315     
316     /** This contains all items that are primitives*/
317     public static int objects[] = {
318         OBJECTINSTANCE,
319         SPHERE,
320         PARABOLOID,
321         CONE,
322         CYLINDER,
323         CURVES,
324         DISK,
325         GENERALPOLYGON,
326         HYPERBOLOID,
327         NUPATCH,
328         PATCH,
329         PATCHMESH,
330         POINTS,
331         POINTSGENERALPOLYGONS,
332         POINTSPOLYGONS,
333         POLYGON,
334         TORUS,
335         BLOBBY,
336         SUBDIVISIONMESH
337     };
338     
339     /** used to spead searching requests array*/
340     public static HashMap map = new HashMap(requests.length + 1, 1);
341     
342     static {//create the map used to translate RIB calls into tokens
343         for (int i = 0; i < requests.length; i++)
344             map.put(requests[i],new Integer(i));
345     }
346     
347     
348     /* various debugging flags*/
349     
350     /** a debug flag - if true substitute bounding boxes for primitives */
351     public static final boolean DEBUGBOUNDINGBOX = false;
352     /** a debug flag - if true substitute bounding boxes at the object level*/
353     public static final boolean DEBUGOBJECTBOUNDINGBOX = false;
354     /** a debugflag - if true write object bounding boxes in world space*/
355     public static final boolean DEBUGOBJECTBOUNDINGWORLD = false;
356     
357     /** This function creates a boolean array with one entry for every valid
358      * RIB request. The array is populated by looking at the parameter fill. For
359      * each request in fill the corresponding member of the boolean array is set
360      * to the value of setTo, other members of the boolean array are set to !setTo.
361      * @param fill an array of RIB Request IDs
362      * @param setTo the value to set in the result.
363      * @return a boolean array populated as described above*/
364     public static boolean[] createFilter(int[] fill, boolean setTo) {
365         boolean result[] = new boolean[requests.length];
366         for (int i = 0; i < result.length; i++)
367             result[i] = !setTo;
368         for (int i = 0; i < fill.length; i++)
369             if ((fill[i] > 0) && (fill[i] < result.length))
370                 result[fill[i]] = setTo;
371         return result;
372     }
373     
374     /** Check to see if a particular requestID is in an array
375      *@param requestID the request to check
376      *@param list the array to check it against
377      *@return true if the item is in the array*/
378     public static boolean arraySearch(int requestID, int[] list ) {
379         for (int i = 0; i < list.length; i++)
380             if (list[i] == requestID)
381                 return true;
382         return false;
383     }
384     
385     
386 }
387 
388