summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README-build.html4
-rw-r--r--build.xml8
-rw-r--r--manifest.mf2
-rw-r--r--nbproject/project.xml10
-rw-r--r--src/classes/org/jdesktop/j3d/examples/texture/TextureImageNPOT.java228
5 files changed, 242 insertions, 10 deletions
diff --git a/README-build.html b/README-build.html
index 528df10..ec62fea 100644
--- a/README-build.html
+++ b/README-build.html
@@ -80,10 +80,10 @@ work.We have built j3d-examples on the following operating environments:<br>
</ul>
<p>The following software must be installed:</p>
<ul>
- <li><a href="http://java.sun.com/j2se">JDK 1.4.2</a> </li>
+ <li><a href="http://java.sun.com/j2se">JDK 1.5.0</a> </li>
<li><a href="http://jakarta.apache.org/ant">Apache Ant 1.6.1</a> </li>
<li><a href="https://java3d.dev.java.net/">Java&nbsp;3D
-1.4.0</a> or later. </li>
+1.5.0</a> or later. </li>
</ul>
<h3><span style="text-decoration: underline;">Building
j3d-examples</span><span
diff --git a/build.xml b/build.xml
index 130d53f..56fae1b 100644
--- a/build.xml
+++ b/build.xml
@@ -46,7 +46,7 @@
*/
-->
-<project name="j3d-examples-1.4.0" default="jar">
+<project name="j3d-examples-1.5.0" default="jar">
<target name="init">
<!-- Set global properties for this build -->
@@ -54,7 +54,7 @@
<property name="build" location="build"/>
<property name="dist" location="dist"/>
<property name="output.jar" location="dist/j3d-examples.jar"/>
- <property name="output.zip" location="dist/j3d-examples-1_4_0-src.zip"/>
+ <property name="output.zip" location="dist/j3d-examples-1_5_0-src.zip"/>
</target>
<target name="compile" depends="init">
@@ -64,8 +64,8 @@
<!-- Compile the java code from ${src}/classes into ${build}/classes -->
<javac srcdir="${src}/classes"
destdir="${build}/classes"
- source="1.4"
- target="1.4"
+ source="1.5"
+ target="1.5"
debug="true"
deprecation="off">
</javac>
diff --git a/manifest.mf b/manifest.mf
index dc0b38e..4ca12ca 100644
--- a/manifest.mf
+++ b/manifest.mf
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
Implementation-Title: Java 3D Example Programs
-Implementation-Version: 1.4.0
+Implementation-Version: 1.5.0
Implementation-Vendor: Sun Microsystems, Inc.
Main-Class: org.jdesktop.j3d.examples.hello_universe.HelloUniverse
diff --git a/nbproject/project.xml b/nbproject/project.xml
index 411d578..63dc7a5 100644
--- a/nbproject/project.xml
+++ b/nbproject/project.xml
@@ -4,7 +4,7 @@
<configuration>
<general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
<!-- Do not use Project Properties customizer when editing this file manually. -->
- <name>j3d-examples-1.4.0</name>
+ <name>j3d-examples-1.5.0</name>
<properties/>
<folders>
<source-folder>
@@ -45,12 +45,16 @@
<ide-action name="rebuild"/>
</context-menu>
</view>
- <subprojects/>
+ <subprojects>
+ <project>../j3d-core</project>
+ <project>../vecmath</project>
+ </subprojects>
</general-data>
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/1">
<compilation-unit>
<package-root>src/classes</package-root>
- <source-level>1.4</source-level>
+ <classpath mode="compile">../j3d-core/build/default/debug/lib/ext/j3dcore.jar:../j3d-core/build/default/debug/lib/ext/j3dutils.jar:../vecmath/build/debug/lib/ext/vecmath.jar</classpath>
+ <source-level>1.5</source-level>
</compilation-unit>
</java-data>
</configuration>
diff --git a/src/classes/org/jdesktop/j3d/examples/texture/TextureImageNPOT.java b/src/classes/org/jdesktop/j3d/examples/texture/TextureImageNPOT.java
new file mode 100644
index 0000000..6a08fe6
--- /dev/null
+++ b/src/classes/org/jdesktop/j3d/examples/texture/TextureImageNPOT.java
@@ -0,0 +1,228 @@
+/*
+ * $RCSfile$
+ *
+ * Copyright (c) 2006 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$
+ */
+
+package org.jdesktop.j3d.examples.texture;
+
+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 com.sun.j3d.utils.image.TextureLoader;
+import com.sun.j3d.utils.geometry.Box;
+import javax.media.j3d.*;
+import javax.vecmath.*;
+import java.util.Map;
+
+public class TextureImageNPOT extends Applet {
+
+ private java.net.URL texImage = null;
+
+ private SimpleUniverse u = null;
+ private boolean allowNonPowerOfTwo = true;
+ private boolean mipmap = true;
+
+ public BranchGroup createSceneGraph() {
+ // Create the root of the branch graph
+ BranchGroup objRoot = new BranchGroup();
+
+ // 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);
+ objRoot.addChild(objTrans);
+
+ // Create the scaling 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
+ // objTrans group
+ TransformGroup objScale = new TransformGroup();
+ objScale.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
+ objTrans.addChild(objScale);
+
+ // Create appearance object for textured cube
+ Appearance app = new Appearance();
+ int flags = 0;
+ if (allowNonPowerOfTwo) {
+ flags |= TextureLoader.ALLOW_NON_POWER_OF_TWO;
+ }
+ if (mipmap) {
+ flags |= TextureLoader.GENERATE_MIPMAP;
+ }
+ Texture tex = new TextureLoader(texImage, flags, this).getTexture();
+ tex.setMagFilter(Texture.BASE_LEVEL_LINEAR);
+ if (mipmap) {
+ tex.setMinFilter(Texture.MULTI_LEVEL_LINEAR);
+ } else {
+ tex.setMinFilter(Texture.BASE_LEVEL_LINEAR);
+ }
+ app.setTexture(tex);
+ TextureAttributes texAttr = new TextureAttributes();
+ texAttr.setTextureMode(TextureAttributes.MODULATE);
+ app.setTextureAttributes(texAttr);
+
+ // Create textured cube and add it to the scene graph.
+ Box textureCube = new Box(0.4f, 0.4f, 0.4f,
+ Box.GENERATE_TEXTURE_COORDS, app);
+ objScale.addChild(textureCube);
+
+ // 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 rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE,
+ 0, 0,
+ 50000, 0, 0,
+ 0, 0, 0);
+
+ 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);
+ objTrans.addChild(rotator);
+
+ // Create a new Behavior object that will perform the desired
+ // operation on the specified transform object and add it into
+ // the scene graph.
+ Alpha scaleAlpha = new Alpha(-1,
+ Alpha.INCREASING_ENABLE | Alpha.DECREASING_ENABLE,
+ 0, 0,
+ 8000, 0, 0,
+ 8000, 0, 0);
+
+ ScaleInterpolator scaler =
+ new ScaleInterpolator(scaleAlpha, objScale, yAxis,
+ 0.01f, 1.5f);
+ scaler.setSchedulingBounds(bounds);
+ objScale.addChild(scaler);
+
+ // Have Java 3D perform optimizations on this scene graph.
+ objRoot.compile();
+
+ return objRoot;
+ }
+
+ public TextureImageNPOT() {
+ }
+
+ public TextureImageNPOT(java.net.URL url) {
+ texImage = url;
+ }
+
+ public void init() {
+ if (texImage == null) {
+ // the path to the image for an applet
+ try {
+ texImage = new java.net.URL(getCodeBase().toString() +
+ "../images/Java3d.jpg");
+ }
+ catch (java.net.MalformedURLException ex) {
+ System.out.println(ex.getMessage());
+ System.exit(1);
+ }
+ }
+ setLayout(new BorderLayout());
+ GraphicsConfiguration config =
+ SimpleUniverse.getPreferredConfiguration();
+
+ Canvas3D c = new Canvas3D(config);
+
+ Map map = c.queryProperties();
+ Boolean value = (Boolean) map.get("textureNonPowerOfTwoAvailable");
+ if (value != null) {
+ System.out.println("textureNonPowerOfTwoAvailable property = " + value);
+ } else {
+ System.out.println("textureNonPowerOfTwoAvailable property not found");
+ }
+
+ add("Center", c);
+
+ // Create a simple scene and attach it to the virtual universe
+ BranchGroup scene = createSceneGraph();
+ u = new SimpleUniverse(c);
+
+ // 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();
+ }
+
+ //
+ // The following allows TextureImageNPOT to be run as an application
+ // as well as an applet
+ //
+ public static void main(String[] args) {
+ java.net.URL url = null;
+ if (args.length > 0) {
+ try {
+ url = new java.net.URL("file:" + args[0]);
+ }
+ catch (java.net.MalformedURLException ex) {
+ System.out.println(ex.getMessage());
+ System.exit(1);
+ }
+ }
+ else {
+ // the path to the image for an application
+ try {
+ url = new java.net.URL("file:../images/Java3d.jpg");
+ }
+ catch (java.net.MalformedURLException ex) {
+ System.out.println(ex.getMessage());
+ System.exit(1);
+ }
+ }
+ new MainFrame(new TextureImageNPOT(url), 512, 512);
+ }
+
+}