diff options
author | nobody <nobody@28c7f869-5b4e-e670-f602-82bfaf57f300> | 2005-05-12 17:18:57 +0000 |
---|---|---|
committer | nobody <nobody@28c7f869-5b4e-e670-f602-82bfaf57f300> | 2005-05-12 17:18:57 +0000 |
commit | 8c0cdc38b3e2a33bf242f34856fd2ac1f8776b4f (patch) | |
tree | 18d617e960a2424c5972c1cee2e2a939730d45b4 | |
parent | 7484cd7321fcbd86c0a782ff4c013856b865f503 (diff) |
This commit was manufactured by cvs2svn to create tagexp-1_4_0-build3
'exp-1_4_0-build3'.
-rw-r--r-- | build.xml | 3 | ||||
-rw-r--r-- | src/CgShaderTest/ObjLoadCg.java | 343 | ||||
-rw-r--r-- | src/CgShaderTest/SphereCg.java | 346 | ||||
-rw-r--r-- | src/CgShaderTest/build.xml | 69 | ||||
-rw-r--r-- | src/CgShaderTest/simple_fp.cg | 68 | ||||
-rw-r--r-- | src/CgShaderTest/simple_vp.cg | 167 | ||||
-rw-r--r-- | src/DepthFuncTest/DepthFuncTest.form | 159 | ||||
-rw-r--r-- | src/DepthFuncTest/DepthFuncTest.java | 242 | ||||
-rw-r--r-- | src/DepthFuncTest/RenderFrame.form | 25 | ||||
-rw-r--r-- | src/DepthFuncTest/RenderFrame.java | 261 | ||||
-rw-r--r-- | src/DepthFuncTest/build.xml | 69 | ||||
-rw-r--r-- | src/GLSLShaderTest/ObjLoadGLSL.java | 343 | ||||
-rw-r--r-- | src/GLSLShaderTest/SphereGLSL.java | 349 | ||||
-rw-r--r-- | src/GLSLShaderTest/build.xml | 69 | ||||
-rw-r--r-- | src/GLSLShaderTest/simple.frag | 62 | ||||
-rw-r--r-- | src/GLSLShaderTest/simple.vert | 129 | ||||
-rw-r--r-- | src/SgChangerListener/ListenerTest.java | 221 | ||||
-rw-r--r-- | src/SgChangerListener/build.xml | 69 | ||||
-rw-r--r-- | www/index.html | 6 |
19 files changed, 2997 insertions, 3 deletions
@@ -69,13 +69,16 @@ <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/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..ac15bd3 --- /dev/null +++ b/src/DepthFuncTest/DepthFuncTest.form @@ -0,0 +1,159 @@ +<?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,-82,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,-106,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> + </SubComponents> +</Form> diff --git a/src/DepthFuncTest/DepthFuncTest.java b/src/DepthFuncTest/DepthFuncTest.java new file mode 100644 index 0000000..66397e9 --- /dev/null +++ b/src/DepthFuncTest/DepthFuncTest.java @@ -0,0 +1,242 @@ +package DepthFuncTest; +/* + * $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(); + + 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); + + setBounds(0, 0, 403, 174); + } + // </editor-fold>//GEN-END:initComponents + + 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.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JComboBox normalComboBox; + 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..ce4e2a0 --- /dev/null +++ b/src/DepthFuncTest/RenderFrame.java @@ -0,0 +1,261 @@ +package DepthFuncTest; +/* + * $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; + + /** 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(); + oGroup.addChild( rotObjectBG ); + oGroup.addChild( staticBoxRotTG ); + 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 ); + globalBG.addChild( lampsBG ); + + // adding lamps. + PointLight frontLamp = new PointLight( new Color3f( 1.0f, 1.0f, 1.0f ), new Point3f( 5, 5, 5 ), new Point3f( 1f, .0f, 0.f ) ); + lampsBG.addChild( frontLamp ); + frontLamp.setBounds( bounds ); + frontLamp.setInfluencingBounds( bounds ); + PointLight backLamp = new PointLight( new Color3f( 1.0f, .0f, .0f ), new Point3f( -5, -5, -5 ), new Point3f( 1f, .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 ); + 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, .1f ); + 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 ); + } + + //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 ); + } + +} 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/GLSLShaderTest/ObjLoadGLSL.java b/src/GLSLShaderTest/ObjLoadGLSL.java new file mode 100644 index 0000000..3abfbae --- /dev/null +++ b/src/GLSLShaderTest/ObjLoadGLSL.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 ObjLoadGLSL 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.vert"); + fragmentProgram = StringIO.readFully("./simple.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] [-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 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 { + 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..ca9717c --- /dev/null +++ b/src/GLSLShaderTest/SphereGLSL.java @@ -0,0 +1,349 @@ +/* + * $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); + Texture t2d = new Texture2D(); + a.setTexture(t2d); + a.setCapability(Appearance.ALLOW_TEXTURE_WRITE); + + 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/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/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/index.html b/www/index.html index 56cb028..1a52a8c 100644 --- a/www/index.html +++ b/www/index.html @@ -31,9 +31,9 @@ instructions</a> for information on downloading and building vecmath. are available on java.net: Release (or FCS) builds; Stable (experimental, early access) builds; and Daily builds. The latest -release build of Java 3D v1.3.2 is available. -Daily builds of 1.4.0 are now available. Stable -builds of Java 3D 1.4.0 will be available soon.</p> +release build of Java 3D v1.3.1 is available. Stable +builds of Java 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 3D. Please refer to the |