aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobody <nobody@28c7f869-5b4e-e670-f602-82bfaf57f300>2005-08-26 21:18:36 +0000
committernobody <nobody@28c7f869-5b4e-e670-f602-82bfaf57f300>2005-08-26 21:18:36 +0000
commitc70acc013c054d977fc7df0309ae29503e3d43af (patch)
tree679d9535fc0313cba50c499fb92a64bb46999fc7
parentd73245421b294f50b9d4728bcbc717876f83d250 (diff)
This commit was manufactured by cvs2svn to create tagexp-1_4_0-build6
'exp-1_4_0-build6'.
-rw-r--r--THIRDPARTY-LICENSE-3DLABS.txt47
-rw-r--r--build.xml4
-rw-r--r--src/CgShaderTest/ObjLoadCg.java343
-rw-r--r--src/CgShaderTest/SphereCg.java346
-rw-r--r--src/CgShaderTest/build.xml69
-rw-r--r--src/CgShaderTest/simple_fp.cg68
-rw-r--r--src/CgShaderTest/simple_vp.cg167
-rw-r--r--src/DepthFuncTest/DepthFuncTest.form217
-rw-r--r--src/DepthFuncTest/DepthFuncTest.java357
-rw-r--r--src/DepthFuncTest/RenderFrame.form25
-rw-r--r--src/DepthFuncTest/RenderFrame.java290
-rw-r--r--src/DepthFuncTest/build.xml69
-rw-r--r--src/DistortGlyph/DistortBehavior.java192
-rw-r--r--src/DistortGlyph/DistortGlyphTest.java208
-rw-r--r--src/DistortGlyph/build.xml69
-rw-r--r--src/DistortGlyph/gold.jpgbin0 -> 42643 bytes
-rw-r--r--src/GLSLShaderTest/ObjLoadGLSL.java346
-rw-r--r--src/GLSLShaderTest/SphereGLSL.java345
-rw-r--r--src/GLSLShaderTest/build.xml69
-rw-r--r--src/GLSLShaderTest/dimple.frag57
-rw-r--r--src/GLSLShaderTest/dimple.vert41
-rw-r--r--src/GLSLShaderTest/polkadot3d.frag48
-rw-r--r--src/GLSLShaderTest/polkadot3d.vert58
-rw-r--r--src/GLSLShaderTest/simple.frag62
-rw-r--r--src/GLSLShaderTest/simple.vert129
-rw-r--r--src/GLSLShaderTest/wood.frag66
-rw-r--r--src/GLSLShaderTest/wood.vert25
-rw-r--r--src/SgChangerListener/ListenerTest.java221
-rw-r--r--src/SgChangerListener/build.xml69
-rw-r--r--www/build-instr.html20
-rw-r--r--www/index.html86
31 files changed, 4083 insertions, 30 deletions
diff --git a/THIRDPARTY-LICENSE-3DLABS.txt b/THIRDPARTY-LICENSE-3DLABS.txt
new file mode 100644
index 0000000..90a7ec1
--- /dev/null
+++ b/THIRDPARTY-LICENSE-3DLABS.txt
@@ -0,0 +1,47 @@
+The following additional provisions apply to third party software
+included as part of this product.
+
+ src/GLSLShaderTest/
+ dimple.frag - shader for ObjLoadGLSL.java
+ dimple.vert - shader for ObjLoadGLSL.java
+ polkadot3d.frag - shader for ObjLoadGLSL.java
+ polkadot3d.vert - shader for ObjLoadGLSL.java
+ wood.frag - shader for ObjLoadGLSL.java
+ wood.vert - shader for ObjLoadGLSL.java
+
+/************************************************************************
+* *
+* Copyright (C) 2002-2004 3Dlabs Inc. Ltd. *
+* *
+* All rights reserved. *
+* *
+* Redistribution and use in source and binary forms, with or without *
+* modification, are permitted provided that the following conditions *
+* are met: *
+* *
+* Redistributions of source code must retain the above copyright *
+* notice, this list of conditions and the following disclaimer. *
+* *
+* Redistributions in binary form must reproduce the above *
+* copyright notice, this list of conditions and the following *
+* disclaimer in the documentation and/or other materials provided *
+* with the distribution. *
+* *
+* Neither the name of 3Dlabs Inc. Ltd. nor the names of its *
+* contributors may be used to endorse or promote products derived *
+* from this software without specific prior written permission. *
+* *
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS *
+* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE *
+* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, *
+* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, *
+* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; *
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER *
+* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT *
+* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN *
+* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
+* POSSIBILITY OF SUCH DAMAGE. *
+* *
+************************************************************************/ \ No newline at end of file
diff --git a/build.xml b/build.xml
index 4644ffe..346fc96 100644
--- a/build.xml
+++ b/build.xml
@@ -69,13 +69,17 @@
<ant dir="src/Appearance" target="${build.target}"/>
<ant dir="src/AppearanceMixed" target="${build.target}"/>
<ant dir="src/Background" target="${build.target}"/>
+ <ant dir="src/CgShaderTest" target="${build.target}"/>
<ant dir="src/ConfiguredUniverse" target="${build.target}"/>
<ant dir="src/ConicWorld" target="${build.target}"/>
+ <ant dir="src/DepthFuncTest" target="${build.target}"/>
+ <ant dir="src/DistortGlyph" target="${build.target}"/>
<ant dir="src/FPSCounter" target="${build.target}"/>
<ant dir="src/FourByFour" target="${build.target}"/>
<ant dir="src/GearTest" target="${build.target}"/>
<ant dir="src/GeometryByReference" target="${build.target}"/>
<ant dir="src/GeometryCompression" target="${build.target}"/>
+ <ant dir="src/GLSLShaderTest" target="${build.target}"/>
<ant dir="src/HelloUniverse" target="${build.target}"/>
<ant dir="src/LOD" target="${build.target}"/>
<ant dir="src/Lightwave" target="${build.target}"/>
diff --git a/src/CgShaderTest/ObjLoadCg.java b/src/CgShaderTest/ObjLoadCg.java
new file mode 100644
index 0000000..0cef002
--- /dev/null
+++ b/src/CgShaderTest/ObjLoadCg.java
@@ -0,0 +1,343 @@
+/*
+ * $RCSfile$
+ *
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
+ * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
+ * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
+ * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
+ * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
+ * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ *
+ * $Revision$
+ * $Date$
+ * $State$
+ */
+
+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 com.sun.j3d.utils.shader.StringIO;
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+import com.sun.j3d.utils.applet.MainFrame;
+import com.sun.j3d.utils.universe.*;
+import javax.media.j3d.*;
+import javax.vecmath.*;
+import java.util.Enumeration;
+import java.io.*;
+import com.sun.j3d.utils.behaviors.vp.*;
+import java.net.URL;
+import java.net.MalformedURLException;
+
+public class ObjLoadCg extends Applet {
+
+ private boolean spin = false;
+ private boolean noTriangulate = false;
+ private boolean noStripify = false;
+ private double creaseAngle = 60.0;
+ private URL filename = null;
+ private SimpleUniverse u;
+ private BoundingSphere bounds;
+
+ public BranchGroup createSceneGraph() {
+ // Create the root of the branch graph
+ BranchGroup objRoot = new BranchGroup();
+
+ // Create a Transformgroup to scale all objects so they
+ // appear in the scene.
+ TransformGroup objScale = new TransformGroup();
+ Transform3D t3d = new Transform3D();
+ t3d.setScale(0.7);
+ objScale.setTransform(t3d);
+ objRoot.addChild(objScale);
+
+ // Create the transform group node and initialize it to the
+ // identity. Enable the TRANSFORM_WRITE capability so that
+ // our behavior code can modify it at runtime. Add it to the
+ // root of the subgraph.
+ TransformGroup objTrans = new TransformGroup();
+ objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
+ objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
+ objScale.addChild(objTrans);
+
+ int flags = ObjectFile.RESIZE;
+ if (!noTriangulate) flags |= ObjectFile.TRIANGULATE;
+ if (!noStripify) flags |= ObjectFile.STRIPIFY;
+ ObjectFile f = new ObjectFile(flags,
+ (float)(creaseAngle * Math.PI / 180.0));
+ Scene s = null;
+ try {
+ s = f.load(filename);
+ }
+ catch (FileNotFoundException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ catch (ParsingErrorException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ catch (IncorrectFormatException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ // Set vertex and fragment shader program for all Shape3D nodes in scene
+ String vertexProgram = null;
+ String fragmentProgram = null;
+ try {
+ vertexProgram = StringIO.readFully("./simple_vp.cg");
+ fragmentProgram = StringIO.readFully("./simple_fp.cg");
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ Shader[] shaders = new Shader[2];
+ shaders[0] = new SourceCodeShader(Shader.SHADING_LANGUAGE_CG,
+ Shader.SHADER_TYPE_VERTEX,
+ vertexProgram);
+ shaders[1] = new SourceCodeShader(Shader.SHADING_LANGUAGE_CG,
+ Shader.SHADER_TYPE_FRAGMENT,
+ fragmentProgram);
+ ShaderProgram shaderProgram = new CgShaderProgram();
+ shaderProgram.setShaders(shaders);
+ setShaderProgram(s.getSceneGroup(), shaderProgram);
+
+ objTrans.addChild(s.getSceneGroup());
+
+ bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
+
+ if (spin) {
+ Transform3D yAxis = new Transform3D();
+ Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE,
+ 0, 0,
+ 4000, 0, 0,
+ 0, 0, 0);
+
+ RotationInterpolator rotator =
+ new RotationInterpolator(rotationAlpha, objTrans, yAxis,
+ 0.0f, (float) Math.PI*2.0f);
+ rotator.setSchedulingBounds(bounds);
+ objTrans.addChild(rotator);
+ }
+
+ // Set up the background
+ Color3f bgColor = new Color3f(0.05f, 0.05f, 0.5f);
+ Background bgNode = new Background(bgColor);
+ bgNode.setApplicationBounds(bounds);
+ objRoot.addChild(bgNode);
+
+ return objRoot;
+ }
+
+ private void usage()
+ {
+ System.out.println(
+ "Usage: java ObjLoadCg [-s] [-n] [-t] [-c degrees] <.obj file>");
+ System.out.println(" -s Spin (no user interaction)");
+ System.out.println(" -n No triangulation");
+ System.out.println(" -t No stripification");
+ System.out.println(
+ " -c Set crease angle for normal generation (default is 60 without");
+ System.out.println(
+ " smoothing group info, otherwise 180 within smoothing groups)");
+ System.exit(0);
+ } // End of usage
+
+
+
+ public void init() {
+ if (filename == null) {
+ // Applet
+ try {
+ URL path = getCodeBase();
+ filename = new URL(path.toString() + "./galleon.obj");
+ }
+ catch (MalformedURLException e) {
+ System.err.println(e);
+ System.exit(1);
+ }
+ }
+
+ setLayout(new BorderLayout());
+ GraphicsConfiguration config =
+ SimpleUniverse.getPreferredConfiguration();
+
+ Canvas3D c = new Canvas3D(config);
+ add("Center", c);
+
+ // Create a simple scene and attach it to the virtual universe
+ BranchGroup scene = createSceneGraph();
+ u = new SimpleUniverse(c);
+
+ // add mouse behaviors to the ViewingPlatform
+ ViewingPlatform viewingPlatform = u.getViewingPlatform();
+
+ PlatformGeometry pg = new PlatformGeometry();
+
+ // Set up the ambient light
+ Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f);
+ AmbientLight ambientLightNode = new AmbientLight(ambientColor);
+ ambientLightNode.setInfluencingBounds(bounds);
+ pg.addChild(ambientLightNode);
+
+ // Set up the directional lights
+ Color3f light1Color = new Color3f(1.0f, 0.2f, 0.4f);
+ Vector3f light1Direction = new Vector3f(-1.0f, -1.0f, -1.0f);
+ Color3f light2Color = new Color3f(1.0f, 1.0f, 0.9f);
+ Vector3f light2Direction = new Vector3f(1.0f, 1.0f, 1.0f);
+
+ DirectionalLight light1
+ = new DirectionalLight(light1Color, light1Direction);
+ light1.setInfluencingBounds(bounds);
+ pg.addChild(light1);
+
+ DirectionalLight light2
+ = new DirectionalLight(light2Color, light2Direction);
+ light2.setInfluencingBounds(bounds);
+ pg.addChild(light2);
+
+ viewingPlatform.setPlatformGeometry( pg );
+
+ // This will move the ViewPlatform back a bit so the
+ // objects in the scene can be viewed.
+ viewingPlatform.setNominalViewingTransform();
+
+ if (!spin) {
+ OrbitBehavior orbit = new OrbitBehavior(c,
+ OrbitBehavior.REVERSE_ALL);
+ BoundingSphere bounds =
+ new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
+ orbit.setSchedulingBounds(bounds);
+ viewingPlatform.setViewPlatformBehavior(orbit);
+ }
+
+ /*
+ // Limit the frame rate to 100 Hz
+ u.getViewer().getView().setMinimumFrameCycleTime(10);
+ */
+
+ u.addBranchGraph(scene);
+ }
+
+ // Set shader program for all nodes in specified branch graph
+ private void setShaderProgram(BranchGroup g, ShaderProgram shaderProgram) {
+ ShaderAppearance myApp = new ShaderAppearance();
+ Material mat = new Material();
+ Texture2D tex2d = new Texture2D();
+ myApp.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
+ myApp.setShaderProgram(shaderProgram);
+ myApp.setMaterial(mat);
+ myApp.setTexture(tex2d);
+ setShaderProgram(g, myApp);
+ }
+
+ // Recursively set shader program for all children of specified group
+ private void setShaderProgram(Group g,
+ ShaderAppearance myApp) {
+
+ Enumeration e = g.getAllChildren();
+ while (e.hasMoreElements()) {
+ Node n = (Node)(e.nextElement());
+ if (n instanceof Group) {
+ setShaderProgram((Group)n, myApp);
+ }
+ else if (n instanceof Shape3D) {
+ Shape3D s = (Shape3D)n;
+ s.setAppearance(myApp);
+ }
+ }
+ }
+
+ // Caled if running as a program
+ public ObjLoadCg(String[] args) {
+ if (args.length != 0) {
+ for (int i = 0 ; i < args.length ; i++) {
+ if (args[i].startsWith("-")) {
+ if (args[i].equals("-s")) {
+ spin = true;
+ } else if (args[i].equals("-n")) {
+ noTriangulate = true;
+ } else if (args[i].equals("-t")) {
+ noStripify = true;
+ } else if (args[i].equals("-c")) {
+ if (i < args.length - 1) {
+ creaseAngle = (new Double(args[++i])).doubleValue();
+ } else usage();
+ } else {
+ usage();
+ }
+ } else {
+ try {
+ if ((args[i].indexOf("file:") == 0) ||
+ (args[i].indexOf("http") == 0)) {
+ filename = new URL(args[i]);
+ }
+ else if (args[i].charAt(0) != '/') {
+ filename = new URL("file:./" + args[i]);
+ }
+ else {
+ filename = new URL("file:" + args[i]);
+ }
+ }
+ catch (MalformedURLException e) {
+ System.err.println(e);
+ System.exit(1);
+ }
+ }
+ }
+ }
+ }
+
+
+
+ // Running as an applet
+ public ObjLoadCg() {
+ }
+
+ public void destroy() {
+ u.cleanup();
+ }
+
+
+
+ //
+ // The following allows ObjLoadCg to be run as an application
+ // as well as an applet
+ //
+ public static void main(String[] args) {
+ new MainFrame(new ObjLoadCg(args), 700, 700);
+ }
+}
diff --git a/src/CgShaderTest/SphereCg.java b/src/CgShaderTest/SphereCg.java
new file mode 100644
index 0000000..266d523
--- /dev/null
+++ b/src/CgShaderTest/SphereCg.java
@@ -0,0 +1,346 @@
+/*
+ * $RCSfile$
+ *
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
+ * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
+ * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
+ * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
+ * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
+ * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ *
+ * $Revision$
+ * $Date$
+ * $State$
+ */
+
+import java.applet.Applet;
+import java.awt.*;
+import java.io.*;
+import com.sun.j3d.utils.applet.MainFrame;
+import com.sun.j3d.utils.geometry.Sphere;
+import com.sun.j3d.utils.shader.StringIO;
+import com.sun.j3d.utils.universe.*;
+import javax.media.j3d.*;
+import javax.vecmath.*;
+import java.util.Enumeration;
+import java.net.URL;
+import java.net.MalformedURLException;
+
+/**
+ * Simple CG Shader test program
+ */
+public class SphereCg extends Applet {
+
+ // Constants for type of light to use
+ private static final int DIRECTIONAL_LIGHT = 0;
+ private static final int POINT_LIGHT = 1;
+ private static final int SPOT_LIGHT = 2;
+
+ // Flag indicates type of lights: directional, point, or spot
+ // lights. This flag is set based on command line argument
+ private static int lightType = DIRECTIONAL_LIGHT;
+
+ private SimpleUniverse u = null;
+
+ public BranchGroup createSceneGraph(SimpleUniverse u) {
+ Color3f eColor = new Color3f(0.0f, 0.0f, 0.0f);
+ Color3f sColor = new Color3f(1.0f, 1.0f, 1.0f);
+ Color3f objColor = new Color3f(0.6f, 0.6f, 0.6f);
+ Color3f lColor1 = new Color3f(1.0f, 0.0f, 0.0f);
+ Color3f lColor2 = new Color3f(0.0f, 1.0f, 0.0f);
+ Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f);
+ Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f);
+
+ Transform3D t;
+
+ // Create the root of the branch graph
+ BranchGroup objRoot = new BranchGroup();
+
+ // Create a Transformgroup to scale all objects so they
+ // appear in the scene.
+ TransformGroup objScale = new TransformGroup();
+ Transform3D t3d = new Transform3D();
+ t3d.setScale(0.4);
+ objScale.setTransform(t3d);
+ objRoot.addChild(objScale);
+
+ // Create a bounds for the background and lights
+ BoundingSphere bounds =
+ new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
+
+ // Set up the background
+ Background bg = new Background(bgColor);
+ bg.setApplicationBounds(bounds);
+ objScale.addChild(bg);
+
+ // Create a Sphere object, generate one copy of the sphere,
+ // and add it into the scene graph.
+ ShaderAppearance a = new ShaderAppearance();
+ Material m = new Material(objColor, eColor, objColor, sColor, 100.0f);
+ m.setLightingEnable(true);
+ Texture t2d = new Texture2D();
+ a.setTexture(t2d);
+ a.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
+
+ String vertexProgram = null;
+ String fragmentProgram = null;
+ try {
+ vertexProgram = StringIO.readFully("./simple_vp.cg");
+ fragmentProgram = StringIO.readFully("./simple_fp.cg");
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ Shader[] shaders = new Shader[2];
+ shaders[0] = new SourceCodeShader(Shader.SHADING_LANGUAGE_CG,
+ Shader.SHADER_TYPE_VERTEX,
+ vertexProgram);
+ shaders[1] = new SourceCodeShader(Shader.SHADING_LANGUAGE_CG,
+ Shader.SHADER_TYPE_FRAGMENT,
+ fragmentProgram);
+ ShaderProgram shaderProgram = new CgShaderProgram();
+ shaderProgram.setShaders(shaders);
+
+ a.setShaderProgram(shaderProgram);
+ a.setMaterial(m);
+ Sphere sph = new Sphere(1.0f, Sphere.GENERATE_NORMALS, 200, a);
+ objScale.addChild(sph);
+
+ // Create the transform group node for the each light and initialize
+ // it to the identity. Enable the TRANSFORM_WRITE capability so that
+ // our behavior code can modify it at runtime. Add them to the root
+ // of the subgraph.
+ TransformGroup l1RotTrans = new TransformGroup();
+ l1RotTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
+ objScale.addChild(l1RotTrans);
+
+ TransformGroup l2RotTrans = new TransformGroup();
+ l2RotTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
+ objScale.addChild(l2RotTrans);
+
+ // Create transformations for the positional lights
+ t = new Transform3D();
+ Vector3d lPos1 = new Vector3d(0.0, 0.0, 2.0);
+ t.set(lPos1);
+ TransformGroup l1Trans = new TransformGroup(t);
+ l1RotTrans.addChild(l1Trans);
+
+ t = new Transform3D();
+ Vector3d lPos2 = new Vector3d(0.5, 0.8, 2.0);
+ t.set(lPos2);
+ TransformGroup l2Trans = new TransformGroup(t);
+ l2RotTrans.addChild(l2Trans);
+
+ /*
+ // Create Geometry for point lights
+ ColoringAttributes caL1 = new ColoringAttributes();
+ ColoringAttributes caL2 = new ColoringAttributes();
+ caL1.setColor(lColor1);
+ caL2.setColor(lColor2);
+ Appearance appL1 = new Appearance();
+ Appearance appL2 = new Appearance();
+ appL1.setColoringAttributes(caL1);
+ appL2.setColoringAttributes(caL2);
+ l1Trans.addChild(new Sphere(0.05f, appL1));
+ l2Trans.addChild(new Sphere(0.05f, appL2));
+ */
+
+ // Create lights
+ AmbientLight aLgt = new AmbientLight(alColor);
+
+ Light lgt1 = null;
+ Light lgt2 = null;
+
+ Point3f lPoint = new Point3f(0.0f, 0.0f, 0.0f);
+ Point3f atten = new Point3f(1.0f, 0.0f, 0.0f);
+ Vector3f lDirect1 = new Vector3f(lPos1);
+ Vector3f lDirect2 = new Vector3f(lPos2);
+ lDirect1.negate();
+ lDirect2.negate();
+
+ switch (lightType) {
+ case DIRECTIONAL_LIGHT:
+ lgt1 = new DirectionalLight(lColor1, lDirect1);
+ lgt2 = new DirectionalLight(lColor2, lDirect2);
+ break;
+ case POINT_LIGHT:
+ lgt1 = new PointLight(lColor1, lPoint, atten);
+ lgt2 = new PointLight(lColor2, lPoint, atten);
+ break;
+ case SPOT_LIGHT:
+ lgt1 = new SpotLight(lColor1, lPoint, atten, lDirect1,
+ 25.0f * (float)Math.PI / 180.0f, 10.0f);
+ lgt2 = new SpotLight(lColor2, lPoint, atten, lDirect2,
+ 25.0f * (float)Math.PI / 180.0f, 10.0f);
+ break;
+ }
+
+ // Set the influencing bounds
+ aLgt.setInfluencingBounds(bounds);
+ lgt1.setInfluencingBounds(bounds);
+ lgt2.setInfluencingBounds(bounds);
+
+ // Add the lights into the scene graph
+ objScale.addChild(aLgt);
+ l1Trans.addChild(lgt1);
+ l2Trans.addChild(lgt2);
+
+ // Create a new Behavior object that will perform the desired
+ // operation on the specified transform object and add it into the
+ // scene graph.
+ Transform3D yAxis = new Transform3D();
+ Alpha rotor1Alpha = new Alpha(-1, Alpha.INCREASING_ENABLE,
+ 0, 0,
+ 4000, 0, 0,
+ 0, 0, 0);
+ RotationInterpolator rotator1 =
+ new RotationInterpolator(rotor1Alpha,
+ l1RotTrans,
+ yAxis,
+ 0.0f, (float) Math.PI*2.0f);
+ rotator1.setSchedulingBounds(bounds);
+ l1RotTrans.addChild(rotator1);
+
+ // Create a new Behavior object that will perform the desired
+ // operation on the specified transform object and add it into the
+ // scene graph.
+ Alpha rotor2Alpha = new Alpha(-1, Alpha.INCREASING_ENABLE,
+ 0, 0,
+ 1000, 0, 0,
+ 0, 0, 0);
+ RotationInterpolator rotator2 =
+ new RotationInterpolator(rotor2Alpha,
+ l2RotTrans,
+ yAxis,
+ 0.0f, 0.0f);
+ bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
+ rotator2.setSchedulingBounds(bounds);
+ l2RotTrans.addChild(rotator2);
+
+ // Create a position interpolator and attach it to the view
+ // platform
+ TransformGroup vpTrans =
+ u.getViewingPlatform().getViewPlatformTransform();
+ Transform3D axisOfTranslation = new Transform3D();
+ Alpha transAlpha = new Alpha(-1,
+ Alpha.INCREASING_ENABLE |
+ Alpha.DECREASING_ENABLE,
+ 0, 0,
+ 5000, 0, 0,
+ 5000, 0, 0);
+ axisOfTranslation.rotY(-Math.PI/2.0);
+ PositionInterpolator translator =
+ new PositionInterpolator(transAlpha,
+ vpTrans,
+ axisOfTranslation,
+ 2.0f, 3.5f);
+ translator.setSchedulingBounds(bounds);
+ objScale.addChild(translator);
+
+ // Let Java 3D perform optimizations on this scene graph.
+ objRoot.compile();
+
+ return objRoot;
+ }
+
+ public SphereCg() {
+ }
+
+ public void init() {
+ setLayout(new BorderLayout());
+ GraphicsConfiguration config =
+ SimpleUniverse.getPreferredConfiguration();
+
+ Canvas3D c = new Canvas3D(config);
+ add("Center", c);
+
+ u = new SimpleUniverse(c);
+ BranchGroup scene = createSceneGraph(u);
+
+ // This will move the ViewPlatform back a bit so the
+ // objects in the scene can be viewed.
+ u.getViewingPlatform().setNominalViewingTransform();
+
+ /*
+ // Limit the frame rate to 100 Hz
+ u.getViewer().getView().setMinimumFrameCycleTime(10);
+ */
+
+ u.addBranchGraph(scene);
+ }
+
+ public void destroy() {
+ u.cleanup();
+ }
+
+ //
+ // The following allows SphereCg to be run as an application
+ // as well as an applet
+ //
+ public static void main(String[] args) {
+ // Parse the Input Arguments
+ String usage = "Usage: java SphereCg [-point | -spot | -dir]";
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].startsWith("-")) {
+ if (args[i].equals("-point")) {
+ /*
+ System.out.println("Using point lights");
+ lightType = POINT_LIGHT;
+ */
+ System.out.println("Point lights not yet implemented, option ignored");
+ }
+ else if (args[i].equals("-spot")) {
+ /*
+ System.out.println("Using spot lights");
+ lightType = SPOT_LIGHT;
+ */
+ System.out.println("Spot lights not yet implemented, option ignored");
+ }
+ else if (args[i].equals("-dir")) {
+ System.out.println("Using directional lights");
+ lightType = DIRECTIONAL_LIGHT;
+ }
+ else {
+ System.out.println(usage);
+ System.exit(0);
+ }
+ }
+ else {
+ System.out.println(usage);
+ System.exit(0);
+ }
+ }
+
+ new MainFrame(new SphereCg(), 700, 700);
+ }
+}
diff --git a/src/CgShaderTest/build.xml b/src/CgShaderTest/build.xml
new file mode 100644
index 0000000..47e5a36
--- /dev/null
+++ b/src/CgShaderTest/build.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+
+<!--
+/*
+ * $RCSfile$
+ *
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
+ * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
+ * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
+ * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
+ * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
+ * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ *
+ * $Revision$
+ * $Date$
+ * $State$
+ */
+ -->
+
+<project basedir="." default="compile">
+ <target name="compile">
+ <javac
+ destdir="." srcdir="."
+ source="1.4" target="1.4"
+ debug="true" deprecation="true">
+ </javac>
+ </target>
+
+ <target name="all" depends="compile">
+ </target>
+
+ <target description="Clean all build products." name="clean">
+ <delete>
+ <fileset dir=".">
+ <include name="**/*.class"/>
+ </fileset>
+ </delete>
+ </target>
+
+</project>
diff --git a/src/CgShaderTest/simple_fp.cg b/src/CgShaderTest/simple_fp.cg
new file mode 100644
index 0000000..d651833
--- /dev/null
+++ b/src/CgShaderTest/simple_fp.cg
@@ -0,0 +1,68 @@
+/*
+ * $RCSfile$
+ *
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
+ * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
+ * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
+ * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
+ * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
+ * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ *
+ * $Revision$
+ * $Date$
+ * $State$
+ */
+
+// Simple fragment program to attenuate the input fragment color as a
+// function of the distance of the fragment position from the center
+// of the window
+
+// define inputs from vertex shader to fragment shader
+struct vertin
+{
+ float4 HPosition : POSITION;
+ float4 FragPos : TEXCOORD0;
+ float4 Color0 : COLOR0;
+};
+
+float4 main(vertin IN) : COLOR
+{
+ // Compute distance from center in range [0.0, 1.0]
+ float2 dist = min(abs(IN.FragPos.xy), 1.0f);
+ float2 invDist = 1.0f - dist;
+
+ // Compute attenuation
+ float atten = invDist.x * invDist.y;
+ float4 outcolor = float4(IN.Color0 * atten);
+
+ return outcolor;
+}
diff --git a/src/CgShaderTest/simple_vp.cg b/src/CgShaderTest/simple_vp.cg
new file mode 100644
index 0000000..cec98ad
--- /dev/null
+++ b/src/CgShaderTest/simple_vp.cg
@@ -0,0 +1,167 @@
+/*
+ * $RCSfile$
+ *
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
+ * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
+ * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
+ * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
+ * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
+ * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ *
+ * $Revision$
+ * $Date$
+ * $State$
+ */
+
+/*********************************************************************NVMH3****
+Path: NVSDK\Common\media\programs
+File: simple.cg
+
+Copyright NVIDIA Corporation 2002
+TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
+*AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS
+BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES
+WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
+BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS)
+ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS
+BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+Comments:
+
+******************************************************************************/
+
+// Simple vertex shader, derived from NVIDIA's simple.cg sample
+// shader, that modulates the lit color with a noise pattern based on
+// vertex position.
+
+// define inputs from application
+struct appin
+{
+ float4 Position : POSITION;
+ float4 Normal : NORMAL;
+};
+
+// define outputs from vertex shader
+struct vertout
+{
+ float4 HPosition : POSITION;
+ float4 FragPos : TEXCOORD0;
+ float4 Color0 : COLOR0;
+};
+
+vertout main(appin IN,
+ uniform float4x4 ModelViewProj,
+ uniform float4x4 ModelViewIT,
+ uniform float4 LightVec,
+ uniform float4 LightColor,
+ uniform float4 DiffuseMaterial,
+ uniform float4 SpecularMaterial)
+{
+ vertout OUT;
+
+// Assume that the profile is PROFILE_ARBVP1...
+// #ifdef PROFILE_ARBVP1
+ ModelViewProj = glstate.matrix.mvp;
+ ModelViewIT = glstate.matrix.invtrans.modelview[0];
+ LightVec = glstate.light[0].position;
+ LightColor = glstate.light[0].diffuse;
+ DiffuseMaterial = glstate.material.front.diffuse;
+ SpecularMaterial = glstate.material.front.specular;
+// #endif
+
+ // transform vertex position into homogenous clip-space
+ OUT.HPosition = mul(ModelViewProj, IN.Position);
+
+ // Output the post-perspective-divide position as FragPos
+ float invW = 1.0f / OUT.HPosition.w;
+ OUT.FragPos = OUT.HPosition * invW;
+
+ // transform normal from model-space to view-space
+ float3 normalVec = normalize(mul(ModelViewIT, IN.Normal).xyz);
+
+ // store normalized light vector
+ float3 lightVec = normalize(LightVec.xyz);
+
+ // calculate half angle vector
+ float3 eyeVec = float3(0.0, 0.0, 1.0);
+ float3 halfVec = normalize(lightVec + eyeVec);
+
+ // calculate diffuse component
+ float diffuse = dot(normalVec, lightVec);
+
+ // calculate specular component
+ float specular = dot(normalVec, halfVec);
+
+ // The lit() function is a handy function in the standard library that
+ // can be used to accelerate your lighting calculations.
+ //
+ // This function return a vector containing these values:
+ // result.x = 1.0;
+ // result.y = max(diffuse, 0);
+ // result.z = if (result.y > 0.0) then pow(specular, 32) else 0.0
+ // result.w = 1.0;
+
+ // Use the lit function to compute lighting vector from diffuse and
+ // specular values
+ float4 lighting = lit(diffuse, specular, 32);
+
+ // combine diffuse and specular contributions
+ float3 color0 = (lighting.y * DiffuseMaterial.xyz * LightColor.xyz) +
+ (lighting.z * SpecularMaterial.xyz);
+
+ // Generate a pseudo-random noise pattern
+// float3 xyz = clamp((normalVec.xyz + 1.0) * 0.5, 0.0, 1.0);
+ float3 xyz = clamp((OUT.HPosition.xyz + 1.0) * 0.5, 0.0, 1.0);
+
+ xyz = frac(xyz * 262144.0);
+ float randSeed = frac(3.0 * xyz.x + 5.0 * xyz.y + 7.0 * xyz.z);
+
+ float3 altColor;
+
+ randSeed = frac(37.0 * randSeed);
+ altColor.x = randSeed * 0.5 + 0.5;
+ randSeed = frac(37.0 * randSeed);
+ altColor.y = randSeed * 0.5 + 0.5;
+ randSeed = frac(37.0 * randSeed);
+ altColor.z = randSeed * 0.5 + 0.5;
+ randSeed = frac(37.0 * randSeed);
+ float altAlpha = randSeed * 0.5;
+
+ // Apply noise and output final vertex color
+ OUT.Color0.rgb = lerp(color0, altColor, altAlpha);
+ OUT.Color0.a = 1.0;
+
+ return OUT;
+}
diff --git a/src/DepthFuncTest/DepthFuncTest.form b/src/DepthFuncTest/DepthFuncTest.form
new file mode 100644
index 0000000..b7d1376
--- /dev/null
+++ b/src/DepthFuncTest/DepthFuncTest.form
@@ -0,0 +1,217 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.2" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="3"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-16,0,0,1,-109"/>
+ <SyntheticProperty name="formPosition" type="java.awt.Point" value="-84,-19,0,5,115,114,0,14,106,97,118,97,46,97,119,116,46,80,111,105,110,116,-74,-60,-118,114,52,126,-56,38,2,0,2,73,0,1,120,73,0,1,121,120,112,0,0,0,0,0,0,0,0"/>
+ <SyntheticProperty name="formSizePolicy" type="int" value="0"/>
+ <SyntheticProperty name="generatePosition" type="boolean" value="true"/>
+ <SyntheticProperty name="generateSize" type="boolean" value="true"/>
+ <SyntheticProperty name="generateCenter" type="boolean" value="false"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-40,0,0,1,-117"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
+ <SubComponents>
+ <Container class="javax.swing.JPanel" name="jPanel1">
+ <Properties>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
+ <TitledBorder title="WireFrame Object"/>
+ </Border>
+ </Property>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="jLabel1">
+ <Properties>
+ <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+ <Font name="Dialog" size="12" style="0"/>
+ </Property>
+ <Property name="text" type="java.lang.String" value="Depth function"/>
+ <Property name="toolTipText" type="java.lang.String" value="Mode for normal object"/>
+ </Properties>
+ <AccessibilityProperties>
+ <Property name="AccessibleContext.accessibleParent" type="javax.accessibility.Accessible" editor="org.netbeans.modules.form.RADVisualComponent$AccessibleParentEditor">
+ <ComponentRef name="shadedComboBox"/>
+ </Property>
+ </AccessibilityProperties>
+ </Component>
+ <Component class="javax.swing.JComboBox" name="normalComboBox">
+ <Properties>
+ <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+ <Font name="Dialog" size="12" style="0"/>
+ </Property>
+ <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
+ <StringArray count="8">
+ <StringItem index="0" value="ALWAYS"/>
+ <StringItem index="1" value="NEVER"/>
+ <StringItem index="2" value="EQUAL"/>
+ <StringItem index="3" value="NOT_EQUAL"/>
+ <StringItem index="4" value="LESS"/>
+ <StringItem index="5" value="LESS_OR_EQUAL"/>
+ <StringItem index="6" value="GREATER"/>
+ <StringItem index="7" value="GREATER_OR_EQUAL"/>
+ </StringArray>
+ </Property>
+ <Property name="selectedIndex" type="int" value="6"/>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="[150, 22]"/>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="normalComboBoxActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JCheckBox" name="wfCheckBox">
+ <Properties>
+ <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+ <Font name="Dialog" size="12" style="0"/>
+ </Property>
+ <Property name="text" type="java.lang.String" value="Write Depth Buffer"/>
+ <Property name="toolTipText" type="java.lang.String" value="Depth will be written for the object, if selected"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="wfCheckBoxActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Container class="javax.swing.JPanel" name="jPanel2">
+ <Properties>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
+ <TitledBorder title="Shaded Object"/>
+ </Border>
+ </Property>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="jLabel3">
+ <Properties>
+ <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+ <Font name="Dialog" size="12" style="0"/>
+ </Property>
+ <Property name="text" type="java.lang.String" value="Depth Function"/>
+ <Property name="toolTipText" type="java.lang.String" value="Mode of shaded object"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JComboBox" name="shadedComboBox">
+ <Properties>
+ <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+ <Font name="Dialog" size="12" style="0"/>
+ </Property>
+ <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
+ <StringArray count="8">
+ <StringItem index="0" value="ALWAYS"/>
+ <StringItem index="1" value="NEVER"/>
+ <StringItem index="2" value="EQUAL"/>
+ <StringItem index="3" value="NOT_EQUAL"/>
+ <StringItem index="4" value="LESS"/>
+ <StringItem index="5" value="LESS_OR_EQUAL"/>
+ <StringItem index="6" value="GREATER"/>
+ <StringItem index="7" value="GREATER_OR_EQUAL"/>
+ </StringArray>
+ </Property>
+ <Property name="selectedIndex" type="int" value="4"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="shadedComboBoxActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JCheckBox" name="shadedCheckBox">
+ <Properties>
+ <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+ <Font name="Dialog" size="12" style="0"/>
+ </Property>
+ <Property name="selected" type="boolean" value="true"/>
+ <Property name="text" type="java.lang.String" value="Write Depth Buffer"/>
+ <Property name="toolTipText" type="java.lang.String" value="Depth will be written for the object, if selected"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="shadedCheckBoxActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Container class="javax.swing.JPanel" name="jPanel3">
+ <Properties>
+ <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
+ <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
+ <TitledBorder title="Rotating Cube"/>
+ </Border>
+ </Property>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="jLabel4">
+ <Properties>
+ <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+ <Font name="Dialog" size="12" style="0"/>
+ </Property>
+ <Property name="text" type="java.lang.String" value="Raster Operator"/>
+ <Property name="toolTipText" type="java.lang.String" value="Raster mode of rotating object (try NOOP)"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JComboBox" name="rotatingComboBox">
+ <Properties>
+ <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
+ <Font name="Dialog" size="12" style="0"/>
+ </Property>
+ <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
+ <StringArray count="16">
+ <StringItem index="0" value="CLEAR"/>
+ <StringItem index="1" value="AND"/>
+ <StringItem index="2" value="AND_REVERSE"/>
+ <StringItem index="3" value="COPY"/>
+ <StringItem index="4" value="AND_INVERTED"/>
+ <StringItem index="5" value="NOOP"/>
+ <StringItem index="6" value="XOR"/>
+ <StringItem index="7" value="OR"/>
+ <StringItem index="8" value="NOR"/>
+ <StringItem index="9" value="EQUIV"/>
+ <StringItem index="10" value="INVERT"/>
+ <StringItem index="11" value="OR_REVERSE"/>
+ <StringItem index="12" value="COPY_INVERTED"/>
+ <StringItem index="13" value="OR_INVERTED"/>
+ <StringItem index="14" value="NAND"/>
+ <StringItem index="15" value="SET"/>
+ </StringArray>
+ </Property>
+ <Property name="selectedIndex" type="int" value="3"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="rotatingComboBoxActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+</Form>
diff --git a/src/DepthFuncTest/DepthFuncTest.java b/src/DepthFuncTest/DepthFuncTest.java
new file mode 100644
index 0000000..b053857
--- /dev/null
+++ b/src/DepthFuncTest/DepthFuncTest.java
@@ -0,0 +1,357 @@
+/*
+ * $RCSfile$
+ *
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
+ * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
+ * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
+ * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
+ * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
+ * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ *
+ * $Revision$
+ * $Date$
+ * $State$
+ */
+
+import javax.media.j3d.*;
+
+
+/**
+ *The goal of that example is to show the use of different ZBuffer comparison modes.
+ */
+public class DepthFuncTest extends javax.swing.JFrame
+{
+
+ RenderFrame rf;
+
+ /**
+ * Creates new form DepthFuncTest
+ */
+ public DepthFuncTest(){
+ initComponents();
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
+ private void initComponents()
+ {
+ java.awt.GridBagConstraints gridBagConstraints;
+
+ jPanel1 = new javax.swing.JPanel();
+ jLabel1 = new javax.swing.JLabel();
+ normalComboBox = new javax.swing.JComboBox();
+ wfCheckBox = new javax.swing.JCheckBox();
+ jPanel2 = new javax.swing.JPanel();
+ jLabel3 = new javax.swing.JLabel();
+ shadedComboBox = new javax.swing.JComboBox();
+ shadedCheckBox = new javax.swing.JCheckBox();
+ jPanel3 = new javax.swing.JPanel();
+ jLabel4 = new javax.swing.JLabel();
+ rotatingComboBox = new javax.swing.JComboBox();
+
+ getContentPane().setLayout(new java.awt.GridBagLayout());
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+ jPanel1.setBorder(new javax.swing.border.TitledBorder("WireFrame Object"));
+ jLabel1.setFont(new java.awt.Font("Dialog", 0, 12));
+ jLabel1.setText("Depth function");
+ jLabel1.setToolTipText("Mode for normal object");
+ jPanel1.add(jLabel1);
+ jLabel1.getAccessibleContext().setAccessibleParent(shadedComboBox);
+
+ normalComboBox.setFont(new java.awt.Font("Dialog", 0, 12));
+ normalComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ALWAYS", "NEVER", "EQUAL", "NOT_EQUAL", "LESS", "LESS_OR_EQUAL", "GREATER", "GREATER_OR_EQUAL" }));
+ normalComboBox.setSelectedIndex(6);
+ normalComboBox.setPreferredSize(new java.awt.Dimension(150, 22));
+ normalComboBox.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ normalComboBoxActionPerformed(evt);
+ }
+ });
+
+ jPanel1.add(normalComboBox);
+
+ wfCheckBox.setFont(new java.awt.Font("Dialog", 0, 12));
+ wfCheckBox.setText("Write Depth Buffer");
+ wfCheckBox.setToolTipText("Depth will be written for the object, if selected");
+ wfCheckBox.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ wfCheckBoxActionPerformed(evt);
+ }
+ });
+
+ jPanel1.add(wfCheckBox);
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ getContentPane().add(jPanel1, gridBagConstraints);
+
+ jPanel2.setBorder(new javax.swing.border.TitledBorder("Shaded Object"));
+ jLabel3.setFont(new java.awt.Font("Dialog", 0, 12));
+ jLabel3.setText("Depth Function");
+ jLabel3.setToolTipText("Mode of shaded object");
+ jPanel2.add(jLabel3);
+
+ shadedComboBox.setFont(new java.awt.Font("Dialog", 0, 12));
+ shadedComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ALWAYS", "NEVER", "EQUAL", "NOT_EQUAL", "LESS", "LESS_OR_EQUAL", "GREATER", "GREATER_OR_EQUAL" }));
+ shadedComboBox.setSelectedIndex(4);
+ shadedComboBox.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ shadedComboBoxActionPerformed(evt);
+ }
+ });
+
+ jPanel2.add(shadedComboBox);
+
+ shadedCheckBox.setFont(new java.awt.Font("Dialog", 0, 12));
+ shadedCheckBox.setSelected(true);
+ shadedCheckBox.setText("Write Depth Buffer");
+ shadedCheckBox.setToolTipText("Depth will be written for the object, if selected");
+ shadedCheckBox.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ shadedCheckBoxActionPerformed(evt);
+ }
+ });
+
+ jPanel2.add(shadedCheckBox);
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ getContentPane().add(jPanel2, gridBagConstraints);
+
+ jPanel3.setBorder(new javax.swing.border.TitledBorder("Rotating Cube"));
+ jLabel4.setFont(new java.awt.Font("Dialog", 0, 12));
+ jLabel4.setText("Raster Operator");
+ jLabel4.setToolTipText("Raster mode of rotating object (try NOOP)");
+ jPanel3.add(jLabel4);
+
+ rotatingComboBox.setFont(new java.awt.Font("Dialog", 0, 12));
+ rotatingComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "CLEAR", "AND", "AND_REVERSE", "COPY", "AND_INVERTED", "NOOP", "XOR", "OR", "NOR", "EQUIV", "INVERT", "OR_REVERSE", "COPY_INVERTED", "OR_INVERTED", "NAND", "SET" }));
+ rotatingComboBox.setSelectedIndex(3);
+ rotatingComboBox.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ rotatingComboBoxActionPerformed(evt);
+ }
+ });
+
+ jPanel3.add(rotatingComboBox);
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 2;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ getContentPane().add(jPanel3, gridBagConstraints);
+
+ setBounds(0, 0, 403, 240);
+ }
+ // </editor-fold>//GEN-END:initComponents
+
+ private void rotatingComboBoxActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_rotatingComboBoxActionPerformed
+ {//GEN-HEADEREND:event_rotatingComboBoxActionPerformed
+ String selectedItem = rotatingComboBox.getSelectedItem().toString(); // how to avoid a cast and all that goes with it. (lazyness)
+ int mode = RenderingAttributes.ROP_COPY;
+ if ( "CLEAR".equals(selectedItem) )
+ {
+ mode = RenderingAttributes.ROP_CLEAR;
+ }
+ else if ( "AND".equals(selectedItem) )
+ {
+ mode = RenderingAttributes.ROP_AND;
+ }
+ else if ( "AND_REVERSE".equals(selectedItem) )
+ {
+ mode = RenderingAttributes.ROP_AND_REVERSE;
+ }
+ else if ( "COPY".equals(selectedItem) )
+ {
+ mode = RenderingAttributes.ROP_COPY;
+ }
+ else if ( "AND_INVERTED".equals(selectedItem) )
+ {
+ mode = RenderingAttributes.ROP_AND_INVERTED;
+ }
+ else if ( "NOOP".equals(selectedItem) )
+ {
+ mode = RenderingAttributes.ROP_NOOP;
+ }
+ else if ( "XOR".equals(selectedItem) )
+ {
+ mode = RenderingAttributes.ROP_XOR;
+ }
+ else if ( "OR".equals(selectedItem) )
+ {
+ mode = RenderingAttributes.ROP_OR;
+ }
+ else if ( "NOR".equals(selectedItem) )
+ {
+ mode = RenderingAttributes.ROP_NOR;
+ }
+ else if ( "EQUIV".equals(selectedItem) )
+ {
+ mode = RenderingAttributes.ROP_EQUIV;
+ }
+ else if ( "INVERT".equals(selectedItem) )
+ {
+ mode = RenderingAttributes.ROP_INVERT;
+ }
+ else if ( "OR_REVERSE".equals(selectedItem) )
+ {
+ mode = RenderingAttributes.ROP_OR_REVERSE;
+ }
+ else if ( "COPY_INVERTED".equals(selectedItem) )
+ {
+ mode = RenderingAttributes.ROP_COPY_INVERTED;
+ }
+ else if ( "OR_INVERTED".equals(selectedItem) )
+ {
+ mode = RenderingAttributes.ROP_OR_INVERTED;
+ }
+ else if ( "NAND".equals(selectedItem) )
+ {
+ mode = RenderingAttributes.ROP_NAND;
+ }
+ else if ( "SET".equals(selectedItem) )
+ {
+ mode = RenderingAttributes.ROP_SET;
+ }
+ else
+ {
+ System.out.println("oops. wrong mode in ROP combo: "+selectedItem);
+ }
+ rf.setRotatingObjectROPMode( mode );
+ }//GEN-LAST:event_rotatingComboBoxActionPerformed
+
+ private void shadedCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_shadedCheckBoxActionPerformed
+ rf.setStaticObjectDBWriteStatus( shadedCheckBox.isSelected() );
+ }//GEN-LAST:event_shadedCheckBoxActionPerformed
+
+ private void wfCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_wfCheckBoxActionPerformed
+ rf.setStaticWFObjectDBWriteStatus( wfCheckBox.isSelected() );
+ }//GEN-LAST:event_wfCheckBoxActionPerformed
+
+ private void shadedComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_shadedComboBoxActionPerformed
+ int func = RenderingAttributes.LESS_OR_EQUAL;
+ String selectedItem = shadedComboBox.getSelectedItem().toString(); // how to avoid a cast and all that goes with it. (lazyness)
+ rf.setStaticObjectTestFunc( getID( selectedItem ) );
+ }//GEN-LAST:event_shadedComboBoxActionPerformed
+
+ private void normalComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_normalComboBoxActionPerformed
+ int func = RenderingAttributes.LESS_OR_EQUAL;
+ String selectedItem = normalComboBox.getSelectedItem().toString(); // how to avoid a cast and all that goes with it. (lazyness)
+ rf.setStaticWFObjectTestFunc( getID( selectedItem ) );
+ }//GEN-LAST:event_normalComboBoxActionPerformed
+
+ int getID( String selectedItem )
+ {
+ int func = RenderingAttributes.LESS_OR_EQUAL;
+ if ( "LESS_OR_EQUAL".equals(selectedItem) )
+ {
+ func = RenderingAttributes.LESS_OR_EQUAL;
+ }
+ else if ( "NEVER".equals(selectedItem) )
+ {
+ func = RenderingAttributes.NEVER;
+ }
+ else if ( "ALWAYS".equals(selectedItem) )
+ {
+ func = RenderingAttributes.ALWAYS;
+ }
+ else if ( "GREATER".equals(selectedItem) )
+ {
+ func = RenderingAttributes.GREATER;
+ }
+ else if ( "GREATER_OR_EQUAL".equals(selectedItem) )
+ {
+ func = RenderingAttributes.GREATER_OR_EQUAL;
+ }
+ else if ( "LESS".equals(selectedItem) )
+ {
+ func = RenderingAttributes.LESS;
+ }
+ else if ( "EQUAL".equals(selectedItem) )
+ {
+ func = RenderingAttributes.EQUAL;
+ }
+ else if ( "NOT_EQUAL".equals(selectedItem) )
+ {
+ func = RenderingAttributes.NOT_EQUAL;
+ }
+ return func;
+ }
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String args[]) {
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ DepthFuncTest dpt = new DepthFuncTest();
+ dpt.rf = new RenderFrame( dpt );
+ dpt.setVisible(true);
+ dpt.rf.setVisible(true);
+ }
+ });
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel3;
+ private javax.swing.JLabel jLabel4;
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JPanel jPanel3;
+ private javax.swing.JComboBox normalComboBox;
+ private javax.swing.JComboBox rotatingComboBox;
+ private javax.swing.JCheckBox shadedCheckBox;
+ private javax.swing.JComboBox shadedComboBox;
+ private javax.swing.JCheckBox wfCheckBox;
+ // End of variables declaration//GEN-END:variables
+
+}
diff --git a/src/DepthFuncTest/RenderFrame.form b/src/DepthFuncTest/RenderFrame.form
new file mode 100644
index 0000000..2edc4bb
--- /dev/null
+++ b/src/DepthFuncTest/RenderFrame.form
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.0" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="3"/>
+ <Property name="title" type="java.lang.String" value="J3D frame"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-32,0,0,2,-128"/>
+ <SyntheticProperty name="formPosition" type="java.awt.Point" value="-84,-19,0,5,115,114,0,14,106,97,118,97,46,97,119,116,46,80,111,105,110,116,-74,-60,-118,114,52,126,-56,38,2,0,2,73,0,1,120,73,0,1,121,120,112,0,0,1,-112,0,0,0,0"/>
+ <SyntheticProperty name="formSizePolicy" type="int" value="0"/>
+ <SyntheticProperty name="generatePosition" type="boolean" value="true"/>
+ <SyntheticProperty name="generateSize" type="boolean" value="true"/>
+ <SyntheticProperty name="generateCenter" type="boolean" value="false"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-56,0,0,2,120"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
+</Form>
diff --git a/src/DepthFuncTest/RenderFrame.java b/src/DepthFuncTest/RenderFrame.java
new file mode 100644
index 0000000..b56e332
--- /dev/null
+++ b/src/DepthFuncTest/RenderFrame.java
@@ -0,0 +1,290 @@
+/*
+ * $RCSfile$
+ *
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
+ * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
+ * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
+ * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
+ * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
+ * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ *
+ * $Revision$
+ * $Date$
+ * $State$
+ */
+
+import com.sun.j3d.utils.behaviors.mouse.*;
+import com.sun.j3d.utils.behaviors.vp.OrbitBehavior;
+import java.awt.GraphicsConfiguration;
+import javax.media.j3d.*;
+import com.sun.j3d.utils.universe.*;
+import com.sun.j3d.utils.geometry.*;
+import javax.vecmath.*;
+
+
+public class RenderFrame extends javax.swing.JFrame {
+
+ DepthFuncTest dpt;
+
+ SimpleUniverse su;
+
+ RenderingAttributes staticWFBoxRA;
+ RenderingAttributes staticBoxRA;
+
+ RenderingAttributes rotatingBoxRA;
+
+ /** Creates new form RenderFrame */
+ public RenderFrame( DepthFuncTest _dpt) {
+ dpt = _dpt;
+ initComponents();
+ initUniverse();
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
+ private void initComponents()
+ {
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
+ setTitle("J3D frame");
+ setBounds(400, 0, 640, 480);
+ }
+ // </editor-fold>//GEN-END:initComponents
+
+ void initUniverse() {
+ GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
+
+ Canvas3D c = new Canvas3D(config);
+ add("Center", c);
+ su = new SimpleUniverse(c);
+ su.addBranchGraph( createScene() );
+ c.getView().setMinimumFrameCycleTime( 10 );
+ }
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ // End of variables declaration//GEN-END:variables
+
+ BranchGroup createScene() {
+ BoundingSphere bounds = new BoundingSphere( new Point3d( 0.0, 0.0, 0.0 ), 100.0 );
+
+ BranchGroup globalBG = new BranchGroup();
+ BranchGroup rotObjectBG = new BranchGroup();
+ OrderedGroup staticObjectOG = new OrderedGroup();
+ BranchGroup lampsBG = new BranchGroup();
+ OrderedGroup oGroup = new OrderedGroup();
+ TransformGroup staticBoxRotTG = new TransformGroup();
+ staticBoxRotTG.addChild( staticObjectOG );
+ TransformGroup objectsTGRot = new TransformGroup();
+ TransformGroup objectsTGTrans = new TransformGroup();
+ Transform3D objectsTGTransT3d = new Transform3D();
+ objectsTGTransT3d.setTranslation( new Vector3f( 0.0f, 0.0f, -10.0f ) );
+ objectsTGTrans.setTransform( objectsTGTransT3d );
+ objectsTGRot.addChild( oGroup );
+ objectsTGTrans.addChild( objectsTGRot );
+ lampsBG.addChild( objectsTGTrans );
+
+ //adding a sphere as backgroung so there is something else than flat black, and cut cube removal as an other implication. (seeing through)
+ Appearance globalSphereAppearance = new Appearance();
+ PolygonAttributes globalSpherePA = new PolygonAttributes();
+ globalSpherePA.setCullFace( globalSpherePA.CULL_FRONT );// so that interior of the sphere is visible.
+ Material globalSphereMaterial = new Material();
+ globalSphereMaterial.setEmissiveColor( .25f ,.3f ,.35f );
+ globalSphereAppearance.setMaterial( globalSphereMaterial );
+ globalSphereAppearance.setPolygonAttributes( globalSpherePA );
+ Sphere globalSphere = new Sphere( 6.0f );
+ globalSphere.setAppearance( globalSphereAppearance );
+ globalSphere.setBounds( bounds );
+ oGroup.addChild( globalSphere );
+
+ globalBG.addChild( lampsBG );
+
+ // adding lamps.
+ PointLight frontLamp = new PointLight( new Color3f( 1.0f, 1.0f, 1.0f ), new Point3f( 20, 20, 20 ), new Point3f( 0.0f, .0f, 0.f ) );
+ lampsBG.addChild( frontLamp );
+ frontLamp.setBounds( bounds );
+ frontLamp.setInfluencingBounds( bounds );
+ PointLight backLamp = new PointLight( new Color3f( 1.0f, .0f, .0f ), new Point3f( -20, -20, -20 ), new Point3f( 0.0f, .0f, 0.f ) );
+ lampsBG.addChild( backLamp );
+ backLamp.setBounds( bounds );
+ backLamp.setInfluencingBounds( bounds );
+
+ //adding shapes.
+ {
+ //adding rotating and scaling cube
+ //doing the rotation
+ TransformGroup rotBoxTGRot = new TransformGroup();
+ rotBoxTGRot.setCapability( rotBoxTGRot.ALLOW_TRANSFORM_WRITE );
+ RotationInterpolator rotBoxRotInt = new RotationInterpolator( new Alpha( -1, 20000 ) , rotBoxTGRot );
+ rotBoxRotInt.setSchedulingBounds( bounds );
+ rotBoxRotInt.setBounds( bounds );
+
+ //doing the scaling
+ Transform3D scaleBoxt3d = new Transform3D();
+ TransformGroup rotBoxTGScale = new TransformGroup();
+ rotBoxTGScale.setCapability( rotBoxTGScale.ALLOW_TRANSFORM_WRITE );
+ ScaleInterpolator rotBoxScaleInt = new ScaleInterpolator( new Alpha( -1, Alpha.INCREASING_ENABLE|Alpha.DECREASING_ENABLE, 0, 0, 3000, 1500, 0, 3000, 1500, 0 ) , rotBoxTGScale, new Transform3D(), 0.7f, 1.6f );
+ rotBoxScaleInt.setSchedulingBounds( bounds );
+ rotBoxScaleInt.setBounds( bounds );
+
+ Appearance rotBoxApp = new Appearance();
+ Material rotBoxMat = new Material();
+ rotBoxMat.setDiffuseColor( .4f, .4f, .4f );
+ rotBoxApp.setMaterial( rotBoxMat );
+ Box rotBox = new Box( 1.1f, 1.1f, 1.1f, rotBoxApp );
+ rotBoxTGScale.addChild( rotBox );
+ rotBoxTGRot.addChild( rotBoxTGScale );
+ TransformGroup rotBoxTG = new TransformGroup();
+ rotBoxTG.addChild( rotBoxTGRot );
+ rotObjectBG.addChild( rotBoxTG );
+ rotObjectBG.addChild( rotBoxScaleInt );
+ rotObjectBG.addChild( rotBoxRotInt );
+ rotBox.setBounds( bounds );
+
+ rotatingBoxRA = new RenderingAttributes();
+ rotatingBoxRA.setRasterOpEnable( true );
+ rotatingBoxRA.setCapability( staticBoxRA.ALLOW_RASTER_OP_WRITE );
+// rotatingBoxRA.setRasterOp( rotatingBoxRA.ROP_XOR );
+ rotBoxApp.setRenderingAttributes( rotatingBoxRA );
+
+
+ rotBox.setAppearance( rotBoxApp );
+ }
+
+ //adding static back face wireframe cube
+ {
+ Box staticWFBoxBack = new Box( );
+ Appearance staticWFBoxApp = new Appearance();
+ Material staticWFBoxMat = new Material();
+ staticWFBoxMat.setDiffuseColor( 0.f, 0.f, 0.f );
+ staticWFBoxMat.setEmissiveColor( 0.f, .4f, 0.f );
+ staticWFBoxApp.setMaterial( staticWFBoxMat );
+ PolygonAttributes staticWFBoxPABack = new PolygonAttributes( PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_FRONT, 0.0f );
+ staticWFBoxApp.setPolygonAttributes( staticWFBoxPABack );
+ staticWFBoxRA = new RenderingAttributes();
+ staticWFBoxRA.setCapability( staticWFBoxRA.ALLOW_DEPTH_TEST_FUNCTION_WRITE );
+ staticWFBoxRA.setCapability( staticWFBoxRA.ALLOW_DEPTH_ENABLE_WRITE );
+ staticWFBoxRA.setDepthTestFunction( staticWFBoxRA.GREATER );
+ staticWFBoxRA.setDepthBufferWriteEnable( false );
+ staticWFBoxApp.setRenderingAttributes( staticWFBoxRA );
+ staticWFBoxBack.setAppearance( staticWFBoxApp );
+ staticWFBoxBack.setBounds( bounds );
+ staticObjectOG.addChild( staticWFBoxBack );
+ }
+
+ //adding static front face wireframe cube
+ {
+ Box staticWFBox = new Box( );
+ Appearance staticWFBoxApp = new Appearance();
+ Material staticWFBoxMat = new Material();
+ staticWFBoxMat.setDiffuseColor( 0.f, 0.f, 0.f );
+ staticWFBoxMat.setEmissiveColor( 0.f, 1.f, 0.f );
+ staticWFBoxApp.setMaterial( staticWFBoxMat );
+ PolygonAttributes staticWFBoxPA = new PolygonAttributes( PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_BACK, 0.0f );
+ staticWFBoxApp.setPolygonAttributes( staticWFBoxPA );
+ staticWFBoxApp.setRenderingAttributes( staticWFBoxRA );
+ staticWFBox.setAppearance( staticWFBoxApp );
+ staticWFBox.setBounds( bounds );
+ staticObjectOG.addChild( staticWFBox );
+ }
+
+
+ {// rotating the static cubes
+ Transform3D boxt3d = new Transform3D();
+ Transform3D tempt3d = new Transform3D();
+ boxt3d.rotZ( Math.PI/4.0f );
+ tempt3d.rotX( Math.PI/4.0f );
+ boxt3d.mul( tempt3d );
+ tempt3d.rotY( Math.PI/4.0f );
+ boxt3d.mul( tempt3d );
+ staticBoxRotTG.setTransform( boxt3d );
+ }
+
+ // adding static flat cube
+ {
+ Box staticBox = new Box( );
+ staticBox.setBounds( bounds );
+ Appearance boxApp = new Appearance();
+ Material boxMat = new Material();
+ boxMat.setDiffuseColor( .7f, .7f, .7f );
+ boxApp.setMaterial( boxMat );
+ staticBoxRA = new RenderingAttributes();
+ staticBoxRA.setCapability( staticBoxRA.ALLOW_DEPTH_TEST_FUNCTION_WRITE );
+ staticBoxRA.setCapability( staticBoxRA.ALLOW_DEPTH_ENABLE_WRITE );
+ staticBoxRA.setDepthTestFunction( staticBoxRA.LESS );
+ staticBoxRA.setDepthBufferWriteEnable( false );
+ boxApp.setRenderingAttributes( staticBoxRA );
+ staticBox.setAppearance( boxApp );
+ staticObjectOG.addChild( staticBox );
+ }
+ oGroup.addChild( rotObjectBG );
+ oGroup.addChild( staticBoxRotTG );
+
+ //adding the mouse rotate behavior to the group of cubes.
+ MouseRotate behavior = new MouseRotate();
+ behavior.setTransformGroup( objectsTGRot );
+ objectsTGRot.addChild( behavior );
+ objectsTGRot.setCapability( objectsTGRot.ALLOW_TRANSFORM_READ );
+ objectsTGRot.setCapability( objectsTGRot.ALLOW_TRANSFORM_WRITE );
+ behavior.setSchedulingBounds(bounds);
+ return globalBG;
+ }
+
+ public void setStaticWFObjectTestFunc( int func )
+ {
+ staticWFBoxRA.setDepthTestFunction( func );
+ }
+
+ public void setStaticObjectTestFunc( int func )
+ {
+ staticBoxRA.setDepthTestFunction( func );
+ }
+
+ public void setStaticWFObjectDBWriteStatus( boolean status )
+ {
+ staticWFBoxRA.setDepthBufferWriteEnable( status );
+ }
+
+ public void setStaticObjectDBWriteStatus( boolean status )
+ {
+ staticBoxRA.setDepthBufferWriteEnable( status );
+ }
+
+ public void setRotatingObjectROPMode( int mode )
+ {
+ rotatingBoxRA.setRasterOp( mode );
+ }
+
+}
diff --git a/src/DepthFuncTest/build.xml b/src/DepthFuncTest/build.xml
new file mode 100644
index 0000000..47e5a36
--- /dev/null
+++ b/src/DepthFuncTest/build.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+
+<!--
+/*
+ * $RCSfile$
+ *
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
+ * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
+ * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
+ * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
+ * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
+ * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ *
+ * $Revision$
+ * $Date$
+ * $State$
+ */
+ -->
+
+<project basedir="." default="compile">
+ <target name="compile">
+ <javac
+ destdir="." srcdir="."
+ source="1.4" target="1.4"
+ debug="true" deprecation="true">
+ </javac>
+ </target>
+
+ <target name="all" depends="compile">
+ </target>
+
+ <target description="Clean all build products." name="clean">
+ <delete>
+ <fileset dir=".">
+ <include name="**/*.class"/>
+ </fileset>
+ </delete>
+ </target>
+
+</project>
diff --git a/src/DistortGlyph/DistortBehavior.java b/src/DistortGlyph/DistortBehavior.java
new file mode 100644
index 0000000..98f20cf
--- /dev/null
+++ b/src/DistortGlyph/DistortBehavior.java
@@ -0,0 +1,192 @@
+/*
+ * $RCSfile$
+ *
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
+ * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
+ * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
+ * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
+ * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
+ * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ *
+ * $Revision$
+ * $Date$
+ * $State$
+ */
+
+import java.util.Enumeration;
+
+import javax.media.j3d.Appearance;
+import javax.media.j3d.Behavior;
+import javax.media.j3d.GeometryArray;
+import javax.media.j3d.Shape3D;
+import javax.media.j3d.Transform3D;
+import javax.media.j3d.WakeupCondition;
+import javax.media.j3d.WakeupCriterion;
+import javax.media.j3d.WakeupOnElapsedFrames;
+import javax.media.j3d.WakeupOnElapsedTime;
+
+import javax.vecmath.Vector3f;
+
+public class DistortBehavior extends Behavior {
+ // the wake up condition for the behavior
+ protected WakeupCondition m_InitialWakeupCondition = null;
+ protected WakeupCondition m_FrameWakeupCondition = null;
+
+ // the GeometryArray for the Shape3D that we are modifying
+ protected Shape3D m_Shape3D = null;
+ protected GeometryArray m_GeometryArray = null;
+
+ protected float[] m_CoordinateArray = null;
+ protected float[] m_OriginalCoordinateArray = null;
+ protected Appearance m_Appearance = null;
+
+ protected int m_nElapsedTime = 0;
+ protected int m_nNumFrames = 0;
+ protected int m_nFrameNumber = 0;
+
+ private int frame = 0;
+ protected Vector3f m_Vector = null;
+
+ public DistortBehavior(Shape3D shape3D, int nElapsedTime, int nNumFrames) {
+ // allocate a temporary vector
+ m_Vector = new Vector3f();
+
+ m_FrameWakeupCondition = new WakeupOnElapsedFrames(0);
+
+ restart(shape3D, nElapsedTime, nNumFrames);
+ }
+
+ public WakeupCondition restart(Shape3D shape3D, int nElapsedTime, int nNumFrames) {
+ m_Shape3D = shape3D;
+ m_nElapsedTime = nElapsedTime;
+ m_nNumFrames = nNumFrames;
+ m_nFrameNumber = 0;
+
+ // create the WakeupCriterion for the behavior
+ m_InitialWakeupCondition = new WakeupOnElapsedTime(m_nElapsedTime);
+
+ // save the GeometryArray that we are modifying
+ m_GeometryArray = (GeometryArray) m_Shape3D.getGeometry();
+
+ if (m_Shape3D.isLive() == false && m_Shape3D.isCompiled() == false) {
+ // set the capability bits that the behavior requires
+ m_Shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
+ m_Shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
+
+ m_Shape3D.getAppearance().setCapability(Appearance.ALLOW_POINT_ATTRIBUTES_WRITE);
+ m_Shape3D.getAppearance().setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_WRITE);
+ m_Shape3D.getAppearance().setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_WRITE);
+ m_Shape3D.getAppearance().setCapability(Appearance.ALLOW_TEXTURE_WRITE);
+
+ m_GeometryArray.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
+ m_GeometryArray.setCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
+ m_GeometryArray.setCapability(GeometryArray.ALLOW_COUNT_READ);
+ }
+
+ // make a copy of the object's original appearance
+ m_Appearance = new Appearance();
+ m_Appearance = (Appearance) m_Shape3D.getAppearance().cloneNodeComponent(true);
+
+ // allocate an array for the model coordinates
+ m_CoordinateArray = new float[3 * m_GeometryArray.getVertexCount()];
+
+ // make a copy of the models original coordinates
+ m_OriginalCoordinateArray = new float[3 * m_GeometryArray.getVertexCount()];
+ m_GeometryArray.getCoordinates(0, m_OriginalCoordinateArray);
+
+ // start (or restart) the behavior
+ setEnable(true);
+
+ return m_InitialWakeupCondition;
+ }
+
+ public void initialize() {
+ // apply the initial WakeupCriterion
+ wakeupOn(m_InitialWakeupCondition);
+ }
+
+ public void processStimulus(Enumeration criteria) {
+ while (criteria.hasMoreElements()) {
+ WakeupCriterion wakeUp = (WakeupCriterion) criteria.nextElement();
+
+ if (wakeUp instanceof WakeupOnElapsedTime) {
+ } else {
+ // we are mid explosion, modify the GeometryArray
+ m_nFrameNumber++;
+ frame++;
+ m_GeometryArray.getCoordinates(0, m_CoordinateArray);
+
+ Transform3D t3 = new Transform3D();
+ for (int n = 0; n < m_CoordinateArray.length; n += 3) {
+ m_Vector.x = m_OriginalCoordinateArray[n];
+ m_Vector.y = m_OriginalCoordinateArray[n + 1];
+ m_Vector.z = m_OriginalCoordinateArray[n + 2];
+
+ float spx = (float) (Math.sin(frame *3f / 500));
+ float spy = (float) (Math.cos(frame *5f / 500));
+ Vector3f v = new Vector3f(spx, spy, 0);
+
+ float px = (m_Vector.x - v.x);
+ float py = (m_Vector.y - v.y);
+ float pz = (m_Vector.z - v.z);
+ float d = (float) Math.sqrt(px * px + py * py + pz * pz);
+
+
+ m_Vector.add(new Vector3f(-.25f, -.25f, -.25f));
+ //m_Vector.scale(d);
+
+ t3.rotZ(d);
+ t3.rotX(d*2);
+ t3.rotY(d);
+ t3.transform(m_Vector);
+
+ m_CoordinateArray[n] = m_Vector.x;
+ m_CoordinateArray[n + 1] = m_Vector.y;
+ m_CoordinateArray[n + 2] = m_Vector.z;
+
+ }
+
+ // assign the new coordinates
+ m_GeometryArray.setCoordinates(0, m_CoordinateArray);
+ }
+ }
+
+ if (m_nFrameNumber < m_nNumFrames) {
+ // assign the next WakeUpCondition, so we are notified again
+ wakeupOn(m_FrameWakeupCondition);
+ } else {
+ // restart
+ m_nFrameNumber = 0;
+ wakeupOn(m_FrameWakeupCondition);
+ }
+ }
+}
diff --git a/src/DistortGlyph/DistortGlyphTest.java b/src/DistortGlyph/DistortGlyphTest.java
new file mode 100644
index 0000000..2e024b8
--- /dev/null
+++ b/src/DistortGlyph/DistortGlyphTest.java
@@ -0,0 +1,208 @@
+/*
+ * $RCSfile$
+ *
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
+ * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
+ * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
+ * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
+ * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
+ * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ *
+ * $Revision$
+ * $Date$
+ * $State$
+ */
+
+import java.applet.Applet;
+import java.awt.Font;
+import java.awt.Frame;
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsEnvironment;
+
+import javax.media.j3d.AmbientLight;
+import javax.media.j3d.Appearance;
+import javax.media.j3d.BoundingSphere;
+import javax.media.j3d.BranchGroup;
+import javax.media.j3d.Canvas3D;
+import javax.media.j3d.DirectionalLight;
+import javax.media.j3d.Font3D;
+import javax.media.j3d.FontExtrusion;
+import javax.media.j3d.GeometryArray;
+import javax.media.j3d.GraphicsConfigTemplate3D;
+import javax.media.j3d.Light;
+import javax.media.j3d.Material;
+import javax.media.j3d.PointLight;
+import javax.media.j3d.Shape3D;
+import javax.media.j3d.TexCoordGeneration;
+import javax.media.j3d.Texture;
+import javax.media.j3d.TransformGroup;
+
+import javax.vecmath.Color3f;
+import javax.vecmath.Point3d;
+import javax.vecmath.Point3f;
+import javax.vecmath.Vector3f;
+
+import com.sun.j3d.utils.applet.MainFrame;
+import com.sun.j3d.utils.behaviors.mouse.MouseRotate;
+import com.sun.j3d.utils.behaviors.mouse.MouseTranslate;
+import com.sun.j3d.utils.behaviors.mouse.MouseZoom;
+import com.sun.j3d.utils.image.TextureLoader;
+import com.sun.j3d.utils.universe.SimpleUniverse;
+
+public class DistortGlyphTest extends Applet {
+ // get a nice graphics config
+ private static GraphicsConfiguration getGraphicsConfig() {
+ GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
+ template.setSceneAntialiasing(GraphicsConfigTemplate3D.PREFERRED);
+ GraphicsConfiguration gcfg = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration(template);
+ return gcfg;
+ }
+
+ private void setupLights(BranchGroup root) {
+ // set up the BoundingSphere for all the lights
+ BoundingSphere bounds = new BoundingSphere(new Point3d(), 100.0);
+
+ // Set up the ambient light
+ AmbientLight lightAmbient = new AmbientLight(new Color3f(0.37f, 0.37f, 0.37f));
+ lightAmbient.setInfluencingBounds(bounds);
+ root.addChild(lightAmbient);
+
+ // Set up the directional light
+ Vector3f lightDirection1 = new Vector3f(0.0f, 0.0f, -1.0f);
+ DirectionalLight lightDirectional1 = new DirectionalLight(new Color3f(1.00f, 0.10f, 0.00f), lightDirection1);
+ lightDirectional1.setInfluencingBounds(bounds);
+ lightDirectional1.setCapability(Light.ALLOW_STATE_WRITE);
+ root.addChild(lightDirectional1);
+
+ Point3f lightPos1 = new Point3f(-4.0f, 8.0f, 16.0f);
+ Point3f lightAttenuation1 = new Point3f(1.0f, 0.0f, 0.0f);
+ PointLight pointLight1 = new PointLight(new Color3f(0.37f, 1.00f, 0.37f), lightPos1, lightAttenuation1);
+ pointLight1.setInfluencingBounds(bounds);
+ root.addChild(pointLight1);
+
+ Point3f lightPos2 = new Point3f(-16.0f, 8.0f, 4.0f);
+ Point3f lightAttenuation2 = new Point3f(1.0f, 0.0f, 0.0f);
+ PointLight pointLight2 = new PointLight(new Color3f(0.37f, 0.37f, 1.00f), lightPos2, lightAttenuation2);
+ pointLight2.setInfluencingBounds(bounds);
+ root.addChild(pointLight2);
+ }
+
+ public BranchGroup createSceneGraph() {
+ // Create the root of the branch graph
+ BranchGroup objRoot = new BranchGroup();
+
+ setupLights(objRoot);
+
+ TransformGroup objTransform = new TransformGroup();
+ objTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
+ objTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
+
+ objRoot.addChild(objTransform);
+
+ // setup a nice textured appearance
+ Appearance app = new Appearance();
+ Color3f objColor = new Color3f(1.0f, 0.7f, 0.8f);
+ Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
+ app.setMaterial(new Material(objColor, black, objColor, black, 80.0f));
+ Texture txtr = new TextureLoader("gold.jpg",this).getTexture();
+ app.setTexture(txtr);
+ TexCoordGeneration tcg = new TexCoordGeneration(TexCoordGeneration.SPHERE_MAP,TexCoordGeneration.TEXTURE_COORDINATE_2);
+ app.setTexCoordGeneration(tcg);
+
+ // use a customized FontExtrusion object to control the depth of the text
+ java.awt.geom.GeneralPath gp = new java.awt.geom.GeneralPath();
+ gp.moveTo(0, 0);
+ gp.lineTo(.01f, .01f);
+ gp.lineTo(.2f, .01f);
+ gp.lineTo(.21f, 0f);
+ FontExtrusion fontEx = new FontExtrusion(gp);
+
+ // our glyph
+ Font fnt = new Font("dialog", Font.BOLD, 1);
+ Font3D f3d = new Font3D(fnt, .001, fontEx);
+ GeometryArray geom = f3d.getGlyphGeometry('A');
+ Shape3D shape = new Shape3D(geom, app);
+ objTransform.addChild(shape);
+
+ // the DistortBehavior
+ DistortBehavior eb = new DistortBehavior(shape, 1000, 1000);
+ eb.setSchedulingBounds(new BoundingSphere());
+ objTransform.addChild(eb);
+
+ MouseRotate myMouseRotate = new MouseRotate();
+ myMouseRotate.setTransformGroup(objTransform);
+ myMouseRotate.setSchedulingBounds(new BoundingSphere());
+ objRoot.addChild(myMouseRotate);
+
+ MouseTranslate myMouseTranslate = new MouseTranslate();
+ myMouseTranslate.setTransformGroup(objTransform);
+ myMouseTranslate.setSchedulingBounds(new BoundingSphere());
+ objRoot.addChild(myMouseTranslate);
+
+ MouseZoom myMouseZoom = new MouseZoom();
+ myMouseZoom.setTransformGroup(objTransform);
+ myMouseZoom.setSchedulingBounds(new BoundingSphere());
+ objRoot.addChild(myMouseZoom);
+
+ // Let Java 3D perform optimizations on this scene graph.
+ objRoot.compile();
+
+ return objRoot;
+ }
+
+ // Create a simple scene and attach it to the virtual universe
+ public DistortGlyphTest() {
+ //setLayout(new BorderLayout());
+ GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
+
+ Canvas3D canvas3D = new Canvas3D(getGraphicsConfig());
+ canvas3D.setBounds(0, 0, 800, 600);
+ add("Center", canvas3D);
+
+ BranchGroup scene = createSceneGraph();
+
+ // SimpleUniverse is a Convenience Utility class
+ SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
+
+ // This will move the ViewPlatform back a bit so the
+ // objects in the scene can be viewed.
+ simpleU.getViewingPlatform().setNominalViewingTransform();
+
+ simpleU.addBranchGraph(scene);
+ }
+
+ // The following allows this to be run as an application
+ // as well as an applet
+ public static void main(String[] args) {
+ Frame frame = new MainFrame(new DistortGlyphTest(), 800, 600);
+ }
+}
diff --git a/src/DistortGlyph/build.xml b/src/DistortGlyph/build.xml
new file mode 100644
index 0000000..47e5a36
--- /dev/null
+++ b/src/DistortGlyph/build.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+
+<!--
+/*
+ * $RCSfile$
+ *
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
+ * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
+ * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
+ * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
+ * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
+ * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ *
+ * $Revision$
+ * $Date$
+ * $State$
+ */
+ -->
+
+<project basedir="." default="compile">
+ <target name="compile">
+ <javac
+ destdir="." srcdir="."
+ source="1.4" target="1.4"
+ debug="true" deprecation="true">
+ </javac>
+ </target>
+
+ <target name="all" depends="compile">
+ </target>
+
+ <target description="Clean all build products." name="clean">
+ <delete>
+ <fileset dir=".">
+ <include name="**/*.class"/>
+ </fileset>
+ </delete>
+ </target>
+
+</project>
diff --git a/src/DistortGlyph/gold.jpg b/src/DistortGlyph/gold.jpg
new file mode 100644
index 0000000..40e8786
--- /dev/null
+++ b/src/DistortGlyph/gold.jpg
Binary files differ
diff --git a/src/GLSLShaderTest/ObjLoadGLSL.java b/src/GLSLShaderTest/ObjLoadGLSL.java
new file mode 100644
index 0000000..12369cd
--- /dev/null
+++ b/src/GLSLShaderTest/ObjLoadGLSL.java
@@ -0,0 +1,346 @@
+/*
+ * $RCSfile$
+ *
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
+ * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
+ * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
+ * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
+ * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
+ * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ *
+ * $Revision$
+ * $Date$
+ * $State$
+ */
+
+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 com.sun.j3d.utils.shader.StringIO;
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+import com.sun.j3d.utils.applet.MainFrame;
+import com.sun.j3d.utils.universe.*;
+import javax.media.j3d.*;
+import javax.vecmath.*;
+import java.util.Enumeration;
+import java.io.*;
+import com.sun.j3d.utils.behaviors.vp.*;
+import java.net.URL;
+import java.net.MalformedURLException;
+
+public class ObjLoadGLSL extends Applet {
+
+ private String shaderName = "polkadot3d";
+ private boolean spin = false;
+ private boolean noTriangulate = false;
+ private boolean noStripify = false;
+ private double creaseAngle = 60.0;
+ private URL filename = null;
+ private SimpleUniverse u;
+ private BoundingSphere bounds;
+
+ public BranchGroup createSceneGraph() {
+ // Create the root of the branch graph
+ BranchGroup objRoot = new BranchGroup();
+
+ // Create a Transformgroup to scale all objects so they
+ // appear in the scene.
+ TransformGroup objScale = new TransformGroup();
+ Transform3D t3d = new Transform3D();
+ t3d.setScale(0.7);
+ objScale.setTransform(t3d);
+ objRoot.addChild(objScale);
+
+ // Create the transform group node and initialize it to the
+ // identity. Enable the TRANSFORM_WRITE capability so that
+ // our behavior code can modify it at runtime. Add it to the
+ // root of the subgraph.
+ TransformGroup objTrans = new TransformGroup();
+ objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
+ objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
+ objScale.addChild(objTrans);
+
+ int flags = ObjectFile.RESIZE;
+ if (!noTriangulate) flags |= ObjectFile.TRIANGULATE;
+ if (!noStripify) flags |= ObjectFile.STRIPIFY;
+ ObjectFile f = new ObjectFile(flags,
+ (float)(creaseAngle * Math.PI / 180.0));
+ Scene s = null;
+ try {
+ s = f.load(filename);
+ }
+ catch (FileNotFoundException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ catch (ParsingErrorException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ catch (IncorrectFormatException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ // Set vertex and fragment shader program for all Shape3D nodes in scene
+ String vertexProgram = null;
+ String fragmentProgram = null;
+ try {
+ vertexProgram = StringIO.readFully(shaderName + ".vert");
+ fragmentProgram = StringIO.readFully(shaderName + ".frag");
+ }
+ catch (IOException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ Shader[] shaders = new Shader[2];
+ shaders[0] = new SourceCodeShader(Shader.SHADING_LANGUAGE_GLSL,
+ Shader.SHADER_TYPE_VERTEX,
+ vertexProgram);
+ shaders[1] = new SourceCodeShader(Shader.SHADING_LANGUAGE_GLSL,
+ Shader.SHADER_TYPE_FRAGMENT,
+ fragmentProgram);
+ ShaderProgram shaderProgram = new GLSLShaderProgram();
+ shaderProgram.setShaders(shaders);
+ setShaderProgram(s.getSceneGroup(), shaderProgram);
+
+ objTrans.addChild(s.getSceneGroup());
+
+ bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
+
+ if (spin) {
+ Transform3D yAxis = new Transform3D();
+ Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE,
+ 0, 0,
+ 4000, 0, 0,
+ 0, 0, 0);
+
+ RotationInterpolator rotator =
+ new RotationInterpolator(rotationAlpha, objTrans, yAxis,
+ 0.0f, (float) Math.PI*2.0f);
+ rotator.setSchedulingBounds(bounds);
+ objTrans.addChild(rotator);
+ }
+
+ // Set up the background
+ Color3f bgColor = new Color3f(0.05f, 0.05f, 0.5f);
+ Background bgNode = new Background(bgColor);
+ bgNode.setApplicationBounds(bounds);
+ objRoot.addChild(bgNode);
+
+ return objRoot;
+ }
+
+ private void usage()
+ {
+ System.out.println(
+ "Usage: java ObjLoadGLSL [-s] [-S shaderName] [-n] [-t] [-c degrees] <.obj file>");
+ System.out.println(" -s Spin (no user interaction)");
+ System.out.println(" -S Set shader name (default is 'simple')");
+ System.out.println(" -n No triangulation");
+ System.out.println(" -t No stripification");
+ System.out.println(
+ " -c Set crease angle for normal generation (default is 60 without");
+ System.out.println(
+ " smoothing group info, otherwise 180 within smoothing groups)");
+ System.exit(0);
+ } // End of usage
+
+
+
+ public void init() {
+ if (filename == null) {
+ // Applet
+ try {
+ URL path = getCodeBase();
+ filename = new URL(path.toString() + "./galleon.obj");
+ }
+ catch (MalformedURLException e) {
+ System.err.println(e);
+ System.exit(1);
+ }
+ }
+
+ setLayout(new BorderLayout());
+ GraphicsConfiguration config =
+ SimpleUniverse.getPreferredConfiguration();
+
+ Canvas3D c = new Canvas3D(config);
+ add("Center", c);
+
+ // Create a simple scene and attach it to the virtual universe
+ BranchGroup scene = createSceneGraph();
+ u = new SimpleUniverse(c);
+
+ // add mouse behaviors to the ViewingPlatform
+ ViewingPlatform viewingPlatform = u.getViewingPlatform();
+
+ PlatformGeometry pg = new PlatformGeometry();
+
+ // Set up the ambient light
+ Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f);
+ AmbientLight ambientLightNode = new AmbientLight(ambientColor);
+ ambientLightNode.setInfluencingBounds(bounds);
+ pg.addChild(ambientLightNode);
+
+ // Set up the directional lights
+ Color3f light1Color = new Color3f(1.0f, 0.2f, 0.4f);
+ Vector3f light1Direction = new Vector3f(-1.0f, -1.0f, -1.0f);
+ Color3f light2Color = new Color3f(1.0f, 1.0f, 0.9f);
+ Vector3f light2Direction = new Vector3f(1.0f, 1.0f, 1.0f);
+
+ DirectionalLight light1
+ = new DirectionalLight(light1Color, light1Direction);
+ light1.setInfluencingBounds(bounds);
+ pg.addChild(light1);
+
+ DirectionalLight light2
+ = new DirectionalLight(light2Color, light2Direction);
+ light2.setInfluencingBounds(bounds);
+ pg.addChild(light2);
+
+ viewingPlatform.setPlatformGeometry( pg );
+
+ // This will move the ViewPlatform back a bit so the
+ // objects in the scene can be viewed.
+ viewingPlatform.setNominalViewingTransform();
+
+ if (!spin) {
+ OrbitBehavior orbit = new OrbitBehavior(c,
+ OrbitBehavior.REVERSE_ALL);
+ BoundingSphere bounds =
+ new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
+ orbit.setSchedulingBounds(bounds);
+ viewingPlatform.setViewPlatformBehavior(orbit);
+ }
+
+ /*
+ // Limit the frame rate to 100 Hz
+ u.getViewer().getView().setMinimumFrameCycleTime(10);
+ */
+
+ u.addBranchGraph(scene);
+ }
+
+ // Set shader program for all nodes in specified branch graph
+ private void setShaderProgram(BranchGroup g, ShaderProgram shaderProgram) {
+ ShaderAppearance myApp = new ShaderAppearance();
+ Material mat = new Material();
+ myApp.setShaderProgram(shaderProgram);
+ myApp.setMaterial(mat);
+ setShaderProgram(g, myApp);
+ }
+
+ // Recursively set shader program for all children of specified group
+ private void setShaderProgram(Group g,
+ ShaderAppearance myApp) {
+
+ Enumeration e = g.getAllChildren();
+ while (e.hasMoreElements()) {
+ Node n = (Node)(e.nextElement());
+ if (n instanceof Group) {
+ setShaderProgram((Group)n, myApp);
+ }
+ else if (n instanceof Shape3D) {
+ Shape3D s = (Shape3D)n;
+ s.setAppearance(myApp);
+ }
+ }
+ }
+
+ // Caled if running as a program
+ public ObjLoadGLSL(String[] args) {
+ if (args.length != 0) {
+ for (int i = 0 ; i < args.length ; i++) {
+ if (args[i].startsWith("-")) {
+ if (args[i].equals("-s")) {
+ spin = true;
+ } else if (args[i].equals("-n")) {
+ noTriangulate = true;
+ } else if (args[i].equals("-t")) {
+ noStripify = true;
+ } else if (args[i].equals("-c")) {
+ if (i < args.length - 1) {
+ creaseAngle = (new Double(args[++i])).doubleValue();
+ } else usage();
+ } else if (args[i].equals("-S")) {
+ if (i < args.length - 1) {
+ shaderName = args[++i];
+ } else usage();
+ } else {
+ usage();
+ }
+ } else {
+ try {
+ if ((args[i].indexOf("file:") == 0) ||
+ (args[i].indexOf("http") == 0)) {
+ filename = new URL(args[i]);
+ }
+ else if (args[i].charAt(0) != '/') {
+ filename = new URL("file:./" + args[i]);
+ }
+ else {
+ filename = new URL("file:" + args[i]);
+ }
+ }
+ catch (MalformedURLException e) {
+ System.err.println(e);
+ System.exit(1);
+ }
+ }
+ }
+ }
+ }
+
+
+
+ // Running as an applet
+ public ObjLoadGLSL() {
+ }
+
+ public void destroy() {
+ u.cleanup();
+ }
+
+
+
+ //
+ // The following allows ObjLoadGLSL to be run as an application
+ // as well as an applet
+ //
+ public static void main(String[] args) {
+ new MainFrame(new ObjLoadGLSL(args), 700, 700);
+ }
+}
diff --git a/src/GLSLShaderTest/SphereGLSL.java b/src/GLSLShaderTest/SphereGLSL.java
new file mode 100644
index 0000000..87d589e
--- /dev/null
+++ b/src/GLSLShaderTest/SphereGLSL.java
@@ -0,0 +1,345 @@
+/*
+ * $RCSfile$
+ *
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
+ * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
+ * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
+ * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
+ * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
+ * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ *
+ * $Revision$
+ * $Date$
+ * $State$
+ */
+
+import java.applet.Applet;
+import java.awt.*;
+import java.io.*;
+import com.sun.j3d.utils.applet.MainFrame;
+import com.sun.j3d.utils.geometry.Sphere;
+import com.sun.j3d.utils.shader.StringIO;
+import com.sun.j3d.utils.universe.*;
+import javax.media.j3d.*;
+import javax.vecmath.*;
+import java.util.Enumeration;
+import java.net.URL;
+import java.net.MalformedURLException;
+
+/**
+ * Simple GLSL Shader test program
+ */
+public class SphereGLSL extends Applet {
+
+ // Constants for type of light to use
+ private static final int DIRECTIONAL_LIGHT = 0;
+ private static final int POINT_LIGHT = 1;
+ private static final int SPOT_LIGHT = 2;
+
+ // Flag indicates type of lights: directional, point, or spot
+ // lights. This flag is set based on command line argument
+ private static int lightType = DIRECTIONAL_LIGHT;
+
+ private SimpleUniverse u = null;
+
+ public BranchGroup createSceneGraph(SimpleUniverse u) {
+ Color3f eColor = new Color3f(0.0f, 0.0f, 0.0f);
+ Color3f sColor = new Color3f(1.0f, 1.0f, 1.0f);
+ Color3f objColor = new Color3f(0.6f, 0.6f, 0.6f);
+ Color3f lColor1 = new Color3f(1.0f, 0.0f, 0.0f);
+ Color3f lColor2 = new Color3f(0.0f, 1.0f, 0.0f);
+ Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f);
+ Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f);
+
+ Transform3D t;
+
+ // Create the root of the branch graph
+ BranchGroup objRoot = new BranchGroup();
+
+ // Create a Transformgroup to scale all objects so they
+ // appear in the scene.
+ TransformGroup objScale = new TransformGroup();
+ Transform3D t3d = new Transform3D();
+ t3d.setScale(0.4);
+ objScale.setTransform(t3d);
+ objRoot.addChild(objScale);
+
+ // Create a bounds for the background and lights
+ BoundingSphere bounds =
+ new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
+
+ // Set up the background
+ Background bg = new Background(bgColor);
+ bg.setApplicationBounds(bounds);
+ objScale.addChild(bg);
+
+ // Create a Sphere object, generate one copy of the sphere,
+ // and add it into the scene graph.
+ ShaderAppearance a = new ShaderAppearance();
+ Material m = new Material(objColor, eColor, objColor, sColor, 100.0f);
+ m.setLightingEnable(true);
+ String vertexProgram = null;
+ String fragmentProgram = null;
+ try {
+ vertexProgram = StringIO.readFully("./simple.vert");
+ fragmentProgram = StringIO.readFully("./simple.frag");
+ }
+ catch (IOException e) {
+ /*
+ e.printStackTrace();
+ System.exit(1);
+ */
+ System.err.println(e);
+ }
+ Shader[] shaders = new Shader[2];
+ shaders[0] = new SourceCodeShader(Shader.SHADING_LANGUAGE_GLSL,
+ Shader.SHADER_TYPE_VERTEX,
+ vertexProgram);
+ shaders[1] = new SourceCodeShader(Shader.SHADING_LANGUAGE_GLSL,
+ Shader.SHADER_TYPE_FRAGMENT,
+ fragmentProgram);
+ ShaderProgram shaderProgram = new GLSLShaderProgram();
+ shaderProgram.setShaders(shaders);
+
+ a.setShaderProgram(shaderProgram);
+ a.setMaterial(m);
+ Sphere sph = new Sphere(1.0f, Sphere.GENERATE_NORMALS, 200, a);
+ objScale.addChild(sph);
+
+ // Create the transform group node for the each light and initialize
+ // it to the identity. Enable the TRANSFORM_WRITE capability so that
+ // our behavior code can modify it at runtime. Add them to the root
+ // of the subgraph.
+ TransformGroup l1RotTrans = new TransformGroup();
+ l1RotTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
+ objScale.addChild(l1RotTrans);
+
+ TransformGroup l2RotTrans = new TransformGroup();
+ l2RotTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
+ objScale.addChild(l2RotTrans);
+
+ // Create transformations for the positional lights
+ t = new Transform3D();
+ Vector3d lPos1 = new Vector3d(0.0, 0.0, 2.0);
+ t.set(lPos1);
+ TransformGroup l1Trans = new TransformGroup(t);
+ l1RotTrans.addChild(l1Trans);
+
+ t = new Transform3D();
+ Vector3d lPos2 = new Vector3d(0.5, 0.8, 2.0);
+ t.set(lPos2);
+ TransformGroup l2Trans = new TransformGroup(t);
+ l2RotTrans.addChild(l2Trans);
+
+ /*
+ // Create Geometry for point lights
+ ColoringAttributes caL1 = new ColoringAttributes();
+ ColoringAttributes caL2 = new ColoringAttributes();
+ caL1.setColor(lColor1);
+ caL2.setColor(lColor2);
+ Appearance appL1 = new Appearance();
+ Appearance appL2 = new Appearance();
+ appL1.setColoringAttributes(caL1);
+ appL2.setColoringAttributes(caL2);
+ l1Trans.addChild(new Sphere(0.05f, appL1));
+ l2Trans.addChild(new Sphere(0.05f, appL2));
+ */
+
+ // Create lights
+ AmbientLight aLgt = new AmbientLight(alColor);
+
+ Light lgt1 = null;
+ Light lgt2 = null;
+
+ Point3f lPoint = new Point3f(0.0f, 0.0f, 0.0f);
+ Point3f atten = new Point3f(1.0f, 0.0f, 0.0f);
+ Vector3f lDirect1 = new Vector3f(lPos1);
+ Vector3f lDirect2 = new Vector3f(lPos2);
+ lDirect1.negate();
+ lDirect2.negate();
+
+ switch (lightType) {
+ case DIRECTIONAL_LIGHT:
+ lgt1 = new DirectionalLight(lColor1, lDirect1);
+ lgt2 = new DirectionalLight(lColor2, lDirect2);
+ break;
+ case POINT_LIGHT:
+ lgt1 = new PointLight(lColor1, lPoint, atten);
+ lgt2 = new PointLight(lColor2, lPoint, atten);
+ break;
+ case SPOT_LIGHT:
+ lgt1 = new SpotLight(lColor1, lPoint, atten, lDirect1,
+ 25.0f * (float)Math.PI / 180.0f, 10.0f);
+ lgt2 = new SpotLight(lColor2, lPoint, atten, lDirect2,
+ 25.0f * (float)Math.PI / 180.0f, 10.0f);
+ break;
+ }
+
+ // Set the influencing bounds
+ aLgt.setInfluencingBounds(bounds);
+ lgt1.setInfluencingBounds(bounds);
+ lgt2.setInfluencingBounds(bounds);
+
+ // Add the lights into the scene graph
+ objScale.addChild(aLgt);
+ l1Trans.addChild(lgt1);
+ l2Trans.addChild(lgt2);
+
+ // Create a new Behavior object that will perform the desired
+ // operation on the specified transform object and add it into the
+ // scene graph.
+ Transform3D yAxis = new Transform3D();
+ Alpha rotor1Alpha = new Alpha(-1, Alpha.INCREASING_ENABLE,
+ 0, 0,
+ 4000, 0, 0,
+ 0, 0, 0);
+ RotationInterpolator rotator1 =
+ new RotationInterpolator(rotor1Alpha,
+ l1RotTrans,
+ yAxis,
+ 0.0f, (float) Math.PI*2.0f);
+ rotator1.setSchedulingBounds(bounds);
+ l1RotTrans.addChild(rotator1);
+
+ // Create a new Behavior object that will perform the desired
+ // operation on the specified transform object and add it into the
+ // scene graph.
+ Alpha rotor2Alpha = new Alpha(-1, Alpha.INCREASING_ENABLE,
+ 0, 0,
+ 1000, 0, 0,
+ 0, 0, 0);
+ RotationInterpolator rotator2 =
+ new RotationInterpolator(rotor2Alpha,
+ l2RotTrans,
+ yAxis,
+ 0.0f, 0.0f);
+ bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
+ rotator2.setSchedulingBounds(bounds);
+ l2RotTrans.addChild(rotator2);
+
+ // Create a position interpolator and attach it to the view
+ // platform
+ TransformGroup vpTrans =
+ u.getViewingPlatform().getViewPlatformTransform();
+ Transform3D axisOfTranslation = new Transform3D();
+ Alpha transAlpha = new Alpha(-1,
+ Alpha.INCREASING_ENABLE |
+ Alpha.DECREASING_ENABLE,
+ 0, 0,
+ 5000, 0, 0,
+ 5000, 0, 0);
+ axisOfTranslation.rotY(-Math.PI/2.0);
+ PositionInterpolator translator =
+ new PositionInterpolator(transAlpha,
+ vpTrans,
+ axisOfTranslation,
+ 2.0f, 3.5f);
+ translator.setSchedulingBounds(bounds);
+ objScale.addChild(translator);
+
+ // Let Java 3D perform optimizations on this scene graph.
+ objRoot.compile();
+
+ return objRoot;
+ }
+
+ public SphereGLSL() {
+ }
+
+ public void init() {
+ setLayout(new BorderLayout());
+ GraphicsConfiguration config =
+ SimpleUniverse.getPreferredConfiguration();
+
+ Canvas3D c = new Canvas3D(config);
+ add("Center", c);
+
+ u = new SimpleUniverse(c);
+ BranchGroup scene = createSceneGraph(u);
+
+ // This will move the ViewPlatform back a bit so the
+ // objects in the scene can be viewed.
+ u.getViewingPlatform().setNominalViewingTransform();
+
+ /*
+ // Limit the frame rate to 100 Hz
+ u.getViewer().getView().setMinimumFrameCycleTime(10);
+ */
+
+ u.addBranchGraph(scene);
+ }
+
+ public void destroy() {
+ u.cleanup();
+ }
+
+ //
+ // The following allows SphereGLSL to be run as an application
+ // as well as an applet
+ //
+ public static void main(String[] args) {
+ // Parse the Input Arguments
+ String usage = "Usage: java SphereGLSL [-point | -spot | -dir]";
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].startsWith("-")) {
+ if (args[i].equals("-point")) {
+ /*
+ System.out.println("Using point lights");
+ lightType = POINT_LIGHT;
+ */
+ System.out.println("Point lights not yet implemented, option ignored");
+ }
+ else if (args[i].equals("-spot")) {
+ /*
+ System.out.println("Using spot lights");
+ lightType = SPOT_LIGHT;
+ */
+ System.out.println("Spot lights not yet implemented, option ignored");
+ }
+ else if (args[i].equals("-dir")) {
+ System.out.println("Using directional lights");
+ lightType = DIRECTIONAL_LIGHT;
+ }
+ else {
+ System.out.println(usage);
+ System.exit(0);
+ }
+ }
+ else {
+ System.out.println(usage);
+ System.exit(0);
+ }
+ }
+
+ new MainFrame(new SphereGLSL(), 700, 700);
+ }
+}
diff --git a/src/GLSLShaderTest/build.xml b/src/GLSLShaderTest/build.xml
new file mode 100644
index 0000000..47e5a36
--- /dev/null
+++ b/src/GLSLShaderTest/build.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+
+<!--
+/*
+ * $RCSfile$
+ *
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
+ * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
+ * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
+ * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
+ * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
+ * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ *
+ * $Revision$
+ * $Date$
+ * $State$
+ */
+ -->
+
+<project basedir="." default="compile">
+ <target name="compile">
+ <javac
+ destdir="." srcdir="."
+ source="1.4" target="1.4"
+ debug="true" deprecation="true">
+ </javac>
+ </target>
+
+ <target name="all" depends="compile">
+ </target>
+
+ <target description="Clean all build products." name="clean">
+ <delete>
+ <fileset dir=".">
+ <include name="**/*.class"/>
+ </fileset>
+ </delete>
+ </target>
+
+</project>
diff --git a/src/GLSLShaderTest/dimple.frag b/src/GLSLShaderTest/dimple.frag
new file mode 100644
index 0000000..70d2982
--- /dev/null
+++ b/src/GLSLShaderTest/dimple.frag
@@ -0,0 +1,57 @@
+
+//
+// dimple.frag: Fragment shader for bump mapping dimples (bumps)
+//
+// author: John Kessenich
+//
+// Copyright (c) 2002: 3Dlabs, Inc.
+//
+//
+varying vec3 LightDir;
+varying vec3 EyeDir;
+varying vec3 Normal;
+
+const vec3 color = vec3(0.7, 0.6, 0.18);
+
+//const float Density = 16.0;
+//const float Size = 0.25;
+
+//uniform float Density;
+//uniform float Size;
+float Density = 27.6;
+float Size = 0.13025;
+
+
+//uniform float Scale;
+
+const float SpecularFactor = 0.5;
+
+void main (void)
+{
+ vec3 litColor;
+
+ vec2 c = Density * (gl_TexCoord[0].xy);
+ vec2 p = fract(c) - vec2(0.5);
+ float d = (p.x * p.x) + (p.y * p.y);
+ if (d >= Size)
+ p = vec2(0.0);
+
+ vec3 normDelta = vec3(-p.x, -p.y, 1.0);
+
+ litColor = color * max(0.0, dot(normDelta, LightDir));
+
+ float t = 2.0 * dot(LightDir, normDelta);
+ vec3 reflectDir = t * normDelta;
+ reflectDir = LightDir - reflectDir;
+
+// vec3 reflectDir = LightDir - 2.0 * dot(LightDir, normDelta) * normDelta;
+
+ float spec = max(dot(EyeDir, reflectDir), 0.0);
+ spec = spec * spec;
+ spec = spec * spec;
+ spec *= SpecularFactor;
+
+ litColor = min(litColor + spec, vec3(1.0));
+ gl_FragColor = vec4(litColor, 1.0);
+// gl_FragColor = vec4(Scale);
+}
diff --git a/src/GLSLShaderTest/dimple.vert b/src/GLSLShaderTest/dimple.vert
new file mode 100644
index 0000000..0707d71
--- /dev/null
+++ b/src/GLSLShaderTest/dimple.vert
@@ -0,0 +1,41 @@
+
+//
+// dimple.vert: Vertex shader for bump mapping dimples (bumps)
+//
+// author: John Kessenich
+//
+// Copyright (c) 2002: 3Dlabs, Inc.
+//
+
+varying vec3 LightDir;
+varying vec3 EyeDir;
+varying vec3 Normal;
+
+//uniform vec3 LightPosition;
+//uniform float Scale;
+vec3 LightPosition = vec3(0.0, 0.0, 5.0);
+float Scale = 1.0;
+
+void main(void)
+{
+ vec4 pos = gl_ModelViewMatrix * gl_Vertex;
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+ vec3 eyeDir = vec3(pos);
+// gl_TexCoord[0] = gl_MultiTexCoord0;
+ gl_TexCoord[0] = gl_Vertex;
+
+ vec3 n = normalize(gl_NormalMatrix * gl_Normal);
+ vec3 t = normalize(cross(vec3(1.141, 2.78, 3.14), n));
+ vec3 b = cross(n, t);
+
+ vec3 v;
+ v.x = dot(LightPosition, t);
+ v.y = dot(LightPosition, b);
+ v.z = dot(LightPosition, n);
+ LightDir = normalize(v);
+
+ v.x = dot(eyeDir, t);
+ v.y = dot(eyeDir, b);
+ v.z = dot(eyeDir, n);
+ EyeDir = normalize(v);
+}
diff --git a/src/GLSLShaderTest/polkadot3d.frag b/src/GLSLShaderTest/polkadot3d.frag
new file mode 100644
index 0000000..b341454
--- /dev/null
+++ b/src/GLSLShaderTest/polkadot3d.frag
@@ -0,0 +1,48 @@
+//
+// Fragment shader for 3 dimensional polka dot shader.
+//
+// Author: Joshua Doss
+//
+// Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
+//
+// See 3Dlabs-License.txt for license information
+//
+varying float LightIntensity;
+varying vec3 MCPosition;
+
+//Create uniform variables so dots can be spaced and scaled by user
+//uniform vec3 Spacing;
+//uniform float DotSize;
+const vec3 Spacing = vec3 (0.314, 0.36, 0.261);
+const float DotSize = 0.123;
+
+//Create colors as uniform variables so they can be easily changed
+//uniform vec3 ModelColor, PolkaDotColor;
+const vec3 ModelColor = vec3 (0.75, 0.2, 0.1);
+const vec3 PolkaDotColor = vec3 (1, 1, 1);
+
+void main(void)
+{
+ float insidesphere, sphereradius, scaledpointlength;
+ vec3 scaledpoint, finalcolor;
+
+ // Scale the coordinate system
+ // The following line of code is not yet implemented in current drivers:
+ // mcpos = mod(Spacing, MCposition);
+ // We will use a workaround found below for now
+ scaledpoint = MCPosition - (Spacing * floor(MCPosition/Spacing));
+
+ // Bring the scaledpoint vector into the center of the scaled coordinate system
+ scaledpoint = scaledpoint - Spacing/2.0;
+
+ // Find the length of the scaledpoint vector and compare it to the dotsize
+ scaledpointlength = length(scaledpoint);
+ insidesphere = step(scaledpointlength,DotSize);
+
+ // Determine final output color before lighting
+ finalcolor = vec3(mix(ModelColor, PolkaDotColor, insidesphere));
+
+ // Output final color and factor in lighting
+ gl_FragColor = clamp((vec4( finalcolor, 1.0 ) * LightIntensity), vec4(0.0), vec4(1.0));
+}
+
diff --git a/src/GLSLShaderTest/polkadot3d.vert b/src/GLSLShaderTest/polkadot3d.vert
new file mode 100644
index 0000000..86f432f
--- /dev/null
+++ b/src/GLSLShaderTest/polkadot3d.vert
@@ -0,0 +1,58 @@
+// This is the Vertex Shader for three dimensional polka dots.
+//
+// author(s): Joshua Doss
+//
+// Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
+
+//Create uniform variables for lighting to allow user interaction
+//uniform float SpecularContribution;
+//uniform vec3 LightPosition;
+
+const float SpecularContribution = 0.36;
+const vec3 LightPosition = vec3 (0, 4, 5);
+
+varying vec3 MCPosition;
+varying float LightIntensity;
+
+void main(void)
+{
+ float diffusecontribution = 1.0 - SpecularContribution;
+
+ // compute the vertex position in eye coordinates
+ vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
+
+ // compute the transformed normal
+ vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal);
+
+ // compute a vector from the model to the light position
+ vec3 lightVec = normalize(LightPosition - ecPosition);
+
+ // compute the reflection vector
+ vec3 reflectVec = reflect(-lightVec, tnorm);
+
+ // compute a unit vector in direction of viewing position
+ vec3 viewVec = normalize(-ecPosition);
+
+ // calculate amount of diffuse light based on normal and light angle
+ float diffuse = max(dot(lightVec, tnorm), 0.0);
+ float spec = 0.0;
+
+ // if there is diffuse lighting, calculate specular
+ if(diffuse > 0.0)
+ {
+ spec = max(dot(reflectVec, viewVec), 0.0);
+ spec = pow(spec, 16.0);
+ }
+
+ // add up the light sources, since this is a varying (global) it will pass to frag shader
+ LightIntensity = diffusecontribution * diffuse * 1.5 +
+ SpecularContribution * spec;
+
+ // the varying variable MCPosition will be used by the fragment shader to determine where
+ // in model space the current pixel is
+ MCPosition = vec3 (gl_Vertex);
+
+ // send vertex information
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+}
+
diff --git a/src/GLSLShaderTest/simple.frag b/src/GLSLShaderTest/simple.frag
new file mode 100644
index 0000000..61c83ec
--- /dev/null
+++ b/src/GLSLShaderTest/simple.frag
@@ -0,0 +1,62 @@
+/*
+ * $RCSfile$
+ *
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
+ * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
+ * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
+ * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
+ * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
+ * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ *
+ * $Revision$
+ * $Date$
+ * $State$
+ */
+
+// Simple GLSL fragment program to attenuate the input fragment color as a
+// function of the distance of the fragment position from the center
+// of the window
+
+const float windowSize = 700.0; // TODO: this should be a built-in parameter!
+
+void main()
+{
+ // Compute distance from center in range [0.0, 1.0]
+ vec2 dist = min(abs((gl_FragCoord.xy - (windowSize)/2.0) / windowSize), 1.0);
+ vec2 invDist = 1.0 - dist;
+
+ // Compute attenuation
+ float atten = invDist.x * invDist.y;
+ vec4 outcolor = (gl_Color + gl_SecondaryColor) * atten;
+
+ gl_FragColor = outcolor;
+}
diff --git a/src/GLSLShaderTest/simple.vert b/src/GLSLShaderTest/simple.vert
new file mode 100644
index 0000000..c593816
--- /dev/null
+++ b/src/GLSLShaderTest/simple.vert
@@ -0,0 +1,129 @@
+/*
+ * $RCSfile$
+ *
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
+ * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
+ * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
+ * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
+ * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
+ * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ *
+ * $Revision$
+ * $Date$
+ * $State$
+ */
+
+// A simple GLSL vertex program for handling 2 directional lights with
+// separate specular
+
+void directionalLight(
+ in int i,
+ in vec3 normal,
+ inout vec4 ambient,
+ inout vec4 diffuse,
+ inout vec4 specular)
+{
+ // Normalized light direction and half vector
+ // (shouldn't they be pre-normalized?!)
+ vec3 lightDirection = normalize(vec3(gl_LightSource[i].position));
+ vec3 halfVector = normalize(vec3(gl_LightSource[i].halfVector));
+
+ float nDotVP; // normal . light_direction
+ float nDotHV; // normal . light_half_vector
+ float pf; // power factor
+
+ nDotVP = max(0.0, dot(normal, lightDirection));
+ nDotHV = max(0.0, dot(normal, halfVector));
+
+ if (nDotVP == 0.0) {
+ pf = 0.0;
+ }
+ else {
+ pf = pow(nDotHV, gl_FrontMaterial.shininess);
+ }
+
+ ambient += gl_LightSource[i].ambient;
+ diffuse += gl_LightSource[i].diffuse * nDotVP;
+ specular += gl_LightSource[i].specular * pf;
+}
+
+
+const int numEnabledLights = 2; // TODO: this should be a built-in parameter!
+
+void main()
+{
+ //vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex;
+ //vec3 ecPosition3 = ecPosition.xyz / ecPosition.w;
+ vec3 tnorm = normalize(vec3(gl_NormalMatrix * gl_Normal));
+ vec4 amb = vec4(0.0);
+ vec4 diff = vec4(0.0);
+ vec4 spec = vec4(0.0);
+ int i;
+
+ // Transform the vertex
+ vec4 outPosition = gl_ModelViewProjectionMatrix * gl_Vertex;
+
+ for (i = 0; i < numEnabledLights; i++) {
+ directionalLight(i, tnorm, amb, diff, spec);
+ }
+
+ // Apply the result of the lighting equation
+ vec4 outSecondaryColor = vec4(vec3(spec * gl_FrontMaterial.specular), 1.0);
+ vec3 color0 = vec3(gl_FrontLightModelProduct.sceneColor +
+ amb * gl_FrontMaterial.ambient +
+ diff * gl_FrontMaterial.diffuse);
+
+ // Generate a pseudo-random noise pattern
+ vec3 xyz = clamp((outPosition.xyz + 1.0) * 0.5, 0.0, 1.0);
+
+ xyz = fract(xyz * 262144.0);
+ float randSeed = fract(3.0 * xyz.x + 5.0 * xyz.y + 7.0 * xyz.z);
+
+ vec3 altColor;
+
+ randSeed = fract(37.0 * randSeed);
+ altColor.x = randSeed * 0.5 + 0.5;
+ randSeed = fract(37.0 * randSeed);
+ altColor.y = randSeed * 0.5 + 0.5;
+ randSeed = fract(37.0 * randSeed);
+ altColor.z = randSeed * 0.5 + 0.5;
+ randSeed = fract(37.0 * randSeed);
+ float altAlpha = randSeed * 0.5;
+
+ // Apply noise and output final vertex color
+ vec4 outColor;
+ outColor = vec4(mix(color0, altColor, altAlpha), 1.0);
+
+ gl_FrontColor = outColor;
+ gl_FrontSecondaryColor = outSecondaryColor;
+ gl_Position = outPosition;
+}
diff --git a/src/GLSLShaderTest/wood.frag b/src/GLSLShaderTest/wood.frag
new file mode 100644
index 0000000..eecf91f
--- /dev/null
+++ b/src/GLSLShaderTest/wood.frag
@@ -0,0 +1,66 @@
+//
+// Simple fragment shader for wood
+//
+// Author: John Kessenich
+//
+// Copyright (c) 2002-2004 3Dlabs Inc. Ltd.
+//
+// See 3Dlabs-License.txt for license information
+//
+
+//uniform float GrainSizeRecip;
+//uniform vec3 DarkColor;
+//uniform vec3 spread;
+const float GrainSizeRecip = 1.0;
+const vec3 DarkColor = vec3 (0.6, 0.3, 0.1);
+const vec3 spread = vec3 (0.15, 0.075, 0.0);
+
+varying float lightIntensity;
+varying vec3 Position;
+
+void main (void)
+{
+ //
+ // cheap noise
+ //
+ vec3 location = Position;
+ vec3 floorvec = vec3(floor(10.0 * Position.x), 0.0, floor(10.0 * Position.z));
+ vec3 noise = Position * 10.0 - floorvec - 0.5;
+ noise *= noise;
+ location += noise * 0.12;
+
+ //
+ // distance from axis
+ //
+ float dist = location.x * location.x + location.z * location.z;
+ float grain = dist * GrainSizeRecip;
+
+ //
+ // grain effects as function of distance
+ //
+ float brightness = fract(grain);
+ if (brightness > 0.5)
+ brightness = (1.0 - brightness);
+ vec3 color = DarkColor + brightness * spread;
+
+ brightness = fract(grain * 7.0);
+ if (brightness > 0.5)
+ brightness = 1.0 - brightness;
+ color -= brightness * spread;
+
+ //
+ // also as a function of lines parallel to the axis
+ //
+ brightness = fract(grain * 47.0) * 0.60;
+ float line = fract(Position.z + Position.x);
+ float snap = floor(line * 20.0) * (1.0/20.0);
+ if (line < snap + 0.006)
+ color -= brightness * spread;
+
+ //
+ // apply lighting effects from vertex processor
+ //
+ color = clamp(color * lightIntensity, 0.0, 1.0);
+
+ gl_FragColor = vec4(color, 1.0);
+}
diff --git a/src/GLSLShaderTest/wood.vert b/src/GLSLShaderTest/wood.vert
new file mode 100644
index 0000000..84651aa
--- /dev/null
+++ b/src/GLSLShaderTest/wood.vert
@@ -0,0 +1,25 @@
+//
+// Simple vertex shader for wood
+//
+// Author: John Kessenich
+//
+// Copyright (c) 2002-2004 3Dlabs Inc. Ltd.
+//
+// See 3Dlabs-License.txt for license information
+//
+
+varying float lightIntensity;
+varying vec3 Position;
+//uniform vec3 LightPosition;
+//uniform float Scale;
+const vec3 LightPosition = vec3 (0.0,0.0,0.4);
+const float Scale = 1.0;
+
+void main(void)
+{
+ vec4 pos = gl_ModelViewMatrix * gl_Vertex;
+ Position = vec3(gl_Vertex) * Scale;
+ vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal);
+ lightIntensity = max(dot(normalize(LightPosition - vec3(pos)), tnorm), 0.0) * 1.5;
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+}
diff --git a/src/SgChangerListener/ListenerTest.java b/src/SgChangerListener/ListenerTest.java
new file mode 100644
index 0000000..740ec74
--- /dev/null
+++ b/src/SgChangerListener/ListenerTest.java
@@ -0,0 +1,221 @@
+/*
+ * $RCSfile$
+ *
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
+ * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
+ * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
+ * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
+ * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
+ * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ *
+ * $Revision$
+ * $Date$
+ * $State$
+ */
+
+import java.applet.Applet;
+import java.awt.BorderLayout;
+import java.awt.GraphicsConfiguration;
+import com.sun.j3d.utils.applet.MainFrame;
+import com.sun.j3d.utils.geometry.ColorCube;
+import com.sun.j3d.utils.geometry.Sphere;
+import com.sun.j3d.utils.universe.*;
+import java.util.Enumeration;
+import javax.media.j3d.*;
+import javax.vecmath.*;
+
+public class ListenerTest extends Applet {
+
+ private SimpleUniverse u = null;
+ private ChangeListener changeListener;
+ private BranchGroup scene;
+
+ public BranchGroup createSceneGraph() {
+ // Create the root of the branch graph
+ BranchGroup objRoot = new BranchGroup();
+ objRoot.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
+ objRoot.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
+ objRoot.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
+ objRoot.setCapability(BranchGroup.ALLOW_DETACH);
+
+ // Create the TransformGroup node and initialize it to the
+ // identity. Enable the TRANSFORM_WRITE capability so that
+ // our behavior code can modify it at run time. Add it to
+ // the root of the subgraph.
+ TransformGroup objTrans = new TransformGroup();
+ objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
+ objRoot.addChild(objTrans);
+
+ // Create a simple Shape3D node; add it to the scene graph.
+ objTrans.addChild(new ColorCube(0.1));
+
+ // Create a new Behavior object that will perform the
+ // desired operation on the specified transform and add
+ // it into the scene graph.
+ Transform3D yAxis = new Transform3D();
+ Alpha rotationAlpha = new Alpha(-1, 4000);
+
+ RotationInterpolator rotator =
+ new RotationInterpolator(rotationAlpha, objTrans, yAxis,
+ 0.0f, (float) Math.PI*2.0f);
+ BoundingSphere bounds =
+ new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
+ rotator.setSchedulingBounds(bounds);
+ objRoot.addChild(rotator);
+
+ objRoot.addChild(new TestBehavior(objRoot));
+
+ return objRoot;
+ }
+
+ public ListenerTest() {
+ }
+
+ public void init() {
+ setLayout(new BorderLayout());
+ GraphicsConfiguration config =
+ SimpleUniverse.getPreferredConfiguration();
+
+ Canvas3D c = new Canvas3D(config);
+ add("Center", c);
+
+ // Create a simple scene and attach it to the virtual universe
+ scene = createSceneGraph();
+ scene.setName("scene");
+ u = new SimpleUniverse(c);
+ changeListener = new ChangeListener();
+ u.addGraphStructureChangeListener(changeListener);
+
+ // This will move the ViewPlatform back a bit so the
+ // objects in the scene can be viewed.
+ u.getViewingPlatform().setNominalViewingTransform();
+
+ u.addBranchGraph(scene);
+ }
+
+ public void destroy() {
+ u.cleanup();
+ }
+
+ BranchGroup createShape(Vector3f pos) {
+ Transform3D t3d = new Transform3D();
+ t3d.set(1f,pos);
+ TransformGroup tg = new TransformGroup(t3d);
+
+ tg.addChild(new Sphere(0.02f));
+
+ BranchGroup bg = new BranchGroup();
+ bg.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
+ bg.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
+ bg.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
+ bg.setCapability(BranchGroup.ALLOW_DETACH);
+ bg.addChild(tg);
+ return bg;
+ }
+
+ //
+ // The following allows HelloUniverse to be run as an application
+ // as well as an applet
+ //
+ public static void main(String[] args) {
+ new MainFrame(new ListenerTest(), 256, 256);
+ }
+
+ class TestBehavior extends Behavior {
+ private BranchGroup root;
+ private WakeupCriterion wakeup = new WakeupOnElapsedFrames(0);
+ private int count = 0;
+ private BranchGroup moveTo;
+ private BranchGroup bg1;
+
+ public TestBehavior(BranchGroup root) {
+ this.root = root;
+ this.setSchedulingBounds(new BoundingSphere(new Point3d(), Double.POSITIVE_INFINITY));
+
+ moveTo = new BranchGroup();
+ moveTo.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
+ moveTo.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
+ moveTo.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
+ root.addChild(moveTo);
+ }
+
+ public void initialize() {
+ wakeupOn(wakeup);
+ }
+
+ public void processStimulus(Enumeration e) {
+ System.out.println("Wakeup");
+
+ switch(count) {
+ case 0:
+ bg1=createShape(new Vector3f(0.02f,0f,0f));
+ bg1.setName("bg1.1");
+ root.addChild(bg1);
+ break;
+ case 1:
+ moveTo.moveTo(bg1);
+ break;
+ case 2:
+ bg1=createShape(new Vector3f(0.03f, 0.03f, 0f));
+ bg1.setName("bg1.2");
+ moveTo.setChild(bg1,0);
+ break;
+ case 3:
+ bg1.detach();
+ break;
+ case 4:
+ u.getLocale().removeBranchGraph(scene);
+ break;
+ }
+
+ count++;
+
+ if(count<5)
+ wakeupOn(wakeup);
+ }
+ }
+
+ class ChangeListener implements GraphStructureChangeListener {
+ public void branchGroupAdded(Object parent, BranchGroup child) {
+ System.out.println("Add "+parent+" "+child.getName()+" "+child.isLive());
+ }
+
+ public void branchGroupMoved(Object oldParent, Object newParent, BranchGroup child) {
+ System.out.println("Move "+oldParent+" "+newParent+" "+child.getName()+" "+child.isLive());
+ }
+
+ public void branchGroupRemoved(Object parent, BranchGroup child) {
+ System.out.println("Removed "+parent+" "+child.getName()+" "+child.isLive());
+ }
+
+ }
+}
diff --git a/src/SgChangerListener/build.xml b/src/SgChangerListener/build.xml
new file mode 100644
index 0000000..47e5a36
--- /dev/null
+++ b/src/SgChangerListener/build.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0"?>
+
+<!--
+/*
+ * $RCSfile$
+ *
+ * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any
+ * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
+ * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
+ * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
+ * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
+ * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
+ * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
+ * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
+ * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
+ * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or
+ * intended for use in the design, construction, operation or
+ * maintenance of any nuclear facility.
+ *
+ * $Revision$
+ * $Date$
+ * $State$
+ */
+ -->
+
+<project basedir="." default="compile">
+ <target name="compile">
+ <javac
+ destdir="." srcdir="."
+ source="1.4" target="1.4"
+ debug="true" deprecation="true">
+ </javac>
+ </target>
+
+ <target name="all" depends="compile">
+ </target>
+
+ <target description="Clean all build products." name="clean">
+ <delete>
+ <fileset dir=".">
+ <include name="**/*.class"/>
+ </fileset>
+ </delete>
+ </target>
+
+</project>
diff --git a/www/build-instr.html b/www/build-instr.html
index 24d3c68..66329f1 100644
--- a/www/build-instr.html
+++ b/www/build-instr.html
@@ -3,11 +3,11 @@
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
- <title>CVS download and build instructions</title>
+ <title>j3d-examples download and building instructions</title>
<meta content="Kevin Rushforth" name="author">
</head>
<body>
-<h3>CVS download and build instructions for j3d-examples</h3>
+<h3>Instructions for downloading and building j3d-examples</h3>
<p>To
build the j3d-examples project, you must first checkout the <a
href="https://j3d-examples.dev.java.net/">j3d-examples</a>
@@ -22,20 +22,6 @@ the cvs checkout command as follows:<br>
<p>After you have downloaded the CVS repository, read the
README-FIRST.txt file, then read and follow the
instructions in the README-build.html
-file.<br>
-</p>
-<p>Go to the "<a href="servlets/ProjectSource">CVS client setup</a>"
-page for instructions on how to access the j3d-examples source code
-from CVS. Click on the "<a href="source/browse/j3d-examples/">Version
-Control
-- CVS</a>" link to browse the j3d-examples source code.
-Automated CVS change messages are sent to the <span
- style="color: blue;">cvs 'at'
-j3d-examples.dev.java.net</span>
-list list.&nbsp;<a href="servlets/ProjectMailingListList">Click here to
-subscribe</a> to this list.<br>
-</p>
-<p><br>
-</p>
+file.</p>
</body>
</html>
diff --git a/www/index.html b/www/index.html
index 15d9851..1a52a8c 100644
--- a/www/index.html
+++ b/www/index.html
@@ -4,6 +4,12 @@
<title>Java 3D Example Programs</title>
</head>
<body style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
+<p style="text-align: center;"> <font size="-2">
+<a href="#Downloads">Downloads</a> |
+<a href="#How_to_Contribute">How to Contribute</a> |
+<a href="#Reporting_Issues">Reporting Issues</a> |
+<a href="#Feedback_and_Discussion">Feedback and Discussion</a></font>
+</p>
<p>This project contains the source code
for the Java&nbsp;3D<sup><font size="-2">TM</font></sup> example
programs.
@@ -14,27 +20,81 @@ programs.
href="https://vecmath.dev.java.net/">vecmath</a>
(the 3D vector math package), and <a
href="https://j3d-core-utils.dev.java.net/">j3d-core-utils</a>
-(the Java&nbsp;3D core utilities). Developers should refer to the <a
- href="build-instr.html">CVS download
+(the Java&nbsp;3D core utilities). Refer to the <a
+ href="build-instr.html">download
and build
-instructions</a> for information on downloading the source code and
-building j3d-examples.
+instructions</a> for information on downloading and building vecmath.
+</p>
+<h3><a name="Downloads"></a>Downloads</h3>
+<p>Three types of Java&nbsp;3D <a
+ href="https://java3d.dev.java.net/binary-builds.html">binary builds</a>
+are available on java.net: Release (or FCS) builds;
+Stable (experimental, early access) builds; and Daily builds. The
+latest
+release build of Java&nbsp;3D v1.3.1 is available. Stable
+builds of Java&nbsp;3D 1.3.2 (beta) are available.
+Daily builds of both 1.3.2 and 1.4.0 are now available.</p>
+<h3><a name="How_to_Contribute"></a>How to Contribute</h3>
+<p>We invite developers to contribute to Java&nbsp;3D. Please refer to
+the
+<a href="https://java3d.dev.java.net/contribute.html">Contributing to
+Java&nbsp;3D</a> page in the parent java3d project to learn
+how to contribute to this project or any other Java&nbsp;3D-related
+project. See the <a href="https://javadesktop.dev.java.net/govern.html">JavaDesktop
+Community Governance Guidelines</a> for general guidelines on
+participating in JavaDesktop community projects, such as j3d-examples.
</p>
-<p><strong><em>For all other project
-information, including contributing to Java&nbsp;3D and reporting
-issues,
-please go to the parent <a href="https://java3d.dev.java.net/">java3d</a>
-project.</em></strong></p>
-<p>NOTE: The issue Tracker in this j3d-core subproject cannot be used
-to file or track issues. Please use the <a
+<h3><a name="Reporting_Issues"></a>Reporting Issues<br>
+</h3>
+<p>We have set up the <a
href="https://java3d.dev.java.net/servlets/ProjectIssues">Issue Tracker</a>
in the parent java3d
project
to track issues (bugs, feature requests, etc.) for
Java&nbsp;3D-related
-sub-projects.<br>
+sub-projects. Please use the above link rather than the Issue Tracker
+in this j3d-examples project. Refer to the <a
+ href="https://java3d.dev.java.net/#Reporting_Issues">Reporting
+Issues</a> section in the parent java3d project for more information.
+</p>
+<h3><a name="Feedback_and_Discussion"></a>Feedback and Discussion<br>
+</h3>
+<p>We have created four Java&nbsp;3D mailing lists in the parent <a
+ href="https://java3d.dev.java.net/">java3d</a> project:&nbsp;<span
+ style="color: blue;">interest 'at' java3d.dev.java.net</span>,
+<span style="color: blue;">announce 'at' java3d.dev.java.net</span>,
+<span style="color: blue;">issues 'at' java3d.dev.java.net</span>,
+and <span style="color: blue;">cvs 'at' java3d.dev.java.net</span>
+(replace 'at' with @).
+<a href="https://java3d.dev.java.net/servlets/ProjectMailingListList">Click
+here to subscribe</a> to any of these lists. The <span
+ style="font-style: italic;">interest</span> list is an open mailing
+list for
+discussing all aspects of Java&nbsp;3D, the reference implementation
+for the
+Java&nbsp;3D core, vecmath, utilities, example programs, etc. The <span
+ style="font-style: italic;">annouce</span> list is a
+low-volume moderated mailing list for announcing Java&nbsp;3D-related
+news
+and information. The <span style="font-style: italic;">issues</span>
+list is for automated issues tracking, and the <span
+ style="font-style: italic;">cvs</span> list is for automated CVS
+change messages (for changes to the parent java3d web pages only).</p>
+<p>For those who prefer a forum to a discussion mailing list, we have
+created the
+<a href="https://java3d.dev.java.net/servlets/ProjectForumView"
+ target="_blank">Java&nbsp;3D
+forum</a>, hosted as part of the JavaDesktop Community. Messages
+posted on the forum are cross-posted to <span style="color: blue;">interest
+'at' java3d.dev.java.net</span>
+and vice-versa.<br>
</p>
-<p><br>
+<p>Finally, each sub-project has its own cvs mailing
+list.&nbsp;<a href="servlets/ProjectMailingListList">Click here to
+subscribe</a> to this list. The <span style="color: blue;">cvs 'at'
+j3d-examples.dev.java.net</span>
+list is for automated CVS change messages and discussion of those
+changes.<br>
</p>
</body>
</html>