diff options
author | phil <[email protected]> | 2016-10-11 12:59:29 +1300 |
---|---|---|
committer | phil <[email protected]> | 2016-10-11 12:59:29 +1300 |
commit | 6e59ac5f89bcd8cbb0b05653c56a0454963984c8 (patch) | |
tree | b5b7612861f7f22b812ef66d85e710b79c5b593d | |
parent | 78924b53370ef6fd874f858e683b226a18bb82c5 (diff) |
New gl2es2 pipeline examples showing usage
Imports organized
Cg shader examples removed
pom.xml added
Resources now has brute force fall back
191 files changed, 7273 insertions, 2472 deletions
diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..69f6275 --- /dev/null +++ b/.classpath @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/classes"/>
+ <classpathentry excluding="classes/|main/java/|test/java/" kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry combineaccessrules="false" kind="src" path="/java3d-core"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/java3d-utils"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/vecmath"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/.project b/.project new file mode 100644 index 0000000..f2c3c59 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>java3d-examples</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..4824b80 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1
+encoding/<project>=UTF-8
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..bbcbc93 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..14b697b --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
@@ -0,0 +1,87 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.jogamp.java3d</groupId> + <artifactId>j3dexamples</artifactId> + <version>1.6.0-SNAPSHOT</version> + + <name>Java 3D Examples</name> + <description>Examples for the Java 3D Graphics API</description> + + <licenses> + <license> + <name>The GNU General Public License (GPL)</name> + <distribution>repo</distribution> + </license> + </licenses> + + <developers> + <developer> + <id>philjord</id> + <name>Philip Jordan</name> + <url>https://github.com/philjord</url> + <organization>JogAmp</organization> + <organizationUrl>http://jogamp.org/</organizationUrl> + </developer> + </developers> + <contributors> + <contributor> + <name>Various from previous project at Java.net</name> + <url>https://java.net/projects/j3d-examples</url> + <organization></organization> + <organizationUrl></organizationUrl> + </contributor> + </contributors> + + <properties> + <jogamp.version>2.3.2</jogamp.version> + + <!-- NB: Avoid platform encoding warning when copying resources. --> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + </properties> + + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>j3dcore</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>vecmath</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>j3dutils</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.1</version> + <configuration> + <source>1.7</source> + <target>1.7</target> + </configuration> + </plugin> + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <version>2.5</version> + <configuration> + <archive> + <manifest> + <addClasspath>true</addClasspath> + </manifest> + </archive> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/src/classes/org/jdesktop/j3d/examples/Resources.java b/src/classes/org/jdesktop/j3d/examples/Resources.java index db7bddb..4010201 100644 --- a/src/classes/org/jdesktop/j3d/examples/Resources.java +++ b/src/classes/org/jdesktop/j3d/examples/Resources.java @@ -44,6 +44,8 @@ package org.jdesktop.j3d.examples; +import java.io.File; +import java.net.MalformedURLException; import java.net.URL; /** @@ -62,7 +64,19 @@ public class Resources { * Return the URL of the filename under the resources directory */ public static URL getResource(String filename) { - URL url = Resources.class.getResource(filename); + URL url = Resources.class.getClassLoader().getResource(filename); + + if(url == null) + { + try + { + url = new File(System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/"+filename).toURL(); + } + catch (MalformedURLException e) + { + e.printStackTrace(); + } + } return url; } diff --git a/src/classes/org/jdesktop/j3d/examples/alternate_appearance/AlternateAppearanceBoundsTest.java b/src/classes/org/jdesktop/j3d/examples/alternate_appearance/AlternateAppearanceBoundsTest.java index 8577772..7bd3d23 100644 --- a/src/classes/org/jdesktop/j3d/examples/alternate_appearance/AlternateAppearanceBoundsTest.java +++ b/src/classes/org/jdesktop/j3d/examples/alternate_appearance/AlternateAppearanceBoundsTest.java @@ -7,7 +7,7 @@ * modification, are permitted provided that the following conditions * are met: * - * - Redistribution of source code must retain the above copyright + * - 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 @@ -44,18 +44,36 @@ package org.jdesktop.j3d.examples.alternate_appearance; -import java.applet.Applet; -import java.awt.*; -import java.awt.event.*; -import com.sun.j3d.utils.applet.MainFrame; -import com.sun.j3d.utils.geometry.*; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.border.*; -import com.sun.j3d.utils.behaviors.mouse.*; +import java.awt.Container; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BoxLayout; +import javax.swing.JApplet; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.border.TitledBorder; + +import org.jogamp.java3d.AlternateAppearance; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BoundingLeaf; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.Bounds; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Group; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3f; public class AlternateAppearanceBoundsTest extends JApplet implements ActionListener { @@ -104,7 +122,7 @@ implements ActionListener { public AlternateAppearanceBoundsTest() { } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); Container contentPane = getContentPane(); Canvas3D c = new Canvas3D(SimpleUniverse.getPreferredConfiguration()); @@ -303,7 +321,7 @@ implements ActionListener { } - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); Frame frame = new MainFrame(new AlternateAppearanceBoundsTest(), 800, 800); } diff --git a/src/classes/org/jdesktop/j3d/examples/alternate_appearance/AlternateAppearanceScopeTest.java b/src/classes/org/jdesktop/j3d/examples/alternate_appearance/AlternateAppearanceScopeTest.java index d2ffe84..bddbee8 100644 --- a/src/classes/org/jdesktop/j3d/examples/alternate_appearance/AlternateAppearanceScopeTest.java +++ b/src/classes/org/jdesktop/j3d/examples/alternate_appearance/AlternateAppearanceScopeTest.java @@ -44,18 +44,37 @@ package org.jdesktop.j3d.examples.alternate_appearance; -import java.applet.Applet; -import java.awt.*; -import java.awt.event.*; -import com.sun.j3d.utils.applet.MainFrame; -import com.sun.j3d.utils.geometry.*; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.border.*; -import com.sun.j3d.utils.behaviors.vp.*; +import java.awt.Container; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BoxLayout; +import javax.swing.JApplet; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.border.TitledBorder; + +import org.jogamp.java3d.AlternateAppearance; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Group; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.behaviors.vp.OrbitBehavior; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3f; public class AlternateAppearanceScopeTest extends JApplet implements ActionListener { @@ -85,7 +104,7 @@ implements ActionListener { public AlternateAppearanceScopeTest() { } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); Container contentPane = getContentPane(); Canvas3D c = new Canvas3D(SimpleUniverse.getPreferredConfiguration()); @@ -349,7 +368,7 @@ implements ActionListener { } - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); Frame frame = new MainFrame(new AlternateAppearanceScopeTest(), 800, 800); } diff --git a/src/classes/org/jdesktop/j3d/examples/alternate_appearance/SphereGroup.java b/src/classes/org/jdesktop/j3d/examples/alternate_appearance/SphereGroup.java index 19d4404..22f8553 100644 --- a/src/classes/org/jdesktop/j3d/examples/alternate_appearance/SphereGroup.java +++ b/src/classes/org/jdesktop/j3d/examples/alternate_appearance/SphereGroup.java @@ -44,9 +44,16 @@ package org.jdesktop.j3d.examples.alternate_appearance; -import javax.media.j3d.*; -import javax.vecmath.*; -import com.sun.j3d.utils.geometry.*; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Group; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.geometry.Primitive; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Vector3d; public class SphereGroup extends Group diff --git a/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java index 22f4ba4..943d387 100644 --- a/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java +++ b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java @@ -44,12 +44,37 @@ package org.jdesktop.j3d.examples.appearance; -import com.sun.j3d.utils.image.TextureLoader; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ColoringAttributes; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.GraphicsContext3D; +import org.jogamp.java3d.Group; +import org.jogamp.java3d.IndexedTriangleArray; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.PointAttributes; +import org.jogamp.java3d.PolygonAttributes; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.TextureAttributes; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.TransparencyAttributes; +import org.jogamp.java3d.utils.image.TextureLoader; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; public class AppearanceMixed extends javax.swing.JFrame { @@ -509,7 +534,7 @@ public class AppearanceMixed extends javax.swing.JFrame { /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new AppearanceMixed().setVisible(true); diff --git a/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.java b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.java index a005828..0f0315a 100644 --- a/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.java +++ b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.java @@ -44,12 +44,34 @@ package org.jdesktop.j3d.examples.appearance; -import com.sun.j3d.utils.image.TextureLoader; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ColoringAttributes; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Group; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.PointAttributes; +import org.jogamp.java3d.PolygonAttributes; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.TextureAttributes; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.TransparencyAttributes; +import org.jogamp.java3d.utils.image.TextureLoader; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; public class AppearanceTest extends javax.swing.JFrame { @@ -382,7 +404,7 @@ public class AppearanceTest extends javax.swing.JFrame { /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new AppearanceTest().setVisible(true); diff --git a/src/classes/org/jdesktop/j3d/examples/appearance/Tetrahedron.java b/src/classes/org/jdesktop/j3d/examples/appearance/Tetrahedron.java index 7cda117..625e7e4 100644 --- a/src/classes/org/jdesktop/j3d/examples/appearance/Tetrahedron.java +++ b/src/classes/org/jdesktop/j3d/examples/appearance/Tetrahedron.java @@ -44,8 +44,12 @@ package org.jdesktop.j3d.examples.appearance; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.TriangleArray; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.TexCoord2f; +import org.jogamp.vecmath.Vector3f; public class Tetrahedron extends Shape3D { private static final float sqrt3 = (float) Math.sqrt(3.0); diff --git a/src/classes/org/jdesktop/j3d/examples/applet3d/Applet3D.java b/src/classes/org/jdesktop/j3d/examples/applet3d/Applet3D.java index e770d8f..1822cba 100644 --- a/src/classes/org/jdesktop/j3d/examples/applet3d/Applet3D.java +++ b/src/classes/org/jdesktop/j3d/examples/applet3d/Applet3D.java @@ -44,26 +44,28 @@ package org.jdesktop.j3d.examples.applet3d; -import com.sun.j3d.utils.geometry.ColorCube; -import com.sun.j3d.utils.universe.SimpleUniverse; import java.awt.BorderLayout; import java.awt.Container; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; -import javax.media.j3d.Alpha; -import javax.media.j3d.BoundingSphere; -import javax.media.j3d.BranchGroup; -import javax.media.j3d.Canvas3D; -import javax.media.j3d.GraphicsConfigTemplate3D; -import javax.media.j3d.RotationInterpolator; -import javax.media.j3d.Transform3D; -import javax.media.j3d.TransformGroup; + import javax.swing.JApplet; import javax.swing.JFrame; import javax.swing.JPopupMenu; import javax.swing.WindowConstants; -import javax.vecmath.Point3d; + +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.GraphicsConfigTemplate3D; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.geometry.ColorCube; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Point3d; /** * Simple Java 3D program that can be run as an application or as an applet. @@ -174,7 +176,7 @@ public class Applet3D extends javax.swing.JPanel { public static class MyApplet extends JApplet { Applet3D mainPanel; - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); setLayout(new BorderLayout()); mainPanel = new Applet3D(this); add(mainPanel, BorderLayout.CENTER); @@ -200,7 +202,7 @@ public class Applet3D extends javax.swing.JPanel { /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new MyFrame().setVisible(true); diff --git a/src/classes/org/jdesktop/j3d/examples/background/BackgroundGeometry.java b/src/classes/org/jdesktop/j3d/examples/background/BackgroundGeometry.java index e05bac3..18d2f5f 100644 --- a/src/classes/org/jdesktop/j3d/examples/background/BackgroundGeometry.java +++ b/src/classes/org/jdesktop/j3d/examples/background/BackgroundGeometry.java @@ -44,14 +44,28 @@ package org.jdesktop.j3d.examples.background; -import com.sun.j3d.utils.image.TextureLoader; -import com.sun.j3d.utils.behaviors.mouse.*; -import com.sun.j3d.utils.geometry.*; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.behaviors.mouse.MouseRotate; +import org.jogamp.java3d.utils.behaviors.mouse.MouseTranslate; +import org.jogamp.java3d.utils.behaviors.mouse.MouseZoom; +import org.jogamp.java3d.utils.geometry.Box; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.image.TextureLoader; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3f; public class BackgroundGeometry extends javax.swing.JFrame { @@ -251,7 +265,7 @@ public class BackgroundGeometry extends javax.swing.JFrame { /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new BackgroundGeometry().setVisible(true); diff --git a/src/classes/org/jdesktop/j3d/examples/cg_shader/ObjLoadCg.java b/src/classes/org/jdesktop/j3d/examples/cg_shader/ObjLoadCg.java deleted file mode 100644 index de83107..0000000 --- a/src/classes/org/jdesktop/j3d/examples/cg_shader/ObjLoadCg.java +++ /dev/null @@ -1,377 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2007 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.cg_shader; - -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 com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; -import java.awt.GraphicsConfiguration; -import java.net.MalformedURLException; -import java.util.Enumeration; -import java.io.*; -import java.net.URL; -import com.sun.j3d.utils.behaviors.vp.*; -import java.io.FileNotFoundException; -import javax.swing.JOptionPane; -import org.jdesktop.j3d.examples.Resources; - -/** - * Simple Java 3D example program to display an .obj object with shader programs. - */ -public class ObjLoadCg extends javax.swing.JFrame { - - private boolean spin = false; - private boolean noTriangulate = false; - private boolean noStripify = false; - private double creaseAngle = 60.0; - private URL filename = null; - - private SimpleUniverse univ = null; - private BranchGroup scene = null; - - 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(Resources.getResource("cg_shader/simple_vp.cg")); - fragmentProgram = StringIO.readFully(Resources.getResource("cg_shader/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()); - - BoundingSphere 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 Canvas3D createUniverse() { - // Get the preferred graphics configuration for the default screen - GraphicsConfiguration config = - SimpleUniverse.getPreferredConfiguration(); - - // Create a Canvas3D using the preferred configuration - Canvas3D canvas3d = new Canvas3D(config); - - // Create simple universe with view branch - univ = new SimpleUniverse(canvas3d); - BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0); - - // Add a ShaderErrorListener - univ.addShaderErrorListener(new ShaderErrorListener() { - public void errorOccurred(ShaderError error) { - error.printVerbose(); - JOptionPane.showMessageDialog(ObjLoadCg.this, - error.toString(), - "ShaderError", - JOptionPane.ERROR_MESSAGE); - } - }); - - // add mouse behaviors to the ViewingPlatform - ViewingPlatform viewingPlatform = univ.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, 1.0f, 0.9f); - Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f); - Color3f light2Color = new Color3f(1.0f, 1.0f, 1.0f); - 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(canvas3d, - OrbitBehavior.REVERSE_ALL); - orbit.setSchedulingBounds(bounds); - viewingPlatform.setViewPlatformBehavior(orbit); - } - - // Ensure at least 5 msec per frame (i.e., < 200Hz) - univ.getViewer().getView().setMinimumFrameCycleTime(5); - - return canvas3d; - } - - 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 - - // 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); - } - } - } - - /** - * Creates new form ObjLoadCg - */ - 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); - } - } - } - } - - if (filename == null) { - filename = Resources.getResource("resources/geometry/galleon.obj"); - if (filename == null) { - System.err.println("resources/geometry/galleon.obj not found"); - System.exit(1); - } - } - - // Initialize the GUI components - initComponents(); - - // Create Canvas3D and SimpleUniverse; add canvas to drawing panel - Canvas3D c = createUniverse(); - drawingPanel.add(c, java.awt.BorderLayout.CENTER); - - // Create the content branch and add it to the universe - scene = createSceneGraph(); - univ.addBranchGraph(scene); - } - - // ---------------------------------------------------------------- - - /** 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() { - drawingPanel = new javax.swing.JPanel(); - - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - setTitle("ObjLoadCg"); - drawingPanel.setLayout(new java.awt.BorderLayout()); - - drawingPanel.setPreferredSize(new java.awt.Dimension(700, 700)); - getContentPane().add(drawingPanel, java.awt.BorderLayout.CENTER); - - pack(); - }// </editor-fold>//GEN-END:initComponents - - /** - * @param args the command line arguments - */ - public static void main(final String args[]) { - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - ObjLoadCg objLoadCg = new ObjLoadCg(args); - objLoadCg.setVisible(true); - } - }); - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JPanel drawingPanel; - // End of variables declaration//GEN-END:variables - -} diff --git a/src/classes/org/jdesktop/j3d/examples/cg_shader/SamplerTestCg.java b/src/classes/org/jdesktop/j3d/examples/cg_shader/SamplerTestCg.java deleted file mode 100644 index 20d3128..0000000 --- a/src/classes/org/jdesktop/j3d/examples/cg_shader/SamplerTestCg.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2007 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.cg_shader; - -import com.sun.j3d.utils.universe.*; -import com.sun.j3d.utils.geometry.Sphere; -import com.sun.j3d.utils.image.TextureLoader; -import com.sun.j3d.utils.shader.StringIO; -import javax.media.j3d.*; -import javax.vecmath.*; -import java.awt.GraphicsConfiguration; -import java.io.IOException; -import java.net.URL; -import javax.swing.JOptionPane; -import org.jdesktop.j3d.examples.Resources; - -public class SamplerTestCg extends javax.swing.JFrame { - - private static String cloudTexName = "resources/images/bg.jpg"; - private static String earthTexName = "resources/images/earth.jpg"; - private static String fragmentProgName = "cg_shader/multitex_fp.cg"; - private URL cloudURL = null; - private URL earthURL = null; - private static final int CLOUD = 0; - private static final int EARTH = 1; - - SimpleUniverse univ = null; - - public BranchGroup createSceneGraph() { - // Create the root of the branch graph - BranchGroup objRoot = new BranchGroup(); - - // 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 texture objects - cloudURL = Resources.getResource(cloudTexName); - Texture cloudTex = new TextureLoader(cloudURL, this).getTexture(); - earthURL = Resources.getResource(earthTexName); - Texture earthTex = new TextureLoader(earthURL, this).getTexture(); - - // Create the shader program - String vertexProgram = null; - String fragmentProgram = null; - try { - fragmentProgram = StringIO.readFully(Resources.getResource(fragmentProgName)); - } - catch (IOException e) { - System.err.println(e); - } - Shader[] shaders = new Shader[1]; - shaders[0] = new SourceCodeShader(Shader.SHADING_LANGUAGE_CG, - Shader.SHADER_TYPE_FRAGMENT, - fragmentProgram); - final String[] shaderAttrNames = { - "cloudFactor" - }; - final Object[] shaderAttrValues = { - new Float(0.6f), - }; - ShaderProgram shaderProgram = new CgShaderProgram(); - shaderProgram.setShaders(shaders); - shaderProgram.setShaderAttrNames(shaderAttrNames); - - // Create the shader attribute set - ShaderAttributeSet shaderAttributeSet = new ShaderAttributeSet(); - for (int i = 0; i < shaderAttrNames.length; i++) { - ShaderAttribute shaderAttribute = - new ShaderAttributeValue(shaderAttrNames[i], shaderAttrValues[i]); - shaderAttributeSet.put(shaderAttribute); - } - - // Create shader appearance to hold the shader program and - // shader attributes - ShaderAppearance app = new ShaderAppearance(); - app.setShaderProgram(shaderProgram); - app.setShaderAttributeSet(shaderAttributeSet); - - // Setup texture coordinate generation - Vector4f plane0S = new Vector4f(3.0f, 1.5f, 0.3f, 0.0f); - Vector4f plane0T = new Vector4f(1.0f, 2.5f, 0.24f, 0.0f); - TexCoordGeneration tcg0 = - new TexCoordGeneration(TexCoordGeneration.OBJECT_LINEAR, - TexCoordGeneration.TEXTURE_COORDINATE_2, plane0S, plane0T); - - // Setup texture coordinate generation - TexCoordGeneration tcg1 = - new TexCoordGeneration(TexCoordGeneration.SPHERE_MAP, - TexCoordGeneration.TEXTURE_COORDINATE_2); - - // Put the textures in unit 0,1 - TextureUnitState[] tus = new TextureUnitState[2]; - tus[CLOUD] = new TextureUnitState(); - tus[CLOUD].setTexture(cloudTex); - tus[CLOUD].setTexCoordGeneration(tcg0); - tus[EARTH] = new TextureUnitState(); - tus[EARTH].setTexture(earthTex); - tus[EARTH].setTexCoordGeneration(tcg1); - app.setTextureUnitState(tus); - - // Create a Sphere object using the shader appearance, - // and add it into the scene graph. - Sphere sph = new Sphere(0.4f, Sphere.GENERATE_NORMALS, 30, app); - objTrans.addChild(sph); - - // 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); - - // Have Java 3D perform optimizations on this scene graph. - //objRoot.compile(); - - return objRoot; - } - - private Canvas3D initScene() { - GraphicsConfiguration config = - SimpleUniverse.getPreferredConfiguration(); - - Canvas3D c = new Canvas3D(config); - - BranchGroup scene = createSceneGraph(); - univ = new SimpleUniverse(c); - - // Add a ShaderErrorListener - univ.addShaderErrorListener(new ShaderErrorListener() { - public void errorOccurred(ShaderError error) { - error.printVerbose(); - JOptionPane.showMessageDialog(SamplerTestCg.this, - error.toString(), - "ShaderError", - JOptionPane.ERROR_MESSAGE); - } - }); - - ViewingPlatform viewingPlatform = univ.getViewingPlatform(); - // This will move the ViewPlatform back a bit so the - // objects in the scene can be viewed. - viewingPlatform.setNominalViewingTransform(); - - univ.addBranchGraph(scene); - - return c; - } - - /** - * Creates new form SamplerTestCg - */ - public SamplerTestCg() { - // Initialize the GUI components - initComponents(); - - // Create the scene and add the Canvas3D to the drawing panel - Canvas3D c = initScene(); - drawingPanel.add(c, java.awt.BorderLayout.CENTER); - } - - // ---------------------------------------------------------------- - - /** 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() { - drawingPanel = new javax.swing.JPanel(); - - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - setTitle("SamplerTestCg"); - drawingPanel.setLayout(new java.awt.BorderLayout()); - - drawingPanel.setPreferredSize(new java.awt.Dimension(500, 500)); - getContentPane().add(drawingPanel, java.awt.BorderLayout.CENTER); - - pack(); - }// </editor-fold>//GEN-END:initComponents - - /** - * @param args the command line arguments - */ - public static void main(String args[]) { - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - new SamplerTestCg().setVisible(true); - } - }); - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JPanel drawingPanel; - // End of variables declaration//GEN-END:variables - -} diff --git a/src/classes/org/jdesktop/j3d/examples/cg_shader/SphereCg.java b/src/classes/org/jdesktop/j3d/examples/cg_shader/SphereCg.java deleted file mode 100644 index 7bbb7c6..0000000 --- a/src/classes/org/jdesktop/j3d/examples/cg_shader/SphereCg.java +++ /dev/null @@ -1,356 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2007 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.cg_shader; - -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.awt.GraphicsConfiguration; -import java.io.*; -import javax.swing.JOptionPane; -import org.jdesktop.j3d.examples.Resources; - -/** - * Simple Java 3D example program with programmable shader. - */ -public class SphereCg extends javax.swing.JFrame { - - // 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 univ = null; - private BranchGroup scene = null; - - public BranchGroup createSceneGraph() { - Color3f eColor = new Color3f(0.0f, 0.0f, 0.0f); - Color3f sColor = new Color3f(1.0f, 1.0f, 1.0f); - Color3f objColor = new Color3f(0.6f, 0.6f, 0.6f); - Color3f lColor1 = new Color3f(1.0f, 0.0f, 0.0f); - Color3f lColor2 = new Color3f(0.0f, 1.0f, 0.0f); - Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f); - Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f); - - Transform3D t; - - // Create the root of the branch graph - BranchGroup objRoot = new BranchGroup(); - - // Create a Transformgroup to scale all objects so they - // appear in the scene. - TransformGroup objScale = new TransformGroup(); - Transform3D t3d = new Transform3D(); - t3d.setScale(0.4); - objScale.setTransform(t3d); - objRoot.addChild(objScale); - - // Create a bounds for the background and lights - BoundingSphere bounds = - new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0); - - // Set up the background - Background bg = new Background(bgColor); - bg.setApplicationBounds(bounds); - objScale.addChild(bg); - - // Create a Sphere object, generate one copy of the sphere, - // and add it into the scene graph. - ShaderAppearance a = new ShaderAppearance(); - Material m = new Material(objColor, eColor, objColor, sColor, 100.0f); - m.setLightingEnable(true); - String vertexProgram = null; - String fragmentProgram = null; - try { - vertexProgram = StringIO.readFully(Resources.getResource("cg_shader/simple_vp.cg")); - fragmentProgram = StringIO.readFully(Resources.getResource("cg_shader/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 = - univ.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; - } - - private Canvas3D createUniverse() { - // Get the preferred graphics configuration for the default screen - GraphicsConfiguration config = - SimpleUniverse.getPreferredConfiguration(); - - // Create a Canvas3D using the preferred configuration - Canvas3D canvas3d = new Canvas3D(config); - - // Create simple universe with view branch - univ = new SimpleUniverse(canvas3d); - BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0); - - // Add a ShaderErrorListener - univ.addShaderErrorListener(new ShaderErrorListener() { - public void errorOccurred(ShaderError error) { - error.printVerbose(); - JOptionPane.showMessageDialog(SphereCg.this, - error.toString(), - "ShaderError", - JOptionPane.ERROR_MESSAGE); - } - }); - - // This will move the ViewPlatform back a bit so the - // objects in the scene can be viewed. - univ.getViewingPlatform().setNominalViewingTransform(); - - // Ensure at least 5 msec per frame (i.e., < 200Hz) - univ.getViewer().getView().setMinimumFrameCycleTime(5); - - return canvas3d; - } - - - /** - * Creates new form SphereCg - */ - public SphereCg() { - - // Initialize the GUI components - initComponents(); - - // Create Canvas3D and SimpleUniverse; add canvas to drawing panel - Canvas3D c = createUniverse(); - drawingPanel.add(c, java.awt.BorderLayout.CENTER); - - // Create the content branch and add it to the universe - scene = createSceneGraph(); - univ.addBranchGraph(scene); } - - // ---------------------------------------------------------------- - - /** 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() { - drawingPanel = new javax.swing.JPanel(); - - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - setTitle("SphereCg"); - drawingPanel.setLayout(new java.awt.BorderLayout()); - - drawingPanel.setPreferredSize(new java.awt.Dimension(700, 700)); - getContentPane().add(drawingPanel, java.awt.BorderLayout.CENTER); - - pack(); - }// </editor-fold>//GEN-END:initComponents - - /** - * @param args the command line arguments - */ - public static void main(final String args[]) { - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - SphereCg sphereCg = new SphereCg(); - sphereCg.setVisible(true); - } - }); - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JPanel drawingPanel; - // End of variables declaration//GEN-END:variables - -} diff --git a/src/classes/org/jdesktop/j3d/examples/cg_shader/VertexAttrTestCg.java b/src/classes/org/jdesktop/j3d/examples/cg_shader/VertexAttrTestCg.java deleted file mode 100644 index 7860554..0000000 --- a/src/classes/org/jdesktop/j3d/examples/cg_shader/VertexAttrTestCg.java +++ /dev/null @@ -1,408 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2007 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.cg_shader; - -import com.sun.j3d.utils.universe.*; -import com.sun.j3d.utils.shader.StringIO; -import javax.media.j3d.*; -import java.awt.GraphicsConfiguration; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.FloatBuffer; -import javax.swing.JFrame; -import javax.swing.JOptionPane; -import javax.vecmath.Color3f; -import javax.vecmath.Point3d; -import org.jdesktop.j3d.examples.Resources; - - -public class VertexAttrTestCg extends javax.swing.JFrame { - - SimpleUniverse univ = null; - BranchGroup scene = null; - - public BranchGroup createSceneGraph(boolean hasVertexAttrs) { - - // Bounds for BG and behavior - BoundingSphere bounds = - new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0); - - // Create the root of the branch graph - BranchGroup objRoot = new BranchGroup(); - objRoot.setCapability(BranchGroup.ALLOW_DETACH); - - // Set up the background - Color3f bgColor = new Color3f(0.1f, 0.1f, 0.1f); - Background bg = new Background(bgColor); - bg.setApplicationBounds(bounds); - objRoot.addChild(bg); - - // 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 MyShape(this, hasVertexAttrs)); - - return objRoot; - } - - private Canvas3D initScene() { - GraphicsConfiguration config = - SimpleUniverse.getPreferredConfiguration(); - - Canvas3D c = new Canvas3D(config); - - univ = new SimpleUniverse(c); - - // Add a ShaderErrorListener - univ.addShaderErrorListener(new ShaderErrorListener() { - public void errorOccurred(ShaderError error) { - error.printVerbose(); - JOptionPane.showMessageDialog(VertexAttrTestCg.this, - error.toString(), - "ShaderError", - JOptionPane.ERROR_MESSAGE); - } - }); - - ViewingPlatform viewingPlatform = univ.getViewingPlatform(); - // This will move the ViewPlatform back a bit so the - // objects in the scene can be viewed. - viewingPlatform.setNominalViewingTransform(); - - return c; - } - - /** - * Creates new form VertexAttrTestCg - */ - public VertexAttrTestCg() { - // Initialize the GUI components - initComponents(); - - // Create the scene and add the Canvas3D to the drawing panel - Canvas3D c = initScene(); - drawingPanel.add(c, java.awt.BorderLayout.CENTER); - } - - static class MyShape extends Shape3D { - // Coordinate data - private static final float[] coords = { - 0.0f, 0.0f, 0.0f, - 0.5f, 0.0f, 0.0f, - 0.0f, 0.5f, 0.0f, - }; - - private static final int[] sizes = { 1, 3 }; - private static final float[] weights = { - 0.45f, - 0.15f, - 0.95f, - }; - private static final float[] temps = { - 1.0f, 0.5f, 0.5f, - 0.5f, 1.0f, 0.5f, - 0.5f, 0.5f, 1.0f, - }; - - private static final String[] vaNames = { "weight", "temperature" }; - - J3DBuffer createDirectFloatBuffer(float[] arr) { - ByteOrder order = ByteOrder.nativeOrder(); - - FloatBuffer nioBuf = ByteBuffer.allocateDirect(arr.length * 4).order(order).asFloatBuffer(); - nioBuf.put(arr); - return new J3DBuffer(nioBuf); - } - - - MyShape(JFrame frame, boolean hasVertexAttrs) { - - int vertexFormat = GeometryArray.COORDINATES; - int vertexAttrCount = 0; - int[] vertexAttrSizes = null; - String[] vertexAttrNames = null; - String[] shaderAttrNames = null; - - if (hasVertexAttrs) { - vertexFormat |= GeometryArray.VERTEX_ATTRIBUTES; - vertexAttrCount = vaNames.length; - vertexAttrSizes = sizes; - vertexAttrNames = vaNames; - } - - TriangleArray tri = new TriangleArray(6, vertexFormat, 0, null, vertexAttrCount, vertexAttrSizes); - tri.setValidVertexCount(3); - tri.setCoordinates(0, coords); - - if (hasVertexAttrs) { - tri.setVertexAttrs(0, 0, weights); - tri.setVertexAttrs(1, 0, temps); - - - String vertexProgram = null; - try { - vertexProgram = StringIO.readFully(Resources.getResource("cg_shader/vertexshader_vp.cg")); - } catch (IOException e) { - throw new RuntimeException(e); - } - - Shader[] shaders = new Shader[1]; - shaders[0] = new SourceCodeShader(Shader.SHADING_LANGUAGE_CG, - Shader.SHADER_TYPE_VERTEX, - vertexProgram); - ShaderProgram shaderProgram = new CgShaderProgram(); - shaderProgram.setShaders(shaders); - shaderProgram.setVertexAttrNames(vertexAttrNames); - - ShaderAppearance app = new ShaderAppearance(); - app.setShaderProgram(shaderProgram); - - this.setGeometry(tri); - this.setAppearance(app); - - } else { - this.setGeometry(tri); - this.setAppearance(new Appearance()); - } - } - } - - // ---------------------------------------------------------------- - - /** 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; - - mainPanel = new javax.swing.JPanel(); - guiPanel = new javax.swing.JPanel(); - vertexCheckBoxPanel = new javax.swing.JPanel(); - jPanel1 = new javax.swing.JPanel(); - jSeparator1 = new javax.swing.JSeparator(); - jSeparator2 = new javax.swing.JSeparator(); - jPanel2 = new javax.swing.JPanel(); - vertexAttrsBox = new javax.swing.JCheckBox(); - geometryPanel = new javax.swing.JPanel(); - createButton = new javax.swing.JButton(); - destroyButton = new javax.swing.JButton(); - drawingPanel = new javax.swing.JPanel(); - jMenuBar1 = new javax.swing.JMenuBar(); - fileMenu = new javax.swing.JMenu(); - exitMenuItem = new javax.swing.JMenuItem(); - - setTitle("Vertex Attribute Test"); - addWindowListener(new java.awt.event.WindowAdapter() { - public void windowClosing(java.awt.event.WindowEvent evt) { - exitForm(evt); - } - }); - - mainPanel.setLayout(new java.awt.BorderLayout()); - - guiPanel.setLayout(new java.awt.GridBagLayout()); - - guiPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - vertexCheckBoxPanel.setLayout(new java.awt.GridBagLayout()); - - vertexCheckBoxPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "vertexFormat", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Lucida Sans", 0, 10))); - jPanel1.setLayout(new java.awt.GridBagLayout()); - - jSeparator1.setPreferredSize(new java.awt.Dimension(0, 4)); - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 1; - jPanel1.add(jSeparator1, gridBagConstraints); - - jSeparator2.setPreferredSize(new java.awt.Dimension(0, 4)); - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 3; - jPanel1.add(jSeparator2, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; - vertexCheckBoxPanel.add(jPanel1, gridBagConstraints); - - jPanel2.setLayout(new java.awt.GridBagLayout()); - - vertexAttrsBox.setSelected(true); - vertexAttrsBox.setText("VertexAttrs"); - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 4; - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; - jPanel2.add(vertexAttrsBox, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; - vertexCheckBoxPanel.add(jPanel2, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 0; - gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); - guiPanel.add(vertexCheckBoxPanel, gridBagConstraints); - - geometryPanel.setLayout(new java.awt.GridBagLayout()); - - createButton.setText("Create Geometry"); - createButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - createButtonActionPerformed(evt); - } - }); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; - geometryPanel.add(createButton, gridBagConstraints); - - destroyButton.setText("Destroy Geometry"); - destroyButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - destroyButtonActionPerformed(evt); - } - }); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridx = 0; - gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; - gridBagConstraints.insets = new java.awt.Insets(0, 0, 2, 0); - geometryPanel.add(destroyButton, gridBagConstraints); - - gridBagConstraints = new java.awt.GridBagConstraints(); - gridBagConstraints.gridy = 0; - gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); - guiPanel.add(geometryPanel, gridBagConstraints); - - mainPanel.add(guiPanel, java.awt.BorderLayout.NORTH); - - drawingPanel.setLayout(new java.awt.BorderLayout()); - - drawingPanel.setPreferredSize(new java.awt.Dimension(500, 500)); - mainPanel.add(drawingPanel, java.awt.BorderLayout.CENTER); - - getContentPane().add(mainPanel, java.awt.BorderLayout.CENTER); - - fileMenu.setText("File"); - exitMenuItem.setText("Exit"); - exitMenuItem.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - exitMenuItemActionPerformed(evt); - } - }); - - fileMenu.add(exitMenuItem); - - jMenuBar1.add(fileMenu); - - setJMenuBar(jMenuBar1); - - pack(); - }// </editor-fold>//GEN-END:initComponents - - private void destroyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_destroyButtonActionPerformed - if (scene != null) { - univ.getLocale().removeBranchGraph(scene); - scene = null; - } - }//GEN-LAST:event_destroyButtonActionPerformed - - private void createButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createButtonActionPerformed - if (scene == null) { - boolean hasVertexAttrs = vertexAttrsBox.isSelected(); - scene = createSceneGraph(hasVertexAttrs); - univ.addBranchGraph(scene); - } - }//GEN-LAST:event_createButtonActionPerformed - - private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed - System.exit(0); - }//GEN-LAST:event_exitMenuItemActionPerformed - - /** Exit the Application */ - private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm - System.exit(0); - }//GEN-LAST:event_exitForm - - /** - * @param args the command line arguments - */ - public static void main(String args[]) { - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - new VertexAttrTestCg().setVisible(true); - } - }); - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton createButton; - private javax.swing.JButton destroyButton; - private javax.swing.JPanel drawingPanel; - private javax.swing.JMenuItem exitMenuItem; - private javax.swing.JMenu fileMenu; - private javax.swing.JPanel geometryPanel; - private javax.swing.JPanel guiPanel; - private javax.swing.JMenuBar jMenuBar1; - private javax.swing.JPanel jPanel1; - private javax.swing.JPanel jPanel2; - private javax.swing.JSeparator jSeparator1; - private javax.swing.JSeparator jSeparator2; - private javax.swing.JPanel mainPanel; - private javax.swing.JCheckBox vertexAttrsBox; - private javax.swing.JPanel vertexCheckBoxPanel; - // End of variables declaration//GEN-END:variables - -} diff --git a/src/classes/org/jdesktop/j3d/examples/cg_shader/simple_vp.cg b/src/classes/org/jdesktop/j3d/examples/cg_shader/simple_vp.cg deleted file mode 100644 index 5f5b5c1..0000000 --- a/src/classes/org/jdesktop/j3d/examples/cg_shader/simple_vp.cg +++ /dev/null @@ -1,167 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2007 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/classes/org/jdesktop/j3d/examples/collision/Box.java b/src/classes/org/jdesktop/j3d/examples/collision/Box.java index bb1aad8..a472fb3 100644 --- a/src/classes/org/jdesktop/j3d/examples/collision/Box.java +++ b/src/classes/org/jdesktop/j3d/examples/collision/Box.java @@ -44,8 +44,10 @@ package org.jdesktop.j3d.examples.collision; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.QuadArray; +import org.jogamp.java3d.Shape3D; +import org.jogamp.vecmath.Point3d; public class Box extends Shape3D { diff --git a/src/classes/org/jdesktop/j3d/examples/collision/CollisionDetector.java b/src/classes/org/jdesktop/j3d/examples/collision/CollisionDetector.java index e58ff98..5d25810 100644 --- a/src/classes/org/jdesktop/j3d/examples/collision/CollisionDetector.java +++ b/src/classes/org/jdesktop/j3d/examples/collision/CollisionDetector.java @@ -45,8 +45,14 @@ package org.jdesktop.j3d.examples.collision; import java.util.Enumeration; -import javax.media.j3d.*; -import javax.vecmath.*; + +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Behavior; +import org.jogamp.java3d.ColoringAttributes; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.WakeupOnCollisionEntry; +import org.jogamp.java3d.WakeupOnCollisionExit; +import org.jogamp.vecmath.Color3f; public class CollisionDetector extends Behavior { private static final Color3f highlightColor = diff --git a/src/classes/org/jdesktop/j3d/examples/collision/TickTockCollision.java b/src/classes/org/jdesktop/j3d/examples/collision/TickTockCollision.java index d21bc5c..8d1cba2 100644 --- a/src/classes/org/jdesktop/j3d/examples/collision/TickTockCollision.java +++ b/src/classes/org/jdesktop/j3d/examples/collision/TickTockCollision.java @@ -44,14 +44,26 @@ package org.jdesktop.j3d.examples.collision; -import java.awt.*; -import java.awt.event.*; -import com.sun.j3d.utils.universe.*; -import com.sun.j3d.utils.geometry.ColorCube; -import javax.media.j3d.*; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ColoringAttributes; +import org.jogamp.java3d.Group; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.geometry.ColorCube; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; + /** * Simple Java 3D example program to display how collision work. */ @@ -245,7 +257,7 @@ public class TickTockCollision extends javax.swing.JFrame { /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new TickTockCollision().setVisible(true); diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/ConfigObjLoad.java b/src/classes/org/jdesktop/j3d/examples/configured_universe/ConfigObjLoad.java index 02aed08..9afa414 100644 --- a/src/classes/org/jdesktop/j3d/examples/configured_universe/ConfigObjLoad.java +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/ConfigObjLoad.java @@ -44,21 +44,36 @@ package org.jdesktop.j3d.examples.configured_universe; -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 java.awt.event.*; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; -import java.io.*; -import com.sun.j3d.utils.behaviors.vp.*; -import com.sun.j3d.utils.behaviors.sensor.Mouse6DPointerBehavior; -import java.net.URL; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.io.FileNotFoundException; import java.net.MalformedURLException; +import java.net.URL; import java.util.Map; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Sensor; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.loaders.IncorrectFormatException; +import org.jogamp.java3d.loaders.ParsingErrorException; +import org.jogamp.java3d.loaders.Scene; +import org.jogamp.java3d.loaders.objectfile.ObjectFile; +import org.jogamp.java3d.utils.behaviors.sensor.Mouse6DPointerBehavior; +import org.jogamp.java3d.utils.behaviors.vp.OrbitBehavior; +import org.jogamp.java3d.utils.universe.ConfiguredUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3f; public class ConfigObjLoad { @@ -178,7 +193,7 @@ public class ConfigObjLoad { } // End of usage - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); if (filename == null) { filename = Resources.getResource("resources/geometry/galleon.obj"); if (filename == null) { @@ -306,7 +321,7 @@ public class ConfigObjLoad { init(); } - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); new ConfigObjLoad(args); } } diff --git a/src/classes/org/jdesktop/j3d/examples/depth_func/DepthFuncTest.java b/src/classes/org/jdesktop/j3d/examples/depth_func/DepthFuncTest.java index e29ab63..0095ca9 100644 --- a/src/classes/org/jdesktop/j3d/examples/depth_func/DepthFuncTest.java +++ b/src/classes/org/jdesktop/j3d/examples/depth_func/DepthFuncTest.java @@ -44,7 +44,7 @@ package org.jdesktop.j3d.examples.depth_func; -import javax.media.j3d.*; +import org.jogamp.java3d.RenderingAttributes; /** @@ -331,7 +331,7 @@ public class DepthFuncTest extends javax.swing.JFrame /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { DepthFuncTest dpt = new DepthFuncTest(); diff --git a/src/classes/org/jdesktop/j3d/examples/depth_func/RenderFrame.java b/src/classes/org/jdesktop/j3d/examples/depth_func/RenderFrame.java index 37489da..04d8a58 100644 --- a/src/classes/org/jdesktop/j3d/examples/depth_func/RenderFrame.java +++ b/src/classes/org/jdesktop/j3d/examples/depth_func/RenderFrame.java @@ -44,13 +44,30 @@ package org.jdesktop.j3d.examples.depth_func; -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.*; + +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.OrderedGroup; +import org.jogamp.java3d.PointLight; +import org.jogamp.java3d.PolygonAttributes; +import org.jogamp.java3d.RenderingAttributes; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.ScaleInterpolator; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.behaviors.mouse.MouseRotate; +import org.jogamp.java3d.utils.geometry.Box; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; public class RenderFrame extends javax.swing.JFrame { diff --git a/src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortBehavior.java b/src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortBehavior.java index dbfdcd4..3ba873f 100644 --- a/src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortBehavior.java +++ b/src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortBehavior.java @@ -46,17 +46,16 @@ package org.jdesktop.j3d.examples.distort_glyph; import java.util.Enumeration; -import javax.media.j3d.Appearance; -import javax.media.j3d.Behavior; -import javax.media.j3d.GeometryArray; -import javax.media.j3d.Shape3D; -import javax.media.j3d.Transform3D; -import javax.media.j3d.WakeupCondition; -import javax.media.j3d.WakeupCriterion; -import javax.media.j3d.WakeupOnElapsedFrames; -import javax.media.j3d.WakeupOnElapsedTime; - -import javax.vecmath.Vector3f; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Behavior; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.WakeupCondition; +import org.jogamp.java3d.WakeupCriterion; +import org.jogamp.java3d.WakeupOnElapsedFrames; +import org.jogamp.java3d.WakeupOnElapsedTime; +import org.jogamp.vecmath.Vector3f; public class DistortBehavior extends Behavior { // the wake up condition for the behavior diff --git a/src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.java b/src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.java index 3e6d2ab..cf88439 100644 --- a/src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.java +++ b/src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.java @@ -44,15 +44,37 @@ package org.jdesktop.j3d.examples.distort_glyph; -import com.sun.j3d.utils.behaviors.mouse.*; -import com.sun.j3d.utils.image.TextureLoader; -import com.sun.j3d.utils.universe.*; import java.awt.Font; import java.awt.GraphicsConfiguration; import java.awt.GraphicsEnvironment; -import javax.media.j3d.*; -import javax.vecmath.*; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Font3D; +import org.jogamp.java3d.FontExtrusion; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.GraphicsConfigTemplate3D; +import org.jogamp.java3d.Light; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.PointLight; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.TexCoordGeneration; +import org.jogamp.java3d.Texture; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.behaviors.mouse.MouseRotate; +import org.jogamp.java3d.utils.behaviors.mouse.MouseTranslate; +import org.jogamp.java3d.utils.behaviors.mouse.MouseZoom; +import org.jogamp.java3d.utils.image.TextureLoader; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; public class DistortGlyphTest extends javax.swing.JFrame { @@ -217,7 +239,7 @@ public class DistortGlyphTest extends javax.swing.JFrame { /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new DistortGlyphTest().setVisible(true); diff --git a/src/classes/org/jdesktop/j3d/examples/dot3/Dot3Demo.java b/src/classes/org/jdesktop/j3d/examples/dot3/Dot3Demo.java index 9566a62..8e5ec84 100644 --- a/src/classes/org/jdesktop/j3d/examples/dot3/Dot3Demo.java +++ b/src/classes/org/jdesktop/j3d/examples/dot3/Dot3Demo.java @@ -44,48 +44,45 @@ package org.jdesktop.j3d.examples.dot3; -import com.sun.j3d.utils.behaviors.vp.OrbitBehavior; -import com.sun.j3d.utils.geometry.GeometryInfo; -import com.sun.j3d.utils.image.TextureLoader; -import com.sun.j3d.utils.universe.SimpleUniverse; -import com.sun.j3d.utils.universe.ViewingPlatform; - import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.image.BufferedImage; - import java.util.Enumeration; -import javax.media.j3d.AmbientLight; -import javax.media.j3d.Appearance; -import javax.media.j3d.Background; -import javax.media.j3d.Behavior; -import javax.media.j3d.BoundingSphere; -import javax.media.j3d.BranchGroup; -import javax.media.j3d.Canvas3D; -import javax.media.j3d.DirectionalLight; -import javax.media.j3d.GeometryArray; -import javax.media.j3d.ImageComponent2D; -import javax.media.j3d.Material; -import javax.media.j3d.PolygonAttributes; -import javax.media.j3d.Shape3D; -import javax.media.j3d.TexCoordGeneration; -import javax.media.j3d.Texture; -import javax.media.j3d.Texture2D; -import javax.media.j3d.TextureAttributes; -import javax.media.j3d.TextureUnitState; -import javax.media.j3d.WakeupOnElapsedFrames; - import javax.swing.JFrame; import javax.swing.JPanel; -import javax.vecmath.Color3f; -import javax.vecmath.Point3d; -import javax.vecmath.Vector3f; import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.Behavior; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.ImageComponent2D; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.PolygonAttributes; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.TexCoordGeneration; +import org.jogamp.java3d.Texture; +import org.jogamp.java3d.Texture2D; +import org.jogamp.java3d.TextureAttributes; +import org.jogamp.java3d.TextureUnitState; +import org.jogamp.java3d.WakeupOnElapsedFrames; +import org.jogamp.java3d.utils.behaviors.vp.OrbitBehavior; +import org.jogamp.java3d.utils.geometry.GeometryInfo; +import org.jogamp.java3d.utils.image.TextureLoader; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3f; /** * This example program is contributed by Alessandro Borges @@ -512,7 +509,7 @@ public class Dot3Demo extends JFrame { * main method * @param args */ - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { new Dot3Demo(); diff --git a/src/classes/org/jdesktop/j3d/examples/dot3/MyCanvas.java b/src/classes/org/jdesktop/j3d/examples/dot3/MyCanvas.java index e873a53..f5f4cfc 100644 --- a/src/classes/org/jdesktop/j3d/examples/dot3/MyCanvas.java +++ b/src/classes/org/jdesktop/j3d/examples/dot3/MyCanvas.java @@ -44,10 +44,16 @@ package org.jdesktop.j3d.examples.dot3; -import java.awt.*; -import java.awt.image.*; -import java.awt.event.*; -import javax.swing.*; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Point; +import java.awt.event.MouseEvent; +import java.awt.image.BufferedImage; + +import javax.swing.JPanel; import javax.swing.event.MouseInputListener; /** diff --git a/src/classes/org/jdesktop/j3d/examples/dot3/TextureControlPanel.java b/src/classes/org/jdesktop/j3d/examples/dot3/TextureControlPanel.java index c8ade16..0aef5f0 100644 --- a/src/classes/org/jdesktop/j3d/examples/dot3/TextureControlPanel.java +++ b/src/classes/org/jdesktop/j3d/examples/dot3/TextureControlPanel.java @@ -51,11 +51,9 @@ import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.BufferedImage; - import java.net.URL; import javax.imageio.ImageIO; - import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JDialog; @@ -64,6 +62,7 @@ import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; + import org.jdesktop.j3d.examples.Resources; /** diff --git a/src/classes/org/jdesktop/j3d/examples/four_by_four/BigCube.java b/src/classes/org/jdesktop/j3d/examples/four_by_four/BigCube.java index cffb4a8..3609c97 100644 --- a/src/classes/org/jdesktop/j3d/examples/four_by_four/BigCube.java +++ b/src/classes/org/jdesktop/j3d/examples/four_by_four/BigCube.java @@ -44,10 +44,9 @@ package org.jdesktop.j3d.examples.four_by_four; -import java.applet.Applet; -import java.awt.event.*; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.QuadArray; +import org.jogamp.java3d.Shape3D; /** * Class BigCube diff --git a/src/classes/org/jdesktop/j3d/examples/four_by_four/Board.java b/src/classes/org/jdesktop/j3d/examples/four_by_four/Board.java index 9ead21a..3ed2f89 100644 --- a/src/classes/org/jdesktop/j3d/examples/four_by_four/Board.java +++ b/src/classes/org/jdesktop/j3d/examples/four_by_four/Board.java @@ -44,7 +44,8 @@ package org.jdesktop.j3d.examples.four_by_four; -import java.awt.*; +import java.awt.Color; +import java.awt.Graphics; /** * Class: Board diff --git a/src/classes/org/jdesktop/j3d/examples/four_by_four/Canvas2D.java b/src/classes/org/jdesktop/j3d/examples/four_by_four/Canvas2D.java index 2fc31be..ea63b4b 100644 --- a/src/classes/org/jdesktop/j3d/examples/four_by_four/Canvas2D.java +++ b/src/classes/org/jdesktop/j3d/examples/four_by_four/Canvas2D.java @@ -44,9 +44,11 @@ package org.jdesktop.j3d.examples.four_by_four; -import java.awt.*; -import java.awt.event.*; -import java.awt.image.*; +import java.awt.Canvas; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; /** * Class: Canvas2D diff --git a/src/classes/org/jdesktop/j3d/examples/four_by_four/Cube.java b/src/classes/org/jdesktop/j3d/examples/four_by_four/Cube.java index beb4bd3..2460881 100644 --- a/src/classes/org/jdesktop/j3d/examples/four_by_four/Cube.java +++ b/src/classes/org/jdesktop/j3d/examples/four_by_four/Cube.java @@ -44,10 +44,9 @@ package org.jdesktop.j3d.examples.four_by_four; -import java.applet.Applet; -import java.awt.event.*; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.QuadArray; +import org.jogamp.java3d.Shape3D; public class Cube extends Object { diff --git a/src/classes/org/jdesktop/j3d/examples/four_by_four/Cylinder.java b/src/classes/org/jdesktop/j3d/examples/four_by_four/Cylinder.java index 522bb3b..db13a32 100644 --- a/src/classes/org/jdesktop/j3d/examples/four_by_four/Cylinder.java +++ b/src/classes/org/jdesktop/j3d/examples/four_by_four/Cylinder.java @@ -44,8 +44,9 @@ package org.jdesktop.j3d.examples.four_by_four; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.QuadArray; +import org.jogamp.java3d.Shape3D; public class Cylinder { diff --git a/src/classes/org/jdesktop/j3d/examples/four_by_four/FourByFour.java b/src/classes/org/jdesktop/j3d/examples/four_by_four/FourByFour.java index c8c7f49..3f1a3e1 100644 --- a/src/classes/org/jdesktop/j3d/examples/four_by_four/FourByFour.java +++ b/src/classes/org/jdesktop/j3d/examples/four_by_four/FourByFour.java @@ -45,15 +45,48 @@ package org.jdesktop.j3d.examples.four_by_four; import java.applet.Applet; -import java.awt.*; -import java.awt.event.*; -import java.io.*; -import java.net.*; -import javax.media.j3d.*; -import javax.vecmath.*; -import com.sun.j3d.utils.universe.SimpleUniverse; -import com.sun.j3d.utils.applet.MainFrame; +import java.awt.Button; +import java.awt.Checkbox; +import java.awt.CheckboxGroup; +import java.awt.Color; +import java.awt.Image; +import java.awt.Label; +import java.awt.Panel; +import java.awt.TextArea; +import java.awt.TextField; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.io.Reader; +import java.io.StreamTokenizer; +import java.net.URL; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingLeaf; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.View; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3f; /** * Class FourByFour @@ -126,7 +159,7 @@ public class FourByFour extends Applet implements ActionListener { /** * Initialization */ - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); // Set the port number. port = 4111; @@ -852,7 +885,7 @@ public class FourByFour extends Applet implements ActionListener { /** * Main method, only used when running as an application. */ - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); FourByFour.appletFlag = false; new MainFrame(new FourByFour(), 730, 450); } diff --git a/src/classes/org/jdesktop/j3d/examples/four_by_four/PickDragBehavior.java b/src/classes/org/jdesktop/j3d/examples/four_by_four/PickDragBehavior.java index 0accb87..697e934 100644 --- a/src/classes/org/jdesktop/j3d/examples/four_by_four/PickDragBehavior.java +++ b/src/classes/org/jdesktop/j3d/examples/four_by_four/PickDragBehavior.java @@ -44,12 +44,28 @@ package org.jdesktop.j3d.examples.four_by_four; -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import javax.media.j3d.*; -import javax.vecmath.*; -import com.sun.j3d.utils.geometry.Sphere; +import java.awt.AWTEvent; +import java.awt.event.MouseEvent; +import java.util.Enumeration; + +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Behavior; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.CapabilityNotSetException; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.Node; +import org.jogamp.java3d.PickRay; +import org.jogamp.java3d.SceneGraphPath; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.WakeupCriterion; +import org.jogamp.java3d.WakeupOnAWTEvent; +import org.jogamp.java3d.WakeupOr; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; /** * Class: PickDragBehavior diff --git a/src/classes/org/jdesktop/j3d/examples/four_by_four/Poles.java b/src/classes/org/jdesktop/j3d/examples/four_by_four/Poles.java index e97dcb5..47ba07e 100644 --- a/src/classes/org/jdesktop/j3d/examples/four_by_four/Poles.java +++ b/src/classes/org/jdesktop/j3d/examples/four_by_four/Poles.java @@ -44,10 +44,8 @@ package org.jdesktop.j3d.examples.four_by_four; -import java.applet.Applet; -import java.awt.event.*; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Group; /** * Class: Poles diff --git a/src/classes/org/jdesktop/j3d/examples/four_by_four/Positions.java b/src/classes/org/jdesktop/j3d/examples/four_by_four/Positions.java index 30e9120..4f5d927 100644 --- a/src/classes/org/jdesktop/j3d/examples/four_by_four/Positions.java +++ b/src/classes/org/jdesktop/j3d/examples/four_by_four/Positions.java @@ -44,12 +44,18 @@ package org.jdesktop.j3d.examples.four_by_four; -import java.applet.Applet; -import java.awt.event.*; -import javax.media.j3d.*; -import javax.vecmath.*; import java.util.BitSet; -import com.sun.j3d.utils.geometry.Sphere; + +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Group; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Switch; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Vector3f; /** * Class: Positions diff --git a/src/classes/org/jdesktop/j3d/examples/fps_counter/FPSCounter.java b/src/classes/org/jdesktop/j3d/examples/fps_counter/FPSCounter.java index 5322fde..fa57927 100644 --- a/src/classes/org/jdesktop/j3d/examples/fps_counter/FPSCounter.java +++ b/src/classes/org/jdesktop/j3d/examples/fps_counter/FPSCounter.java @@ -44,9 +44,10 @@ package org.jdesktop.j3d.examples.fps_counter; -import javax.media.j3d.*; -import javax.vecmath.*; -import java.text.*; +import java.text.NumberFormat; + +import org.jogamp.java3d.Behavior; +import org.jogamp.java3d.WakeupOnElapsedFrames; /** This behavior calculates the frame rate and average frame rate of a * Java3D application. diff --git a/src/classes/org/jdesktop/j3d/examples/fps_counter/FPSCounterDemo.java b/src/classes/org/jdesktop/j3d/examples/fps_counter/FPSCounterDemo.java index 41c723b..d72aa9f 100644 --- a/src/classes/org/jdesktop/j3d/examples/fps_counter/FPSCounterDemo.java +++ b/src/classes/org/jdesktop/j3d/examples/fps_counter/FPSCounterDemo.java @@ -44,13 +44,21 @@ package org.jdesktop.j3d.examples.fps_counter; -import com.sun.j3d.utils.universe.*; -import com.sun.j3d.utils.geometry.ColorCube; -import javax.media.j3d.*; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; + import javax.swing.JOptionPane; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.geometry.ColorCube; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Point3d; + /** * This program demonstrates the use of the frames per second counter. * The program displays a rotating cube and sets up the FPSCounter to compute diff --git a/src/classes/org/jdesktop/j3d/examples/gears/Gear.java b/src/classes/org/jdesktop/j3d/examples/gears/Gear.java index 2bd6430..63ececf 100644 --- a/src/classes/org/jdesktop/j3d/examples/gears/Gear.java +++ b/src/classes/org/jdesktop/j3d/examples/gears/Gear.java @@ -44,11 +44,15 @@ package org.jdesktop.j3d.examples.gears; -import java.lang.Math.*; -import javax.media.j3d.*; -import javax.vecmath.*; - -public class Gear extends javax.media.j3d.TransformGroup { +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.TriangleStripArray; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; + +public class Gear extends TransformGroup { // Specifiers determining whether to generate outward facing normals or // inward facing normals. diff --git a/src/classes/org/jdesktop/j3d/examples/gears/GearBox.java b/src/classes/org/jdesktop/j3d/examples/gears/GearBox.java index 81bbb44..9f3bf6f 100644 --- a/src/classes/org/jdesktop/j3d/examples/gears/GearBox.java +++ b/src/classes/org/jdesktop/j3d/examples/gears/GearBox.java @@ -44,14 +44,28 @@ package org.jdesktop.j3d.examples.gears; -import com.sun.j3d.utils.behaviors.mouse.*; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; -import java.lang.Integer; -import com.sun.j3d.utils.behaviors.vp.*; import java.awt.GraphicsConfiguration; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.behaviors.vp.OrbitBehavior; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; + /** * Simple Java 3D example program to display a spinning cube. */ diff --git a/src/classes/org/jdesktop/j3d/examples/gears/GearTest.java b/src/classes/org/jdesktop/j3d/examples/gears/GearTest.java index d11980a..d50d7d3 100644 --- a/src/classes/org/jdesktop/j3d/examples/gears/GearTest.java +++ b/src/classes/org/jdesktop/j3d/examples/gears/GearTest.java @@ -44,12 +44,25 @@ package org.jdesktop.j3d.examples.gears; -import com.sun.j3d.utils.universe.*; -import com.sun.j3d.utils.geometry.ColorCube; -import javax.media.j3d.*; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3f; + /** * Simple Java 3D example program to display a spinning cube. */ diff --git a/src/classes/org/jdesktop/j3d/examples/gears/Shaft.java b/src/classes/org/jdesktop/j3d/examples/gears/Shaft.java index 580ea7e..18f1c1a 100644 --- a/src/classes/org/jdesktop/j3d/examples/gears/Shaft.java +++ b/src/classes/org/jdesktop/j3d/examples/gears/Shaft.java @@ -44,11 +44,16 @@ package org.jdesktop.j3d.examples.gears; -import java.lang.Math.*; -import javax.media.j3d.*; -import javax.vecmath.*; - -public class Shaft extends javax.media.j3d.TransformGroup { +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.TriangleFanArray; +import org.jogamp.java3d.TriangleStripArray; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; + +public class Shaft extends TransformGroup { /** * Construct a Shaft; diff --git a/src/classes/org/jdesktop/j3d/examples/gears/SpurGear.java b/src/classes/org/jdesktop/j3d/examples/gears/SpurGear.java index cca884b..0649e96 100644 --- a/src/classes/org/jdesktop/j3d/examples/gears/SpurGear.java +++ b/src/classes/org/jdesktop/j3d/examples/gears/SpurGear.java @@ -44,9 +44,14 @@ package org.jdesktop.j3d.examples.gears; -import java.lang.Math.*; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.QuadArray; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.TriangleStripArray; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; public class SpurGear extends Gear { diff --git a/src/classes/org/jdesktop/j3d/examples/gears/SpurGearThinBody.java b/src/classes/org/jdesktop/j3d/examples/gears/SpurGearThinBody.java index dd4c64f..39a7b20 100644 --- a/src/classes/org/jdesktop/j3d/examples/gears/SpurGearThinBody.java +++ b/src/classes/org/jdesktop/j3d/examples/gears/SpurGearThinBody.java @@ -44,9 +44,7 @@ package org.jdesktop.j3d.examples.gears; -import java.lang.Math.*; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.Appearance; public class SpurGearThinBody extends SpurGear { diff --git a/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/GeometryByReferenceNIOBuffer.java b/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/GeometryByReferenceNIOBuffer.java index 2f6c622..ec58e4c 100644 --- a/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/GeometryByReferenceNIOBuffer.java +++ b/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/GeometryByReferenceNIOBuffer.java @@ -44,19 +44,52 @@ package org.jdesktop.j3d.examples.geometry_by_ref; -import java.applet.Applet; -import java.awt.*; -import java.awt.event.*; -import com.sun.j3d.utils.applet.MainFrame; -import com.sun.j3d.utils.geometry.*; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.border.*; -import com.sun.j3d.utils.behaviors.vp.*; -import java.nio.*; +import java.awt.Container; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; + +import javax.swing.BoxLayout; +import javax.swing.JApplet; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.border.TitledBorder; + +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ColoringAttributes; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Geometry; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.GeometryUpdater; +import org.jogamp.java3d.IndexedGeometryArray; +import org.jogamp.java3d.IndexedTriangleArray; +import org.jogamp.java3d.IndexedTriangleStripArray; +import org.jogamp.java3d.J3DBuffer; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.RenderingAttributes; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.TransparencyAttributes; +import org.jogamp.java3d.TriangleArray; +import org.jogamp.java3d.TriangleStripArray; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.behaviors.vp.OrbitBehavior; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; public class GeometryByReferenceNIOBuffer extends JApplet implements ActionListener, GeometryUpdater { @@ -299,7 +332,7 @@ GeometryUpdater { public GeometryByReferenceNIOBuffer() { } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); Container contentPane = getContentPane(); Canvas3D c = new Canvas3D(SimpleUniverse.getPreferredConfiguration()); @@ -396,7 +429,7 @@ GeometryUpdater { - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); Frame frame = new MainFrame(new GeometryByReferenceNIOBuffer(), 800, 800); } diff --git a/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/GeometryByReferenceTest.java b/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/GeometryByReferenceTest.java index 7d27860..55be4a5 100644 --- a/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/GeometryByReferenceTest.java +++ b/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/GeometryByReferenceTest.java @@ -44,18 +44,48 @@ package org.jdesktop.j3d.examples.geometry_by_ref; -import java.applet.Applet; -import java.awt.*; -import java.awt.event.*; -import com.sun.j3d.utils.applet.MainFrame; -import com.sun.j3d.utils.geometry.*; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; -import javax.swing.*; -import javax.swing.event.*; -import javax.swing.border.*; -import com.sun.j3d.utils.behaviors.vp.*; +import java.awt.Container; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BoxLayout; +import javax.swing.JApplet; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.border.TitledBorder; + +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ColoringAttributes; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Geometry; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.GeometryUpdater; +import org.jogamp.java3d.IndexedGeometryArray; +import org.jogamp.java3d.IndexedTriangleArray; +import org.jogamp.java3d.IndexedTriangleStripArray; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.RenderingAttributes; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.TransparencyAttributes; +import org.jogamp.java3d.TriangleArray; +import org.jogamp.java3d.TriangleStripArray; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.behaviors.vp.OrbitBehavior; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; public class GeometryByReferenceTest extends JApplet implements ActionListener, GeometryUpdater { @@ -300,7 +330,7 @@ GeometryUpdater { public GeometryByReferenceTest() { } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); Container contentPane = getContentPane(); Canvas3D c = new Canvas3D(SimpleUniverse.getPreferredConfiguration()); @@ -439,7 +469,7 @@ GeometryUpdater { - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); Frame frame = new MainFrame(new GeometryByReferenceTest(), 800, 800); } diff --git a/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/ImageComponentByReferenceTest.java b/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/ImageComponentByReferenceTest.java index 59b5986..6829952 100644 --- a/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/ImageComponentByReferenceTest.java +++ b/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/ImageComponentByReferenceTest.java @@ -44,17 +44,39 @@ package org.jdesktop.j3d.examples.geometry_by_ref; -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 javax.swing.*; -import com.sun.j3d.utils.image.TextureLoader; -import com.sun.j3d.utils.geometry.Box; -import java.awt.image.*; +import java.awt.Container; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; +import java.awt.image.RenderedImage; + +import javax.swing.BoxLayout; +import javax.swing.JApplet; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.Group; +import org.jogamp.java3d.ImageComponent; +import org.jogamp.java3d.ImageComponent2D; +import org.jogamp.java3d.Raster; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Texture; +import org.jogamp.java3d.Texture2D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.geometry.Box; +import org.jogamp.java3d.utils.image.TextureLoader; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; public class ImageComponentByReferenceTest extends JApplet implements ActionListener { @@ -73,7 +95,7 @@ public class ImageComponentByReferenceTest extends JApplet implements ActionList ImageComponent2D[] image = new ImageComponent2D[8]; Appearance dummyApp = new Appearance(); Texture2D texOne, texCheckBoard; - javax.media.j3d.Raster raster; + Raster raster; Box textureCube; Shape3D boxShape; int w1 = 64, h1 = 32, checkw = 16 , checkh = 16; @@ -242,7 +264,7 @@ public class ImageComponentByReferenceTest extends JApplet implements ActionList texImage = url; } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); texImage = Resources.getResource("resources/images/one.jpg"); if (texImage == null) { @@ -271,7 +293,7 @@ public class ImageComponentByReferenceTest extends JApplet implements ActionList u.cleanup(); } - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); java.net.URL url = null; // the path to the image file for an application url = Resources.getResource("resources/images/one.jpg"); @@ -290,11 +312,11 @@ public class ImageComponentByReferenceTest extends JApplet implements ActionList TransformGroup tg; // Left - raster = new javax.media.j3d.Raster( ); - raster.setCapability(javax.media.j3d.Raster.ALLOW_IMAGE_WRITE); - raster.setCapability(javax.media.j3d.Raster.ALLOW_SIZE_WRITE); + raster = new Raster( ); + raster.setCapability(Raster.ALLOW_IMAGE_WRITE); + raster.setCapability(Raster.ALLOW_SIZE_WRITE); raster.setPosition( new Point3f( -0.9f, 0.75f, 0.0f ) ); - raster.setType( javax.media.j3d.Raster.RASTER_COLOR ); + raster.setType( Raster.RASTER_COLOR ); raster.setOffset( 0, 0 ); raster.setSize( image[2].getWidth(), image[2].getHeight() ); diff --git a/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/InterleavedNIOBuffer.java b/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/InterleavedNIOBuffer.java index 7440fa2..2d642f2 100644 --- a/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/InterleavedNIOBuffer.java +++ b/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/InterleavedNIOBuffer.java @@ -44,18 +44,55 @@ package org.jdesktop.j3d.examples.geometry_by_ref; -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 javax.media.j3d.*; -import javax.vecmath.*; -import javax.swing.*; -import javax.swing.border.*; -import com.sun.j3d.utils.behaviors.vp.*; -import java.nio.*; +import java.awt.Container; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; + +import javax.swing.BoxLayout; +import javax.swing.JApplet; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.border.TitledBorder; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ColoringAttributes; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.IndexedTriangleArray; +import org.jogamp.java3d.IndexedTriangleStripArray; +import org.jogamp.java3d.J3DBuffer; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.RenderingAttributes; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Texture; +import org.jogamp.java3d.TextureAttributes; +import org.jogamp.java3d.TextureUnitState; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.TransparencyAttributes; +import org.jogamp.java3d.TriangleArray; +import org.jogamp.java3d.TriangleStripArray; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.behaviors.vp.OrbitBehavior; +import org.jogamp.java3d.utils.image.TextureLoader; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point2f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; public class InterleavedNIOBuffer extends JApplet implements ActionListener { @@ -331,7 +368,7 @@ public class InterleavedNIOBuffer extends JApplet implements ActionListener { texImage2 = texURL2; } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); // create textures texImage1 = Resources.getResource("resources/images/bg.jpg"); @@ -412,7 +449,7 @@ public class InterleavedNIOBuffer extends JApplet implements ActionListener { - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); java.net.URL texURL1 = null; java.net.URL texURL2 = null; // the path to the image for an application diff --git a/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/InterleavedTest.java b/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/InterleavedTest.java index 95da98d..0fd0217 100644 --- a/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/InterleavedTest.java +++ b/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/InterleavedTest.java @@ -44,17 +44,51 @@ package org.jdesktop.j3d.examples.geometry_by_ref; -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 javax.media.j3d.*; -import javax.vecmath.*; -import javax.swing.*; -import javax.swing.border.*; -import com.sun.j3d.utils.behaviors.vp.*; +import java.awt.Container; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BoxLayout; +import javax.swing.JApplet; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.border.TitledBorder; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ColoringAttributes; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.IndexedTriangleArray; +import org.jogamp.java3d.IndexedTriangleStripArray; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.RenderingAttributes; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Texture; +import org.jogamp.java3d.TextureAttributes; +import org.jogamp.java3d.TextureUnitState; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.TransparencyAttributes; +import org.jogamp.java3d.TriangleArray; +import org.jogamp.java3d.TriangleStripArray; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.behaviors.vp.OrbitBehavior; +import org.jogamp.java3d.utils.image.TextureLoader; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point2f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; public class InterleavedTest extends JApplet implements ActionListener { @@ -310,7 +344,7 @@ public class InterleavedTest extends JApplet implements ActionListener { texImage2 = texURL2; } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); // create textures texImage1 = Resources.getResource("resources/images/bg.jpg"); @@ -391,7 +425,7 @@ public class InterleavedTest extends JApplet implements ActionListener { - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); java.net.URL texURL1 = null; java.net.URL texURL2 = null; // the path to the image for an application diff --git a/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/TiledImage.java b/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/TiledImage.java index 7b42709..0e06f0e 100644 --- a/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/TiledImage.java +++ b/src/classes/org/jdesktop/j3d/examples/geometry_by_ref/TiledImage.java @@ -44,10 +44,19 @@ package org.jdesktop.j3d.examples.geometry_by_ref; -import java.awt.*; -import java.awt.image.*; -import java.util.Vector; +import java.awt.Rectangle; +import java.awt.Transparency; import java.awt.color.ColorSpace; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.ComponentColorModel; +import java.awt.image.DataBuffer; +import java.awt.image.DataBufferByte; +import java.awt.image.Raster; +import java.awt.image.RenderedImage; +import java.awt.image.SampleModel; +import java.awt.image.WritableRaster; +import java.util.Vector; public class TiledImage extends Object implements RenderedImage { diff --git a/src/classes/org/jdesktop/j3d/examples/geometry_compression/ObjectFileCompressor.java b/src/classes/org/jdesktop/j3d/examples/geometry_compression/ObjectFileCompressor.java index bcc030a..15db111 100644 --- a/src/classes/org/jdesktop/j3d/examples/geometry_compression/ObjectFileCompressor.java +++ b/src/classes/org/jdesktop/j3d/examples/geometry_compression/ObjectFileCompressor.java @@ -44,17 +44,21 @@ package org.jdesktop.j3d.examples.geometry_compression; -import com.sun.j3d.loaders.IncorrectFormatException; -import com.sun.j3d.loaders.ParsingErrorException; -import com.sun.j3d.loaders.Scene; -import com.sun.j3d.loaders.objectfile.ObjectFile; -import com.sun.j3d.utils.geometry.compression.*; import java.io.FileNotFoundException; import java.io.IOException; import java.io.Reader; import java.net.URL; import java.util.Hashtable; -import javax.media.j3d.Shape3D; + +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.loaders.IncorrectFormatException; +import org.jogamp.java3d.loaders.ParsingErrorException; +import org.jogamp.java3d.loaders.Scene; +import org.jogamp.java3d.loaders.objectfile.ObjectFile; +import org.jogamp.java3d.utils.geometry.compression.CompressedGeometryData; +import org.jogamp.java3d.utils.geometry.compression.CompressedGeometryFile; +import org.jogamp.java3d.utils.geometry.compression.CompressionStream; +import org.jogamp.java3d.utils.geometry.compression.GeometryCompressor; /** * This extension of ObjectFile provides the methods setQuantization() and diff --git a/src/classes/org/jdesktop/j3d/examples/geometry_compression/cgview.java b/src/classes/org/jdesktop/j3d/examples/geometry_compression/cgview.java index 30d4f00..e3eae64 100644 --- a/src/classes/org/jdesktop/j3d/examples/geometry_compression/cgview.java +++ b/src/classes/org/jdesktop/j3d/examples/geometry_compression/cgview.java @@ -44,15 +44,28 @@ package org.jdesktop.j3d.examples.geometry_compression; -import com.sun.j3d.utils.applet.MainFrame; -import com.sun.j3d.utils.behaviors.vp.OrbitBehavior; -import com.sun.j3d.utils.geometry.compression.*; -import com.sun.j3d.utils.universe.*; import java.applet.Applet; import java.awt.BorderLayout; import java.io.IOException; -import javax.media.j3d.*; -import javax.vecmath.*; + +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.behaviors.vp.OrbitBehavior; +import org.jogamp.java3d.utils.geometry.compression.CompressedGeometryData; +import org.jogamp.java3d.utils.geometry.compression.CompressedGeometryFile; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3f; public class cgview extends Applet { @@ -195,7 +208,7 @@ public class cgview extends Applet { // The following allows cgview to be run as an application // as well as an applet. // - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); new MainFrame(new cgview(args), 700, 700) ; } } diff --git a/src/classes/org/jdesktop/j3d/examples/geometry_compression/obj2cg.java b/src/classes/org/jdesktop/j3d/examples/geometry_compression/obj2cg.java index c2cefcc..c0fea26 100644 --- a/src/classes/org/jdesktop/j3d/examples/geometry_compression/obj2cg.java +++ b/src/classes/org/jdesktop/j3d/examples/geometry_compression/obj2cg.java @@ -44,9 +44,10 @@ package org.jdesktop.j3d.examples.geometry_compression; -import com.sun.j3d.utils.geometry.compression.*; import java.io.IOException; +import org.jogamp.java3d.utils.geometry.compression.CompressedGeometryFile; + class obj2cg { public static void main(String args[]) throws IOException { diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/EnvironmentMappingGLSL.form b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/EnvironmentMappingGLSL.form new file mode 100644 index 0000000..b6a3e94 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/EnvironmentMappingGLSL.form @@ -0,0 +1,36 @@ +<?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="EnvironmentMappingGLSL"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[500, 500]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/EnvironmentMappingGLSL.java b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/EnvironmentMappingGLSL.java new file mode 100644 index 0000000..5eba8df --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/EnvironmentMappingGLSL.java @@ -0,0 +1,265 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2007 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.gl2es2pipeline; + +import java.awt.GraphicsConfiguration; +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; + +import javax.swing.JOptionPane; + +import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.GLSLShaderProgram; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.J3DBuffer; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Shader; +import org.jogamp.java3d.ShaderAppearance; +import org.jogamp.java3d.ShaderAttribute; +import org.jogamp.java3d.ShaderAttributeSet; +import org.jogamp.java3d.ShaderAttributeValue; +import org.jogamp.java3d.ShaderError; +import org.jogamp.java3d.ShaderErrorListener; +import org.jogamp.java3d.ShaderProgram; +import org.jogamp.java3d.SourceCodeShader; +import org.jogamp.java3d.Texture; +import org.jogamp.java3d.TextureUnitState; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.TriangleStripArray; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.image.TextureLoader; +import org.jogamp.java3d.utils.shader.StringIO; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; + +public class EnvironmentMappingGLSL extends javax.swing.JFrame +{ + + private URL textureURL = null; + private static final int NUM_TEX_UNITS = 1; + private static final int TEX_UNIT = 0; + + SimpleUniverse univ = null; + + public BranchGroup createSceneGraph() + { + // Create the root of the branch graph + BranchGroup objRoot = new BranchGroup(); + + // 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 texture object + textureURL = Resources.getResource("resources/images/duke-gears.jpg"); + Texture tex = new TextureLoader(textureURL, this).getTexture(); + // Create the shader program + String vertexProgram = null; + String fragmentProgram = null; + try + { + vertexProgram = StringIO.readFully( + new File(System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/envmap.vert")); + fragmentProgram = StringIO.readFully( + new File(System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/envmap.frag")); + } + catch (IOException e) + { + 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); + final String[] shaderAttrNames = { "LightPos", "BaseColor", "MixRatio", "EnvMap", }; + final Object[] shaderAttrValues = { new Point3f(1.0f, -1.0f, 2.0f), new Color3f(0.2f, 0.9f, 0.5f), new Float(0.4f), + new Integer(TEX_UNIT), }; + ShaderProgram shaderProgram = new GLSLShaderProgram(); + shaderProgram.setShaders(shaders); + shaderProgram.setShaderAttrNames(shaderAttrNames); + + // Create the shader attribute set + ShaderAttributeSet shaderAttributeSet = new ShaderAttributeSet(); + for (int i = 0; i < shaderAttrNames.length; i++) + { + ShaderAttribute shaderAttribute = new ShaderAttributeValue(shaderAttrNames[i], shaderAttrValues[i]); + shaderAttributeSet.put(shaderAttribute); + } + + // Create shader appearance to hold the shader program and + // shader attributes + ShaderAppearance app = new ShaderAppearance(); + app.setShaderProgram(shaderProgram); + app.setShaderAttributeSet(shaderAttributeSet); + + // Put the texture in specified texture unit + TextureUnitState[] tus = new TextureUnitState[NUM_TEX_UNITS]; + tus[TEX_UNIT] = new TextureUnitState(); + tus[TEX_UNIT].setTexture(tex); + app.setTextureUnitState(tus); + + // Create a Sphere object using the shader appearance, + // and add it into the scene graph. + Sphere sph = new Sphere(0.4f, Sphere.GENERATE_NORMALS, 20, app); + SphereGLSL.makeNIO(sph); + objTrans.addChild(sph); + + // 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); + + // Have Java 3D perform optimizations on this scene graph. + //objRoot.compile(); + + return objRoot; + } + + + + private Canvas3D initScene() + { + GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); + + Canvas3D c = new Canvas3D(config); + + BranchGroup scene = createSceneGraph(); + univ = new SimpleUniverse(c); + + // Add a ShaderErrorListener + univ.addShaderErrorListener(new ShaderErrorListener() { + public void errorOccurred(ShaderError error) + { + error.printVerbose(); + JOptionPane.showMessageDialog(EnvironmentMappingGLSL.this, error.toString(), "ShaderError", JOptionPane.ERROR_MESSAGE); + } + }); + + ViewingPlatform viewingPlatform = univ.getViewingPlatform(); + // This will move the ViewPlatform back a bit so the + // objects in the scene can be viewed. + viewingPlatform.setNominalViewingTransform(); + + univ.addBranchGraph(scene); + + return c; + } + + /** + * Creates new form EnvironmentMappingGLSL + */ + public EnvironmentMappingGLSL() + { + // Initialize the GUI components + initComponents(); + + // Create the scene and add the Canvas3D to the drawing panel + Canvas3D c = initScene(); + drawingPanel.add(c, java.awt.BorderLayout.CENTER); + } + + // ---------------------------------------------------------------- + + /** 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() + { + drawingPanel = new javax.swing.JPanel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("EnvironmentMappingGLSL"); + drawingPanel.setLayout(new java.awt.BorderLayout()); + + drawingPanel.setPreferredSize(new java.awt.Dimension(500, 500)); + getContentPane().add(drawingPanel, java.awt.BorderLayout.CENTER); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(String args[]) + { + System.setProperty("sun.awt.noerasebackground", "true"); + System.setProperty("j3d.rend", "jogl2es2"); + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() + { + new EnvironmentMappingGLSL().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel drawingPanel; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/classes/org/jdesktop/j3d/examples/cg_shader/ObjLoadCg.form b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/ObjLoadGLSL.form index 1483b2c..343b6d5 100644 --- a/src/classes/org/jdesktop/j3d/examples/cg_shader/ObjLoadCg.form +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/ObjLoadGLSL.form @@ -3,7 +3,7 @@ <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="ObjLoadCg"/> + <Property name="title" type="java.lang.String" value="ObjLoadGLSL"/> </Properties> <SyntheticProperties> <SyntheticProperty name="formSizePolicy" type="int" value="1"/> diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/ObjLoadGLSL.java b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/ObjLoadGLSL.java new file mode 100644 index 0000000..709ff47 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/ObjLoadGLSL.java @@ -0,0 +1,444 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2007 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.gl2es2pipeline; + +import java.awt.GraphicsConfiguration; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Enumeration; + +import javax.swing.JOptionPane; + +import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.GLSLShaderProgram; +import org.jogamp.java3d.Group; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.Node; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Shader; +import org.jogamp.java3d.ShaderAppearance; +import org.jogamp.java3d.ShaderError; +import org.jogamp.java3d.ShaderErrorListener; +import org.jogamp.java3d.ShaderProgram; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.SourceCodeShader; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.loaders.IncorrectFormatException; +import org.jogamp.java3d.loaders.ParsingErrorException; +import org.jogamp.java3d.loaders.Scene; +import org.jogamp.java3d.loaders.objectfile.ObjectFile; +import org.jogamp.java3d.utils.behaviors.vp.OrbitBehavior; +import org.jogamp.java3d.utils.shader.StringIO; +import org.jogamp.java3d.utils.universe.PlatformGeometry; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3f; + +/** + * Simple Java 3D example program to display an .obj object with shader programs. + */ +public class ObjLoadGLSL extends javax.swing.JFrame +{ + + private String shaderName = "polkadot3d"; + private boolean spin = false; + private boolean noTriangulate = false; + private boolean noStripify = false; + private double creaseAngle = 60.0; + private URL filename = null; + + private SimpleUniverse univ = null; + private BranchGroup scene = null; + + 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) + { + System.err.println(e); + System.exit(1); + } + catch (ParsingErrorException e) + { + System.err.println(e); + System.exit(1); + } + catch (IncorrectFormatException e) + { + System.err.println(e); + 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(new File( + System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/" + shaderName + ".vert")); + fragmentProgram = StringIO.readFully(new File( + System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/" + shaderName + ".frag")); + } + catch (IOException e) + { + throw new RuntimeException(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); + setShaderProgram(s.getSceneGroup(), shaderProgram); + + objTrans.addChild(s.getSceneGroup()); + + BoundingSphere 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 Canvas3D createUniverse() + { + // Get the preferred graphics configuration for the default screen + GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); + + // Create a Canvas3D using the preferred configuration + Canvas3D canvas3d = new Canvas3D(config); + + // Create simple universe with view branch + univ = new SimpleUniverse(canvas3d); + BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); + + // Add a ShaderErrorListener + univ.addShaderErrorListener(new ShaderErrorListener() { + public void errorOccurred(ShaderError error) + { + error.printVerbose(); + JOptionPane.showMessageDialog(ObjLoadGLSL.this, error.toString(), "ShaderError", JOptionPane.ERROR_MESSAGE); + } + }); + + // add mouse behaviors to the ViewingPlatform + ViewingPlatform viewingPlatform = univ.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, 1.0f, 0.9f); + Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f); + Color3f light2Color = new Color3f(1.0f, 1.0f, 1.0f); + 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(canvas3d, OrbitBehavior.REVERSE_ALL); + orbit.setSchedulingBounds(bounds); + viewingPlatform.setViewPlatformBehavior(orbit); + } + + // Ensure at least 5 msec per frame (i.e., < 200Hz) + univ.getViewer().getView().setMinimumFrameCycleTime(5); + + return canvas3d; + } + + private void usage() + { + System.out.println("Usage: java ObjLoadGLSL [-s] [-S shaderName] [-n] [-t] [-c degrees] <.obj file>"); + System.out.println(" -s Spin (no user interaction)"); + System.out.println(" -S Set shader name (default is 'simple')"); + System.out.println(" -n No triangulation"); + System.out.println(" -t No stripification"); + System.out.println(" -c Set crease angle for normal generation (default is 60 without"); + System.out.println(" smoothing group info, otherwise 180 within smoothing groups)"); + System.exit(0); + } // End of usage + + // Set shader program for all nodes in specified branch graph + private void setShaderProgram(BranchGroup g, ShaderProgram shaderProgram) + { + ShaderAppearance myApp = new ShaderAppearance(); + Material mat = new Material(); + myApp.setShaderProgram(shaderProgram); + myApp.setMaterial(mat); + setShaderProgram(g, myApp); + } + + // Recursively set shader program for all children of specified group + private void setShaderProgram(Group g, ShaderAppearance myApp) + { + + Enumeration e = g.getAllChildren(); + while (e.hasMoreElements()) + { + Node n = (Node) (e.nextElement()); + if (n instanceof Group) + { + setShaderProgram((Group) n, myApp); + } + else if (n instanceof Shape3D) + { + Shape3D s = (Shape3D) n; + s.setAppearance(myApp); + } + } + } + + /** + * Creates new form ObjLoadGLSL + */ + public ObjLoadGLSL(String args[]) + { + if (args.length != 0) + { + for (int i = 0; i < args.length; i++) + { + if (args[i].startsWith("-")) + { + if (args[i].equals("-s")) + { + spin = true; + } + else if (args[i].equals("-n")) + { + noTriangulate = true; + } + else if (args[i].equals("-t")) + { + noStripify = true; + } + else if (args[i].equals("-c")) + { + if (i < args.length - 1) + { + creaseAngle = (new Double(args[++i])).doubleValue(); + } + else + usage(); + } + else if (args[i].equals("-S")) + { + if (i < args.length - 1) + { + shaderName = args[++i]; + } + else + usage(); + } + else + { + usage(); + } + } + else + { + try + { + if ((args[i].indexOf("file:") == 0) || (args[i].indexOf("http") == 0)) + { + filename = new URL(args[i]); + } + else if (args[i].charAt(0) != '/') + { + filename = new URL("file:./" + args[i]); + } + else + { + filename = new URL("file:" + args[i]); + } + } + catch (MalformedURLException e) + { + System.err.println(e); + System.exit(1); + } + } + } + } + + if (filename == null) + { + filename = Resources.getResource("resources/geometry/galleon.obj"); + if (filename == null) + { + System.err.println("resources/geometry/galleon.obj not found"); + System.exit(1); + } + } + + // Initialize the GUI components + initComponents(); + + // Create Canvas3D and SimpleUniverse; add canvas to drawing panel + Canvas3D c = createUniverse(); + drawingPanel.add(c, java.awt.BorderLayout.CENTER); + + // Create the content branch and add it to the universe + scene = createSceneGraph(); + univ.addBranchGraph(scene); + } + + // ---------------------------------------------------------------- + + /** 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() + { + drawingPanel = new javax.swing.JPanel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("ObjLoadGLSL"); + drawingPanel.setLayout(new java.awt.BorderLayout()); + + drawingPanel.setPreferredSize(new java.awt.Dimension(700, 700)); + getContentPane().add(drawingPanel, java.awt.BorderLayout.CENTER); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(final String args[]) + { + System.setProperty("sun.awt.noerasebackground", "true"); + System.setProperty("j3d.rend","jogl2es2"); + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() + { + ObjLoadGLSL objLoadGLSL = new ObjLoadGLSL(args); + objLoadGLSL.setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel drawingPanel; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/PhongShadingGLSL.form b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/PhongShadingGLSL.form new file mode 100644 index 0000000..dcccf73 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/PhongShadingGLSL.form @@ -0,0 +1,138 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.0" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <NonVisualComponents> + <Component class="javax.swing.ButtonGroup" name="shaderButtonGroup"> + </Component> + <Menu class="javax.swing.JMenuBar" name="jMenuBar1"> + <SubComponents> + <Menu class="javax.swing.JMenu" name="fileMenu"> + <Properties> + <Property name="text" type="java.lang.String" value="File"/> + </Properties> + <SubComponents> + <MenuItem class="javax.swing.JMenuItem" name="exitMenuItem"> + <Properties> + <Property name="text" type="java.lang.String" value="Exit"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exitMenuItemActionPerformed"/> + </Events> + </MenuItem> + </SubComponents> + </Menu> + </SubComponents> + </Menu> + </NonVisualComponents> + <Properties> + <Property name="defaultCloseOperation" type="int" value="3"/> + <Property name="title" type="java.lang.String" value="Phong Shading Test"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="guiPanel"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <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="Shader"/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="4" insetsLeft="4" insetsBottom="4" insetsRight="4" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Component class="javax.swing.JRadioButton" name="gouraudButton"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="shaderButtonGroup"/> + </Property> + <Property name="selected" type="boolean" value="true"/> + <Property name="text" type="java.lang.String" value="Per-Vertex Lighting (Gouraud)"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="0" left="0" right="0" top="0"/> + </Border> + </Property> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 0, 0, 0]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="gouraudButtonActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="2" insetsBottom="2" insetsRight="2" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JRadioButton" name="phongButton"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="shaderButtonGroup"/> + </Property> + <Property name="text" type="java.lang.String" value="Per-Pixel Lighting (Phong)"/> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> + <EmptyBorder bottom="0" left="0" right="0" top="0"/> + </Border> + </Property> + <Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor"> + <Insets value="[0, 0, 0, 0]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="phongButtonActionPerformed"/> + </Events> + <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="2" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="2" insetsBottom="2" insetsRight="2" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[500, 500]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/PhongShadingGLSL.java b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/PhongShadingGLSL.java new file mode 100644 index 0000000..03fbd3d --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/PhongShadingGLSL.java @@ -0,0 +1,501 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2007 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.gl2es2pipeline; + +import java.awt.GraphicsConfiguration; +import java.io.File; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; + +import javax.swing.JOptionPane; + +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ColoringAttributes; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.GLSLShaderProgram; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.J3DBuffer; +import org.jogamp.java3d.Light; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.PointLight; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Shader; +import org.jogamp.java3d.ShaderAppearance; +import org.jogamp.java3d.ShaderError; +import org.jogamp.java3d.ShaderErrorListener; +import org.jogamp.java3d.ShaderProgram; +import org.jogamp.java3d.SourceCodeShader; +import org.jogamp.java3d.SpotLight; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.TriangleStripArray; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.shader.StringIO; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; + +/** + * + * @author kcr + */ +public class PhongShadingGLSL extends javax.swing.JFrame +{ + + // 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. + private static int lightType = DIRECTIONAL_LIGHT; + + private SimpleUniverse univ = null; + + private ShaderAppearance sApp = null; + private ShaderProgram gouraudSP = null; + private ShaderProgram phongSP = null; + + public BranchGroup createSceneGraph() + { + 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 lColor1 = new Color3f(1.0f, 1.0f, 0.5f); + 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.5); + 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); + objRoot.addChild(bg); + + // 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); + objScale.addChild(objTrans); + + // Create a Sphere object, generate one copy of the sphere, + // and add it into the scene graph. + sApp = new ShaderAppearance(); + sApp.setCapability(ShaderAppearance.ALLOW_SHADER_PROGRAM_WRITE); + Material m = new Material(objColor, eColor, objColor, sColor, 100.0f); + sApp.setMaterial(m); + + // Create Gouraud and Phong shader programs + String vertexProgram = null; + String fragmentProgram = null; + Shader[] shaders = new Shader[2]; + String[] attrNames = { "numLights" }; + + try + { + vertexProgram = StringIO.readFully( + new File(System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/gouraud.vert")); + fragmentProgram = StringIO.readFully( + new File(System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/gouraud.frag")); + } + catch (IOException e) + { + throw new RuntimeException(e); + } + 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); + gouraudSP = new GLSLShaderProgram(); + gouraudSP.setShaders(shaders); + + try + { + vertexProgram = StringIO.readFully( + new File(System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/phong.vert")); + fragmentProgram = StringIO.readFully( + new File(System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/phong.frag")); + } + catch (IOException e) + { + throw new RuntimeException(e); + } + 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); + phongSP = new GLSLShaderProgram(); + phongSP.setShaders(shaders); + + if (gouraudButton.isSelected()) + { + sApp.setShaderProgram(gouraudSP); + } + else if (phongButton.isSelected()) + { + sApp.setShaderProgram(phongSP); + } + Sphere sph = new Sphere(1.0f, Sphere.GENERATE_NORMALS, 30, sApp); + SphereGLSL.makeNIO(sph); + objTrans.addChild(sph); + + // 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(); + yAxis.rotZ(Math.PI); + Alpha rotationAlpha = new Alpha(-1, 10000); + + RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, 0.0f, (float) Math.PI * 2.0f); + rotator.setSchedulingBounds(bounds); + objRoot.addChild(rotator); + + // 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); + + Sphere sph2 = new Sphere(0.05f, appL1); + SphereGLSL.makeNIO(sph2); + l1Trans.addChild(sph2); + // 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: + assert false : "can't get here"; + lgt1 = new PointLight(lColor1, lPoint, atten); + // lgt2 = new PointLight(lColor2, lPoint, atten); + break; + case SPOT_LIGHT: + assert false : "can't get here"; + 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. + 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); + + return objRoot; + } + + + + private Canvas3D initScene() + { + GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); + + Canvas3D c = new Canvas3D(config); + + univ = new SimpleUniverse(c); + + // Add a ShaderErrorListener + univ.addShaderErrorListener(new ShaderErrorListener() { + public void errorOccurred(ShaderError error) + { + error.printVerbose(); + JOptionPane.showMessageDialog(PhongShadingGLSL.this, error.toString(), "ShaderError", JOptionPane.ERROR_MESSAGE); + } + }); + + // This will move the ViewPlatform back a bit so the + // objects in the scene can be viewed. + univ.getViewingPlatform().setNominalViewingTransform(); + + BranchGroup scene = createSceneGraph(); + univ.addBranchGraph(scene); + + return c; + } + + /** + * Creates new form PhongShadingGLSL + */ + public PhongShadingGLSL() + { + // Initialize the GUI components + initComponents(); + + // Create the scene and add the Canvas3D to the drawing panel + Canvas3D c = initScene(); + drawingPanel.add(c, java.awt.BorderLayout.CENTER); + } + + // ---------------------------------------------------------------- + + /** 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; + + shaderButtonGroup = new javax.swing.ButtonGroup(); + guiPanel = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + gouraudButton = new javax.swing.JRadioButton(); + phongButton = new javax.swing.JRadioButton(); + drawingPanel = new javax.swing.JPanel(); + jMenuBar1 = new javax.swing.JMenuBar(); + fileMenu = new javax.swing.JMenu(); + exitMenuItem = new javax.swing.JMenuItem(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("Phong Shading Test"); + guiPanel.setLayout(new java.awt.GridBagLayout()); + + jPanel1.setLayout(new java.awt.GridBagLayout()); + + jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Shader")); + shaderButtonGroup.add(gouraudButton); + gouraudButton.setSelected(true); + gouraudButton.setText("Per-Vertex Lighting (Gouraud)"); + gouraudButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); + gouraudButton.setMargin(new java.awt.Insets(0, 0, 0, 0)); + gouraudButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + gouraudButtonActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); + jPanel1.add(gouraudButton, gridBagConstraints); + + shaderButtonGroup.add(phongButton); + phongButton.setText("Per-Pixel Lighting (Phong)"); + phongButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); + phongButton.setMargin(new java.awt.Insets(0, 0, 0, 0)); + phongButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + phongButtonActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); + jPanel1.add(phongButton, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); + guiPanel.add(jPanel1, gridBagConstraints); + + getContentPane().add(guiPanel, java.awt.BorderLayout.NORTH); + + drawingPanel.setLayout(new java.awt.BorderLayout()); + + drawingPanel.setPreferredSize(new java.awt.Dimension(500, 500)); + getContentPane().add(drawingPanel, java.awt.BorderLayout.CENTER); + + fileMenu.setText("File"); + exitMenuItem.setText("Exit"); + exitMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + exitMenuItemActionPerformed(evt); + } + }); + + fileMenu.add(exitMenuItem); + + jMenuBar1.add(fileMenu); + + setJMenuBar(jMenuBar1); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void phongButtonActionPerformed(java.awt.event.ActionEvent evt) + {//GEN-FIRST:event_phongButtonActionPerformed + sApp.setShaderProgram(phongSP); + }//GEN-LAST:event_phongButtonActionPerformed + + private void gouraudButtonActionPerformed(java.awt.event.ActionEvent evt) + {//GEN-FIRST:event_gouraudButtonActionPerformed + sApp.setShaderProgram(gouraudSP); + }//GEN-LAST:event_gouraudButtonActionPerformed + + private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) + {//GEN-FIRST:event_exitMenuItemActionPerformed + System.exit(0); + }//GEN-LAST:event_exitMenuItemActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) + { + System.setProperty("sun.awt.noerasebackground", "true"); + System.setProperty("j3d.rend", "jogl2es2"); + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() + { + new PhongShadingGLSL().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel drawingPanel; + private javax.swing.JMenuItem exitMenuItem; + private javax.swing.JMenu fileMenu; + private javax.swing.JRadioButton gouraudButton; + private javax.swing.JPanel guiPanel; + private javax.swing.JMenuBar jMenuBar1; + private javax.swing.JPanel jPanel1; + private javax.swing.JRadioButton phongButton; + private javax.swing.ButtonGroup shaderButtonGroup; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/classes/org/jdesktop/j3d/examples/cg_shader/SamplerTestCg.form b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/SamplerTestGLSL.form index 2be0fec..6a1a031 100644 --- a/src/classes/org/jdesktop/j3d/examples/cg_shader/SamplerTestCg.form +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/SamplerTestGLSL.form @@ -3,7 +3,7 @@ <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="SamplerTestCg"/> + <Property name="title" type="java.lang.String" value="SamplerTestGLSL"/> </Properties> <SyntheticProperties> <SyntheticProperty name="formSizePolicy" type="int" value="1"/> diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/SamplerTestGLSL.java b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/SamplerTestGLSL.java new file mode 100644 index 0000000..c641095 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/SamplerTestGLSL.java @@ -0,0 +1,289 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2007 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.gl2es2pipeline; + +import java.awt.GraphicsConfiguration; +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; + +import javax.swing.JOptionPane; + +import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.GLSLShaderProgram; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.J3DBuffer; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Shader; +import org.jogamp.java3d.ShaderAppearance; +import org.jogamp.java3d.ShaderAttribute; +import org.jogamp.java3d.ShaderAttributeSet; +import org.jogamp.java3d.ShaderAttributeValue; +import org.jogamp.java3d.ShaderError; +import org.jogamp.java3d.ShaderErrorListener; +import org.jogamp.java3d.ShaderProgram; +import org.jogamp.java3d.SourceCodeShader; +import org.jogamp.java3d.TexCoordGeneration; +import org.jogamp.java3d.Texture; +import org.jogamp.java3d.TextureUnitState; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.TriangleStripArray; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.image.TextureLoader; +import org.jogamp.java3d.utils.shader.StringIO; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector4f; + +public class SamplerTestGLSL extends javax.swing.JFrame +{ + + private static String cloudTexName = "resources/images/bg.jpg"; + private static String earthTexName = "resources/images/earth.jpg"; + + private URL cloudURL = null; + private URL earthURL = null; + private static final int CLOUD = 0; + private static final int EARTH = 1; + + SimpleUniverse univ = null; + + public BranchGroup createSceneGraph() + { + // Create the root of the branch graph + BranchGroup objRoot = new BranchGroup(); + + // 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 texture objects + cloudURL = Resources.getResource(cloudTexName); + Texture cloudTex = new TextureLoader(cloudURL, this).getTexture(); + earthURL = Resources.getResource(earthTexName); + Texture earthTex = new TextureLoader(earthURL, this).getTexture(); + + // Create the shader program + String vertexProgram = null; + String fragmentProgram = null; + try + { + vertexProgram = StringIO.readFully( + new File(System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/multitex.vert")); + fragmentProgram = StringIO.readFully( + new File(System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/multitex.frag")); + } + catch (IOException e) + { + 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); + final String[] shaderAttrNames = { "cloudFactor", "cloudTex", "earthTex", }; + final Object[] shaderAttrValues = { new Float(0.6f), new Integer(0), new Integer(1), }; + ShaderProgram shaderProgram = new GLSLShaderProgram(); + shaderProgram.setShaders(shaders); + shaderProgram.setShaderAttrNames(shaderAttrNames); + + // Create the shader attribute set + ShaderAttributeSet shaderAttributeSet = new ShaderAttributeSet(); + for (int i = 0; i < shaderAttrNames.length; i++) + { + ShaderAttribute shaderAttribute = new ShaderAttributeValue(shaderAttrNames[i], shaderAttrValues[i]); + shaderAttributeSet.put(shaderAttribute); + } + + // Create shader appearance to hold the shader program and + // shader attributes + ShaderAppearance app = new ShaderAppearance(); + app.setShaderProgram(shaderProgram); + app.setShaderAttributeSet(shaderAttributeSet); + + // GL2ES2: Tex coord gen done in shader now + //Vector4f plane0S = new Vector4f(3.0f, 1.5f, 0.3f, 0.0f); + //Vector4f plane0T = new Vector4f(1.0f, 2.5f, 0.24f, 0.0f); + //TexCoordGeneration tcg0 = new TexCoordGeneration(TexCoordGeneration.OBJECT_LINEAR, TexCoordGeneration.TEXTURE_COORDINATE_2, plane0S, + // plane0T); + //TexCoordGeneration tcg1 = new TexCoordGeneration(TexCoordGeneration.SPHERE_MAP, TexCoordGeneration.TEXTURE_COORDINATE_2); + + // Put the textures in unit 0,1 + TextureUnitState[] tus = new TextureUnitState[2]; + tus[CLOUD] = new TextureUnitState(); + tus[CLOUD].setTexture(cloudTex); + + // GL2ES2: Tex coord gen done in shader now + //tus[CLOUD].setTexCoordGeneration(tcg0); + + tus[EARTH] = new TextureUnitState(); + tus[EARTH].setTexture(earthTex); + + // GL2ES2: Tex coord gen done in shader now + //tus[EARTH].setTexCoordGeneration(tcg1); + + app.setTextureUnitState(tus); + + // Create a Sphere object using the shader appearance, + // and add it into the scene graph. + Sphere sph = new Sphere(0.4f, Sphere.GENERATE_NORMALS, 30, app); + + SphereGLSL.makeNIO(sph); + objTrans.addChild(sph); + + + // 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); + + // Have Java 3D perform optimizations on this scene graph. + //objRoot.compile(); + + return objRoot; + } + + + private Canvas3D initScene() + { + GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); + + Canvas3D c = new Canvas3D(config); + + BranchGroup scene = createSceneGraph(); + univ = new SimpleUniverse(c); + + // Add a ShaderErrorListener + univ.addShaderErrorListener(new ShaderErrorListener() { + public void errorOccurred(ShaderError error) + { + error.printVerbose(); + JOptionPane.showMessageDialog(SamplerTestGLSL.this, error.toString(), "ShaderError", JOptionPane.ERROR_MESSAGE); + } + }); + + ViewingPlatform viewingPlatform = univ.getViewingPlatform(); + // This will move the ViewPlatform back a bit so the + // objects in the scene can be viewed. + viewingPlatform.setNominalViewingTransform(); + + univ.addBranchGraph(scene); + + return c; + } + + /** + * Creates new form SamplerTestGLSL + */ + public SamplerTestGLSL() + { + // Initialize the GUI components + initComponents(); + + // Create the scene and add the Canvas3D to the drawing panel + Canvas3D c = initScene(); + drawingPanel.add(c, java.awt.BorderLayout.CENTER); + } + + // ---------------------------------------------------------------- + + /** 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() + { + drawingPanel = new javax.swing.JPanel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("SamplerTestGLSL"); + drawingPanel.setLayout(new java.awt.BorderLayout()); + + drawingPanel.setPreferredSize(new java.awt.Dimension(500, 500)); + getContentPane().add(drawingPanel, java.awt.BorderLayout.CENTER); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(String args[]) + { + System.setProperty("sun.awt.noerasebackground", "true"); + System.setProperty("j3d.rend","jogl2es2"); + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() + { + new SamplerTestGLSL().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel drawingPanel; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/ShaderTestGLSL.form b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/ShaderTestGLSL.form new file mode 100644 index 0000000..714273d --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/ShaderTestGLSL.form @@ -0,0 +1,266 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <NonVisualComponents> + <Component class="javax.swing.ButtonGroup" name="densityButtonGroup"> + </Component> + <Component class="javax.swing.ButtonGroup" name="colorButtonGroup"> + </Component> + <Component class="javax.swing.ButtonGroup" name="sceneGraphButtonGroup"> + </Component> + <Menu class="javax.swing.JMenuBar" name="jMenuBar1"> + <SubComponents> + <Menu class="javax.swing.JMenu" name="fileMenu"> + <Properties> + <Property name="text" type="java.lang.String" value="File"/> + </Properties> + <SubComponents> + <MenuItem class="javax.swing.JMenuItem" name="exitMenuItem"> + <Properties> + <Property name="text" type="java.lang.String" value="Exit"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exitMenuItemActionPerformed"/> + </Events> + </MenuItem> + </SubComponents> + </Menu> + </SubComponents> + </Menu> + </NonVisualComponents> + <Properties> + <Property name="title" type="java.lang.String" value="Window Title"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </SyntheticProperties> + <Events> + <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="exitForm"/> + </Events> + <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,-85,0,0,2,0"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="mainPanel"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="guiPanel"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="densityPanel"> + <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="Density"/> + </Border> + </Property> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleName" type="java.lang.String" value="ShaderAttributeValue 
"/> + </AccessibilityProperties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Component class="javax.swing.JRadioButton" name="zeroButton"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="densityButtonGroup"/> + </Property> + <Property name="text" type="java.lang.String" value="Zero"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="zeroButtonActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JRadioButton" name="halfButton"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="densityButtonGroup"/> + </Property> + <Property name="text" type="java.lang.String" value="Half"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="halfButtonActionPerformed"/> + </Events> + <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="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JRadioButton" name="fullButton"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="densityButtonGroup"/> + </Property> + <Property name="selected" type="boolean" value="true"/> + <Property name="text" type="java.lang.String" value="Full"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="fullButtonActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="colorPanel"> + <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="Color"/> + </Border> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Component class="javax.swing.JRadioButton" name="goldButton"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="colorButtonGroup"/> + </Property> + <Property name="selected" type="boolean" value="true"/> + <Property name="text" type="java.lang.String" value="Gold"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="goldButtonActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JRadioButton" name="silverButton"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="colorButtonGroup"/> + </Property> + <Property name="text" type="java.lang.String" value="Silver"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="silverButtonActionPerformed"/> + </Events> + <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="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="sceneGraphPanel"> + <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="Scene Graph"/> + </Border> + </Property> + </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Component class="javax.swing.JToggleButton" name="DetachButton"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="sceneGraphButtonGroup"/> + </Property> + <Property name="selected" type="boolean" value="true"/> + <Property name="text" type="java.lang.String" value="Detach"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="DetachButtonActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JToggleButton" name="AttachButton"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="sceneGraphButtonGroup"/> + </Property> + <Property name="text" type="java.lang.String" value="Create"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="AttachButtonActionPerformed"/> + </Events> + <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="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="replaceSPButton"> + <Properties> + <Property name="text" type="java.lang.String" value="Replace Shader"/> + <Property name="enabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="replaceSPButtonActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[500, 500]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/ShaderTestGLSL.java b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/ShaderTestGLSL.java new file mode 100644 index 0000000..65f40bb --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/ShaderTestGLSL.java @@ -0,0 +1,745 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2007 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.gl2es2pipeline; + +import java.awt.GraphicsConfiguration; +import java.io.File; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; + +import javax.swing.JOptionPane; + +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.GLSLShaderProgram; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.J3DBuffer; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.PositionInterpolator; +import org.jogamp.java3d.Shader; +import org.jogamp.java3d.ShaderAppearance; +import org.jogamp.java3d.ShaderAttributeObject; +import org.jogamp.java3d.ShaderAttributeSet; +import org.jogamp.java3d.ShaderAttributeValue; +import org.jogamp.java3d.ShaderError; +import org.jogamp.java3d.ShaderErrorListener; +import org.jogamp.java3d.ShaderProgram; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.SourceCodeShader; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.TriangleStripArray; +import org.jogamp.java3d.View; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.shader.StringIO; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; + +public class ShaderTestGLSL extends javax.swing.JFrame +{ + + static final int GOLD = 1; + static final int SILVER = 2; + + static final int DIMPLE_SHADER = 1; + static final int BRICK_SHADER = 2; + static final int WOOD_SHADER = 3; + static final int POLKADOT3D_SHADER = 4; + + static final String[] shaderAttrNames1 = { "Density", "Size", "LightPosition", "Color" }; + + static final String[] shaderAttrNames2 = { "BrickColor", "LightPosition" }; + + private SimpleUniverse univ = null; + private View view; + private BranchGroup transpObj; + private BranchGroup scene = null; + private int shaderSelected = DIMPLE_SHADER; + private float density = 16.0f; + private int color = GOLD; + + private Color3f eColor = new Color3f(0.2f, 0.2f, 0.2f); + private Color3f sColor = new Color3f(0.8f, 0.8f, 0.8f); + private Color3f objColor = new Color3f(0.6f, 0.6f, 0.6f); + private Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f); + private Color3f gold = new Color3f(0.7f, 0.6f, 0.18f); + private Color3f silver = new Color3f(0.75f, 0.75f, 0.75f); + + // Handlers for doing update + private ShaderAppearance sApp1 = null; + private ShaderAppearance sApp2 = null; + private ShaderAppearance sApp3 = null; + private ShaderAppearance sApp4 = null; + private ShaderProgram sp1 = null; + private ShaderProgram sp2 = null; + private ShaderProgram sp3 = null; + private ShaderProgram sp4 = null; + private ShaderAttributeSet sas1 = null; + private ShaderAttributeSet sas2 = null; + private ShaderAttributeObject sao1 = null; + private ShaderAttributeObject sao2 = null; + private Sphere sphere = null; + private Shape3D s3d = null; + + private Material createMaterial() + { + Material m; + m = new Material(objColor, eColor, objColor, sColor, 100.0f); + m.setLightingEnable(true); + return m; + } + + private ShaderProgram createGLSLShaderProgram(int index) + { + String vertexProgram = null; + String fragmentProgram = null; + + try + { + switch (index) + { + case DIMPLE_SHADER: + vertexProgram = StringIO.readFully( + new File(System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/dimple.vert")); + fragmentProgram = StringIO.readFully( + new File(System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/dimple.frag")); + break; + case BRICK_SHADER: + vertexProgram = StringIO.readFully( + new File(System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/aabrick.vert")); + fragmentProgram = StringIO.readFully( + new File(System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/aabrick.frag")); + break; + case WOOD_SHADER: + vertexProgram = StringIO.readFully( + new File(System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/wood.vert")); + fragmentProgram = StringIO.readFully( + new File(System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/wood.frag")); + break; + case POLKADOT3D_SHADER: + vertexProgram = StringIO.readFully( + new File(System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/polkadot3d.vert")); + fragmentProgram = StringIO.readFully( + new File(System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/polkadot3d.frag")); + break; + default: + } + } + catch (IOException e) + { + throw new RuntimeException(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); + return shaderProgram; + } + + private ShaderAttributeSet createShaderAttributeSet(int index) + { + ShaderAttributeSet shaderAttributeSet = new ShaderAttributeSet(); + ShaderAttributeObject shaderAttribute = null; + + switch (index) + { + case DIMPLE_SHADER: + // "Density", "Size", "Scale", "Color", "LightPosition" + shaderAttribute = new ShaderAttributeValue("Size", new Float(0.25)); + shaderAttributeSet.put(shaderAttribute); + shaderAttribute = new ShaderAttributeValue("LightPosition", new Point3f(0.0f, 0.0f, 0.5f)); + shaderAttributeSet.put(shaderAttribute); + + sao1 = new ShaderAttributeValue("Density", new Float(density)); + sao1.setCapability(ShaderAttributeObject.ALLOW_VALUE_READ); + sao1.setCapability(ShaderAttributeObject.ALLOW_VALUE_WRITE); + shaderAttributeSet.put(sao1); + + if (color == GOLD) + { + sao2 = new ShaderAttributeValue("Color", gold); + } + else if (color == SILVER) + { + sao2 = new ShaderAttributeValue("Color", silver); + } + sao2.setCapability(ShaderAttributeObject.ALLOW_VALUE_READ); + sao2.setCapability(ShaderAttributeObject.ALLOW_VALUE_WRITE); + shaderAttributeSet.put(sao2); + break; + + case BRICK_SHADER: + // "BrickColor", "LightPosition" + shaderAttribute = new ShaderAttributeValue("BrickColor", new Color3f(1.0f, 0.3f, 0.2f)); + shaderAttributeSet.put(shaderAttribute); + shaderAttribute = new ShaderAttributeValue("LightPosition", new Point3f(0.0f, 0.0f, 0.5f)); + shaderAttributeSet.put(shaderAttribute); + break; + default: + assert false; + } + return shaderAttributeSet; + } + + private ShaderAppearance createShaderAppearance() + { + ShaderAppearance sApp = new ShaderAppearance(); + sApp.setMaterial(createMaterial()); + return sApp; + } + + private BranchGroup createSubSceneGraph() + { + // Create the sub-root of the branch graph + BranchGroup subRoot = new BranchGroup(); + + // + // Create 1 spheres with a GLSLShader and add it into the scene graph. + // + sApp1 = createShaderAppearance(); + sApp1.setCapability(ShaderAppearance.ALLOW_SHADER_PROGRAM_READ); + sApp1.setCapability(ShaderAppearance.ALLOW_SHADER_PROGRAM_WRITE); + sApp1.setCapability(ShaderAppearance.ALLOW_SHADER_ATTRIBUTE_SET_READ); + sApp1.setCapability(ShaderAppearance.ALLOW_SHADER_ATTRIBUTE_SET_WRITE); + + sp1 = createGLSLShaderProgram(1); + sp1.setShaderAttrNames(shaderAttrNames1); + sas1 = createShaderAttributeSet(1); + sas1.setCapability(ShaderAttributeSet.ALLOW_ATTRIBUTES_READ); + sas1.setCapability(ShaderAttributeSet.ALLOW_ATTRIBUTES_WRITE); + sApp1.setShaderProgram(sp1); + sApp1.setShaderAttributeSet(sas1); + + // Setup Brick shader + sp2 = createGLSLShaderProgram(2); + sp2.setShaderAttrNames(shaderAttrNames2); + sas2 = createShaderAttributeSet(2); + sApp2 = createShaderAppearance(); + sApp2.setShaderProgram(sp2); + sApp2.setShaderAttributeSet(sas2); + + // Setup Wood shader + sp3 = createGLSLShaderProgram(3); + sApp3 = createShaderAppearance(); + sApp3.setShaderProgram(sp3); + + // Setup Polkadot3d shader + sp4 = createGLSLShaderProgram(4); + sApp4 = createShaderAppearance(); + sApp4.setShaderProgram(sp4); + + sphere = new Sphere(1.5f, Sphere.GENERATE_NORMALS, 200, null); + SphereGLSL.makeNIO(sphere); + s3d = sphere.getShape(); + s3d.setCapability(Shape3D.ALLOW_APPEARANCE_READ); + s3d.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); + s3d.setAppearance(sApp1); + + TransformGroup objTG; + Transform3D t = new Transform3D(); + t.set(new Vector3d(0.0, 0.0, 0.0)); + objTG = new TransformGroup(t); + objTG.addChild(sphere); + subRoot.addChild(objTG); + + return subRoot; + } + + + private BranchGroup createSceneGraph(int selectedScene) + { + // Create the root of the branch graph + BranchGroup objRoot = new BranchGroup(); + objRoot.setCapability(BranchGroup.ALLOW_DETACH); + + // 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); + + objScale.addChild(createSubSceneGraph()); + + // Create a position interpolator and attach it to the view + // platform + TransformGroup vpTrans = univ.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; + } + + private Canvas3D initScene() + { + GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); + + Canvas3D c = new Canvas3D(config); + + univ = new SimpleUniverse(c); + + // Add a ShaderErrorListener + univ.addShaderErrorListener(new ShaderErrorListener() { + public void errorOccurred(ShaderError error) + { + error.printVerbose(); + JOptionPane.showMessageDialog(ShaderTestGLSL.this, error.toString(), "ShaderError", JOptionPane.ERROR_MESSAGE); + } + }); + + ViewingPlatform viewingPlatform = univ.getViewingPlatform(); + // This will move the ViewPlatform back a bit so the + // objects in the scene can be viewed. + viewingPlatform.setNominalViewingTransform(); + + view = univ.getViewer().getView(); + + return c; + } + + /** + * Creates new form ShaderTestGLSL + */ + public ShaderTestGLSL() + { + // Initialize the GUI components + initComponents(); + + // Create the scene and add the Canvas3D to the drawing panel + Canvas3D c = initScene(); + drawingPanel.add(c, java.awt.BorderLayout.CENTER); + } + + // ---------------------------------------------------------------- + + /** 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; + + densityButtonGroup = new javax.swing.ButtonGroup(); + colorButtonGroup = new javax.swing.ButtonGroup(); + sceneGraphButtonGroup = new javax.swing.ButtonGroup(); + mainPanel = new javax.swing.JPanel(); + guiPanel = new javax.swing.JPanel(); + densityPanel = new javax.swing.JPanel(); + zeroButton = new javax.swing.JRadioButton(); + halfButton = new javax.swing.JRadioButton(); + fullButton = new javax.swing.JRadioButton(); + colorPanel = new javax.swing.JPanel(); + goldButton = new javax.swing.JRadioButton(); + silverButton = new javax.swing.JRadioButton(); + sceneGraphPanel = new javax.swing.JPanel(); + DetachButton = new javax.swing.JToggleButton(); + AttachButton = new javax.swing.JToggleButton(); + replaceSPButton = new javax.swing.JButton(); + drawingPanel = new javax.swing.JPanel(); + jMenuBar1 = new javax.swing.JMenuBar(); + fileMenu = new javax.swing.JMenu(); + exitMenuItem = new javax.swing.JMenuItem(); + + setTitle("Window Title"); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) + { + exitForm(evt); + } + }); + + mainPanel.setLayout(new java.awt.BorderLayout()); + + guiPanel.setLayout(new javax.swing.BoxLayout(guiPanel, javax.swing.BoxLayout.X_AXIS)); + + guiPanel.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0))); + densityPanel.setLayout(new java.awt.GridBagLayout()); + + densityPanel.setBorder(new javax.swing.border.TitledBorder("Density")); + densityButtonGroup.add(zeroButton); + zeroButton.setText("Zero"); + zeroButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + zeroButtonActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + densityPanel.add(zeroButton, gridBagConstraints); + + densityButtonGroup.add(halfButton); + halfButton.setText("Half"); + halfButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + halfButtonActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + densityPanel.add(halfButton, gridBagConstraints); + + densityButtonGroup.add(fullButton); + fullButton.setSelected(true); + fullButton.setText("Full"); + fullButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + fullButtonActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + densityPanel.add(fullButton, gridBagConstraints); + + guiPanel.add(densityPanel); + densityPanel.getAccessibleContext().setAccessibleName("ShaderAttributeValue \n"); + + colorPanel.setLayout(new java.awt.GridBagLayout()); + + colorPanel.setBorder(new javax.swing.border.TitledBorder("Color")); + colorButtonGroup.add(goldButton); + goldButton.setSelected(true); + goldButton.setText("Gold"); + goldButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + goldButtonActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + colorPanel.add(goldButton, gridBagConstraints); + + colorButtonGroup.add(silverButton); + silverButton.setText("Silver"); + silverButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + silverButtonActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + colorPanel.add(silverButton, gridBagConstraints); + + guiPanel.add(colorPanel); + + sceneGraphPanel.setLayout(new java.awt.GridBagLayout()); + + sceneGraphPanel.setBorder(new javax.swing.border.TitledBorder("Scene Graph")); + sceneGraphButtonGroup.add(DetachButton); + DetachButton.setSelected(true); + DetachButton.setText("Detach"); + DetachButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + DetachButtonActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + sceneGraphPanel.add(DetachButton, gridBagConstraints); + + sceneGraphButtonGroup.add(AttachButton); + AttachButton.setText("Create"); + AttachButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + AttachButtonActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + sceneGraphPanel.add(AttachButton, gridBagConstraints); + + replaceSPButton.setText("Replace Shader"); + replaceSPButton.setEnabled(false); + replaceSPButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + replaceSPButtonActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + sceneGraphPanel.add(replaceSPButton, gridBagConstraints); + + guiPanel.add(sceneGraphPanel); + + mainPanel.add(guiPanel, java.awt.BorderLayout.NORTH); + + drawingPanel.setLayout(new java.awt.BorderLayout()); + + drawingPanel.setPreferredSize(new java.awt.Dimension(500, 500)); + mainPanel.add(drawingPanel, java.awt.BorderLayout.CENTER); + + getContentPane().add(mainPanel, java.awt.BorderLayout.CENTER); + + fileMenu.setText("File"); + exitMenuItem.setText("Exit"); + exitMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + exitMenuItemActionPerformed(evt); + } + }); + + fileMenu.add(exitMenuItem); + + jMenuBar1.add(fileMenu); + + setJMenuBar(jMenuBar1); + + pack(); + } + // </editor-fold>//GEN-END:initComponents + + private void silverButtonActionPerformed(java.awt.event.ActionEvent evt) + {//GEN-FIRST:event_silverButtonActionPerformed + color = SILVER; + if (scene != null) + { + sao2.setValue(silver); + } + }//GEN-LAST:event_silverButtonActionPerformed + + private void goldButtonActionPerformed(java.awt.event.ActionEvent evt) + {//GEN-FIRST:event_goldButtonActionPerformed + color = GOLD; + if (scene != null) + { + sao2.setValue(gold); + } + }//GEN-LAST:event_goldButtonActionPerformed + + private void replaceSPButtonActionPerformed(java.awt.event.ActionEvent evt) + {//GEN-FIRST:event_replaceSPButtonActionPerformed + if (shaderSelected != DIMPLE_SHADER) + { + goldButton.setEnabled(false); + silverButton.setEnabled(false); + zeroButton.setEnabled(false); + halfButton.setEnabled(false); + fullButton.setEnabled(false); + } + + switch (shaderSelected) + { + case DIMPLE_SHADER: + s3d.setAppearance(sApp1); + goldButton.setEnabled(true); + silverButton.setEnabled(true); + zeroButton.setEnabled(true); + halfButton.setEnabled(true); + fullButton.setEnabled(true); + shaderSelected = BRICK_SHADER; + break; + case BRICK_SHADER: + s3d.setAppearance(sApp2); + shaderSelected = WOOD_SHADER; + break; + case WOOD_SHADER: + s3d.setAppearance(sApp3); + shaderSelected = POLKADOT3D_SHADER; + break; + case POLKADOT3D_SHADER: + s3d.setAppearance(sApp4); + shaderSelected = DIMPLE_SHADER; + break; + default: + assert false; + } + + }//GEN-LAST:event_replaceSPButtonActionPerformed + + private void fullButtonActionPerformed(java.awt.event.ActionEvent evt) + {//GEN-FIRST:event_fullButtonActionPerformed + density = 16.0f; + if (scene != null) + { + sao1.setValue(new Float(density)); + } + }//GEN-LAST:event_fullButtonActionPerformed + + private void DetachButtonActionPerformed(java.awt.event.ActionEvent evt) + {//GEN-FIRST:event_DetachButtonActionPerformed + if (scene != null) + { + scene.detach(); + scene = null; + replaceSPButton.setEnabled(false); + goldButton.setEnabled(true); + silverButton.setEnabled(true); + zeroButton.setEnabled(true); + halfButton.setEnabled(true); + fullButton.setEnabled(true); + shaderSelected = DIMPLE_SHADER; + } + }//GEN-LAST:event_DetachButtonActionPerformed + + private void AttachButtonActionPerformed(java.awt.event.ActionEvent evt) + {//GEN-FIRST:event_AttachButtonActionPerformed + if (scene == null) + { + scene = createSceneGraph(1); + univ.addBranchGraph(scene); + replaceSPButton.setEnabled(true); + shaderSelected = BRICK_SHADER; + } + }//GEN-LAST:event_AttachButtonActionPerformed + + private void halfButtonActionPerformed(java.awt.event.ActionEvent evt) + {//GEN-FIRST:event_halfButtonActionPerformed + density = 8.0f; + if (scene != null) + { + sao1.setValue(new Float(density)); + } + }//GEN-LAST:event_halfButtonActionPerformed + + private void zeroButtonActionPerformed(java.awt.event.ActionEvent evt) + {//GEN-FIRST:event_zeroButtonActionPerformed + density = 0.0f; + if (scene != null) + { + sao1.setValue(new Float(density)); + } + + }//GEN-LAST:event_zeroButtonActionPerformed + + private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) + {//GEN-FIRST:event_exitMenuItemActionPerformed + System.exit(0); + }//GEN-LAST:event_exitMenuItemActionPerformed + + /** Exit the Application */ + private void exitForm(java.awt.event.WindowEvent evt) + {//GEN-FIRST:event_exitForm + System.exit(0); + }//GEN-LAST:event_exitForm + + /** + * @param args the command line arguments + */ + public static void main(String args[]) + { + System.setProperty("sun.awt.noerasebackground", "true"); + System.setProperty("j3d.rend","jogl2es2"); + new ShaderTestGLSL().setVisible(true); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JToggleButton AttachButton; + private javax.swing.JToggleButton DetachButton; + private javax.swing.ButtonGroup colorButtonGroup; + private javax.swing.JPanel colorPanel; + private javax.swing.ButtonGroup densityButtonGroup; + private javax.swing.JPanel densityPanel; + private javax.swing.JPanel drawingPanel; + private javax.swing.JMenuItem exitMenuItem; + private javax.swing.JMenu fileMenu; + private javax.swing.JRadioButton fullButton; + private javax.swing.JRadioButton goldButton; + private javax.swing.JPanel guiPanel; + private javax.swing.JRadioButton halfButton; + private javax.swing.JMenuBar jMenuBar1; + private javax.swing.JPanel mainPanel; + private javax.swing.JButton replaceSPButton; + private javax.swing.ButtonGroup sceneGraphButtonGroup; + private javax.swing.JPanel sceneGraphPanel; + private javax.swing.JRadioButton silverButton; + private javax.swing.JRadioButton zeroButton; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/classes/org/jdesktop/j3d/examples/cg_shader/SphereCg.form b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/SphereGLSL.form index ef60e53..26e9b32 100644 --- a/src/classes/org/jdesktop/j3d/examples/cg_shader/SphereCg.form +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/SphereGLSL.form @@ -3,7 +3,7 @@ <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="SphereCg"/> + <Property name="title" type="java.lang.String" value="SphereGLSL"/> </Properties> <SyntheticProperties> <SyntheticProperty name="formSizePolicy" type="int" value="1"/> diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/SphereGLSL.java b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/SphereGLSL.java new file mode 100644 index 0000000..f49c42a --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/SphereGLSL.java @@ -0,0 +1,410 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2007 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.gl2es2pipeline; + +import java.awt.GraphicsConfiguration; +import java.io.File; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; + +import javax.swing.JOptionPane; + +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ColoringAttributes; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.GLSLShaderProgram; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.J3DBuffer; +import org.jogamp.java3d.Light; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.PointLight; +import org.jogamp.java3d.PositionInterpolator; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Shader; +import org.jogamp.java3d.ShaderAppearance; +import org.jogamp.java3d.ShaderError; +import org.jogamp.java3d.ShaderErrorListener; +import org.jogamp.java3d.ShaderProgram; +import org.jogamp.java3d.SourceCodeShader; +import org.jogamp.java3d.SpotLight; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.TriangleStripArray; +import org.jogamp.java3d.utils.geometry.Sphere; +//import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.shader.StringIO; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; + +/** + * Simple Java 3D example program with programmable shader. + */ +public class SphereGLSL extends javax.swing.JFrame +{ + + // 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 univ = null; + private BranchGroup scene = null; + + public BranchGroup createSceneGraph() + { + Color3f eColor = new Color3f(0.0f, 0.0f, 0.0f); + Color3f sColor = new Color3f(1.0f, 1.0f, 1.0f); + Color3f objColor = new Color3f(0.6f, 0.6f, 0.6f); + Color3f lColor1 = new Color3f(1.0f, 0.0f, 0.0f); + Color3f lColor2 = new Color3f(0.0f, 1.0f, 0.0f); + Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f); + Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f); + + Transform3D t; + + // Create the root of the branch graph + BranchGroup objRoot = new BranchGroup(); + + // Create a Transformgroup to scale all objects so they + // appear in the scene. + TransformGroup objScale = new TransformGroup(); + Transform3D t3d = new Transform3D(); + t3d.setScale(0.4); + objScale.setTransform(t3d); + objRoot.addChild(objScale); + + // Create a bounds for the background and lights + BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); + + // Set up the background + Background bg = new Background(bgColor); + bg.setApplicationBounds(bounds); + objScale.addChild(bg); + + // Create a Sphere object, generate one copy of the sphere, + // and add it into the scene graph. + ShaderAppearance a = new ShaderAppearance(); + Material m = new Material(objColor, eColor, objColor, sColor, 100.0f); + m.setLightingEnable(true); + String vertexProgram = null; + String fragmentProgram = null; + try + { + vertexProgram = StringIO.readFully( + new File(System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/simple.vert")); + fragmentProgram = StringIO.readFully( + new File(System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/simple.frag")); + } + catch (IOException e) + { + throw new RuntimeException(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); + makeNIO(sph); + 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); + + Sphere sph2 = new Sphere(0.05f, appL1); + makeNIO(sph2); + l1Trans.addChild(sph2); + Sphere sph3 = new Sphere(0.05f, appL2); + makeNIO(sph3); + l2Trans.addChild(sph3); + + // 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 = univ.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; + } + + + + private Canvas3D createUniverse() + { + // Get the preferred graphics configuration for the default screen + GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); + + // Create a Canvas3D using the preferred configuration + Canvas3D canvas3d = new Canvas3D(config); + + // Create simple universe with view branch + univ = new SimpleUniverse(canvas3d); + BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); + + // Add a ShaderErrorListener + univ.addShaderErrorListener(new ShaderErrorListener() { + public void errorOccurred(ShaderError error) + { + error.printVerbose(); + JOptionPane.showMessageDialog(SphereGLSL.this, error.toString(), "ShaderError", JOptionPane.ERROR_MESSAGE); + } + }); + + // This will move the ViewPlatform back a bit so the + // objects in the scene can be viewed. + univ.getViewingPlatform().setNominalViewingTransform(); + + // Ensure at least 5 msec per frame (i.e., < 200Hz) + univ.getViewer().getView().setMinimumFrameCycleTime(5); + + return canvas3d; + } + + /** + * Creates new form SphereGLSL + */ + public SphereGLSL() + { + + // Initialize the GUI components + initComponents(); + + // Create Canvas3D and SimpleUniverse; add canvas to drawing panel + Canvas3D c = createUniverse(); + drawingPanel.add(c, java.awt.BorderLayout.CENTER); + + // Create the content branch and add it to the universe + scene = createSceneGraph(); + univ.addBranchGraph(scene); + } + + // ---------------------------------------------------------------- + + /** 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() + { + drawingPanel = new javax.swing.JPanel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("SphereGLSL"); + drawingPanel.setLayout(new java.awt.BorderLayout()); + + drawingPanel.setPreferredSize(new java.awt.Dimension(700, 700)); + getContentPane().add(drawingPanel, java.awt.BorderLayout.CENTER); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(final String args[]) + { + System.setProperty("sun.awt.noerasebackground", "true"); + System.setProperty("j3d.rend", "jogl2es2"); + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() + { + SphereGLSL sphereGLSL = new SphereGLSL(); + sphereGLSL.setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel drawingPanel; + + + + // End of variables declaration//GEN-END:variables + public static void makeNIO(Sphere sph) + { + //Make it NIO + TriangleStripArray geo = (TriangleStripArray) sph.getShape().getGeometry(); + int[] stripVertexCounts = new int[geo.getNumStrips()]; + geo.getStripVertexCounts(stripVertexCounts); + TriangleStripArray newGeo = new TriangleStripArray(geo.getVertexCount(), GeometryArray.COORDINATES | GeometryArray.NORMALS + //| GeometryArray.TEXTURE_COORDINATE_2 + | GeometryArray.USE_NIO_BUFFER | GeometryArray.BY_REFERENCE, stripVertexCounts); + + float[] coords = new float[geo.getValidVertexCount() * 3]; + geo.getCoordinates(0, coords); + newGeo.setCoordRefBuffer(new J3DBuffer(makeFloatBuffer(coords))); + float[] norms = new float[geo.getValidVertexCount() * 3]; + geo.getNormals(0, norms); + newGeo.setNormalRefBuffer(new J3DBuffer(makeFloatBuffer(norms))); + sph.getShape().setGeometry(newGeo); + + } + + private static FloatBuffer makeFloatBuffer(float[] arr) + { + ByteBuffer bb = ByteBuffer.allocateDirect(arr.length * 4); + bb.order(ByteOrder.nativeOrder()); + FloatBuffer fb = bb.asFloatBuffer(); + fb.put(arr); + fb.position(0); + return fb; + } +} diff --git a/src/classes/org/jdesktop/j3d/examples/cg_shader/VertexAttrTestCg.form b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/VertexAttrTestGLSL.form index 736b93c..6e31a8f 100644 --- a/src/classes/org/jdesktop/j3d/examples/cg_shader/VertexAttrTestCg.form +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/VertexAttrTestGLSL.form @@ -23,7 +23,7 @@ </Menu> </NonVisualComponents> <Properties> - <Property name="title" type="java.lang.String" value="Vertex Attribute Test"/> + <Property name="title" type="java.lang.String" value="VertexAttrTestGLSL"/> </Properties> <SyntheticProperties> <SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/> diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/VertexAttrTestGLSL.java b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/VertexAttrTestGLSL.java new file mode 100644 index 0000000..96bc0c9 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/VertexAttrTestGLSL.java @@ -0,0 +1,451 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2007 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.gl2es2pipeline; + +import java.awt.GraphicsConfiguration; +import java.io.File; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; + +import javax.swing.JFrame; +import javax.swing.JOptionPane; + +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.GLSLShaderProgram; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.J3DBuffer; +import org.jogamp.java3d.Shader; +import org.jogamp.java3d.ShaderAppearance; +import org.jogamp.java3d.ShaderError; +import org.jogamp.java3d.ShaderErrorListener; +import org.jogamp.java3d.ShaderProgram; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.SourceCodeShader; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.TriangleArray; +import org.jogamp.java3d.utils.shader.StringIO; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; + +public class VertexAttrTestGLSL extends javax.swing.JFrame +{ + + SimpleUniverse univ = null; + BranchGroup scene = null; + + public BranchGroup createSceneGraph(boolean hasVertexAttrs) + { + + // Bounds for BG and behavior + BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); + + // Create the root of the branch graph + BranchGroup objRoot = new BranchGroup(); + objRoot.setCapability(BranchGroup.ALLOW_DETACH); + + // Set up the background + Color3f bgColor = new Color3f(0.1f, 0.1f, 0.1f); + Background bg = new Background(bgColor); + bg.setApplicationBounds(bounds); + objRoot.addChild(bg); + + // 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 MyShape(this, hasVertexAttrs)); + + return objRoot; + } + + private Canvas3D initScene() + { + GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); + + Canvas3D c = new Canvas3D(config); + univ = new SimpleUniverse(c); + + // Add a ShaderErrorListener + univ.addShaderErrorListener(new ShaderErrorListener() { + public void errorOccurred(ShaderError error) + { + error.printVerbose(); + JOptionPane.showMessageDialog(VertexAttrTestGLSL.this, error.toString(), "ShaderError", JOptionPane.ERROR_MESSAGE); + } + }); + + ViewingPlatform viewingPlatform = univ.getViewingPlatform(); + // This will move the ViewPlatform back a bit so the + // objects in the scene can be viewed. + viewingPlatform.setNominalViewingTransform(); + + return c; + } + + /** + * Creates new form VertexAttrTestGLSL + */ + public VertexAttrTestGLSL() + { + // Initialize the GUI components + initComponents(); + + // Create the scene and add the Canvas3D to the drawing panel + Canvas3D c = initScene(); + drawingPanel.add(c, java.awt.BorderLayout.CENTER); + } + + static class MyShape extends Shape3D + { + + // Coordinate data + private static final float[] coords = { 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, }; + + private static final int[] sizes = { 1, 3 }; + private static final float[] weights = { 0.45f, 0.15f, 0.95f, }; + private static final float[] temps = { 1.0f, 0.5f, 0.5f, 0.5f, 1.0f, 0.5f, 0.5f, 0.5f, 1.0f, }; + + private static final String[] vaNames = { "weight", "temperature" }; + + J3DBuffer createDirectFloatBuffer(float[] arr) + { + ByteOrder order = ByteOrder.nativeOrder(); + + FloatBuffer nioBuf = ByteBuffer.allocateDirect(arr.length * 4).order(order).asFloatBuffer(); + nioBuf.put(arr); + return new J3DBuffer(nioBuf); + } + + MyShape(JFrame frame, boolean hasVertexAttrs) + { + + int vertexFormat = GeometryArray.COORDINATES; + int vertexAttrCount = 0; + int[] vertexAttrSizes = null; + String[] vertexAttrNames = null; + String[] shaderAttrNames = null; + + if (hasVertexAttrs) + { + vertexFormat |= GeometryArray.VERTEX_ATTRIBUTES; + vertexAttrCount = vaNames.length; + vertexAttrSizes = sizes; + vertexAttrNames = vaNames; + } + + //GL2ES2: requires by reference + vertexFormat |= GeometryArray.BY_REFERENCE; + + TriangleArray tri = new TriangleArray(6, vertexFormat, 0, null, vertexAttrCount, vertexAttrSizes); + tri.setValidVertexCount(3); + //tri.setCoordinates(0, coords); + tri.setCoordRefFloat(coords); + + if (hasVertexAttrs) + { + //tri.setVertexAttrs(0, 0, weights); + //tri.setVertexAttrs(1, 0, temps); + + tri.setVertexAttrRefFloat(0, weights); + tri.setVertexAttrRefFloat(1, temps); + + String vertexProgram = null; + String fragmentProgram = null; + try + { + vertexProgram = StringIO.readFully(new File( + System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/vertexshader.vert")); + fragmentProgram = StringIO.readFully(new File( + System.getProperty("user.dir") + "/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/vertexshader.frag")); + } + catch (IOException e) + { + throw new RuntimeException(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); + shaderProgram.setVertexAttrNames(vertexAttrNames); + shaderProgram.setShaderAttrNames(shaderAttrNames); + + ShaderAppearance app = new ShaderAppearance(); + app.setShaderProgram(shaderProgram); + + this.setGeometry(tri); + + this.setAppearance(app); + } + else + { + this.setGeometry(tri); + this.setAppearance(new Appearance()); + } + } + } + + // ---------------------------------------------------------------- + + /** 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; + + mainPanel = new javax.swing.JPanel(); + guiPanel = new javax.swing.JPanel(); + vertexCheckBoxPanel = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jSeparator1 = new javax.swing.JSeparator(); + jSeparator2 = new javax.swing.JSeparator(); + jPanel2 = new javax.swing.JPanel(); + vertexAttrsBox = new javax.swing.JCheckBox(); + geometryPanel = new javax.swing.JPanel(); + createButton = new javax.swing.JButton(); + destroyButton = new javax.swing.JButton(); + drawingPanel = new javax.swing.JPanel(); + jMenuBar1 = new javax.swing.JMenuBar(); + fileMenu = new javax.swing.JMenu(); + exitMenuItem = new javax.swing.JMenuItem(); + + setTitle("VertexAttrTestGLSL"); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) + { + exitForm(evt); + } + }); + + mainPanel.setLayout(new java.awt.BorderLayout()); + + guiPanel.setLayout(new java.awt.GridBagLayout()); + + guiPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + vertexCheckBoxPanel.setLayout(new java.awt.GridBagLayout()); + + vertexCheckBoxPanel.setBorder( + javax.swing.BorderFactory.createTitledBorder(null, "vertexFormat", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, + javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Lucida Sans", 0, 10))); + jPanel1.setLayout(new java.awt.GridBagLayout()); + + jSeparator1.setPreferredSize(new java.awt.Dimension(0, 4)); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + jPanel1.add(jSeparator1, gridBagConstraints); + + jSeparator2.setPreferredSize(new java.awt.Dimension(0, 4)); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 3; + jPanel1.add(jSeparator2, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; + vertexCheckBoxPanel.add(jPanel1, gridBagConstraints); + + jPanel2.setLayout(new java.awt.GridBagLayout()); + + vertexAttrsBox.setSelected(true); + vertexAttrsBox.setText("VertexAttrs"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 4; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + jPanel2.add(vertexAttrsBox, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; + vertexCheckBoxPanel.add(jPanel2, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 0; + gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); + guiPanel.add(vertexCheckBoxPanel, gridBagConstraints); + + geometryPanel.setLayout(new java.awt.GridBagLayout()); + + createButton.setText("Create Geometry"); + createButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + createButtonActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + geometryPanel.add(createButton, gridBagConstraints); + + destroyButton.setText("Destroy Geometry"); + destroyButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + destroyButtonActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new java.awt.Insets(0, 0, 2, 0); + geometryPanel.add(destroyButton, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 0; + gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); + guiPanel.add(geometryPanel, gridBagConstraints); + + mainPanel.add(guiPanel, java.awt.BorderLayout.NORTH); + + drawingPanel.setLayout(new java.awt.BorderLayout()); + + drawingPanel.setPreferredSize(new java.awt.Dimension(500, 500)); + mainPanel.add(drawingPanel, java.awt.BorderLayout.CENTER); + + getContentPane().add(mainPanel, java.awt.BorderLayout.CENTER); + + fileMenu.setText("File"); + exitMenuItem.setText("Exit"); + exitMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + exitMenuItemActionPerformed(evt); + } + }); + + fileMenu.add(exitMenuItem); + + jMenuBar1.add(fileMenu); + + setJMenuBar(jMenuBar1); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void destroyButtonActionPerformed(java.awt.event.ActionEvent evt) + {//GEN-FIRST:event_destroyButtonActionPerformed + if (scene != null) + { + univ.getLocale().removeBranchGraph(scene); + scene = null; + } + }//GEN-LAST:event_destroyButtonActionPerformed + + private void createButtonActionPerformed(java.awt.event.ActionEvent evt) + {//GEN-FIRST:event_createButtonActionPerformed + if (scene == null) + { + boolean hasVertexAttrs = vertexAttrsBox.isSelected(); + scene = createSceneGraph(hasVertexAttrs); + univ.addBranchGraph(scene); + } + }//GEN-LAST:event_createButtonActionPerformed + + private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) + {//GEN-FIRST:event_exitMenuItemActionPerformed + System.exit(0); + }//GEN-LAST:event_exitMenuItemActionPerformed + + /** Exit the Application */ + private void exitForm(java.awt.event.WindowEvent evt) + {//GEN-FIRST:event_exitForm + System.exit(0); + }//GEN-LAST:event_exitForm + + /** + * @param args the command line arguments + */ + public static void main(String args[]) + { + System.setProperty("sun.awt.noerasebackground", "true"); + System.setProperty("j3d.rend","jogl2es2"); + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() + { + new VertexAttrTestGLSL().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton createButton; + private javax.swing.JButton destroyButton; + private javax.swing.JPanel drawingPanel; + private javax.swing.JMenuItem exitMenuItem; + private javax.swing.JMenu fileMenu; + private javax.swing.JPanel geometryPanel; + private javax.swing.JPanel guiPanel; + private javax.swing.JMenuBar jMenuBar1; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JSeparator jSeparator1; + private javax.swing.JSeparator jSeparator2; + private javax.swing.JPanel mainPanel; + private javax.swing.JCheckBox vertexAttrsBox; + private javax.swing.JPanel vertexCheckBoxPanel; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/aabrick.frag b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/aabrick.frag new file mode 100644 index 0000000..030b811 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/aabrick.frag @@ -0,0 +1,56 @@ +// +// Fragment shader for antialiased procedural bricks +// +// Authors: Dave Baldwin, Randi Rost +// based on a shader by Darwyn Peachey +// +// Copyright (c) 2002-2004 3Dlabs Inc. Ltd. +// +// See 3Dlabs-License.txt for license information +// + +uniform vec3 BrickColor; +//uniform vec3 MortarColor; +//uniform vec2 BrickSize; +//uniform vec2 BrickPct; +//uniform vec2 MortarPct; + +//const vec3 BrickColor = vec3 (1, 0.3, 0.2); +const vec3 MortarColor = vec3 (0.85, 0.86, 0.84); +const vec2 BrickSize = vec2 (0.3, 0.15); +const vec2 BrickPct = vec2 (0.9, 0.85); +const vec2 MortarPct = vec2 (0.1, 0.15); + +varying vec2 MCposition; +varying float LightIntensity; + +#define Integral(x, p, notp) ((floor(x)*(p)) + max(fract(x)-(notp), 0.0)) + +void main(void) +{ + vec2 position, fw, useBrick; + vec3 color; + + // Determine position within the brick pattern + position = MCposition / BrickSize; + + // Adjust every other row by an offset of half a brick + if (fract(position.y * 0.5) > 0.5) + position.x += 0.5; + + // Calculate filter size + //fw = fwidth(position); //fwidth not implemented on WildcatVP + fw = (abs(dFdx(MCposition)) + abs(dFdy(MCposition))) / BrickSize; + + // Perform filtering by integrating the 2D pulse made by the + // brick pattern over the filter width and height + useBrick = (Integral(position + fw, BrickPct, MortarPct) - + Integral(position, BrickPct, MortarPct)) / fw; + + // Determine final color + color = mix(MortarColor, BrickColor, useBrick.x * useBrick.y); + color *= LightIntensity; + + // GL2ES2: gl_FragColor is unchanged + gl_FragColor = vec4 (color, 1.0); +} diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/aabrick.vert b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/aabrick.vert new file mode 100644 index 0000000..9b96195 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/aabrick.vert @@ -0,0 +1,64 @@ +// +// Vertex shader for antialiased procedural bricks +// +// Authors: Dave Baldwin, Steve Koren, Randi Rost +// based on a shader by Darwyn Peachey +// +// Copyright (c) 2002-2004 3Dlabs Inc. Ltd. +// +// See 3Dlabs-License.txt for license information +// + +// GL2ES2: Java3D built-in attributes, these are calculated and passsed in if declared here +attribute vec4 glVertex; +attribute vec3 glNormal; + +// GL2ES2: Java3D built-in uniforms, these are calculated and passsed in if declared here +uniform mat4 glModelViewMatrix; +uniform mat4 glModelViewProjectionMatrix; +uniform mat3 glNormalMatrix; + + +uniform vec3 LightPosition; +//const vec3 LightPosition = vec3 (0, 4, 4); + +const float SpecularContribution = 0.3; +const float DiffuseContribution = 1.0 - SpecularContribution; + +varying float LightIntensity; +varying vec2 MCposition; + +void main(void) +{ + // GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top) + //vec3 ecPosition = vec3 (gl_ModelViewMatrix * gl_Vertex); + vec3 ecPosition = vec3 (glModelViewMatrix * glVertex); + // GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top) + //vec3 tnorm = normalize(gl_NormalMatrix * glNormal); + vec3 tnorm = normalize(glNormalMatrix * glNormal); + + + vec3 lightVec = normalize(LightPosition - ecPosition); + vec3 reflectVec = reflect(-lightVec, tnorm); + vec3 viewVec = normalize(-ecPosition); + float diffuse = max(dot(lightVec, tnorm), 0.0); + float spec = 0.0; + + if (diffuse > 0.0) + { + spec = max(dot(reflectVec, viewVec), 0.0); + spec = pow(spec, 16.0); + } + + LightIntensity = DiffuseContribution * diffuse + + SpecularContribution * spec; + + // GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top) + //MCposition = gl_Vertex.xy; + MCposition = glVertex.xy; + + // GL2ES2: ftransform() no longer exists, but it is simple (note use of Java3D built-in uniforms and attributes) + // GL2ES2: gl_Position is unchanged + //gl_Position = ftransform(); + gl_Position = glModelViewProjectionMatrix * glVertex; +} diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/dimple.frag b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/dimple.frag new file mode 100644 index 0000000..b2a2ef7 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/dimple.frag @@ -0,0 +1,68 @@ + +// +// dimple.frag: Fragment shader for bump mapping dimples (bumps) +// +// author: John Kessenich +// +// Copyright (c) 2002: 3Dlabs, Inc. +// +// + +// GL2ES2: non buit-in varyings +varying vec2 glTexCoord0; +varying vec4 C; + +varying vec3 LightDir; +varying vec3 EyeDir; +varying vec3 Normal; + +//const vec3 Color = vec3(0.7, 0.6, 0.18); + +//const float Density = 16.0; +//const float Size = 0.25; + +uniform vec3 Color; +uniform float Density; +uniform float Size; +// uniform float SpecularFactor; + +//float Density = 27.6; +//float Size = 0.13025; + + +//uniform float Scale; + +const float SpecularFactor = 0.4; + +void main (void) +{ + vec3 litColor; + + // GL2ES2: non buit-in varying + vec2 c = Density * (glTexCoord0.xy); + vec2 p = fract(c) - vec2(0.5); + float d = (p.x * p.x) + (p.y * p.y); + if (d >= Size) + p = vec2(0.0); + + vec3 normDelta = vec3(-p.x, -p.y, 1.0); + + litColor = Color * max(0.0, dot(normDelta, LightDir)); + + float t = 2.0 * dot(LightDir, normDelta); + vec3 reflectDir = t * normDelta; + reflectDir = LightDir - reflectDir; + +// vec3 reflectDir = LightDir - 2.0 * dot(LightDir, normDelta) * normDelta; + + float spec = max(dot(EyeDir, reflectDir), 0.0); + spec = spec * spec; + spec = spec * spec; + spec *= SpecularFactor; + + litColor = min(litColor + spec, vec3(1.0)); + // GL2ES2: gl_FragColor is unchanged, C is a non built-in varying + gl_FragColor = vec4(litColor, C.a); +// gl_FragColor = vec4(litColor, 1.0); +// gl_FragColor = vec4(Scale); +} diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/dimple.vert b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/dimple.vert new file mode 100644 index 0000000..9b06148 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/dimple.vert @@ -0,0 +1,76 @@ +#version 120 +// +// dimple.vert: Vertex shader for bump mapping dimples (bumps) +// +// author: John Kessenich +// +// Copyright (c) 2002: 3Dlabs, Inc. +// + + +// GL2ES2: Java3D built-in attributes, these are calculated and passsed in if declared here +attribute vec4 glVertex; +attribute vec3 glNormal; +attribute vec4 glColor; + +// GL2ES2: Java3D built-in uniforms, these are calculated and passsed in if declared here +uniform mat4 glModelViewMatrix; +uniform mat4 glModelViewProjectionMatrix; +uniform mat3 glNormalMatrix; + +uniform vec4 glFrontMaterialdiffuse; +uniform int ignoreVertexColors; + +// GL2ES2: new output varyings, these replace gl_TexCoord[] and gl_FrontColor (along with A and D) +varying vec2 glTexCoord0; +varying vec4 C; + +varying vec3 LightDir; +varying vec3 EyeDir; +varying vec3 Normal; + +uniform vec3 LightPosition; +// uniform float Scale; +// vec3 LightPosition = vec3(0.0, 0.0, 5.0); +float Scale = 1.0; + + + +void main(void) +{ + // GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top) + vec4 pos = glModelViewMatrix * glVertex; + // GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top) + gl_Position = glModelViewProjectionMatrix * glVertex; + vec3 eyeDir = vec3(pos); + // GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top) + // GL2ES2: swap built-in varying for declared varying + //gl_TexCoord[0] = gl_MultiTexCoord0; + glTexCoord0 = glVertex.xy; + // GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top) + // GL2ES2: swap built-in varying for declared varying + //gl_FrontColor = gl_Color; + + if( ignoreVertexColors != 0) + C = glFrontMaterialdiffuse; + else + C = glColor; + + vec3 n = normalize(glNormalMatrix * glNormal); + vec3 t = normalize(cross(vec3(1.141, 2.78, 3.14), n)); + vec3 b = cross(n, t); + + vec3 v; + v.x = dot(LightPosition, t); + v.y = dot(LightPosition, b); + v.z = dot(LightPosition, n); + LightDir = normalize(v); + + v.x = dot(eyeDir, t); + v.y = dot(eyeDir, b); + v.z = dot(eyeDir, n); + EyeDir = normalize(v); + + + +} diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/envmap.frag b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/envmap.frag new file mode 100644 index 0000000..3e298f8 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/envmap.frag @@ -0,0 +1,61 @@ +// +// Fragment shader for environment mapping with an +// equirectangular 2D texture +// +// Authors: John Kessenich, Randi Rost +// +// Copyright (c) 2002-2004 3Dlabs Inc. Ltd. +// +// See 3Dlabs-License.txt for license information +// + +const vec3 Xunitvec = vec3 (1.0, 0.0, 0.0); +const vec3 Yunitvec = vec3 (0.0, 1.0, 0.0); + +uniform vec3 BaseColor; +uniform float MixRatio; + +uniform sampler2D EnvMap; + +varying vec3 Normal; +varying vec3 EyeDir; +varying float LightIntensity; + +void main (void) +{ + // Compute reflection vector + vec3 reflectDir = reflect(EyeDir, Normal); + + // Compute altitude and azimuth angles + + vec2 index; + + index.y = dot(normalize(reflectDir), Yunitvec); + reflectDir.y = 0.0; + index.x = dot(normalize(reflectDir), Xunitvec) * 0.5; + + // Translate index values into proper range + + if (reflectDir.z >= 0.0) + index = (index + 1.0) * 0.5; + else + { + index.t = (index.t + 1.0) * 0.5; + index.s = (-index.s) * 0.5 + 1.0; + } + + // if reflectDir.z >= 0.0, s will go from 0.25 to 0.75 + // if reflectDir.z < 0.0, s will go from 0.75 to 1.25, and + // that's OK, because we've set the texture to wrap. + + // Do a lookup into the environment map. + + vec3 envColor = vec3 (texture2D(EnvMap, index)); + + // Add lighting to base color and mix + + vec3 base = LightIntensity * BaseColor; + envColor = mix(envColor, base, MixRatio); + + gl_FragColor = vec4 (envColor, 1.0); +} diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/envmap.vert b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/envmap.vert new file mode 100644 index 0000000..2cae4ab --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/envmap.vert @@ -0,0 +1,46 @@ +// +// Vertex shader for environment mapping with an +// equirectangular 2D texture +// +// Authors: John Kessenich, Randi Rost +// +// Copyright (c) 2002-2004 3Dlabs Inc. Ltd. +// +// See 3Dlabs-License.txt for license information +// + +// GL2ES2: Java3D built-in attributes, these are calculated and passsed in if declared here +attribute vec4 glVertex; +attribute vec3 glNormal; + +// GL2ES2: Java3D built-in uniforms, these are calculated and passsed in if declared here +uniform mat4 glModelViewMatrix; +uniform mat4 glModelViewProjectionMatrix; +uniform mat3 glNormalMatrix; + + +varying vec3 Normal; +varying vec3 EyeDir; +varying float LightIntensity; + +uniform vec3 LightPos; + +void main(void) +{ + // GL2ES2: ftransform() no longer exists, but it is simple (note use of Java3D built-in uniforms and attributes) + // GL2ES2: gl_Position is unchanged + //gl_Position = ftransform(); + gl_Position = glModelViewProjectionMatrix * glVertex; + + // compute the transformed normal + // GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top) + //vec3 Normal = normalize(gl_NormalMatrix * gl_Normal); + vec3 Normal = normalize(glNormalMatrix * glNormal); + + // GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top) + //vec4 pos = gl_ModelViewMatrix * gl_Vertex; + vec4 pos = glModelViewMatrix * glVertex; + + EyeDir = pos.xyz; + LightIntensity = max(dot(normalize(LightPos - EyeDir), Normal), 0.0); +} diff --git a/src/classes/org/jdesktop/j3d/examples/cg_shader/multitex_fp.cg b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/gouraud.frag index c9fb66b..9169661 100644 --- a/src/classes/org/jdesktop/j3d/examples/cg_shader/multitex_fp.cg +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/gouraud.frag @@ -42,15 +42,9 @@ * $State$ */ -float4 main(float2 tc0 : TEXCOORD0, - float2 tc1: TEXCOORD1, - uniform float cloudFactor, - uniform sampler2D earthTex : TEXUNIT1, - uniform sampler2D cloudTex : TEXUNIT0): COLOR -{ - float3 color0 = tex2D(cloudTex, tc0).rgb; - float3 color1 = tex2D(earthTex, tc1).rgb; - float3 finalColor = color0*cloudFactor + color1; +// Simple GLSL fragment program to add the primary and secondary (specular) colors - return float4(finalColor, 1.0); +void main() +{ + gl_FragColor = gl_Color + gl_SecondaryColor; } diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/gouraud.vert b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/gouraud.vert new file mode 100644 index 0000000..900f598 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/gouraud.vert @@ -0,0 +1,109 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2007 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 GLSL vertex program for handling 1 directional light with specular. +// This implements per-vertex lighting (Gouraud shading). + +// GL2ES2: Java3D built-in attributes, these are calculated and passsed in if declared here +attribute vec4 glVertex; +attribute vec3 glNormal; + +// GL2ES2: Java3D built-in uniforms, these are calculated and passsed in if declared here +uniform mat4 glModelViewMatrix; +uniform mat4 glModelViewProjectionMatrix; +uniform mat3 glNormalMatrix; + +void directionalLight0( + in vec3 normal, + inout vec4 ambient, + inout vec4 diffuse, + inout vec4 specular) +{ + // Normalized light direction and half vector + vec3 lightDirection = normalize(vec3(gl_LightSource[0].position)); + vec3 halfVector = normalize(vec3(gl_LightSource[0].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[0].ambient; + diffuse += gl_LightSource[0].diffuse * nDotVP; + specular += gl_LightSource[0].specular * pf; +} + + +void main() +{ + vec3 tnorm = normalize(vec3(glNormalMatrix * glNormal)); + vec4 amb = vec4(0.0); + vec4 diff = vec4(0.0); + vec4 spec = vec4(0.0); + int i; + + // Transform the vertex + vec4 outPosition = glModelViewProjectionMatrix * glVertex; + + directionalLight0(tnorm, amb, diff, spec); + + // Apply the result of the lighting equation + vec4 outSecondaryColor = vec4(vec3(spec * gl_FrontMaterial.specular), 1.0); + vec4 outColor = vec4(vec3(gl_FrontLightModelProduct.sceneColor + + amb * gl_FrontMaterial.ambient + + diff * gl_FrontMaterial.diffuse), 1.0); + + gl_FrontColor = outColor; + gl_FrontSecondaryColor = outSecondaryColor; + gl_Position = outPosition; +} diff --git a/src/classes/org/jdesktop/j3d/examples/cg_shader/vertexshader_vp.cg b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/multitex.frag index d5b1b1a..3606b31 100644 --- a/src/classes/org/jdesktop/j3d/examples/cg_shader/vertexshader_vp.cg +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/multitex.frag @@ -42,36 +42,23 @@ * $State$ */ +uniform float cloudFactor; +uniform sampler2D earthTex; +uniform sampler2D cloudTex; -// define inputs from application -struct appin -{ - float4 Position : POSITION; - float4 Normal : NORMAL; -}; - -// define outputs from vertex shader -struct vertout -{ - float4 Position : POSITION; - float4 Color0 : COLOR0; -}; +uniform sampler2D EnvMap; +varying vec2 texCoord0; +varying vec2 texCoord1; -vertout main(appin IN, - float3 temperature, - float weight, - uniform float4x4 ModelViewProj) +void main (void) { - vertout OUT; - - ModelViewProj = glstate.matrix.mvp; - - // transform vertex position into homogenous clip-space - OUT.Position = mul(ModelViewProj, IN.Position); + vec2 tc0 = texCoord0.xy; + vec2 tc1 = texCoord1.xy; - // Compute color from temperature, weight - OUT.Color0 = float4(temperature * weight, 1.0); + vec3 color0 = vec3(texture2D(cloudTex, tc0)); + vec3 color1 = vec3(texture2D(earthTex, tc1)); + vec3 finalColor = color0*cloudFactor + color1; - return OUT; + gl_FragColor = vec4(finalColor, 1.0); } diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/multitex.vert b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/multitex.vert new file mode 100644 index 0000000..4132cae --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/multitex.vert @@ -0,0 +1,69 @@ +// tex coord gen sample from http://www.ogre3d.org/forums/viewtopic.php?f=4&t=59737 + + + + +// GL2ES2: Java3D built-in attributes, these are calculated and passsed in if declared here +attribute vec4 glVertex; +attribute vec3 glNormal; + +// GL2ES2: Java3D built-in uniforms, these are calculated and passsed in if declared here +uniform mat4 glModelViewProjectionMatrix; +uniform mat4 glModelViewMatrix; +uniform mat3 glNormalMatrix; + +// Per-pixel normal (output to fragment shader) +varying vec3 Normal; + +varying vec2 texCoord0; +varying vec2 texCoord1; + + //Example 8-4 Sphere Map Texture Coordinate Generation + // position is the normalized position coordinate in eye space + // normal is the normalized normal coordinate in eye space + // returns a vec2 texture coordinate +vec2 sphere_map(vec3 position, vec3 normal) +{ + vec3 reflection = reflect(position, normal); + float m = 2.0 * sqrt(reflection.x * reflection.x + reflection.y * reflection.y + (reflection.z + 1.0) * (reflection.z + 1.0)); + return vec2((reflection.x / m + 0.5), (reflection.y / m + 0.5)); +} + + //Example 8-5 Cube Map Texture Coordinate Generation + + // position is the normalized position coordinate in eye space + // normal is the normalized normal coordinate in eye space + // returns the reflection vector as a vec3 texture coordinate +vec3 cube_map(vec3 position, vec3 normal) +{ + return reflect(position, normal); +} + +//Object Linear Mapping +//When the texture generation mode is set to GL_OBJECT_LINEAR, texture coordinates are generated using the following function: +//coord = P1*X + P2*Y + P3*Z + P4*W +// The X, Y, Z, and W values are the vertex coordinates from the object being textured, and the P1–P4 values are the coefficients for a plane equation. + +//For this shader in my code I have: +//Vector4f plane0S = new Vector4f(3.0f, 1.5f, 0.3f, 0.0f); //to calc coord S +//Vector4f plane0T = new Vector4f(1.0f, 2.5f, 0.24f, 0.0f); //to calc coord T +//I could hand them is as uniforms, but I choose to hard code them + + +vec2 object_linear(vec4 pos, vec4 planeOS, vec4 planeOT) +{ + return vec2(pos.x*planeOS.x+pos.y*planeOS.y+pos.z*planeOS.z+ pos.w*planeOS.w,pos.x*planeOT.x+pos.y*planeOT.y+pos.z*planeOT.z+pos.w*planeOT.w); +} + + +void main() +{ + Normal = normalize(vec3(glNormalMatrix * glNormal)); + + // Transform the vertex + gl_Position = glModelViewProjectionMatrix * glVertex; + + texCoord0 = object_linear(gl_Position, vec4(3.0, 1.5, 0.3, 0.0),vec4(1.0, 2.5, 0.24, 0.0)); + texCoord1 = sphere_map(gl_Position.xyz, Normal); + +} diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/phong.frag b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/phong.frag new file mode 100644 index 0000000..fdea058 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/phong.frag @@ -0,0 +1,123 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2007 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 GLSL fragment program for handling 1 directional light with specular. +// This implements per-pixel lighting (Phong shading) + +uniform vec4 glLightSource0position; +uniform vec4 glLightSource0diffuse; + +uniform vec4 glLightModelambient; + +uniform vec4 glFrontMaterialdiffuse; +uniform float glFrontMaterialshininess; +uniform vec3 glFrontMaterialspecular; + +varying vec3 worldPos; + +void directionalLight0(in vec3 normal, inout vec4 ambient, inout vec4 diffuse, inout vec3 specular) +{ + // Normalized light direction and half vector + vec3 lightDirection = normalize(vec3(glLightSource0position)); + + + // half vector requires a few calcs + //vec3 halfVector = normalize(vec3(gl_LightSource[0].halfVector)); + + vec3 L = normalize(glLightSource0position.xyz - worldPos); + vec3 V = vec3(0,0,1);//eye position + vec3 halfVector = (L + V); + + + 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, glFrontMaterialshininess); + } + + // GL2ES2: ambient is part of light model + //ambient += gl_LightSource[0].ambient; + ambient += glLightModelambient; + diffuse += glLightSource0diffuse * nDotVP; + + // GL2ES2: specular is part of material + //specular += gl_LightSource[0].specular * pf; + specular += glFrontMaterialspecular * pf; +} + + +// Per-pixel normal (input from vertex shader) +varying vec3 Normal; + +void main() +{ + vec3 unitNorm = normalize(Normal); + vec4 amb = vec4(0.0); + vec4 diff = vec4(0.0); + vec3 spec = vec3(0.0); + int i; + + + directionalLight0(unitNorm, amb, diff, spec); + + + // Apply the result of the lighting equation + vec4 secondaryColor = vec4(spec * glFrontMaterialspecular, 1.0); + // GL2ES2: need to look up the calculations on sceneColor + //vec4 color = vec4(vec3(gl_FrontLightModelProduct.sceneColor + + // amb * glFrontMaterialambient + + vec4 color = vec4(vec3(glFrontMaterialdiffuse + + amb * glLightModelambient + + diff * glFrontMaterialdiffuse), 1.0); + + gl_FragColor = color + secondaryColor; +} diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/phong.vert b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/phong.vert new file mode 100644 index 0000000..b436ee2 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/phong.vert @@ -0,0 +1,70 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2007 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 GLSL vertex program for doing Phone shading (per-fragment lighting) + + +// GL2ES2: Java3D built-in attributes, these are calculated and passsed in if declared here +attribute vec4 glVertex; +attribute vec3 glNormal; + +// GL2ES2: Java3D built-in uniforms, these are calculated and passsed in if declared here +uniform mat4 glModelViewProjectionMatrix; +uniform mat4 glModelViewMatrix; +uniform mat3 glNormalMatrix; + +// Per-pixel normal (output to fragment shader) +varying vec3 Normal; +varying vec3 worldPos; + + +void main() +{ + Normal = normalize(vec3(glNormalMatrix * glNormal)); + + worldPos = vec3(glModelViewMatrix * glVertex); + + // Transform the vertex + gl_Position = glModelViewProjectionMatrix * glVertex; +} diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/polkadot3d.frag b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/polkadot3d.frag new file mode 100644 index 0000000..605cb5f --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/polkadot3d.frag @@ -0,0 +1,49 @@ +// +// Fragment shader for 3 dimensional polka dot shader. +// +// Author: Joshua Doss +// +// Copyright (C) 2002-2004 3Dlabs Inc. Ltd. +// +// See 3Dlabs-License.txt for license information +// +varying float LightIntensity; +varying vec3 MCPosition; + +//Create uniform variables so dots can be spaced and scaled by user +//uniform vec3 Spacing; +//uniform float DotSize; +const vec3 Spacing = vec3 (0.314, 0.36, 0.261); +const float DotSize = 0.123; + +//Create colors as uniform variables so they can be easily changed +//uniform vec3 ModelColor, PolkaDotColor; +const vec3 ModelColor = vec3 (0.75, 0.2, 0.1); +const vec3 PolkaDotColor = vec3 (1, 1, 1); + +void main(void) +{ + float insidesphere, sphereradius, scaledpointlength; + vec3 scaledpoint, finalcolor; + + // Scale the coordinate system + // The following line of code is not yet implemented in current drivers: + // mcpos = mod(Spacing, MCposition); + // We will use a workaround found below for now + scaledpoint = MCPosition - (Spacing * floor(MCPosition/Spacing)); + + // Bring the scaledpoint vector into the center of the scaled coordinate system + scaledpoint = scaledpoint - Spacing/2.0; + + // Find the length of the scaledpoint vector and compare it to the dotsize + scaledpointlength = length(scaledpoint); + insidesphere = step(scaledpointlength,DotSize); + + // Determine final output color before lighting + finalcolor = vec3(mix(ModelColor, PolkaDotColor, insidesphere)); + + // Output final color and factor in lighting + // GL2ES2: gl_FragColor is unchanged + gl_FragColor = clamp((vec4( finalcolor, 1.0 ) * LightIntensity), vec4(0.0), vec4(1.0)); +} + diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/polkadot3d.vert b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/polkadot3d.vert new file mode 100644 index 0000000..0422670 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/polkadot3d.vert @@ -0,0 +1,75 @@ +// This is the Vertex Shader for three dimensional polka dots. +// +// author(s): Joshua Doss +// +// Copyright (C) 2002-2004 3Dlabs Inc. Ltd. + +// GL2ES2: Java3D built-in attributes, these are calculated and passsed in if declared here +attribute vec4 glVertex; +attribute vec3 glNormal; + +// GL2ES2: Java3D built-in uniforms, these are calculated and passsed in if declared here +uniform mat4 glModelViewMatrix; +uniform mat4 glModelViewProjectionMatrix; +uniform mat3 glNormalMatrix; + +//Create uniform variables for lighting to allow user interaction +//uniform float SpecularContribution; +//uniform vec3 LightPosition; + +const float SpecularContribution = 0.36; +const vec3 LightPosition = vec3 (0, 4, 5); + +varying vec3 MCPosition; +varying float LightIntensity; + +void main(void) +{ + float diffusecontribution = 1.0 - SpecularContribution; + + // compute the vertex position in eye coordinates + // GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top) + //vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex); + vec3 ecPosition = vec3(glModelViewMatrix * glVertex); + + // compute the transformed normal + // GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top) + //vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal); + vec3 tnorm = normalize(glNormalMatrix * glNormal); + + // compute a vector from the model to the light position + vec3 lightVec = normalize(LightPosition - ecPosition); + + // compute the reflection vector + vec3 reflectVec = reflect(-lightVec, tnorm); + + // compute a unit vector in direction of viewing position + vec3 viewVec = normalize(-ecPosition); + + // calculate amount of diffuse light based on normal and light angle + float diffuse = max(dot(lightVec, tnorm), 0.0); + float spec = 0.0; + + // if there is diffuse lighting, calculate specular + if(diffuse > 0.0) + { + spec = max(dot(reflectVec, viewVec), 0.0); + spec = pow(spec, 16.0); + } + + // add up the light sources, since this is a varying (global) it will pass to frag shader + LightIntensity = diffusecontribution * diffuse * 1.5 + + SpecularContribution * spec; + + // the varying variable MCPosition will be used by the fragment shader to determine where + // in model space the current pixel is + // GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top) + //MCPosition = vec3 (gl_Vertex); + MCPosition = vec3 (glVertex); + + // send vertex information + // GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top) + //gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_Position = glModelViewProjectionMatrix * glVertex; +} + diff --git a/src/classes/org/jdesktop/j3d/examples/cg_shader/simple_fp.cg b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/simple.frag index 85840c5..96a6e64 100644 --- a/src/classes/org/jdesktop/j3d/examples/cg_shader/simple_fp.cg +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/simple.frag @@ -42,27 +42,27 @@ * $State$ */ -// Simple fragment program to attenuate the input fragment color as a +// 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 -// define inputs from vertex shader to fragment shader -struct vertin -{ - float4 HPosition : POSITION; - float4 FragPos : TEXCOORD0; - float4 Color0 : COLOR0; -}; +//GL2ES2: varying color data needs to be defined +varying vec4 glFrontColor; +varying vec4 glFrontSecondaryColor; + +//GL2ES2: see particle system point size for mechanism +const float windowSize = 700.0; // TODO: this should be a built-in parameter! -float4 main(vertin IN) : COLOR +void main() { // Compute distance from center in range [0.0, 1.0] - float2 dist = min(abs(IN.FragPos.xy), 1.0f); - float2 invDist = 1.0f - dist; + //GL2ES2: gl_FragCoord still exists + 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; - float4 outcolor = float4(IN.Color0 * atten); + vec4 outcolor = (glFrontColor + glFrontSecondaryColor) * atten; - return outcolor; + gl_FragColor = outcolor; } diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/simple.vert b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/simple.vert new file mode 100644 index 0000000..96ccf6b --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/simple.vert @@ -0,0 +1,174 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2007 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 + +// GL2ES2: Java3D built-in attributes, these are calculated and passsed in if declared here +attribute vec4 glVertex; +attribute vec3 glNormal; +attribute vec4 glColor; + +// GL2ES2: Java3D built-in uniforms, these are calculated and passsed in if declared here +uniform mat4 glModelViewMatrix; +uniform mat4 glModelViewProjectionMatrix; +uniform mat3 glNormalMatrix; + +uniform vec4 glFrontMaterialdiffuse; +uniform vec4 glFrontMaterialemission; +uniform vec3 glFrontMaterialspecular; +uniform float glFrontMaterialshininess; +uniform int ignoreVertexColors; + +uniform vec4 glLightModelambient; + +uniform vec4 glLightSource0position; +uniform vec4 glLightSource0diffuse; + +//GL2ES2: varying color data needs to be defined +varying vec4 glFrontColor; +varying vec4 glFrontSecondaryColor; + +void directionalLight( + in int i, + in vec3 normal, + inout vec4 ambient, + inout vec4 diffuse, + inout vec3 specular) +{ + // Normalized light direction and half vector + // (shouldn't they be pre-normalized?!) + + //GL2ES2 notice not using the i parameter but hard coded to 0 + vec3 lightDirection = normalize(vec3(glLightSource0position)); + + //GL2ES2: half vector must be calculated + //vec3 halfVector = normalize(vec3(gl_LightSource[0].halfVector)); + vec3 worldPos = vec3(glModelViewMatrix * glVertex); + vec3 L = normalize(glLightSource0position.xyz - worldPos); + vec3 V = vec3(0,0,1);//eye position + vec3 halfVector = (L + V); + + + + 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, glFrontMaterialshininess); + } + + ambient += glLightModelambient; + diffuse += glLightSource0diffuse * nDotVP; + specular += glFrontMaterialspecular * pf; +} + +//GL2ES2: only a single light for now +const int numEnabledLights = 1; // TODO: this should be a built-in parameter! + +void main() +{ + //vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex; + //vec3 ecPosition3 = ecPosition.xyz / ecPosition.w; + // GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top) + //vec3 tnorm = normalize(vec3(gl_NormalMatrix * gl_Normal)); + vec3 tnorm = normalize(vec3(glNormalMatrix * glNormal)); + vec4 amb = vec4(0.0); + vec4 diff = vec4(0.0); + vec3 spec = vec3(0.0); + int i; + + // Transform the vertex + // GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top) + //vec4 outPosition = gl_ModelViewProjectionMatrix * gl_Vertex; + vec4 outPosition = glModelViewProjectionMatrix * glVertex; + + for (i = 0; i < numEnabledLights; i++) { + directionalLight(i, tnorm, amb, diff, spec); + } + + vec4 sceneColor; + if( ignoreVertexColors != 0) + sceneColor = glFrontMaterialdiffuse; + else + sceneColor = glColor; + + // Apply the result of the lighting equation + vec4 outSecondaryColor = vec4(vec3(spec * glFrontMaterialspecular), 1.0); + vec3 color0 = vec3(sceneColor + + amb * glLightModelambient + + diff * glFrontMaterialdiffuse); + + // 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); + + glFrontColor = outColor; + glFrontSecondaryColor = outSecondaryColor; + gl_Position = outPosition; +} diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/toon.frag b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/toon.frag new file mode 100644 index 0000000..fa50453 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/toon.frag @@ -0,0 +1,34 @@ +// +// Fragment shader for cartoon-style shading +// +// Author: Philip Rideout +// +// Copyright (c) 2004 3Dlabs Inc. Ltd. +// +// See 3Dlabs-License.txt for license information +// + +//uniform vec3 DiffuseColor; +//uniform vec3 PhongColor; +//uniform float Edge; +//uniform float Phong; + +vec3 DiffuseColor = vec3(0.5,0.5,1.0); +vec3 PhongColor = vec3(0.75,0.75,1.0); +float Edge = 0.64; +float Phong = 0.90; + +varying vec3 Normal; +varying vec3 LightDir; + +void main (void) +{ + vec3 color = DiffuseColor; + float f = max( 0.0, dot(LightDir,Normal)); + if (abs(f) < Edge) + color = DiffuseColor * 0.2; + if (f > Phong) + color = PhongColor; + + gl_FragColor = vec4(color, 1); +} diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/toon.vert b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/toon.vert new file mode 100644 index 0000000..d044af7 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/toon.vert @@ -0,0 +1,19 @@ +// +// Vertex shader for cartoon-style shading +// +// Author: Philip Rideout +// +// Copyright (c) 2004 3Dlabs Inc. Ltd. +// +// See 3Dlabs-License.txt for license information +// + +varying vec3 Normal; +varying vec3 LightDir; + +void main(void) +{ + Normal = normalize(gl_NormalMatrix * gl_Normal); + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + LightDir = vec3(normalize(gl_LightSource[0].position)); +} diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/vertexshader.frag b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/vertexshader.frag new file mode 100644 index 0000000..029b044 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/vertexshader.frag @@ -0,0 +1,52 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2007 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$ + */ + + +//GL2ES2: varying color data needs to be defined +varying vec4 glFrontColor; + +void main() +{ + gl_FragColor = glFrontColor; +} diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/vertexshader.vert b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/vertexshader.vert new file mode 100644 index 0000000..12f3662 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/vertexshader.vert @@ -0,0 +1,70 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2007 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$ + */ + +// GL2ES2: Java3D built-in attributes, these are calculated and passsed in if declared here +attribute vec4 glVertex; + +// GL2ES2: Java3D built-in uniforms, these are calculated and passsed in if declared here +uniform mat4 glModelViewProjectionMatrix; + +// A simple GLSL vertex program for demo. vertex attributes + +attribute float weight; +attribute vec3 temperature; + +//GL2ES2: varying color data needs to be defined +varying vec4 glFrontColor; + +void main() +{ + // Transform the vertex + vec4 outPosition = glModelViewProjectionMatrix * glVertex; + + // Compute color from temperature + vec4 outColor; + outColor = vec4(temperature * weight, 1); + // Assign output parameters + glFrontColor = outColor; + gl_Position = outPosition; +} diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/wood.frag b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/wood.frag new file mode 100644 index 0000000..6686190 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/wood.frag @@ -0,0 +1,67 @@ +// +// Simple fragment shader for wood +// +// Author: John Kessenich +// +// Copyright (c) 2002-2004 3Dlabs Inc. Ltd. +// +// See 3Dlabs-License.txt for license information +// + +//uniform float GrainSizeRecip; +//uniform vec3 DarkColor; +//uniform vec3 spread; +const float GrainSizeRecip = 1.0; +const vec3 DarkColor = vec3 (0.6, 0.3, 0.1); +const vec3 spread = vec3 (0.15, 0.075, 0.0); + +varying float lightIntensity; +varying vec3 Position; + +void main (void) +{ + // + // cheap noise + // + vec3 location = Position; + vec3 floorvec = vec3(floor(10.0 * Position.x), 0.0, floor(10.0 * Position.z)); + vec3 noise = Position * 10.0 - floorvec - 0.5; + noise *= noise; + location += noise * 0.12; + + // + // distance from axis + // + float dist = location.x * location.x + location.z * location.z; + float grain = dist * GrainSizeRecip; + + // + // grain effects as function of distance + // + float brightness = fract(grain); + if (brightness > 0.5) + brightness = (1.0 - brightness); + vec3 color = DarkColor + brightness * spread; + + brightness = fract(grain * 7.0); + if (brightness > 0.5) + brightness = 1.0 - brightness; + color -= brightness * spread; + + // + // also as a function of lines parallel to the axis + // + brightness = fract(grain * 47.0) * 0.60; + float line = fract(Position.z + Position.x); + float snap = floor(line * 20.0) * (1.0/20.0); + if (line < snap + 0.006) + color -= brightness * spread; + + // + // apply lighting effects from vertex processor + // + color = clamp(color * lightIntensity, 0.0, 1.0); + + // GL2ES2: gl_FragColor is unchanged + gl_FragColor = vec4(color, 1.0); +} diff --git a/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/wood.vert b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/wood.vert new file mode 100644 index 0000000..e04ba6d --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gl2es2pipeline/wood.vert @@ -0,0 +1,43 @@ +// +// Simple vertex shader for wood +// +// Author: John Kessenich +// +// Copyright (c) 2002-2004 3Dlabs Inc. Ltd. +// +// See 3Dlabs-License.txt for license information +// + +// GL2ES2: Java3D built-in attributes, these are calculated and passsed in if declared here +attribute vec4 glVertex; +attribute vec3 glNormal; + +// GL2ES2: Java3D built-in uniforms, these are calculated and passsed in if declared here +uniform mat4 glModelViewMatrix; +uniform mat4 glModelViewProjectionMatrix; +uniform mat3 glNormalMatrix; + +varying float lightIntensity; +varying vec3 Position; +//uniform vec3 LightPosition; +//uniform float Scale; +const vec3 LightPosition = vec3 (0.0,0.0,0.4); +const float Scale = 1.0; + +void main(void) +{ + // GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top) + //vec4 pos = glModelViewMatrix * glVertex; + vec4 pos = glModelViewMatrix * glVertex; + // GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top) + //Position = vec3(glVertex) * Scale; + Position = vec3(glVertex) * Scale; + // GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top) + //vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal); + vec3 tnorm = normalize(glNormalMatrix * glNormal); + lightIntensity = max(dot(normalize(LightPosition - vec3(pos)), tnorm), 0.0) * 1.5; + + // GL2ES2: swap built-in variable for Java3d built-in uniforms and attributes gl_* = gl* + declaration (at top) + //gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; + gl_Position = glModelViewProjectionMatrix * glVertex; +} diff --git a/src/classes/org/jdesktop/j3d/examples/glsl_shader/EnvironmentMappingGLSL.java b/src/classes/org/jdesktop/j3d/examples/glsl_shader/EnvironmentMappingGLSL.java index 3259505..ff5e9cd 100644 --- a/src/classes/org/jdesktop/j3d/examples/glsl_shader/EnvironmentMappingGLSL.java +++ b/src/classes/org/jdesktop/j3d/examples/glsl_shader/EnvironmentMappingGLSL.java @@ -44,17 +44,40 @@ package org.jdesktop.j3d.examples.glsl_shader; -import com.sun.j3d.utils.universe.*; -import com.sun.j3d.utils.geometry.Sphere; -import com.sun.j3d.utils.image.TextureLoader; -import com.sun.j3d.utils.shader.StringIO; -import javax.media.j3d.*; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; import java.io.IOException; import java.net.URL; + import javax.swing.JOptionPane; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.GLSLShaderProgram; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Shader; +import org.jogamp.java3d.ShaderAppearance; +import org.jogamp.java3d.ShaderAttribute; +import org.jogamp.java3d.ShaderAttributeSet; +import org.jogamp.java3d.ShaderAttributeValue; +import org.jogamp.java3d.ShaderError; +import org.jogamp.java3d.ShaderErrorListener; +import org.jogamp.java3d.ShaderProgram; +import org.jogamp.java3d.SourceCodeShader; +import org.jogamp.java3d.Texture; +import org.jogamp.java3d.TextureUnitState; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.image.TextureLoader; +import org.jogamp.java3d.utils.shader.StringIO; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; public class EnvironmentMappingGLSL extends javax.swing.JFrame { diff --git a/src/classes/org/jdesktop/j3d/examples/glsl_shader/ObjLoadGLSL.java b/src/classes/org/jdesktop/j3d/examples/glsl_shader/ObjLoadGLSL.java index 6e0679a..2feb50a 100644 --- a/src/classes/org/jdesktop/j3d/examples/glsl_shader/ObjLoadGLSL.java +++ b/src/classes/org/jdesktop/j3d/examples/glsl_shader/ObjLoadGLSL.java @@ -44,23 +44,49 @@ package org.jdesktop.j3d.examples.glsl_shader; -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 com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; +import java.io.FileNotFoundException; +import java.io.IOException; import java.net.MalformedURLException; -import java.util.Enumeration; -import java.io.*; import java.net.URL; -import com.sun.j3d.utils.behaviors.vp.*; -import java.io.FileNotFoundException; +import java.util.Enumeration; + import javax.swing.JOptionPane; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.GLSLShaderProgram; +import org.jogamp.java3d.Group; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.Node; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Shader; +import org.jogamp.java3d.ShaderAppearance; +import org.jogamp.java3d.ShaderError; +import org.jogamp.java3d.ShaderErrorListener; +import org.jogamp.java3d.ShaderProgram; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.SourceCodeShader; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.loaders.IncorrectFormatException; +import org.jogamp.java3d.loaders.ParsingErrorException; +import org.jogamp.java3d.loaders.Scene; +import org.jogamp.java3d.loaders.objectfile.ObjectFile; +import org.jogamp.java3d.utils.behaviors.vp.OrbitBehavior; +import org.jogamp.java3d.utils.shader.StringIO; +import org.jogamp.java3d.utils.universe.PlatformGeometry; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3f; /** * Simple Java 3D example program to display an .obj object with shader programs. diff --git a/src/classes/org/jdesktop/j3d/examples/glsl_shader/PhongShadingGLSL.java b/src/classes/org/jdesktop/j3d/examples/glsl_shader/PhongShadingGLSL.java index a54d553..45b4b94 100644 --- a/src/classes/org/jdesktop/j3d/examples/glsl_shader/PhongShadingGLSL.java +++ b/src/classes/org/jdesktop/j3d/examples/glsl_shader/PhongShadingGLSL.java @@ -44,15 +44,43 @@ package org.jdesktop.j3d.examples.glsl_shader; -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.swing.JOptionPane; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; import java.io.IOException; + +import javax.swing.JOptionPane; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ColoringAttributes; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.GLSLShaderProgram; +import org.jogamp.java3d.Light; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.PointLight; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Shader; +import org.jogamp.java3d.ShaderAppearance; +import org.jogamp.java3d.ShaderError; +import org.jogamp.java3d.ShaderErrorListener; +import org.jogamp.java3d.ShaderProgram; +import org.jogamp.java3d.SourceCodeShader; +import org.jogamp.java3d.SpotLight; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.shader.StringIO; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; /** * diff --git a/src/classes/org/jdesktop/j3d/examples/glsl_shader/SamplerTestGLSL.java b/src/classes/org/jdesktop/j3d/examples/glsl_shader/SamplerTestGLSL.java index 6abac23..d2c3265 100644 --- a/src/classes/org/jdesktop/j3d/examples/glsl_shader/SamplerTestGLSL.java +++ b/src/classes/org/jdesktop/j3d/examples/glsl_shader/SamplerTestGLSL.java @@ -44,17 +44,40 @@ package org.jdesktop.j3d.examples.glsl_shader; -import com.sun.j3d.utils.universe.*; -import com.sun.j3d.utils.geometry.Sphere; -import com.sun.j3d.utils.image.TextureLoader; -import com.sun.j3d.utils.shader.StringIO; -import javax.media.j3d.*; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; import java.io.IOException; import java.net.URL; + import javax.swing.JOptionPane; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.GLSLShaderProgram; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Shader; +import org.jogamp.java3d.ShaderAppearance; +import org.jogamp.java3d.ShaderAttribute; +import org.jogamp.java3d.ShaderAttributeSet; +import org.jogamp.java3d.ShaderAttributeValue; +import org.jogamp.java3d.ShaderError; +import org.jogamp.java3d.ShaderErrorListener; +import org.jogamp.java3d.ShaderProgram; +import org.jogamp.java3d.SourceCodeShader; +import org.jogamp.java3d.TexCoordGeneration; +import org.jogamp.java3d.Texture; +import org.jogamp.java3d.TextureUnitState; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.image.TextureLoader; +import org.jogamp.java3d.utils.shader.StringIO; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector4f; public class SamplerTestGLSL extends javax.swing.JFrame { diff --git a/src/classes/org/jdesktop/j3d/examples/glsl_shader/ShaderTestGLSL.java b/src/classes/org/jdesktop/j3d/examples/glsl_shader/ShaderTestGLSL.java index 090d55d..f7f82e9 100644 --- a/src/classes/org/jdesktop/j3d/examples/glsl_shader/ShaderTestGLSL.java +++ b/src/classes/org/jdesktop/j3d/examples/glsl_shader/ShaderTestGLSL.java @@ -44,15 +44,41 @@ package org.jdesktop.j3d.examples.glsl_shader; -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.awt.GraphicsConfiguration; import java.io.IOException; + import javax.swing.JOptionPane; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.GLSLShaderProgram; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.PositionInterpolator; +import org.jogamp.java3d.Shader; +import org.jogamp.java3d.ShaderAppearance; +import org.jogamp.java3d.ShaderAttributeObject; +import org.jogamp.java3d.ShaderAttributeSet; +import org.jogamp.java3d.ShaderAttributeValue; +import org.jogamp.java3d.ShaderError; +import org.jogamp.java3d.ShaderErrorListener; +import org.jogamp.java3d.ShaderProgram; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.SourceCodeShader; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.View; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.shader.StringIO; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; public class ShaderTestGLSL extends javax.swing.JFrame { diff --git a/src/classes/org/jdesktop/j3d/examples/glsl_shader/SphereGLSL.java b/src/classes/org/jdesktop/j3d/examples/glsl_shader/SphereGLSL.java index ca75cdc..5d869c9 100644 --- a/src/classes/org/jdesktop/j3d/examples/glsl_shader/SphereGLSL.java +++ b/src/classes/org/jdesktop/j3d/examples/glsl_shader/SphereGLSL.java @@ -44,15 +44,44 @@ package org.jdesktop.j3d.examples.glsl_shader; -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.awt.GraphicsConfiguration; -import java.io.*; +import java.io.IOException; + import javax.swing.JOptionPane; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ColoringAttributes; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.GLSLShaderProgram; +import org.jogamp.java3d.Light; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.PointLight; +import org.jogamp.java3d.PositionInterpolator; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Shader; +import org.jogamp.java3d.ShaderAppearance; +import org.jogamp.java3d.ShaderError; +import org.jogamp.java3d.ShaderErrorListener; +import org.jogamp.java3d.ShaderProgram; +import org.jogamp.java3d.SourceCodeShader; +import org.jogamp.java3d.SpotLight; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.shader.StringIO; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; /** * Simple Java 3D example program with programmable shader. diff --git a/src/classes/org/jdesktop/j3d/examples/glsl_shader/VertexAttrTestGLSL.java b/src/classes/org/jdesktop/j3d/examples/glsl_shader/VertexAttrTestGLSL.java index 4cac630..014c0e9 100644 --- a/src/classes/org/jdesktop/j3d/examples/glsl_shader/VertexAttrTestGLSL.java +++ b/src/classes/org/jdesktop/j3d/examples/glsl_shader/VertexAttrTestGLSL.java @@ -44,19 +44,38 @@ package org.jdesktop.j3d.examples.glsl_shader; -import com.sun.j3d.utils.universe.*; -import com.sun.j3d.utils.shader.StringIO; -import javax.media.j3d.*; import java.awt.GraphicsConfiguration; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; + import javax.swing.JFrame; import javax.swing.JOptionPane; -import javax.vecmath.Color3f; -import javax.vecmath.Point3d; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.GLSLShaderProgram; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.J3DBuffer; +import org.jogamp.java3d.Shader; +import org.jogamp.java3d.ShaderAppearance; +import org.jogamp.java3d.ShaderError; +import org.jogamp.java3d.ShaderErrorListener; +import org.jogamp.java3d.ShaderProgram; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.SourceCodeShader; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.TriangleArray; +import org.jogamp.java3d.utils.shader.StringIO; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; public class VertexAttrTestGLSL extends javax.swing.JFrame { diff --git a/src/classes/org/jdesktop/j3d/examples/hello_universe/HelloUniverse.java b/src/classes/org/jdesktop/j3d/examples/hello_universe/HelloUniverse.java index 451de6a..a085405 100644 --- a/src/classes/org/jdesktop/j3d/examples/hello_universe/HelloUniverse.java +++ b/src/classes/org/jdesktop/j3d/examples/hello_universe/HelloUniverse.java @@ -44,12 +44,19 @@ package org.jdesktop.j3d.examples.hello_universe; -import com.sun.j3d.utils.universe.*; -import com.sun.j3d.utils.geometry.ColorCube; -import javax.media.j3d.*; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.geometry.ColorCube; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Point3d; + /** * Simple Java 3D example program to display a spinning cube. */ @@ -154,7 +161,7 @@ public class HelloUniverse extends javax.swing.JFrame { /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new HelloUniverse().setVisible(true); diff --git a/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JCanvas3DExample.java b/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JCanvas3DExample.java index 4ebd367..1a83fdd 100644 --- a/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JCanvas3DExample.java +++ b/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JCanvas3DExample.java @@ -49,7 +49,6 @@ package org.jdesktop.j3d.examples.jcanvas3d; * Simple Java 3D example program that displays universes within lightweight swing components, layed in JInternalFrame objects. */ import java.awt.Toolkit; -import javax.swing.table.DefaultTableModel; public class JCanvas3DExample extends javax.swing.JFrame implements java.awt.event.ActionListener { diff --git a/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JInternalWorld.java b/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JInternalWorld.java index 43f06e5..e702bc2 100644 --- a/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JInternalWorld.java +++ b/src/classes/org/jdesktop/j3d/examples/jcanvas3d/JInternalWorld.java @@ -44,38 +44,36 @@ package org.jdesktop.j3d.examples.jcanvas3d; -import com.sun.j3d.exp.swing.JCanvas3D; -import com.sun.j3d.utils.behaviors.mouse.MouseRotate; -import com.sun.j3d.utils.universe.SimpleUniverse; - import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; import java.awt.Font; -import javax.media.j3d.Alpha; -import javax.media.j3d.AmbientLight; -import javax.media.j3d.Appearance; -import javax.media.j3d.BoundingSphere; -import javax.media.j3d.BranchGroup; -import javax.media.j3d.DirectionalLight; -import javax.media.j3d.Font3D; -import javax.media.j3d.FontExtrusion; -import javax.media.j3d.GraphicsConfigTemplate3D; -import javax.media.j3d.Material; -import javax.media.j3d.RotationInterpolator; -import javax.media.j3d.Shape3D; -import javax.media.j3d.Text3D; -import javax.media.j3d.Transform3D; -import javax.media.j3d.TransformGroup; - import javax.swing.JInternalFrame; -import javax.vecmath.Color3f; -import javax.vecmath.Point3d; -import javax.vecmath.Point3f; -import javax.vecmath.Vector3d; -import javax.vecmath.Vector3f; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Font3D; +import org.jogamp.java3d.FontExtrusion; +import org.jogamp.java3d.GraphicsConfigTemplate3D; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Text3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.exp.swing.JCanvas3D; +import org.jogamp.java3d.utils.behaviors.mouse.MouseRotate; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; /** diff --git a/src/classes/org/jdesktop/j3d/examples/lightwave/Viewer.java b/src/classes/org/jdesktop/j3d/examples/lightwave/Viewer.java index 489678f..063c7cc 100644 --- a/src/classes/org/jdesktop/j3d/examples/lightwave/Viewer.java +++ b/src/classes/org/jdesktop/j3d/examples/lightwave/Viewer.java @@ -45,20 +45,20 @@ package org.jdesktop.j3d.examples.lightwave; import java.applet.Applet; -import java.awt.*; - -import javax.media.j3d.BranchGroup; -import javax.media.j3d.Canvas3D; -import javax.media.j3d.Transform3D; -import javax.media.j3d.TransformGroup; -import javax.media.j3d.View; -import javax.vecmath.Matrix4d; - -import com.sun.j3d.loaders.lw3d.Lw3dLoader; -import com.sun.j3d.loaders.Loader; -import com.sun.j3d.loaders.Scene; -import com.sun.j3d.utils.applet.MainFrame; -import com.sun.j3d.utils.universe.SimpleUniverse; +import java.awt.BorderLayout; +import java.awt.GraphicsConfiguration; + +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.View; +import org.jogamp.java3d.loaders.Loader; +import org.jogamp.java3d.loaders.Scene; +import org.jogamp.java3d.loaders.lw3d.Lw3dLoader; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Matrix4d; /** @@ -80,7 +80,7 @@ public class Viewer extends Applet { public Viewer() {} - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); if (filename == null) { // the path to the file for an applet try { @@ -172,7 +172,7 @@ public class Viewer extends Applet { * file must be reachable from the directory in which you're running * this application. */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.net.URL url = null; java.net.URL pathUrl = null; if (args.length > 0) { diff --git a/src/classes/org/jdesktop/j3d/examples/lod/LOD.java b/src/classes/org/jdesktop/j3d/examples/lod/LOD.java index d421761..67aac84 100644 --- a/src/classes/org/jdesktop/j3d/examples/lod/LOD.java +++ b/src/classes/org/jdesktop/j3d/examples/lod/LOD.java @@ -44,13 +44,24 @@ package org.jdesktop.j3d.examples.lod; -import com.sun.j3d.utils.geometry.*; -import com.sun.j3d.utils.behaviors.vp.*; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.DistanceLOD; +import org.jogamp.java3d.Switch; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.behaviors.vp.OrbitBehavior; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3f; + /** * Simple Java 3D example program to display a spinning cube. */ @@ -76,8 +87,8 @@ public class LOD extends javax.swing.JFrame { // Create a switch to hold the different levels of detail Switch sw = new Switch(0); - sw.setCapability(javax.media.j3d.Switch.ALLOW_SWITCH_READ); - sw.setCapability(javax.media.j3d.Switch.ALLOW_SWITCH_WRITE); + sw.setCapability(Switch.ALLOW_SWITCH_READ); + sw.setCapability(Switch.ALLOW_SWITCH_WRITE); // Create several levels for the switch, with less detailed @@ -209,7 +220,7 @@ public class LOD extends javax.swing.JFrame { /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new LOD().setVisible(true); diff --git a/src/classes/org/jdesktop/j3d/examples/model_clip/ModelClipTest.java b/src/classes/org/jdesktop/j3d/examples/model_clip/ModelClipTest.java index 8880697..618b7f2 100644 --- a/src/classes/org/jdesktop/j3d/examples/model_clip/ModelClipTest.java +++ b/src/classes/org/jdesktop/j3d/examples/model_clip/ModelClipTest.java @@ -44,15 +44,29 @@ package org.jdesktop.j3d.examples.model_clip; -import com.sun.j3d.utils.behaviors.mouse.*; -import com.sun.j3d.utils.geometry.Cylinder; 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.awt.BorderLayout; +import java.awt.GraphicsConfiguration; + +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.ModelClip; +import org.jogamp.java3d.PolygonAttributes; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.behaviors.mouse.MouseRotate; +import org.jogamp.java3d.utils.behaviors.mouse.MouseZoom; +import org.jogamp.java3d.utils.geometry.Cylinder; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3f; +import org.jogamp.vecmath.Vector4d; /** * ModelClipTest draws a cylinder and creates two clip planes @@ -141,7 +155,7 @@ public class ModelClipTest extends Applet { public ModelClipTest (){ } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); diff --git a/src/classes/org/jdesktop/j3d/examples/model_clip/ModelClipTest2.java b/src/classes/org/jdesktop/j3d/examples/model_clip/ModelClipTest2.java index 34e4e98..ef5a407 100644 --- a/src/classes/org/jdesktop/j3d/examples/model_clip/ModelClipTest2.java +++ b/src/classes/org/jdesktop/j3d/examples/model_clip/ModelClipTest2.java @@ -44,16 +44,32 @@ package org.jdesktop.j3d.examples.model_clip; -import com.sun.j3d.utils.behaviors.mouse.*; -import com.sun.j3d.utils.geometry.Cylinder; -import com.sun.j3d.utils.geometry.Box; 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.awt.BorderLayout; +import java.awt.GraphicsConfiguration; + +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.ModelClip; +import org.jogamp.java3d.PolygonAttributes; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.behaviors.mouse.MouseRotate; +import org.jogamp.java3d.utils.behaviors.mouse.MouseZoom; +import org.jogamp.java3d.utils.geometry.Box; +import org.jogamp.java3d.utils.geometry.Cylinder; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.AxisAngle4f; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3f; +import org.jogamp.vecmath.Vector4d; /** * ModelClipTest2 draws a cylinder and creates two clip planes @@ -161,7 +177,7 @@ public class ModelClipTest2 extends Applet { public ModelClipTest2 (){ } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); diff --git a/src/classes/org/jdesktop/j3d/examples/morphing/ColorCube.java b/src/classes/org/jdesktop/j3d/examples/morphing/ColorCube.java index 07f6045..df36e9d 100644 --- a/src/classes/org/jdesktop/j3d/examples/morphing/ColorCube.java +++ b/src/classes/org/jdesktop/j3d/examples/morphing/ColorCube.java @@ -44,8 +44,7 @@ package org.jdesktop.j3d.examples.morphing; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.QuadArray; class ColorCube extends QuadArray { private static final float[] verts = { diff --git a/src/classes/org/jdesktop/j3d/examples/morphing/ColorPyramidDown.java b/src/classes/org/jdesktop/j3d/examples/morphing/ColorPyramidDown.java index 6301ab0..89d1a8b 100644 --- a/src/classes/org/jdesktop/j3d/examples/morphing/ColorPyramidDown.java +++ b/src/classes/org/jdesktop/j3d/examples/morphing/ColorPyramidDown.java @@ -44,8 +44,7 @@ package org.jdesktop.j3d.examples.morphing; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.QuadArray; class ColorPyramidDown extends QuadArray { private static final float[] verts = { diff --git a/src/classes/org/jdesktop/j3d/examples/morphing/ColorPyramidUp.java b/src/classes/org/jdesktop/j3d/examples/morphing/ColorPyramidUp.java index 4ce39fc..b94e6f0 100644 --- a/src/classes/org/jdesktop/j3d/examples/morphing/ColorPyramidUp.java +++ b/src/classes/org/jdesktop/j3d/examples/morphing/ColorPyramidUp.java @@ -44,8 +44,7 @@ package org.jdesktop.j3d.examples.morphing; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.QuadArray; class ColorPyramidUp extends QuadArray { private static final float[] verts = { diff --git a/src/classes/org/jdesktop/j3d/examples/morphing/Morphing.java b/src/classes/org/jdesktop/j3d/examples/morphing/Morphing.java index 11023f9..4604f66 100644 --- a/src/classes/org/jdesktop/j3d/examples/morphing/Morphing.java +++ b/src/classes/org/jdesktop/j3d/examples/morphing/Morphing.java @@ -44,16 +44,33 @@ package org.jdesktop.j3d.examples.morphing; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; -import java.io.*; -import com.sun.j3d.loaders.objectfile.ObjectFile; -import com.sun.j3d.loaders.Scene; -import com.sun.j3d.loaders.ParsingErrorException; -import com.sun.j3d.loaders.IncorrectFormatException; +import java.io.FileNotFoundException; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.Morph; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.loaders.IncorrectFormatException; +import org.jogamp.java3d.loaders.ParsingErrorException; +import org.jogamp.java3d.loaders.Scene; +import org.jogamp.java3d.loaders.objectfile.ObjectFile; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; public class Morphing extends javax.swing.JFrame { diff --git a/src/classes/org/jdesktop/j3d/examples/morphing/MorphingBehavior.java b/src/classes/org/jdesktop/j3d/examples/morphing/MorphingBehavior.java index 6ee6e8b..49520c2 100644 --- a/src/classes/org/jdesktop/j3d/examples/morphing/MorphingBehavior.java +++ b/src/classes/org/jdesktop/j3d/examples/morphing/MorphingBehavior.java @@ -45,8 +45,11 @@ package org.jdesktop.j3d.examples.morphing; import java.util.Enumeration; -import javax.media.j3d.*; -import javax.vecmath.*; + +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.Behavior; +import org.jogamp.java3d.Morph; +import org.jogamp.java3d.WakeupOnElapsedFrames; // User-defined morphing behavior class public class MorphingBehavior extends Behavior { diff --git a/src/classes/org/jdesktop/j3d/examples/morphing/Pyramid2Cube.java b/src/classes/org/jdesktop/j3d/examples/morphing/Pyramid2Cube.java index cb99aed..7435588 100644 --- a/src/classes/org/jdesktop/j3d/examples/morphing/Pyramid2Cube.java +++ b/src/classes/org/jdesktop/j3d/examples/morphing/Pyramid2Cube.java @@ -44,11 +44,25 @@ package org.jdesktop.j3d.examples.morphing; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.Morph; +import org.jogamp.java3d.QuadArray; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; + public class Pyramid2Cube extends javax.swing.JFrame { private SimpleUniverse univ = null; @@ -221,7 +235,7 @@ public class Pyramid2Cube extends javax.swing.JFrame { /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Pyramid2Cube().setVisible(true); diff --git a/src/classes/org/jdesktop/j3d/examples/objload/ObjLoad.java b/src/classes/org/jdesktop/j3d/examples/objload/ObjLoad.java index 34aa831..9936e97 100644 --- a/src/classes/org/jdesktop/j3d/examples/objload/ObjLoad.java +++ b/src/classes/org/jdesktop/j3d/examples/objload/ObjLoad.java @@ -44,20 +44,33 @@ package org.jdesktop.j3d.examples.objload; -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.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; +import java.io.FileNotFoundException; import java.net.MalformedURLException; import java.net.URL; -import com.sun.j3d.utils.behaviors.vp.*; -import java.io.FileNotFoundException; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.loaders.IncorrectFormatException; +import org.jogamp.java3d.loaders.ParsingErrorException; +import org.jogamp.java3d.loaders.Scene; +import org.jogamp.java3d.loaders.objectfile.ObjectFile; +import org.jogamp.java3d.utils.behaviors.vp.OrbitBehavior; +import org.jogamp.java3d.utils.universe.PlatformGeometry; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3f; /** * Simple Java 3D example program to display an .obj object. diff --git a/src/classes/org/jdesktop/j3d/examples/offscreen_canvas3d/OffScreenCanvas3D.java b/src/classes/org/jdesktop/j3d/examples/offscreen_canvas3d/OffScreenCanvas3D.java index 21465cb..913bc74 100644 --- a/src/classes/org/jdesktop/j3d/examples/offscreen_canvas3d/OffScreenCanvas3D.java +++ b/src/classes/org/jdesktop/j3d/examples/offscreen_canvas3d/OffScreenCanvas3D.java @@ -44,11 +44,13 @@ package org.jdesktop.j3d.examples.offscreen_canvas3d; -import java.awt.*; +import java.awt.GraphicsConfiguration; import java.awt.image.BufferedImage; -import java.awt.event.*; -import javax.media.j3d.*; -import javax.vecmath.*; + +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ImageComponent; +import org.jogamp.java3d.ImageComponent2D; +import org.jogamp.java3d.Raster; class OffScreenCanvas3D extends Canvas3D { diff --git a/src/classes/org/jdesktop/j3d/examples/offscreen_canvas3d/OffScreenTest.java b/src/classes/org/jdesktop/j3d/examples/offscreen_canvas3d/OffScreenTest.java index 52acb9e..dbb841e 100644 --- a/src/classes/org/jdesktop/j3d/examples/offscreen_canvas3d/OffScreenTest.java +++ b/src/classes/org/jdesktop/j3d/examples/offscreen_canvas3d/OffScreenTest.java @@ -44,13 +44,25 @@ package org.jdesktop.j3d.examples.offscreen_canvas3d; -import com.sun.j3d.utils.universe.*; -import com.sun.j3d.utils.geometry.ColorCube; -import javax.media.j3d.*; -import javax.vecmath.*; -import java.awt.*; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsEnvironment; import java.awt.image.BufferedImage; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.GraphicsConfigTemplate3D; +import org.jogamp.java3d.ImageComponent; +import org.jogamp.java3d.ImageComponent2D; +import org.jogamp.java3d.Raster; +import org.jogamp.java3d.Screen3D; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.View; +import org.jogamp.java3d.utils.geometry.ColorCube; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; + /** * OffScreenTest programs with no UI. */ @@ -204,7 +216,7 @@ public class OffScreenTest extends javax.swing.JFrame { /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new OffScreenTest().setVisible(true); diff --git a/src/classes/org/jdesktop/j3d/examples/offscreen_canvas3d/OnScreenCanvas3D.java b/src/classes/org/jdesktop/j3d/examples/offscreen_canvas3d/OnScreenCanvas3D.java index c8d791e..ce671e2 100644 --- a/src/classes/org/jdesktop/j3d/examples/offscreen_canvas3d/OnScreenCanvas3D.java +++ b/src/classes/org/jdesktop/j3d/examples/offscreen_canvas3d/OnScreenCanvas3D.java @@ -44,15 +44,9 @@ package org.jdesktop.j3d.examples.offscreen_canvas3d; -import com.sun.j3d.utils.geometry.ColorCube; -import java.applet.Applet; -import java.awt.*; -import java.awt.event.*; -import java.awt.image.BufferedImage; -import com.sun.j3d.utils.applet.MainFrame; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; +import java.awt.GraphicsConfiguration; + +import org.jogamp.java3d.Canvas3D; class OnScreenCanvas3D extends Canvas3D { diff --git a/src/classes/org/jdesktop/j3d/examples/offscreen_canvas3d/PrintFromButton.java b/src/classes/org/jdesktop/j3d/examples/offscreen_canvas3d/PrintFromButton.java index fb040f7..e53a094 100644 --- a/src/classes/org/jdesktop/j3d/examples/offscreen_canvas3d/PrintFromButton.java +++ b/src/classes/org/jdesktop/j3d/examples/offscreen_canvas3d/PrintFromButton.java @@ -44,15 +44,27 @@ package org.jdesktop.j3d.examples.offscreen_canvas3d; -import com.sun.j3d.utils.universe.*; -import com.sun.j3d.utils.geometry.ColorCube; -import javax.media.j3d.*; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; -import javax.swing.JPopupMenu; -import java.awt.*; +import java.awt.GraphicsEnvironment; import java.awt.image.BufferedImage; +import javax.swing.JPopupMenu; + +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.GraphicsConfigTemplate3D; +import org.jogamp.java3d.ImageComponent; +import org.jogamp.java3d.ImageComponent2D; +import org.jogamp.java3d.Raster; +import org.jogamp.java3d.Screen3D; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.View; +import org.jogamp.java3d.utils.geometry.ColorCube; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; + /** * PrintFromButton programs with simple UI. */ @@ -242,7 +254,7 @@ public class PrintFromButton extends javax.swing.JFrame { /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new PrintFromButton().setVisible(true); diff --git a/src/classes/org/jdesktop/j3d/examples/oriented_shape3d/MouseRotateY.java b/src/classes/org/jdesktop/j3d/examples/oriented_shape3d/MouseRotateY.java index 0abc391..473eaf7 100644 --- a/src/classes/org/jdesktop/j3d/examples/oriented_shape3d/MouseRotateY.java +++ b/src/classes/org/jdesktop/j3d/examples/oriented_shape3d/MouseRotateY.java @@ -44,12 +44,16 @@ package org.jdesktop.j3d.examples.oriented_shape3d; -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import javax.media.j3d.*; -import javax.vecmath.*; -import com.sun.j3d.utils.behaviors.mouse.*; +import java.awt.AWTEvent; +import java.awt.event.MouseEvent; +import java.util.Enumeration; + +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.WakeupCriterion; +import org.jogamp.java3d.WakeupOnAWTEvent; +import org.jogamp.java3d.utils.behaviors.mouse.MouseBehavior; +import org.jogamp.vecmath.Matrix4d; +import org.jogamp.vecmath.Vector3d; /** * MouseRotateY is a Java3D behavior object that lets users control the diff --git a/src/classes/org/jdesktop/j3d/examples/oriented_shape3d/OrientedPtTest.java b/src/classes/org/jdesktop/j3d/examples/oriented_shape3d/OrientedPtTest.java index 4443ad0..2810378 100644 --- a/src/classes/org/jdesktop/j3d/examples/oriented_shape3d/OrientedPtTest.java +++ b/src/classes/org/jdesktop/j3d/examples/oriented_shape3d/OrientedPtTest.java @@ -46,18 +46,38 @@ package org.jdesktop.j3d.examples.oriented_shape3d; import java.applet.Applet; import java.awt.BorderLayout; -import com.sun.j3d.utils.image.TextureLoader; -import com.sun.j3d.utils.applet.MainFrame; -import com.sun.j3d.utils.geometry.ColorCube; -import com.sun.j3d.utils.geometry.Cone; -import com.sun.j3d.utils.geometry.Cylinder; -import com.sun.j3d.utils.geometry.Sphere; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; -import java.awt.*; -import com.sun.j3d.utils.behaviors.vp.*; +import java.awt.Font; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Font3D; +import org.jogamp.java3d.FontExtrusion; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.OrientedShape3D; +import org.jogamp.java3d.Text3D; +import org.jogamp.java3d.TextureAttributes; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.behaviors.vp.OrbitBehavior; +import org.jogamp.java3d.utils.geometry.ColorCube; +import org.jogamp.java3d.utils.geometry.Cone; +import org.jogamp.java3d.utils.geometry.Cylinder; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.image.TextureLoader; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; public class OrientedPtTest extends Applet { @@ -222,7 +242,7 @@ public class OrientedPtTest extends Applet { stoneImage = stoneURL; } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); // the paths to the image files for an applet earthImage = Resources.getResource("resources/images/earth.jpg"); if (earthImage == null) { @@ -269,7 +289,7 @@ public class OrientedPtTest extends Applet { // The following allows OrientedPtTest to be run as an application // as well as an applet // - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); java.net.URL earthURL = null; java.net.URL stoneURL = null; earthURL = Resources.getResource("resources/images/earth.jpg"); diff --git a/src/classes/org/jdesktop/j3d/examples/oriented_shape3d/OrientedTest.java b/src/classes/org/jdesktop/j3d/examples/oriented_shape3d/OrientedTest.java index 7402af9..0f062e1 100644 --- a/src/classes/org/jdesktop/j3d/examples/oriented_shape3d/OrientedTest.java +++ b/src/classes/org/jdesktop/j3d/examples/oriented_shape3d/OrientedTest.java @@ -45,15 +45,40 @@ package org.jdesktop.j3d.examples.oriented_shape3d; import java.applet.Applet; -import java.awt.*; -import com.sun.j3d.utils.image.TextureLoader; -import com.sun.j3d.utils.applet.MainFrame; -import com.sun.j3d.utils.geometry.*; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; -import com.sun.j3d.utils.behaviors.mouse.*; +import java.awt.BorderLayout; +import java.awt.Font; +import java.awt.GraphicsConfiguration; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Font3D; +import org.jogamp.java3d.FontExtrusion; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.OrientedShape3D; +import org.jogamp.java3d.Text3D; +import org.jogamp.java3d.TextureAttributes; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.behaviors.mouse.MouseTranslate; +import org.jogamp.java3d.utils.behaviors.mouse.MouseZoom; +import org.jogamp.java3d.utils.geometry.ColorCube; +import org.jogamp.java3d.utils.geometry.Cone; +import org.jogamp.java3d.utils.geometry.Cylinder; +import org.jogamp.java3d.utils.image.TextureLoader; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; public class OrientedTest extends Applet { @@ -210,7 +235,7 @@ public class OrientedTest extends Applet { stoneImage = stoneURL; } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); // the paths to the image files for an applet earthImage = Resources.getResource("resources/images/earth.jpg"); if (earthImage == null) { @@ -283,7 +308,7 @@ public class OrientedTest extends Applet { // The following allows OrientedTest to be run as an application // as well as an applet // - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); java.net.URL earthURL = null; java.net.URL stoneURL = null; diff --git a/src/classes/org/jdesktop/j3d/examples/package_info/PackageInfo.java b/src/classes/org/jdesktop/j3d/examples/package_info/PackageInfo.java index 3890253..d44e2a9 100644 --- a/src/classes/org/jdesktop/j3d/examples/package_info/PackageInfo.java +++ b/src/classes/org/jdesktop/j3d/examples/package_info/PackageInfo.java @@ -90,8 +90,8 @@ public class PackageInfo extends javax.swing.JFrame { ClassLoader classLoader = getClass().getClassLoader(); - pkgInfo(myTextArea, classLoader, "javax.vecmath", "Point3d"); - pkgInfo(myTextArea, classLoader, "javax.media.j3d", "SceneGraphObject"); + pkgInfo(myTextArea, classLoader, "org.jogamp.vecmath", "Point3d"); + pkgInfo(myTextArea, classLoader, "org.jogamp.java3d", "SceneGraphObject"); pkgInfo(myTextArea, classLoader, "com.sun.j3d.utils.universe", "SimpleUniverse"); } @@ -123,7 +123,7 @@ public class PackageInfo extends javax.swing.JFrame { /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new PackageInfo().setVisible(true); diff --git a/src/classes/org/jdesktop/j3d/examples/package_info/QueryProperties.java b/src/classes/org/jdesktop/j3d/examples/package_info/QueryProperties.java index cf58c4f..16a3116 100644 --- a/src/classes/org/jdesktop/j3d/examples/package_info/QueryProperties.java +++ b/src/classes/org/jdesktop/j3d/examples/package_info/QueryProperties.java @@ -44,19 +44,21 @@ package org.jdesktop.j3d.examples.package_info; -import java.awt.GraphicsEnvironment; import java.awt.GraphicsConfiguration; +import java.awt.GraphicsEnvironment; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; -import javax.media.j3d.Canvas3D; -import javax.media.j3d.GraphicsConfigTemplate3D; -import javax.media.j3d.VirtualUniverse; + import javax.swing.JTextArea; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.GraphicsConfigTemplate3D; +import org.jogamp.java3d.VirtualUniverse; + public class QueryProperties extends javax.swing.JFrame { public static void printProps(JTextArea textArea, Map map, String[] propList) { @@ -185,7 +187,7 @@ public class QueryProperties extends javax.swing.JFrame { /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new QueryProperties().setVisible(true); diff --git a/src/classes/org/jdesktop/j3d/examples/picking/BoltCG.java b/src/classes/org/jdesktop/j3d/examples/picking/BoltCG.java index 6fcc05a..44db05f 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/BoltCG.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/BoltCG.java @@ -44,8 +44,8 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.CompressedGeometry; +import org.jogamp.java3d.CompressedGeometryHeader; class BoltCG extends CompressedGeometry { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/ColorCube.java b/src/classes/org/jdesktop/j3d/examples/picking/ColorCube.java index 6719264..a92f641 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/ColorCube.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/ColorCube.java @@ -44,8 +44,7 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.QuadArray; class ColorCube extends QuadArray { private static final float[] verts = { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/ColorPyramidDown.java b/src/classes/org/jdesktop/j3d/examples/picking/ColorPyramidDown.java index 9e56e95..3cf18cb 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/ColorPyramidDown.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/ColorPyramidDown.java @@ -44,8 +44,7 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.QuadArray; class ColorPyramidDown extends QuadArray { private static final float[] verts = { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/ColorPyramidUp.java b/src/classes/org/jdesktop/j3d/examples/picking/ColorPyramidUp.java index 2b6067a..c59211d 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/ColorPyramidUp.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/ColorPyramidUp.java @@ -44,8 +44,7 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.QuadArray; class ColorPyramidUp extends QuadArray { private static final float[] verts = { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/Cube.java b/src/classes/org/jdesktop/j3d/examples/picking/Cube.java index 7a86521..4c5faf4 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/Cube.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/Cube.java @@ -44,8 +44,11 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Geometry; +import org.jogamp.java3d.QuadArray; +import org.jogamp.java3d.Shape3D; +import org.jogamp.vecmath.Vector3f; public class Cube extends Shape3D { private static final float[] verts = { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/CubeIQA.java b/src/classes/org/jdesktop/j3d/examples/picking/CubeIQA.java index a2656a5..e9dcd12 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/CubeIQA.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/CubeIQA.java @@ -44,8 +44,10 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.IndexedQuadArray; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3f; class CubeIQA extends IndexedQuadArray { CubeIQA() { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/CubeQA.java b/src/classes/org/jdesktop/j3d/examples/picking/CubeQA.java index f27aa80..246e506 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/CubeQA.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/CubeQA.java @@ -44,8 +44,10 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.QuadArray; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3f; class CubeQA extends QuadArray { CubeQA() { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/GullCG.java b/src/classes/org/jdesktop/j3d/examples/picking/GullCG.java index c7816bb..dee9e2a 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/GullCG.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/GullCG.java @@ -44,8 +44,8 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.CompressedGeometry; +import org.jogamp.java3d.CompressedGeometryHeader; class GullCG extends CompressedGeometry { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/IcosahedronITSA.java b/src/classes/org/jdesktop/j3d/examples/picking/IcosahedronITSA.java index 08b623f..5d87553 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/IcosahedronITSA.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/IcosahedronITSA.java @@ -44,8 +44,10 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.IndexedTriangleStripArray; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3f; class IcosahedronITSA extends IndexedTriangleStripArray { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/IcosahedronTSA.java b/src/classes/org/jdesktop/j3d/examples/picking/IcosahedronTSA.java index 0d21f7c..065b410 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/IcosahedronTSA.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/IcosahedronTSA.java @@ -44,8 +44,10 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.TriangleStripArray; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3f; class IcosahedronTSA extends TriangleStripArray { private static final int[] sVertCnt = { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/IntersectInfoBehavior.java b/src/classes/org/jdesktop/j3d/examples/picking/IntersectInfoBehavior.java index 7bd4b25..56c12da 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/IntersectInfoBehavior.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/IntersectInfoBehavior.java @@ -44,13 +44,31 @@ package org.jdesktop.j3d.examples.picking; -import java.awt.*; -import java.awt.event.*; -import java.util.*; -import javax.media.j3d.*; -import javax.vecmath.*; -import com.sun.j3d.utils.pickfast.*; -import com.sun.j3d.utils.geometry.*; +import java.awt.AWTEvent; +import java.awt.event.MouseEvent; +import java.util.Enumeration; + +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Behavior; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.Node; +import org.jogamp.java3d.PickInfo; +import org.jogamp.java3d.PolygonAttributes; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.WakeupCriterion; +import org.jogamp.java3d.WakeupOnAWTEvent; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.pickfast.PickCanvas; +import org.jogamp.java3d.utils.pickfast.PickIntersection; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Color4f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; /** * Class: IntersectInfoBehavior diff --git a/src/classes/org/jdesktop/j3d/examples/picking/IntersectTest.java b/src/classes/org/jdesktop/j3d/examples/picking/IntersectTest.java index 720586c..a95c377 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/IntersectTest.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/IntersectTest.java @@ -46,13 +46,29 @@ package org.jdesktop.j3d.examples.picking; import java.applet.Applet; import java.awt.BorderLayout; -import java.awt.event.*; import java.awt.GraphicsConfiguration; -import com.sun.j3d.utils.applet.MainFrame; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; -import com.sun.j3d.utils.behaviors.keyboard.*; + +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.Group; +import org.jogamp.java3d.LineArray; +import org.jogamp.java3d.PointArray; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.View; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.behaviors.keyboard.KeyNavigatorBehavior; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; public class IntersectTest extends Applet { @@ -177,7 +193,7 @@ public class IntersectTest extends Applet { public IntersectTest () { } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); setLayout(new BorderLayout()); GraphicsConfiguration config = @@ -219,7 +235,7 @@ public class IntersectTest extends Applet { // The following allows IntersectTest to be run as an application // as well as an applet // - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); String s = "\n\nIntersectTest:\n-----------\n"; s += "Pick with the mouse over the primitives\n"; s += "- A sphere will be placed to indicate the picked point.\n"; diff --git a/src/classes/org/jdesktop/j3d/examples/picking/MorphingBehavior.java b/src/classes/org/jdesktop/j3d/examples/picking/MorphingBehavior.java index 3cb87a6..0aaf1e1 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/MorphingBehavior.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/MorphingBehavior.java @@ -45,8 +45,11 @@ package org.jdesktop.j3d.examples.picking; import java.util.Enumeration; -import javax.media.j3d.*; -import javax.vecmath.*; + +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.Behavior; +import org.jogamp.java3d.Morph; +import org.jogamp.java3d.WakeupOnElapsedFrames; // User-defined morphing behavior class public class MorphingBehavior extends Behavior { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/OctahedronITFA.java b/src/classes/org/jdesktop/j3d/examples/picking/OctahedronITFA.java index 0e4bb35..b81a00b 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/OctahedronITFA.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/OctahedronITFA.java @@ -44,8 +44,10 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.IndexedTriangleFanArray; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3f; class OctahedronITFA extends IndexedTriangleFanArray { private static final int[] sVertCnt = { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/OctahedronTFA.java b/src/classes/org/jdesktop/j3d/examples/picking/OctahedronTFA.java index 341668a..18e1328 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/OctahedronTFA.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/OctahedronTFA.java @@ -44,8 +44,10 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.TriangleFanArray; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3f; class OctahedronTFA extends TriangleFanArray { private static final int[] sVertCnt = { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/PickHighlightBehavior.java b/src/classes/org/jdesktop/j3d/examples/picking/PickHighlightBehavior.java index 27704d3..afc5630 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/PickHighlightBehavior.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/PickHighlightBehavior.java @@ -44,16 +44,16 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import com.sun.j3d.utils.picking.PickTool; -import com.sun.j3d.utils.picking.PickResult; -import com.sun.j3d.utils.picking.behaviors.PickMouseBehavior; -import java.util.*; -import java.awt.*; -import java.awt.Event; -import java.awt.AWTEvent; -import java.awt.event.MouseEvent; -import javax.vecmath.*; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Bounds; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.utils.picking.PickResult; +import org.jogamp.java3d.utils.picking.PickTool; +import org.jogamp.java3d.utils.picking.behaviors.PickMouseBehavior; +import org.jogamp.vecmath.Color3f; public class PickHighlightBehavior extends PickMouseBehavior { Appearance savedAppearance = null; diff --git a/src/classes/org/jdesktop/j3d/examples/picking/PickTest.java b/src/classes/org/jdesktop/j3d/examples/picking/PickTest.java index 1896bce..e36c28b 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/PickTest.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/PickTest.java @@ -44,21 +44,47 @@ package org.jdesktop.j3d.examples.picking; -import com.sun.j3d.utils.pickfast.behaviors.*; -import com.sun.j3d.utils.pickfast.*; - import java.applet.Applet; import java.awt.BorderLayout; -import java.awt.event.*; import java.awt.Component; -import com.sun.j3d.utils.applet.MainFrame; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; -import java.awt.Point; -import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BoxLayout; +import javax.swing.ButtonGroup; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; import javax.swing.border.BevelBorder; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Geometry; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.Group; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.Morph; +import org.jogamp.java3d.PickInfo; +import org.jogamp.java3d.PointAttributes; +import org.jogamp.java3d.QuadArray; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.View; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.pickfast.behaviors.PickRotateBehavior; +import org.jogamp.java3d.utils.pickfast.behaviors.PickTranslateBehavior; +import org.jogamp.java3d.utils.pickfast.behaviors.PickZoomBehavior; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; + /** * PickTest shows how to use the Picking utilities on various GeometryArray * subclasses and Morph object. @@ -379,7 +405,7 @@ public class PickTest extends Applet implements ActionListener { public PickTest (){ } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); setLayout(new BorderLayout()); Canvas3D c = new Canvas3D(SimpleUniverse.getPreferredConfiguration()); add("Center", c); diff --git a/src/classes/org/jdesktop/j3d/examples/picking/PickText3DBounds.java b/src/classes/org/jdesktop/j3d/examples/picking/PickText3DBounds.java index 4575435..35ef883 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/PickText3DBounds.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/PickText3DBounds.java @@ -46,16 +46,36 @@ package org.jdesktop.j3d.examples.picking; import java.applet.Applet; import java.awt.BorderLayout; -import com.sun.j3d.utils.picking.PickTool; -import com.sun.j3d.utils.picking.behaviors.*; -import com.sun.j3d.utils.geometry.Sphere; -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.awt.*; -import java.lang.String; +import java.awt.Font; +import java.awt.GraphicsConfiguration; + +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ColoringAttributes; +import org.jogamp.java3d.Font3D; +import org.jogamp.java3d.FontExtrusion; +import org.jogamp.java3d.Light; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.PointLight; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Text3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.picking.PickTool; +import org.jogamp.java3d.utils.picking.behaviors.PickRotateBehavior; +import org.jogamp.java3d.utils.picking.behaviors.PickTranslateBehavior; +import org.jogamp.java3d.utils.picking.behaviors.PickZoomBehavior; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; public class PickText3DBounds extends Applet { @@ -202,7 +222,7 @@ public class PickText3DBounds extends Applet { public PickText3DBounds() { } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); @@ -228,7 +248,7 @@ public class PickText3DBounds extends Applet { // The following allows Text3DMotion to be run as an application // as well as an applet // - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); new MainFrame(new PickText3DBounds(), 700, 700); } } diff --git a/src/classes/org/jdesktop/j3d/examples/picking/PickText3DGeometry.java b/src/classes/org/jdesktop/j3d/examples/picking/PickText3DGeometry.java index 85cbb53..577c217 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/PickText3DGeometry.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/PickText3DGeometry.java @@ -46,16 +46,37 @@ package org.jdesktop.j3d.examples.picking; import java.applet.Applet; import java.awt.BorderLayout; -import com.sun.j3d.utils.picking.PickTool; -import com.sun.j3d.utils.picking.behaviors.*; -import com.sun.j3d.utils.geometry.Sphere; -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.awt.*; -import java.lang.String; +import java.awt.Font; +import java.awt.GraphicsConfiguration; + +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ColoringAttributes; +import org.jogamp.java3d.Font3D; +import org.jogamp.java3d.FontExtrusion; +import org.jogamp.java3d.Geometry; +import org.jogamp.java3d.Light; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.PointLight; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Text3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.picking.PickTool; +import org.jogamp.java3d.utils.picking.behaviors.PickRotateBehavior; +import org.jogamp.java3d.utils.picking.behaviors.PickTranslateBehavior; +import org.jogamp.java3d.utils.picking.behaviors.PickZoomBehavior; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; public class PickText3DGeometry extends Applet { @@ -221,7 +242,7 @@ public class PickText3DGeometry extends Applet { public PickText3DGeometry() { } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); @@ -246,7 +267,7 @@ public class PickText3DGeometry extends Applet { // The following allows Text3DMotion to be run as an application // as well as an applet // - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); new MainFrame(new PickText3DGeometry(), 700, 700); } } diff --git a/src/classes/org/jdesktop/j3d/examples/picking/RandomColorCube.java b/src/classes/org/jdesktop/j3d/examples/picking/RandomColorCube.java index 1e41317..e278580 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/RandomColorCube.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/RandomColorCube.java @@ -44,8 +44,10 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.QuadArray; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3f; class RandomColorCube extends QuadArray { RandomColorCube() { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/RandomColorTetrahedron.java b/src/classes/org/jdesktop/j3d/examples/picking/RandomColorTetrahedron.java index 101c787..dd8c1b0 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/RandomColorTetrahedron.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/RandomColorTetrahedron.java @@ -44,8 +44,10 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.TriangleArray; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3f; class RandomColorTetrahedron extends TriangleArray { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/Tetrahedron.java b/src/classes/org/jdesktop/j3d/examples/picking/Tetrahedron.java index 64dbeb6..5f8859b 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/Tetrahedron.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/Tetrahedron.java @@ -44,8 +44,13 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Geometry; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.TriangleArray; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.TexCoord2f; +import org.jogamp.vecmath.Vector3f; public class Tetrahedron extends Shape3D { private static final float sqrt3 = (float) Math.sqrt(3.0); diff --git a/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronILA.java b/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronILA.java index 53a9d0a..507edf1 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronILA.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronILA.java @@ -44,8 +44,10 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.IndexedLineArray; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3f; class TetrahedronILA extends IndexedLineArray { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronILSA.java b/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronILSA.java index b206001..27af0ae 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronILSA.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronILSA.java @@ -44,8 +44,10 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.IndexedLineStripArray; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3f; class TetrahedronILSA extends IndexedLineStripArray { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronIPA.java b/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronIPA.java index 663d107..3daec58 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronIPA.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronIPA.java @@ -44,8 +44,10 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.IndexedPointArray; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3f; class TetrahedronIPA extends IndexedPointArray { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronITA.java b/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronITA.java index aa8db44..b4d7a48 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronITA.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronITA.java @@ -44,8 +44,10 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.IndexedTriangleArray; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3f; class TetrahedronITA extends IndexedTriangleArray { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronLA.java b/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronLA.java index a4f02fd..52ed5b6 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronLA.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronLA.java @@ -44,8 +44,10 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.LineArray; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3f; class TetrahedronLA extends LineArray { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronLSA.java b/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronLSA.java index 7f9544b..5d598fd 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronLSA.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronLSA.java @@ -44,8 +44,10 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.LineStripArray; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3f; class TetrahedronLSA extends LineStripArray { private static final int[] lineLengths = { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronPA.java b/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronPA.java index 6476432..137efef 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronPA.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronPA.java @@ -44,8 +44,10 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.PointArray; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3f; class TetrahedronPA extends PointArray { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronTA.java b/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronTA.java index 773c905..aeaef87 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronTA.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/TetrahedronTA.java @@ -44,8 +44,10 @@ package org.jdesktop.j3d.examples.picking; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.GeometryArray; +import org.jogamp.java3d.TriangleArray; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3f; class TetrahedronTA extends TriangleArray { diff --git a/src/classes/org/jdesktop/j3d/examples/picking/TickTockPicking.java b/src/classes/org/jdesktop/j3d/examples/picking/TickTockPicking.java index 64be1f9..b9d76f9 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/TickTockPicking.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/TickTockPicking.java @@ -44,12 +44,34 @@ package org.jdesktop.j3d.examples.picking; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; -import com.sun.j3d.utils.image.TextureLoader; import java.awt.GraphicsConfiguration; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ColoringAttributes; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Group; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.PointAttributes; +import org.jogamp.java3d.PolygonAttributes; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.TextureAttributes; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.TransparencyAttributes; +import org.jogamp.java3d.utils.image.TextureLoader; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; public class TickTockPicking extends javax.swing.JFrame { @@ -451,7 +473,7 @@ public class TickTockPicking extends javax.swing.JFrame { /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new TickTockPicking().setVisible(true); diff --git a/src/classes/org/jdesktop/j3d/examples/platform_geometry/SimpleGeometry.java b/src/classes/org/jdesktop/j3d/examples/platform_geometry/SimpleGeometry.java index 3561d0f..5cb03a5 100644 --- a/src/classes/org/jdesktop/j3d/examples/platform_geometry/SimpleGeometry.java +++ b/src/classes/org/jdesktop/j3d/examples/platform_geometry/SimpleGeometry.java @@ -44,15 +44,28 @@ package org.jdesktop.j3d.examples.platform_geometry; -import com.sun.j3d.utils.geometry.ColorCube; -import com.sun.j3d.utils.geometry.*; -import com.sun.j3d.utils.behaviors.mouse.MouseTranslate; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; import java.applet.Applet; -import com.sun.j3d.utils.applet.MainFrame; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.GraphicsConfiguration; + +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.TransparencyAttributes; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.behaviors.mouse.MouseTranslate; +import org.jogamp.java3d.utils.geometry.ColorCube; +import org.jogamp.java3d.utils.geometry.Cylinder; +import org.jogamp.java3d.utils.universe.PlatformGeometry; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3d; /** * This class demonstrates the use of the Universe builder for stand-alone @@ -156,7 +169,7 @@ public class SimpleGeometry extends Applet { return pg; } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); setLayout(new BorderLayout()); GraphicsConfiguration config = @@ -194,7 +207,7 @@ public class SimpleGeometry extends Applet { u.cleanup(); } - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); new MainFrame(new SimpleGeometry(args), 256, 256); } } diff --git a/src/classes/org/jdesktop/j3d/examples/print_canvas3d/ImageDisplayer.java b/src/classes/org/jdesktop/j3d/examples/print_canvas3d/ImageDisplayer.java index 21af01a..36dfeb0 100644 --- a/src/classes/org/jdesktop/j3d/examples/print_canvas3d/ImageDisplayer.java +++ b/src/classes/org/jdesktop/j3d/examples/print_canvas3d/ImageDisplayer.java @@ -44,14 +44,22 @@ package org.jdesktop.j3d.examples.print_canvas3d; -import javax.swing.*; -import java.awt.BorderLayout; -import java.awt.Container; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.awt.image.BufferedImage; -import java.awt.event.*; + +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSeparator; class ImageDisplayer extends JFrame implements ActionListener { BufferedImage bImage; diff --git a/src/classes/org/jdesktop/j3d/examples/print_canvas3d/ImagePrinter.java b/src/classes/org/jdesktop/j3d/examples/print_canvas3d/ImagePrinter.java index ea8aca9..85b00ac 100644 --- a/src/classes/org/jdesktop/j3d/examples/print_canvas3d/ImagePrinter.java +++ b/src/classes/org/jdesktop/j3d/examples/print_canvas3d/ImagePrinter.java @@ -44,13 +44,16 @@ package org.jdesktop.j3d.examples.print_canvas3d; -import java.awt.print.*; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; +import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; import java.awt.image.ImageObserver; -import java.awt.geom.AffineTransform; +import java.awt.print.PageFormat; +import java.awt.print.Printable; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; class ImagePrinter implements Printable, ImageObserver { BufferedImage bImage; diff --git a/src/classes/org/jdesktop/j3d/examples/print_canvas3d/OffScreenCanvas3D.java b/src/classes/org/jdesktop/j3d/examples/print_canvas3d/OffScreenCanvas3D.java index eb7ba97..782e5ad 100644 --- a/src/classes/org/jdesktop/j3d/examples/print_canvas3d/OffScreenCanvas3D.java +++ b/src/classes/org/jdesktop/j3d/examples/print_canvas3d/OffScreenCanvas3D.java @@ -46,8 +46,10 @@ package org.jdesktop.j3d.examples.print_canvas3d; import java.awt.GraphicsConfiguration; import java.awt.image.BufferedImage; -import javax.media.j3d.*; -import javax.vecmath.*; + +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ImageComponent; +import org.jogamp.java3d.ImageComponent2D; class OffScreenCanvas3D extends Canvas3D { diff --git a/src/classes/org/jdesktop/j3d/examples/print_canvas3d/PrintCanvas3D.java b/src/classes/org/jdesktop/j3d/examples/print_canvas3d/PrintCanvas3D.java index 29b1061..23b881f 100644 --- a/src/classes/org/jdesktop/j3d/examples/print_canvas3d/PrintCanvas3D.java +++ b/src/classes/org/jdesktop/j3d/examples/print_canvas3d/PrintCanvas3D.java @@ -44,23 +44,39 @@ package org.jdesktop.j3d.examples.print_canvas3d; -import com.sun.j3d.utils.universe.*; -import java.net.MalformedURLException; -import javax.media.j3d.*; -import javax.vecmath.*; -import java.awt.*; +import java.awt.Dimension; import java.awt.GraphicsConfiguration; -import javax.swing.JPopupMenu; - -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 java.awt.GraphicsEnvironment; +import java.awt.Point; import java.awt.image.BufferedImage; -import java.io.*; -import com.sun.j3d.utils.behaviors.mouse.*; +import java.io.FileNotFoundException; +import java.net.MalformedURLException; import java.net.URL; + +import javax.swing.JPopupMenu; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.GraphicsConfigTemplate3D; +import org.jogamp.java3d.Screen3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.loaders.IncorrectFormatException; +import org.jogamp.java3d.loaders.ParsingErrorException; +import org.jogamp.java3d.loaders.Scene; +import org.jogamp.java3d.loaders.objectfile.ObjectFile; +import org.jogamp.java3d.utils.behaviors.mouse.MouseRotate; +import org.jogamp.java3d.utils.behaviors.mouse.MouseTranslate; +import org.jogamp.java3d.utils.behaviors.mouse.MouseZoom; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3f; public class PrintCanvas3D extends javax.swing.JFrame { diff --git a/src/classes/org/jdesktop/j3d/examples/pure_immediate/PureImmediate.java b/src/classes/org/jdesktop/j3d/examples/pure_immediate/PureImmediate.java index 30f9faa..7648cba 100644 --- a/src/classes/org/jdesktop/j3d/examples/pure_immediate/PureImmediate.java +++ b/src/classes/org/jdesktop/j3d/examples/pure_immediate/PureImmediate.java @@ -44,11 +44,18 @@ package org.jdesktop.j3d.examples.pure_immediate; -import com.sun.j3d.utils.universe.*; -import com.sun.j3d.utils.geometry.ColorCube; -import javax.media.j3d.*; import java.awt.GraphicsConfiguration; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.Geometry; +import org.jogamp.java3d.GraphicsContext3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.utils.geometry.ColorCube; +import org.jogamp.java3d.utils.universe.SimpleUniverse; + /** * Pure immediate mode example program. In pure immediate mode, the * renderer must be stopped on the Canvas being rendered into. In our @@ -164,7 +171,7 @@ public class PureImmediate extends javax.swing.JFrame implements Runnable { /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new PureImmediate().setVisible(true); diff --git a/src/classes/org/jdesktop/j3d/examples/pure_immediate/PureImmediateStereo.java b/src/classes/org/jdesktop/j3d/examples/pure_immediate/PureImmediateStereo.java index 5919f2e..9e0f0e5 100644 --- a/src/classes/org/jdesktop/j3d/examples/pure_immediate/PureImmediateStereo.java +++ b/src/classes/org/jdesktop/j3d/examples/pure_immediate/PureImmediateStereo.java @@ -44,13 +44,25 @@ package org.jdesktop.j3d.examples.pure_immediate; -import java.util.*; -import com.sun.j3d.utils.geometry.*; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; import java.awt.GraphicsEnvironment; +import java.util.Map; + +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.GraphicsConfigTemplate3D; +import org.jogamp.java3d.GraphicsContext3D; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.utils.geometry.Cone; +import org.jogamp.java3d.utils.geometry.Primitive; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Vector3f; /** * Pure immediate mode stereo example program for stereo. In pure @@ -281,7 +293,7 @@ public class PureImmediateStereo extends javax.swing.JFrame implements Runnable /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new PureImmediateStereo().setVisible(true); diff --git a/src/classes/org/jdesktop/j3d/examples/read_raster/ReadRaster.java b/src/classes/org/jdesktop/j3d/examples/read_raster/ReadRaster.java index 763d92d..780e3fe 100644 --- a/src/classes/org/jdesktop/j3d/examples/read_raster/ReadRaster.java +++ b/src/classes/org/jdesktop/j3d/examples/read_raster/ReadRaster.java @@ -46,17 +46,29 @@ package org.jdesktop.j3d.examples.read_raster; import java.applet.Applet; import java.awt.BorderLayout; -import java.awt.event.*; -import java.awt.image.DataBufferInt; -import java.awt.image.BufferedImage; import java.awt.GraphicsConfiguration; -import com.sun.j3d.utils.applet.MainFrame; -import com.sun.j3d.utils.geometry.ColorCube; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; +import java.awt.image.BufferedImage; import java.util.Enumeration; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.GraphicsContext3D; +import org.jogamp.java3d.ImageComponent; +import org.jogamp.java3d.ImageComponent2D; +import org.jogamp.java3d.Raster; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.geometry.ColorCube; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; + public class ReadRaster extends Applet { private SimpleUniverse u = null; @@ -123,7 +135,7 @@ public class ReadRaster extends Applet { public ReadRaster() { } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); int width = 128; int height = 128; @@ -164,7 +176,7 @@ public class ReadRaster extends Applet { // The following allows ReadRaster to be run as an application // as well as an applet // - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); new MainFrame(new ReadRaster(), 256, 256); } } diff --git a/src/classes/org/jdesktop/j3d/examples/sound/AudioReverberate.java b/src/classes/org/jdesktop/j3d/examples/sound/AudioReverberate.java index 40ae2b8..f54b43f 100644 --- a/src/classes/org/jdesktop/j3d/examples/sound/AudioReverberate.java +++ b/src/classes/org/jdesktop/j3d/examples/sound/AudioReverberate.java @@ -45,10 +45,16 @@ package org.jdesktop.j3d.examples.sound; import java.net.URL; -import javax.media.j3d.*; -import javax.vecmath.*; import java.util.Enumeration; +import org.jogamp.java3d.AuralAttributes; +import org.jogamp.java3d.Behavior; +import org.jogamp.java3d.MediaContainer; +import org.jogamp.java3d.PointSound; +import org.jogamp.java3d.WakeupOnBehaviorPost; +import org.jogamp.java3d.WakeupOnElapsedTime; +import org.jogamp.vecmath.Point3f; + /* * Pick the JavaSound reverb type that matches the input parameters * as best as possible. diff --git a/src/classes/org/jdesktop/j3d/examples/sound/BackgroundSoundBehavior.java b/src/classes/org/jdesktop/j3d/examples/sound/BackgroundSoundBehavior.java index 9f421fe..bc8f5e6 100644 --- a/src/classes/org/jdesktop/j3d/examples/sound/BackgroundSoundBehavior.java +++ b/src/classes/org/jdesktop/j3d/examples/sound/BackgroundSoundBehavior.java @@ -46,9 +46,15 @@ package org.jdesktop.j3d.examples.sound; import java.net.URL; import java.util.Enumeration; -import javax.media.j3d.*; -import javax.vecmath.*; -import org.jdesktop.j3d.examples.Resources; + +import org.jogamp.java3d.BackgroundSound; +import org.jogamp.java3d.Behavior; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.Bounds; +import org.jogamp.java3d.MediaContainer; +import org.jogamp.java3d.WakeupCondition; +import org.jogamp.java3d.WakeupOnElapsedFrames; +import org.jogamp.vecmath.Point3d; public class BackgroundSoundBehavior extends Behavior { diff --git a/src/classes/org/jdesktop/j3d/examples/sound/BackgroundSoundTest.java b/src/classes/org/jdesktop/j3d/examples/sound/BackgroundSoundTest.java index a21759c..b2011d0 100644 --- a/src/classes/org/jdesktop/j3d/examples/sound/BackgroundSoundTest.java +++ b/src/classes/org/jdesktop/j3d/examples/sound/BackgroundSoundTest.java @@ -43,17 +43,35 @@ */ package org.jdesktop.j3d.examples.sound; -import com.sun.j3d.utils.behaviors.keyboard.KeyNavigatorBehavior; -import com.sun.j3d.utils.geometry.Sphere; -import com.sun.j3d.utils.universe.*; -import com.sun.j3d.utils.geometry.ColorCube; -import java.net.URL; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JFrame; -import javax.media.j3d.*; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; +import java.net.URL; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BackgroundSound; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.Bounds; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ColoringAttributes; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.LineArray; +import org.jogamp.java3d.LineAttributes; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.PolygonAttributes; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Sound; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.behaviors.keyboard.KeyNavigatorBehavior; +import org.jogamp.java3d.utils.geometry.ColorCube; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.Viewer; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3f; /** * This is a test for a BackgroundSound. @@ -256,7 +274,7 @@ public class BackgroundSoundTest extends javax.swing.JFrame { /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new BackgroundSoundTest().setVisible(true); diff --git a/src/classes/org/jdesktop/j3d/examples/sound/PointSoundBehavior.java b/src/classes/org/jdesktop/j3d/examples/sound/PointSoundBehavior.java index beea15c..754847c 100644 --- a/src/classes/org/jdesktop/j3d/examples/sound/PointSoundBehavior.java +++ b/src/classes/org/jdesktop/j3d/examples/sound/PointSoundBehavior.java @@ -46,9 +46,16 @@ package org.jdesktop.j3d.examples.sound; import java.net.URL; import java.util.Enumeration; -import javax.media.j3d.*; -import javax.vecmath.*; -import org.jdesktop.j3d.examples.Resources; + +import org.jogamp.java3d.Behavior; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.Bounds; +import org.jogamp.java3d.MediaContainer; +import org.jogamp.java3d.PointSound; +import org.jogamp.java3d.WakeupCondition; +import org.jogamp.java3d.WakeupOnElapsedFrames; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; public class PointSoundBehavior extends Behavior { diff --git a/src/classes/org/jdesktop/j3d/examples/sound/PointSoundTest.java b/src/classes/org/jdesktop/j3d/examples/sound/PointSoundTest.java index fd62169..a39bc87 100644 --- a/src/classes/org/jdesktop/j3d/examples/sound/PointSoundTest.java +++ b/src/classes/org/jdesktop/j3d/examples/sound/PointSoundTest.java @@ -44,17 +44,37 @@ package org.jdesktop.j3d.examples.sound; -import com.sun.j3d.utils.behaviors.keyboard.KeyNavigatorBehavior; -import com.sun.j3d.utils.geometry.Sphere; -import com.sun.j3d.utils.universe.*; -import com.sun.j3d.utils.geometry.ColorCube; -import java.net.URL; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JFrame; -import javax.media.j3d.*; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; +import java.net.URL; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.Bounds; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ColoringAttributes; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Group; +import org.jogamp.java3d.LineArray; +import org.jogamp.java3d.LineAttributes; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.PointSound; +import org.jogamp.java3d.PolygonAttributes; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Sound; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.behaviors.keyboard.KeyNavigatorBehavior; +import org.jogamp.java3d.utils.geometry.ColorCube; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.Viewer; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; /** * This is a test for a PointSound. @@ -283,7 +303,7 @@ public class PointSoundTest extends javax.swing.JFrame { /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new PointSoundTest().setVisible(true); diff --git a/src/classes/org/jdesktop/j3d/examples/sound/ReverberateSound.java b/src/classes/org/jdesktop/j3d/examples/sound/ReverberateSound.java index 935063d..9cf7ad0 100644 --- a/src/classes/org/jdesktop/j3d/examples/sound/ReverberateSound.java +++ b/src/classes/org/jdesktop/j3d/examples/sound/ReverberateSound.java @@ -55,15 +55,28 @@ package org.jdesktop.j3d.examples.sound; */ import java.applet.Applet; -import java.awt.*; -import com.sun.j3d.utils.applet.MainFrame; -import com.sun.j3d.utils.geometry.ColorCube; -import com.sun.j3d.utils.universe.*; +import java.awt.BorderLayout; +import java.awt.GraphicsConfiguration; import java.net.URL; -import javax.media.j3d.*; + import javax.swing.JOptionPane; -import javax.vecmath.*; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AudioDevice; +import org.jogamp.java3d.AuralAttributes; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.PointSound; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Soundscape; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.geometry.ColorCube; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Point3d; public class ReverberateSound extends Applet { @@ -141,7 +154,7 @@ public class ReverberateSound extends Applet { public ReverberateSound() { } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); url = Resources.getResource("resources/audio/hello_universe.au"); if (url == null) { System.err.println("resources/audio/hello_universe.au not found"); @@ -183,7 +196,7 @@ public class ReverberateSound extends Applet { // The following allows ReverberateSound to be run as an application // as well as an applet // - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); new MainFrame(new ReverberateSound(), 256, 256); } } diff --git a/src/classes/org/jdesktop/j3d/examples/sound/SimpleSounds.java b/src/classes/org/jdesktop/j3d/examples/sound/SimpleSounds.java index fb40243..c5df424 100644 --- a/src/classes/org/jdesktop/j3d/examples/sound/SimpleSounds.java +++ b/src/classes/org/jdesktop/j3d/examples/sound/SimpleSounds.java @@ -45,15 +45,27 @@ package org.jdesktop.j3d.examples.sound; import java.applet.Applet; +import java.awt.BorderLayout; +import java.awt.GraphicsConfiguration; import java.net.URL; -import java.awt.*; -import com.sun.j3d.utils.applet.MainFrame; -import com.sun.j3d.utils.geometry.ColorCube; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; + import javax.swing.JOptionPane; -import javax.vecmath.*; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AudioDevice; +import org.jogamp.java3d.BackgroundSound; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.PointSound; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.geometry.ColorCube; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Point3d; /* * This Java3D program: @@ -189,7 +201,7 @@ public class SimpleSounds extends Applet { public SimpleSounds() { } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); setLayout(new BorderLayout()); GraphicsConfiguration config = @@ -244,7 +256,7 @@ public class SimpleSounds extends Applet { * The following allows SimpleSounds to be run as an application * as well as an applet */ - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); new MainFrame(new SimpleSounds(), args, 256, 256); } } diff --git a/src/classes/org/jdesktop/j3d/examples/sound/SimpleSoundsBehavior.java b/src/classes/org/jdesktop/j3d/examples/sound/SimpleSoundsBehavior.java index 4d4c881..3c7560e 100644 --- a/src/classes/org/jdesktop/j3d/examples/sound/SimpleSoundsBehavior.java +++ b/src/classes/org/jdesktop/j3d/examples/sound/SimpleSoundsBehavior.java @@ -44,11 +44,19 @@ package org.jdesktop.j3d.examples.sound; -import javax.media.j3d.*; -import javax.vecmath.*; import java.net.URL; import java.util.Enumeration; +import org.jogamp.java3d.BackgroundSound; +import org.jogamp.java3d.Behavior; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.MediaContainer; +import org.jogamp.java3d.PointSound; +import org.jogamp.java3d.Sound; +import org.jogamp.java3d.WakeupOnBehaviorPost; +import org.jogamp.java3d.WakeupOnElapsedTime; +import org.jogamp.vecmath.Point3f; + // User defined audio behavior class public class SimpleSoundsBehavior extends Behavior { WakeupOnElapsedTime wt; diff --git a/src/classes/org/jdesktop/j3d/examples/sphere_motion/SphereMotion.java b/src/classes/org/jdesktop/j3d/examples/sphere_motion/SphereMotion.java index 1540b1b..f98085b 100644 --- a/src/classes/org/jdesktop/j3d/examples/sphere_motion/SphereMotion.java +++ b/src/classes/org/jdesktop/j3d/examples/sphere_motion/SphereMotion.java @@ -44,12 +44,33 @@ package org.jdesktop.j3d.examples.sphere_motion; -import com.sun.j3d.utils.geometry.Sphere; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ColoringAttributes; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Light; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.PointLight; +import org.jogamp.java3d.PositionInterpolator; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.SpotLight; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; + public class SphereMotion extends javax.swing.JFrame { private SimpleUniverse univ = null; diff --git a/src/classes/org/jdesktop/j3d/examples/spline_anim/SplineAnim.java b/src/classes/org/jdesktop/j3d/examples/spline_anim/SplineAnim.java index 83eca88..4b4d28f 100644 --- a/src/classes/org/jdesktop/j3d/examples/spline_anim/SplineAnim.java +++ b/src/classes/org/jdesktop/j3d/examples/spline_anim/SplineAnim.java @@ -44,23 +44,51 @@ package org.jdesktop.j3d.examples.spline_anim; -import java.io.*; import java.applet.Applet; +import java.awt.Button; +import java.awt.Choice; import java.awt.FlowLayout; -import java.awt.*; -import java.awt.event.*; -import java.util.Hashtable; -import javax.media.j3d.*; -import javax.vecmath.*; -import com.sun.j3d.utils.applet.MainFrame; -import com.sun.j3d.utils.geometry.*; -import com.sun.j3d.utils.universe.*; -import com.sun.j3d.loaders.Scene; -import com.sun.j3d.loaders.objectfile.ObjectFile; -import com.sun.j3d.loaders.ParsingErrorException; -import com.sun.j3d.loaders.IncorrectFormatException; -import com.sun.j3d.utils.behaviors.vp.*; -import com.sun.j3d.utils.behaviors.interpolators.*; +import java.awt.Frame; +import java.awt.GraphicsConfiguration; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.ItemSelectable; +import java.awt.Label; +import java.awt.Panel; +import java.awt.Scrollbar; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.AdjustmentEvent; +import java.awt.event.AdjustmentListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; + +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ColoringAttributes; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Light; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.behaviors.interpolators.KBKeyFrame; +import org.jogamp.java3d.utils.behaviors.interpolators.KBRotPosScaleSplinePathInterpolator; +import org.jogamp.java3d.utils.behaviors.vp.OrbitBehavior; +import org.jogamp.java3d.utils.geometry.Cone; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; @@ -136,7 +164,7 @@ public class SplineAnim extends Applet implements ActionListener, public SplineAnim() { } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); this.setLayout(new FlowLayout()); // Create the canvas and the UI @@ -597,7 +625,7 @@ public class SplineAnim extends Applet implements ActionListener, - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); Frame frame = new MainFrame(new SplineAnim(), 500, 600); } } diff --git a/src/classes/org/jdesktop/j3d/examples/swing_interaction/SwingInteraction.java b/src/classes/org/jdesktop/j3d/examples/swing_interaction/SwingInteraction.java index db51354..e360059 100644 --- a/src/classes/org/jdesktop/j3d/examples/swing_interaction/SwingInteraction.java +++ b/src/classes/org/jdesktop/j3d/examples/swing_interaction/SwingInteraction.java @@ -44,16 +44,23 @@ package org.jdesktop.j3d.examples.swing_interaction; -import com.sun.j3d.utils.universe.*; -import com.sun.j3d.utils.geometry.ColorCube; -import javax.media.j3d.*; -import javax.vecmath.*; import java.awt.GraphicsConfiguration; -import java.awt.event.ActionEvent; -import java.awt.event.MouseEvent; import java.util.Enumeration; + import javax.swing.JPopupMenu; +import org.jogamp.java3d.Behavior; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.WakeupCriterion; +import org.jogamp.java3d.WakeupOnBehaviorPost; +import org.jogamp.java3d.utils.geometry.ColorCube; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Point3d; + /** * Simple Java 3D test program created in NetBeans to illustrate interacting * with a Java 3D scene graph from an Swing-based program. @@ -232,7 +239,7 @@ public class SwingInteraction extends javax.swing.JFrame { /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) {System.setProperty("sun.awt.noerasebackground", "true"); java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new SwingInteraction().setVisible(true); diff --git a/src/classes/org/jdesktop/j3d/examples/text2d/MoverBehavior.java b/src/classes/org/jdesktop/j3d/examples/text2d/MoverBehavior.java index 35dbf9f..6005d5b 100644 --- a/src/classes/org/jdesktop/j3d/examples/text2d/MoverBehavior.java +++ b/src/classes/org/jdesktop/j3d/examples/text2d/MoverBehavior.java @@ -44,11 +44,21 @@ package org.jdesktop.j3d.examples.text2d; -import java.awt.event.*; import java.awt.AWTEvent; -import javax.media.j3d.*; +import java.awt.event.KeyEvent; import java.util.Enumeration; -import javax.vecmath.*; + +import org.jogamp.java3d.Behavior; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.Bounds; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.WakeupCondition; +import org.jogamp.java3d.WakeupCriterion; +import org.jogamp.java3d.WakeupOnAWTEvent; +import org.jogamp.java3d.WakeupOr; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3f; // Mover behavior class - used to allow viewer to move using arrow keys class MoverBehavior extends Behavior diff --git a/src/classes/org/jdesktop/j3d/examples/text2d/Text2DTest.java b/src/classes/org/jdesktop/j3d/examples/text2d/Text2DTest.java index 6fb903a..49a0ac2 100644 --- a/src/classes/org/jdesktop/j3d/examples/text2d/Text2DTest.java +++ b/src/classes/org/jdesktop/j3d/examples/text2d/Text2DTest.java @@ -45,14 +45,26 @@ package org.jdesktop.j3d.examples.text2d; import java.applet.Applet; -import java.awt.*; +import java.awt.BorderLayout; import java.awt.Font; -import java.awt.event.*; -import com.sun.j3d.utils.applet.MainFrame; -import com.sun.j3d.utils.geometry.Text2D; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; +import java.awt.GraphicsConfiguration; + +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.PolygonAttributes; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.geometry.Text2D; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3f; public class Text2DTest extends Applet { @@ -154,7 +166,7 @@ public class Text2DTest extends Applet { public Text2DTest() { } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); @@ -187,7 +199,7 @@ public class Text2DTest extends Applet { // The following allows HelloUniverse to be run as an application // as well as an applet // - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); new MainFrame(new Text2DTest(), 256, 256); } } diff --git a/src/classes/org/jdesktop/j3d/examples/text3d/Text3DLoad.java b/src/classes/org/jdesktop/j3d/examples/text3d/Text3DLoad.java index e6b1e3a..a61531e 100644 --- a/src/classes/org/jdesktop/j3d/examples/text3d/Text3DLoad.java +++ b/src/classes/org/jdesktop/j3d/examples/text3d/Text3DLoad.java @@ -44,17 +44,39 @@ package org.jdesktop.j3d.examples.text3d; -import com.sun.j3d.loaders.objectfile.*; 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.io.*; -import com.sun.j3d.utils.behaviors.vp.*; -import com.sun.j3d.utils.behaviors.keyboard.*; +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Font; +import java.awt.GraphicsConfiguration; +import java.awt.Panel; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.Font3D; +import org.jogamp.java3d.FontExtrusion; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.Text3D; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.behaviors.vp.OrbitBehavior; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3f; public class Text3DLoad extends Applet implements ActionListener { @@ -211,7 +233,7 @@ public class Text3DLoad extends Applet implements ActionListener { } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); if (textString == null) { textString = "Java3D"; @@ -280,7 +302,7 @@ public class Text3DLoad extends Applet implements ActionListener { // The following allows Text3DLoad to be run as an application // as well as an applet // - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); new MainFrame(new Text3DLoad(args), 700, 700); } } diff --git a/src/classes/org/jdesktop/j3d/examples/texture/MultiTextureTest.java b/src/classes/org/jdesktop/j3d/examples/texture/MultiTextureTest.java index 3ec6e0b..49f9406 100644 --- a/src/classes/org/jdesktop/j3d/examples/texture/MultiTextureTest.java +++ b/src/classes/org/jdesktop/j3d/examples/texture/MultiTextureTest.java @@ -44,18 +44,37 @@ package org.jdesktop.j3d.examples.texture; -import com.sun.j3d.utils.image.TextureLoader; -import com.sun.j3d.utils.geometry.Box; -import com.sun.j3d.utils.behaviors.vp.*; 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.awt.BorderLayout; +import java.awt.Choice; +import java.awt.GraphicsConfiguration; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; import java.awt.image.BufferedImage; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.ImageComponent; +import org.jogamp.java3d.ImageComponent2D; +import org.jogamp.java3d.Texture; +import org.jogamp.java3d.Texture2D; +import org.jogamp.java3d.TextureAttributes; +import org.jogamp.java3d.TextureUnitState; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.behaviors.vp.OrbitBehavior; +import org.jogamp.java3d.utils.geometry.Box; +import org.jogamp.java3d.utils.image.TextureLoader; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.java3d.utils.universe.ViewingPlatform; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3f; public class MultiTextureTest extends Applet implements ItemListener{ @@ -208,7 +227,7 @@ public class MultiTextureTest extends Applet implements ItemListener{ skyImage = skyURL; } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); if (stoneImage == null) { // the path to the image for an applet stoneImage = Resources.getResource("resources/images/stone.jpg"); diff --git a/src/classes/org/jdesktop/j3d/examples/texture/TextureImage.java b/src/classes/org/jdesktop/j3d/examples/texture/TextureImage.java index bedb83e..59f8aa5 100644 --- a/src/classes/org/jdesktop/j3d/examples/texture/TextureImage.java +++ b/src/classes/org/jdesktop/j3d/examples/texture/TextureImage.java @@ -45,14 +45,25 @@ package org.jdesktop.j3d.examples.texture; import java.applet.Applet; -import java.awt.*; -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.awt.BorderLayout; +import java.awt.GraphicsConfiguration; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Texture; +import org.jogamp.java3d.TextureAttributes; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.geometry.Box; +import org.jogamp.java3d.utils.image.TextureLoader; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Point3d; public class TextureImage extends Applet { @@ -119,7 +130,7 @@ public class TextureImage extends Applet { texImage = url; } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); if (texImage == null) { // the path to the image for an applet texImage = Resources.getResource(defaultFileName); @@ -154,7 +165,7 @@ public class TextureImage extends Applet { // The following allows TextureImage to be run as an application // as well as an applet // - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); java.net.URL url = null; if (args.length > 0) { try { diff --git a/src/classes/org/jdesktop/j3d/examples/texture/TextureImageNPOT.java b/src/classes/org/jdesktop/j3d/examples/texture/TextureImageNPOT.java index ed7abfa..f55493c 100644 --- a/src/classes/org/jdesktop/j3d/examples/texture/TextureImageNPOT.java +++ b/src/classes/org/jdesktop/j3d/examples/texture/TextureImageNPOT.java @@ -44,18 +44,30 @@ package org.jdesktop.j3d.examples.texture; -import com.sun.j3d.utils.applet.MainFrame; -import com.sun.j3d.utils.geometry.Box; -import com.sun.j3d.utils.image.TextureLoader; -import com.sun.j3d.utils.universe.SimpleUniverse; import java.applet.Applet; import java.awt.BorderLayout; import java.awt.GraphicsConfiguration; import java.util.Map; -import javax.media.j3d.*; + import javax.swing.JOptionPane; -import javax.vecmath.Point3d; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.ScaleInterpolator; +import org.jogamp.java3d.Texture; +import org.jogamp.java3d.TextureAttributes; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.geometry.Box; +import org.jogamp.java3d.utils.image.TextureLoader; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Point3d; public class TextureImageNPOT extends Applet { @@ -159,7 +171,7 @@ public class TextureImageNPOT extends Applet { texImage = url; } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); if (texImage == null) { // the path to the image for an applet texImage = Resources.getResource(defaultFileName); @@ -214,7 +226,7 @@ public class TextureImageNPOT extends Applet { // The following allows TextureImageNPOT to be run as an application // as well as an applet // - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); java.net.URL url = null; if (args.length > 0) { try { diff --git a/src/classes/org/jdesktop/j3d/examples/texture_by_ref/AnimateTexturesBehavior.java b/src/classes/org/jdesktop/j3d/examples/texture_by_ref/AnimateTexturesBehavior.java index d99d212..a0fb1e1 100644 --- a/src/classes/org/jdesktop/j3d/examples/texture_by_ref/AnimateTexturesBehavior.java +++ b/src/classes/org/jdesktop/j3d/examples/texture_by_ref/AnimateTexturesBehavior.java @@ -44,12 +44,18 @@ package org.jdesktop.j3d.examples.texture_by_ref; -import javax.media.j3d.*; import java.awt.image.BufferedImage; -import java.awt.*; -import com.sun.j3d.utils.image.TextureLoader; import java.util.Enumeration; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Behavior; +import org.jogamp.java3d.ImageComponent; +import org.jogamp.java3d.ImageComponent2D; +import org.jogamp.java3d.Texture2D; +import org.jogamp.java3d.WakeupCriterion; +import org.jogamp.java3d.WakeupOnElapsedFrames; +import org.jogamp.java3d.utils.image.TextureLoader; + public class AnimateTexturesBehavior extends Behavior { diff --git a/src/classes/org/jdesktop/j3d/examples/texture_by_ref/ImageOps.java b/src/classes/org/jdesktop/j3d/examples/texture_by_ref/ImageOps.java index 8af3ca7..aa689b6 100644 --- a/src/classes/org/jdesktop/j3d/examples/texture_by_ref/ImageOps.java +++ b/src/classes/org/jdesktop/j3d/examples/texture_by_ref/ImageOps.java @@ -44,9 +44,15 @@ package org.jdesktop.j3d.examples.texture_by_ref; -import java.awt.*; -import java.awt.image.*; -import java.awt.color.*; +import java.awt.Transparency; +import java.awt.color.ColorSpace; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.ComponentColorModel; +import java.awt.image.DataBuffer; +import java.awt.image.DataBufferByte; +import java.awt.image.Raster; +import java.awt.image.WritableRaster; // some useful, static image operations diff --git a/src/classes/org/jdesktop/j3d/examples/texture_by_ref/Tetrahedron.java b/src/classes/org/jdesktop/j3d/examples/texture_by_ref/Tetrahedron.java index b3fcefc..063529c 100644 --- a/src/classes/org/jdesktop/j3d/examples/texture_by_ref/Tetrahedron.java +++ b/src/classes/org/jdesktop/j3d/examples/texture_by_ref/Tetrahedron.java @@ -44,8 +44,13 @@ package org.jdesktop.j3d.examples.texture_by_ref; -import javax.media.j3d.*; -import javax.vecmath.*; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Shape3D; +import org.jogamp.java3d.TriangleArray; +import org.jogamp.vecmath.Point2f; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.TexCoord2f; +import org.jogamp.vecmath.Vector3f; public class Tetrahedron extends Shape3D { diff --git a/src/classes/org/jdesktop/j3d/examples/texture_by_ref/TextureByReference.java b/src/classes/org/jdesktop/j3d/examples/texture_by_ref/TextureByReference.java index 090ce51..b30b9a2 100644 --- a/src/classes/org/jdesktop/j3d/examples/texture_by_ref/TextureByReference.java +++ b/src/classes/org/jdesktop/j3d/examples/texture_by_ref/TextureByReference.java @@ -45,17 +45,51 @@ package org.jdesktop.j3d.examples.texture_by_ref; 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.awt.image.*; -import com.sun.j3d.utils.image.TextureLoader; -import javax.swing.*; -import javax.swing.event.*; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.GraphicsConfiguration; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.image.BufferedImage; + +import javax.swing.BoxLayout; +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JSlider; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + import org.jdesktop.j3d.examples.Resources; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.ImageComponent2D; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Texture; +import org.jogamp.java3d.Texture2D; +import org.jogamp.java3d.TextureAttributes; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.image.TextureLoader; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Vector3f; public class TextureByReference extends Applet @@ -109,7 +143,7 @@ implements ItemListener, ActionListener, ChangeListener { urls = fnamesP; } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); if (urls == null) { urls = new java.net.URL[defaultFiles.length]; for (int i = 0; i < defaultFiles.length; i++) { @@ -502,7 +536,7 @@ implements ItemListener, ActionListener, ChangeListener { } // allows TextureByReference to be run as an application as well as an applet - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); java.net.URL fnames[] = null; if (args.length > 1) { fnames = new java.net.URL[args.length]; diff --git a/src/classes/org/jdesktop/j3d/examples/virtual_input_device/ButtonPositionControls.java b/src/classes/org/jdesktop/j3d/examples/virtual_input_device/ButtonPositionControls.java index 11b334a..82f3393 100644 --- a/src/classes/org/jdesktop/j3d/examples/virtual_input_device/ButtonPositionControls.java +++ b/src/classes/org/jdesktop/j3d/examples/virtual_input_device/ButtonPositionControls.java @@ -44,10 +44,15 @@ package org.jdesktop.j3d.examples.virtual_input_device; -import java.awt.*; -import java.awt.event.*; -import javax.vecmath.*; -import javax.media.j3d.*; +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.GridLayout; +import java.awt.Panel; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +import org.jogamp.java3d.InputDevice; +import org.jogamp.vecmath.Vector3f; public class ButtonPositionControls extends Panel implements PositionControls, MouseListener { private final static int STILL=0; diff --git a/src/classes/org/jdesktop/j3d/examples/virtual_input_device/PositionControls.java b/src/classes/org/jdesktop/j3d/examples/virtual_input_device/PositionControls.java index e3774fa..eeff16d 100644 --- a/src/classes/org/jdesktop/j3d/examples/virtual_input_device/PositionControls.java +++ b/src/classes/org/jdesktop/j3d/examples/virtual_input_device/PositionControls.java @@ -44,8 +44,7 @@ package org.jdesktop.j3d.examples.virtual_input_device; -import java.awt.Component; -import javax.vecmath.Vector3f; +import org.jogamp.vecmath.Vector3f; // Classes that implement this interface must be a // subclass of java.awt.Component diff --git a/src/classes/org/jdesktop/j3d/examples/virtual_input_device/RotationControls.java b/src/classes/org/jdesktop/j3d/examples/virtual_input_device/RotationControls.java index 8295152..ea5b8c9 100644 --- a/src/classes/org/jdesktop/j3d/examples/virtual_input_device/RotationControls.java +++ b/src/classes/org/jdesktop/j3d/examples/virtual_input_device/RotationControls.java @@ -44,8 +44,6 @@ package org.jdesktop.j3d.examples.virtual_input_device; -import java.awt.Component; - // Classes that implement this interface must be a subclass // of java.awt.Component diff --git a/src/classes/org/jdesktop/j3d/examples/virtual_input_device/SensorBehavior.java b/src/classes/org/jdesktop/j3d/examples/virtual_input_device/SensorBehavior.java index 8223e13..0cb0ca6 100644 --- a/src/classes/org/jdesktop/j3d/examples/virtual_input_device/SensorBehavior.java +++ b/src/classes/org/jdesktop/j3d/examples/virtual_input_device/SensorBehavior.java @@ -44,8 +44,13 @@ package org.jdesktop.j3d.examples.virtual_input_device; -import javax.media.j3d.*; -import java.util.*; +import java.util.Enumeration; + +import org.jogamp.java3d.Behavior; +import org.jogamp.java3d.Sensor; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.WakeupOnElapsedFrames; public class SensorBehavior extends Behavior { diff --git a/src/classes/org/jdesktop/j3d/examples/virtual_input_device/VirtualInputDevice.java b/src/classes/org/jdesktop/j3d/examples/virtual_input_device/VirtualInputDevice.java index dd84519..380dae9 100644 --- a/src/classes/org/jdesktop/j3d/examples/virtual_input_device/VirtualInputDevice.java +++ b/src/classes/org/jdesktop/j3d/examples/virtual_input_device/VirtualInputDevice.java @@ -44,10 +44,15 @@ package org.jdesktop.j3d.examples.virtual_input_device; -import javax.media.j3d.*; -import javax.vecmath.*; -import java.awt.*; -import java.awt.event.*; +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.Panel; + +import org.jogamp.java3d.InputDevice; +import org.jogamp.java3d.Sensor; +import org.jogamp.java3d.SensorRead; +import org.jogamp.java3d.Transform3D; +import org.jogamp.vecmath.Vector3f; public class VirtualInputDevice implements InputDevice { diff --git a/src/classes/org/jdesktop/j3d/examples/virtual_input_device/VirtualInputDeviceTest.java b/src/classes/org/jdesktop/j3d/examples/virtual_input_device/VirtualInputDeviceTest.java index 3e8bae3..281bc63 100644 --- a/src/classes/org/jdesktop/j3d/examples/virtual_input_device/VirtualInputDeviceTest.java +++ b/src/classes/org/jdesktop/j3d/examples/virtual_input_device/VirtualInputDeviceTest.java @@ -45,13 +45,21 @@ package org.jdesktop.j3d.examples.virtual_input_device; import java.applet.Applet; -import java.awt.*; -import java.awt.event.*; -import com.sun.j3d.utils.applet.MainFrame; -import com.sun.j3d.utils.geometry.ColorCube; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; +import java.awt.BorderLayout; +import java.awt.GraphicsConfiguration; + +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.InputDevice; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.applet.MainFrame; +import org.jogamp.java3d.utils.geometry.ColorCube; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Point3d; public class VirtualInputDeviceTest extends Applet { @@ -84,7 +92,7 @@ public class VirtualInputDeviceTest extends Applet { } - public void init() { + public void init() {System.setProperty("sun.awt.noerasebackground", "true"); // These are the string arguments given to the VirtualInputDevice // constructor. These are settable parameters. Look in the // VirtualInputDevice constructor for a complete list. @@ -130,7 +138,7 @@ public class VirtualInputDeviceTest extends Applet { } - public static void main(String[] args) { + public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); new MainFrame(new VirtualInputDeviceTest(), 350, 350); } } diff --git a/src/classes/org/jdesktop/j3d/examples/virtual_input_device/WheelControls.java b/src/classes/org/jdesktop/j3d/examples/virtual_input_device/WheelControls.java index c8898b1..60181af 100644 --- a/src/classes/org/jdesktop/j3d/examples/virtual_input_device/WheelControls.java +++ b/src/classes/org/jdesktop/j3d/examples/virtual_input_device/WheelControls.java @@ -44,9 +44,18 @@ package org.jdesktop.j3d.examples.virtual_input_device; -import java.awt.*; -import java.awt.geom.*; -import java.awt.event.*; +import java.awt.Canvas; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Point; +import java.awt.Polygon; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.awt.geom.AffineTransform; public class WheelControls extends Canvas implements RotationControls, MouseMotionListener, MouseListener { |