001: /*
002: * $RCSfile: CompressedGeometryHeader.java,v $
003: *
004: * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
006: *
007: * This code is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License version 2 only, as
009: * published by the Free Software Foundation. Sun designates this
010: * particular file as subject to the "Classpath" exception as provided
011: * by Sun in the LICENSE file that accompanied this code.
012: *
013: * This code is distributed in the hope that it will be useful, but WITHOUT
014: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: * version 2 for more details (a copy is included in the LICENSE file that
017: * accompanied this code).
018: *
019: * You should have received a copy of the GNU General Public License version
020: * 2 along with this work; if not, write to the Free Software Foundation,
021: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
022: *
023: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
024: * CA 95054 USA or visit www.sun.com if you need additional information or
025: * have any questions.
026: *
027: * $Revision: 1.6 $
028: * $Date: 2008/02/28 20:17:20 $
029: * $State: Exp $
030: */
031:
032: package javax.media.j3d;
033:
034: import javax.vecmath.*;
035:
036: /**
037: * The CompressedGeometrHeader object is used in conjunction with
038: * the CompressedGeometry object. The CompressedGeometrHeader object
039: * contains information specific to the compressed geometry stored in
040: * CompressedGeometry NodeComponent object. This information
041: * is used to aid the decompression of the compressed geometry.
042: * <P>
043: * All instance data is declared public and no get or set methods are
044: * provided.
045: *
046: * @see CompressedGeometry
047: *
048: * @deprecated As of Java 3D version 1.4.
049: */
050: public class CompressedGeometryHeader extends Object {
051:
052: /**
053: * bufferType: compressed geometry is made up of individual points.
054: */
055: public static final int POINT_BUFFER = 0;
056:
057: /**
058: * bufferType: compressed geometry is made up of line segments.
059: */
060: public static final int LINE_BUFFER = 1;
061:
062: /**
063: * bufferType: compressed geometry is made up of triangles.
064: */
065: public static final int TRIANGLE_BUFFER = 2;
066:
067: // Valid values for the bufferDataPresent field.
068:
069: /**
070: * bufferDataPresent: bit indicating that normal information is
071: * bundled with the vertices in the compressed geometry buffer.
072: */
073: public static final int NORMAL_IN_BUFFER = 1;
074:
075: /**
076: * bufferDataPresent: bit indicating that RGB color information is
077: * bundled with the vertices in the compressed geometry buffer.
078: */
079: public static final int COLOR_IN_BUFFER = 2;
080:
081: /**
082: * bufferDataPresent: bit indicating that alpha information is
083: * bundled with the vertices in the compressed geometry buffer.
084: */
085: public static final int ALPHA_IN_BUFFER = 4;
086:
087: /**
088: * The major version number for the compressed geometry format that
089: * was used to compress the geometry.
090: * If the version number of compressed geometry is incompatible
091: * with the supported version of compressed geometry in the
092: * current version of Java 3D, the compressed geometry obejct will
093: * not be rendered.
094: *
095: * @see Canvas3D#queryProperties
096: */
097: public int majorVersionNumber;
098:
099: /**
100: * The minor version number for the compressed geometry format that
101: * was used to compress the geometry.
102: * If the version number of compressed geometry is incompatible
103: * with the supported version of compressed geometry in the
104: * current version of Java 3D, the compressed geometry obejct will
105: * not be rendered.
106: *
107: * @see Canvas3D#queryProperties
108: */
109: public int minorVersionNumber;
110:
111: /**
112: * The minor-minor version number for the compressed geometry format
113: * that was used to compress the geometry.
114: * If the version number of compressed geometry is incompatible
115: * with the supported version of compressed geometry in the
116: * current version of Java 3D, the compressed geometry obejct will
117: * not be rendered.
118: *
119: * @see Canvas3D#queryProperties
120: */
121: public int minorMinorVersionNumber;
122:
123: /**
124: * Describes the type of data in the compressed geometry buffer.
125: * Only one type may be present in any given compressed geometry
126: * buffer.
127: */
128: public int bufferType;
129:
130: /**
131: * Contains bits indicating what data is bundled with the vertices in the
132: * compressed geometry buffer. If this data is not present (e.g. color)
133: * then this info will be inherited from the Appearance node.
134: */
135: public int bufferDataPresent;
136:
137: /**
138: * Size of the compressed geometry in bytes.
139: */
140: public int size;
141:
142: /**
143: * Offset in bytes of the start of the compressed geometry from the
144: * beginning of the compressed geometry byte array passed to the
145: * CompressedGeometry constructor. <p>
146: *
147: * If the CompressedGeometry is created with reference access semantics,
148: * then this allow external compressors or file readers to embed several
149: * blocks of compressed geometry in a single large byte array, possibly
150: * interspersed with metadata that is not specific to Java 3D, without
151: * having to copy each block to a separate byte array. <p>
152: *
153: * If the CompressedGeometry is created with copy access semantics, then
154: * <code>size</code> bytes of compressed geometry data are copied from the
155: * offset indicated by <code>start</code> instead of copying the entire
156: * byte array. The getCompressedGeometry() method will return only the
157: * bytes used to construct the object, and the getCompressedGeometryHeader()
158: * method will return a header with the <code>start</code> field set to 0.
159: */
160: public int start;
161:
162: /**
163: * A point that defines the lower bound of the <i>x</i>,
164: * <i>y</i>, and <i>z</i> components for all positions in the
165: * compressed geometry buffer. If null, a lower bound of
166: * (-1,-1,-1) is assumed. Java 3D will use this information to
167: * construct a bounding box around compressed geometry objects
168: * that are used in nodes for which the auto compute bounds flag
169: * is true. The default value for this point is null.
170: *
171: * @since Java 3D 1.2
172: */
173: public Point3d lowerBound = null;
174:
175: /**
176: * A point that defines the upper bound of the <i>x</i>,
177: * <i>y</i>, and <i>z</i> components for all positions in the
178: * compressed geometry buffer. If null, an upper bound of (1,1,1)
179: * is assumed. Java 3D will use this information to construct a
180: * bounding box around compressed geometry objects that are used
181: * in nodes for which the auto compute bounds flag is true. The
182: * default value for this point is null.
183: *
184: * @since Java 3D 1.2
185: */
186: public Point3d upperBound = null;
187:
188: /**
189: * Creates a new CompressedGeometryHeader object used for the
190: * creation of a CompressedGeometry NodeComponent object.
191: * All instance data is declared public and no get or set methods are
192: * provided. All values are set to 0 by default and must be filled
193: * in by the application.
194: *
195: * @see CompressedGeometry
196: */
197: public CompressedGeometryHeader() {
198: }
199:
200: /**
201: * Package-scoped method to copy current CompressedGeometryHeader object
202: * to the passed-in CompressedGeometryHeader object.
203: *
204: * @param hdr the CompressedGeometryHeader object into which to copy the
205: * current CompressedGeometryHeader.
206: */
207: void copy(CompressedGeometryHeader hdr) {
208: hdr.majorVersionNumber = this .majorVersionNumber;
209: hdr.minorVersionNumber = this .minorVersionNumber;
210: hdr.minorMinorVersionNumber = this .minorMinorVersionNumber;
211: hdr.bufferType = this .bufferType;
212: hdr.bufferDataPresent = this .bufferDataPresent;
213: hdr.size = this .size;
214: hdr.start = this .start;
215: hdr.lowerBound = this .lowerBound;
216: hdr.upperBound = this .upperBound;
217: }
218:
219: /**
220: * Returns a String describing the contents of the
221: * CompressedGeometryHeader object.
222: *
223: * @return a String describing contents of the compressed geometry header
224: */
225: public String toString() {
226: String type = "UNKNOWN";
227: switch (bufferType) {
228: case POINT_BUFFER:
229: type = "POINT_BUFFER";
230: break;
231: case LINE_BUFFER:
232: type = "LINE_BUFFER";
233: break;
234: case TRIANGLE_BUFFER:
235: type = "TRIANGLE_BUFFER";
236: break;
237: }
238:
239: String data = "";
240: if ((bufferDataPresent & NORMAL_IN_BUFFER) != 0)
241: data = data + "NORMALS ";
242: if ((bufferDataPresent & COLOR_IN_BUFFER) != 0)
243: data = data + "COLORS ";
244: if ((bufferDataPresent & ALPHA_IN_BUFFER) != 0)
245: data = data + "ALPHA ";
246:
247: String lbound = "null";
248: if (lowerBound != null)
249: lbound = lowerBound.toString();
250:
251: String ubound = "null";
252: if (upperBound != null)
253: ubound = upperBound.toString();
254:
255: return "majorVersionNumber: " + majorVersionNumber + " "
256: + "minorVersionNumber: " + minorVersionNumber + " "
257: + "minorMinorVersionNumber: " + minorMinorVersionNumber
258: + "\n" + "bufferType: " + type + " "
259: + "bufferDataPresent: " + data + "\n" + "size: " + size
260: + " " + "start: " + start + "\n" + "lower bound: "
261: + lbound + "\n" + "upper bound: " + ubound + " ";
262: }
263: }
|