summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkcr <kcr@28c7f869-5b4e-e670-f602-82bfaf57f300>2006-07-17 20:02:22 +0000
committerkcr <kcr@28c7f869-5b4e-e670-f602-82bfaf57f300>2006-07-17 20:02:22 +0000
commitb4d205c19104de8b9b0ef175f8af2e2c9dd578ee (patch)
tree8c5f9b4eed21290546b13add74347ab32e9958f3
parentd99590104c448c1947a2a9d26845350012c6fae7 (diff)
Changed example program to use new compressed geometry utility (see issue 246).
-rw-r--r--src/classes/org/jdesktop/j3d/examples/geometry_compression/ObjectFileCompressor.java40
-rw-r--r--src/classes/org/jdesktop/j3d/examples/geometry_compression/README.txt2
-rw-r--r--src/classes/org/jdesktop/j3d/examples/geometry_compression/cgview.java49
-rw-r--r--src/classes/org/jdesktop/j3d/examples/geometry_compression/obj2cg.java5
4 files changed, 42 insertions, 54 deletions
diff --git a/src/classes/org/jdesktop/j3d/examples/geometry_compression/ObjectFileCompressor.java b/src/classes/org/jdesktop/j3d/examples/geometry_compression/ObjectFileCompressor.java
index 57267eb..2155581 100644
--- a/src/classes/org/jdesktop/j3d/examples/geometry_compression/ObjectFileCompressor.java
+++ b/src/classes/org/jdesktop/j3d/examples/geometry_compression/ObjectFileCompressor.java
@@ -44,15 +44,17 @@
package org.jdesktop.j3d.examples.geometry_compression;
-import com.sun.j3d.utils.compression.* ;
-import com.sun.j3d.loaders.objectfile.ObjectFile ;
-import com.sun.j3d.loaders.ParsingErrorException ;
-import com.sun.j3d.loaders.IncorrectFormatException ;
-import com.sun.j3d.loaders.Scene ;
-import javax.media.j3d.* ;
-import java.util.* ;
-import java.net.* ;
-import java.io.* ;
+import com.sun.j3d.loaders.IncorrectFormatException;
+import com.sun.j3d.loaders.ParsingErrorException;
+import com.sun.j3d.loaders.Scene;
+import com.sun.j3d.loaders.objectfile.ObjectFile;
+import com.sun.j3d.utils.geometry.compression.*;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.Reader;
+import java.net.URL;
+import java.util.Hashtable;
+import javax.media.j3d.Shape3D;
/**
* This extension of ObjectFile provides the methods setQuantization() and
@@ -104,12 +106,12 @@ public class ObjectFileCompressor extends ObjectFile {
}
/**
- * Compress the specified .obj file into a CompressedGeometry node
+ * Compress the specified .obj file into a CompressedGeometryData node
* component.
* @param objFileName String object representing the path to a .obj file
- * @return a CompressedGeometry node component
+ * @return a CompressedGeometryData node component
*/
- public CompressedGeometry compress(String objFileName) {
+ public CompressedGeometryData compress(String objFileName) {
return compressScene(getScene(objFileName)) ;
}
@@ -126,12 +128,12 @@ public class ObjectFileCompressor extends ObjectFile {
}
/**
- * Compress the specified .obj file into a CompressedGeometry node
+ * Compress the specified .obj file into a CompressedGeometryData node
* component.
* @param reader an open .obj file
- * @return a CompressedGeometry node component
+ * @return a CompressedGeometryData node component
*/
- public CompressedGeometry compress(Reader reader) {
+ public CompressedGeometryData compress(Reader reader) {
return compressScene(getScene(reader)) ;
}
@@ -148,12 +150,12 @@ public class ObjectFileCompressor extends ObjectFile {
}
/**
- * Compress the specified .obj file into a CompressedGeometry node
+ * Compress the specified .obj file into a CompressedGeometryData node
* component.
* @param url Uniform Resource Locator for the .obj file
- * @return a CompressedGeometry node component
+ * @return a CompressedGeometryData node component
*/
- public CompressedGeometry compress(URL url) {
+ public CompressedGeometryData compress(URL url) {
return compressScene(getScene(url)) ;
}
@@ -169,7 +171,7 @@ public class ObjectFileCompressor extends ObjectFile {
compressScene(getScene(url), file) ;
}
- private CompressedGeometry compressScene(Scene scene) {
+ private CompressedGeometryData compressScene(Scene scene) {
return compressor.compress(getStream(scene)) ;
}
diff --git a/src/classes/org/jdesktop/j3d/examples/geometry_compression/README.txt b/src/classes/org/jdesktop/j3d/examples/geometry_compression/README.txt
index 1cab35b..345766b 100644
--- a/src/classes/org/jdesktop/j3d/examples/geometry_compression/README.txt
+++ b/src/classes/org/jdesktop/j3d/examples/geometry_compression/README.txt
@@ -1,5 +1,5 @@
This directory contains example code for using compressed geometry in
-Java 3D through the com.sun.j3d.utils.compression package.
+Java 3D through the com.sun.j3d.utils.geometry.compression package.
Applications:
diff --git a/src/classes/org/jdesktop/j3d/examples/geometry_compression/cgview.java b/src/classes/org/jdesktop/j3d/examples/geometry_compression/cgview.java
index 2efc221..23e027a 100644
--- a/src/classes/org/jdesktop/j3d/examples/geometry_compression/cgview.java
+++ b/src/classes/org/jdesktop/j3d/examples/geometry_compression/cgview.java
@@ -44,22 +44,21 @@
package org.jdesktop.j3d.examples.geometry_compression;
-import com.sun.j3d.utils.compression.* ;
-import com.sun.j3d.utils.behaviors.vp.* ;
-import com.sun.j3d.utils.applet.MainFrame ;
-import com.sun.j3d.utils.universe.* ;
-import javax.media.j3d.* ;
-import javax.vecmath.* ;
-import java.applet.Applet ;
-import java.awt.BorderLayout ;
-import java.awt.event.* ;
-import java.io.* ;
+import com.sun.j3d.utils.applet.MainFrame;
+import com.sun.j3d.utils.behaviors.vp.OrbitBehavior;
+import com.sun.j3d.utils.geometry.compression.*;
+import com.sun.j3d.utils.universe.*;
+import java.applet.Applet;
+import java.awt.BorderLayout;
+import java.io.IOException;
+import javax.media.j3d.*;
+import javax.vecmath.*;
public class cgview extends Applet {
private SimpleUniverse u = null;
- public BranchGroup createSceneGraph(CompressedGeometry cg) {
+ public BranchGroup createSceneGraph(CompressedGeometryData cg) {
// Create the root of the branch graph
BranchGroup objRoot = new BranchGroup() ;
@@ -81,27 +80,15 @@ public class cgview extends Applet {
objScale.addChild(objTrans) ;
// Add compressed geometry to the scene graph.
- CompressedGeometryHeader hdr = new CompressedGeometryHeader() ;
+ CompressedGeometryData.Header hdr = new CompressedGeometryData.Header() ;
cg.getCompressedGeometryHeader(hdr) ;
- // There isn't really enough information in the compressed geometry
- // header to unamiguously determine the proper rendering attributes.
- // The bufferDataPresent field specifies whether or not normals are
- // bundled with vertices, but the compressed buffer can still contain
- // normals that should be lit. Assume that any surface geometry
- // should be lit and that lines and points should not unless the
- // header contains the NORMAL_IN_BUFFER bit.
- Material m = new Material() ;
- if ((hdr.bufferType == hdr.TRIANGLE_BUFFER) ||
- ((hdr.bufferDataPresent & hdr.NORMAL_IN_BUFFER) == 1))
- m.setLightingEnable(true) ;
- else
- m.setLightingEnable(false) ;
-
- Appearance a = new Appearance() ;
- a.setMaterial(m) ;
-
- objTrans.addChild(new Shape3D(cg, a)) ;
+ Shape3D[] shapes = cg.decompress();
+ if (shapes != null) {
+ for (int i = 0; i < shapes.length; i++) {
+ objTrans.addChild(shapes[i]);
+ }
+ }
// Create mouse behavior scheduling bounds.
BoundingSphere bounds =
@@ -158,7 +145,7 @@ public class cgview extends Applet {
usage() ;
// Read the compressed geometry.
- CompressedGeometry cg = null ;
+ CompressedGeometryData cg = null ;
try {
CompressedGeometryFile cgf ;
cgf = new CompressedGeometryFile(filename, false) ;
diff --git a/src/classes/org/jdesktop/j3d/examples/geometry_compression/obj2cg.java b/src/classes/org/jdesktop/j3d/examples/geometry_compression/obj2cg.java
index e863dbc..4d3fa66 100644
--- a/src/classes/org/jdesktop/j3d/examples/geometry_compression/obj2cg.java
+++ b/src/classes/org/jdesktop/j3d/examples/geometry_compression/obj2cg.java
@@ -44,9 +44,8 @@
package org.jdesktop.j3d.examples.geometry_compression;
-import com.sun.j3d.utils.compression.* ;
-import javax.media.j3d.* ;
-import java.io.* ;
+import com.sun.j3d.utils.geometry.compression.*;
+import java.io.IOException;
class obj2cg {