diff options
author | jada <jada@28c7f869-5b4e-e670-f602-82bfaf57f300> | 2006-02-17 02:11:00 +0000 |
---|---|---|
committer | jada <jada@28c7f869-5b4e-e670-f602-82bfaf57f300> | 2006-02-17 02:11:00 +0000 |
commit | f7decc35f64cd13be2a832347f78a5ba97d13a4d (patch) | |
tree | bd7fa63b66bb4cb4240331ffcd5f42202559fb05 /src | |
parent | 21f0d6b572a4a632944a12b46e6909ae50d92aba (diff) |
1. Converted example programs, under appearance, background and collision, to use JFrame instead of MainFrame.
2. Created a GUI .form file for each example program.
3. Rename universe configuration file, ie. add .cfg as file extension.
Diffstat (limited to 'src')
21 files changed, 479 insertions, 223 deletions
diff --git a/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.form b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.form new file mode 100644 index 0000000..2440a43 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.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="AppearanceMixed"/> + </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="[700, 700]"/> + </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/appearance/AppearanceMixed.java b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java index bed5d0b..f499fd0 100644 --- a/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java +++ b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java @@ -44,22 +44,22 @@ package org.jdesktop.j3d.examples.appearance; -import java.applet.Applet; -import java.awt.*; -import java.awt.GraphicsConfiguration; -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.universe.*; import javax.media.j3d.*; import javax.vecmath.*; +import java.awt.GraphicsConfiguration; import org.jdesktop.j3d.examples.Resources; -public class AppearanceMixed extends Applet { - - private java.net.URL bgImage; - private java.net.URL texImage; +/** + * Simple Java 3D example program to display a spinning cube. + */ +public class AppearanceMixed extends javax.swing.JFrame { - private SimpleUniverse u = null; + private java.net.URL texImage = null; + private java.net.URL bgImage = null; + private SimpleUniverse univ = null; + private BranchGroup scene = null; static class MyCanvas3D extends Canvas3D { private GraphicsContext3D gc; @@ -432,16 +432,34 @@ public class AppearanceMixed extends Applet { } - public AppearanceMixed() { - } + private Canvas3D createUniverse() { + // Get the preferred graphics configuration for the default screen + GraphicsConfiguration config = + SimpleUniverse.getPreferredConfiguration(); + + // Create a MyCanvas3D using the preferred configuration + MyCanvas3D c = new MyCanvas3D(config); + + // Create simple universe with view branch + univ = new SimpleUniverse(c); - public AppearanceMixed(java.net.URL bgurl, java.net.URL texurl) { - bgImage = bgurl; - texImage = texurl; + // 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 c; } - public void init() { + + /** + * Creates new form AppearanceTest + */ + public AppearanceMixed() { + if (bgImage == null) { - // the path to the image for an applet + // the path to the image for an applet bgImage = Resources.getResource("resources/images/bg.jpg"); if (bgImage == null) { System.err.println("resources/images/bg.jpg not found"); @@ -458,48 +476,52 @@ public class AppearanceMixed extends Applet { } } - setLayout(new BorderLayout()); - GraphicsConfiguration config = - SimpleUniverse.getPreferredConfiguration(); + // Initialize the GUI components + initComponents(); - MyCanvas3D c = new MyCanvas3D(config); - add("Center", c); + // Create Canvas3D and SimpleUniverse; add canvas to drawing panel + Canvas3D c = createUniverse(); + drawingPanel.add(c, java.awt.BorderLayout.CENTER); - // Create a simple scene and attach it to the virtual universe - BranchGroup scene = createSceneGraph(); - u = new SimpleUniverse(c); - - // This will move the ViewPlatform back a bit so the - // objects in the scene can be viewed. - u.getViewingPlatform().setNominalViewingTransform(); - - u.addBranchGraph(scene); + // Create the content branch and add it to the universe + scene = createSceneGraph(); + univ.addBranchGraph(scene); } - public void destroy() { - u.cleanup(); - } - - - // - // The following allows AppearanceMixed to be run as an application - // as well as an applet - // - public static void main(String[] args) { - // the path to the image file for an application - java.net.URL bgurl = null; - java.net.URL texurl = null; - bgurl = Resources.getResource("resources/images/bg.jpg"); - if (bgurl == null) { - System.err.println("resources/images/bg.jpg not found"); - System.exit(1); - } - texurl = Resources.getResource("resources/images/apimage.jpg"); - if (texurl == null) { - System.err.println("resources/images/apimage.jpg not found"); - System.exit(1); - } - - new MainFrame(new AppearanceMixed(bgurl, texurl), 700, 700); + // ---------------------------------------------------------------- + + /** 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("AppearanceTest"); + 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(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new AppearanceMixed().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/appearance/AppearanceTest.form b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.form new file mode 100644 index 0000000..43cd90f --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.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="AppearanceTest"/> + </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="[700, 700]"/> + </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/appearance/AppearanceTest.java b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.java index 03f25d8..86091f7 100644 --- a/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.java +++ b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.java @@ -44,21 +44,22 @@ package org.jdesktop.j3d.examples.appearance; -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.universe.*; import javax.media.j3d.*; import javax.vecmath.*; +import java.awt.GraphicsConfiguration; import org.jdesktop.j3d.examples.Resources; -public class AppearanceTest extends Applet { +/** + * Simple Java 3D example program to display a spinning cube. + */ +public class AppearanceTest extends javax.swing.JFrame { private java.net.URL texImage = null; private java.net.URL bgImage = null; - - private SimpleUniverse u = null; + private SimpleUniverse univ = null; + private BranchGroup scene = null; private BranchGroup createSceneGraph() { // Create the root of the branch graph @@ -305,16 +306,32 @@ public class AppearanceTest extends Applet { return objTrans; } + private Canvas3D createUniverse() { + // Get the preferred graphics configuration for the default screen + GraphicsConfiguration config = + SimpleUniverse.getPreferredConfiguration(); - public AppearanceTest() { - } + // Create a Canvas3D using the preferred configuration + Canvas3D c = new Canvas3D(config); + + // Create simple universe with view branch + univ = new SimpleUniverse(c); + + // This will move the ViewPlatform back a bit so the + // objects in the scene can be viewed. + univ.getViewingPlatform().setNominalViewingTransform(); - public AppearanceTest(java.net.URL bgurl, java.net.URL texurl) { - bgImage = bgurl; - texImage = texurl; + // Ensure at least 5 msec per frame (i.e., < 200Hz) + univ.getViewer().getView().setMinimumFrameCycleTime(5); + + return c; } - - public void init() { + + /** + * Creates new form AppearanceTest + */ + public AppearanceTest() { + if (bgImage == null) { // the path to the image for an applet bgImage = Resources.getResource("resources/images/bg.jpg"); @@ -332,50 +349,53 @@ public class AppearanceTest extends Applet { System.exit(1); } } - - setLayout(new BorderLayout()); - GraphicsConfiguration config = - SimpleUniverse.getPreferredConfiguration(); - - Canvas3D c = new Canvas3D(config); - add("Center", c); - // Create a simple scene and attach it to the virtual universe - BranchGroup scene = createSceneGraph(); - u = new SimpleUniverse(c); + // Initialize the GUI components + initComponents(); - // This will move the ViewPlatform back a bit so the - // objects in the scene can be viewed. - u.getViewingPlatform().setNominalViewingTransform(); - - u.addBranchGraph(scene); - } + // Create Canvas3D and SimpleUniverse; add canvas to drawing panel + Canvas3D c = createUniverse(); + drawingPanel.add(c, java.awt.BorderLayout.CENTER); - public void destroy() { - u.cleanup(); + // Create the content branch and add it to the universe + scene = createSceneGraph(); + univ.addBranchGraph(scene); } - - // - // The following allows AppearanceTest to be run as an application - // as well as an applet - // - public static void main(String[] args) { - // the path to the image file for an application - java.net.URL bgurl = null; - java.net.URL texurl = null; - - bgurl = Resources.getResource("resources/images/bg.jpg"); - if (bgurl == null) { - System.err.println("resources/images/bg.jpg not found"); - System.exit(1); - } - texurl = Resources.getResource("resources/images/apimage.jpg"); - if (texurl == null) { - System.err.println("resources/images/apimage.jpg not found"); - System.exit(1); - } - - new MainFrame(new AppearanceTest(bgurl, texurl), 700, 700); + // ---------------------------------------------------------------- + + /** 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("AppearanceTest"); + 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(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new AppearanceMixed().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/background/BackgroundGeometry.form b/src/classes/org/jdesktop/j3d/examples/background/BackgroundGeometry.form new file mode 100644 index 0000000..9e76404 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/background/BackgroundGeometry.form @@ -0,0 +1,37 @@ +<?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="BackgroundGeometry"/> + </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="opaque" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 700]"/> + </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/background/BackgroundGeometry.java b/src/classes/org/jdesktop/j3d/examples/background/BackgroundGeometry.java index 86c380a..e3391b4 100644 --- a/src/classes/org/jdesktop/j3d/examples/background/BackgroundGeometry.java +++ b/src/classes/org/jdesktop/j3d/examples/background/BackgroundGeometry.java @@ -46,22 +46,22 @@ package org.jdesktop.j3d.examples.background; import com.sun.j3d.utils.image.TextureLoader; import com.sun.j3d.utils.behaviors.mouse.*; -import java.applet.Applet; -import java.awt.*; -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 java.awt.GraphicsConfiguration; import org.jdesktop.j3d.examples.Resources; -public class BackgroundGeometry extends Applet { - - BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0); +/** + * Simple Java 3D example program to display a spinning cube. + */ +public class BackgroundGeometry extends javax.swing.JFrame { + private SimpleUniverse univ = null; + private BranchGroup scene = null; private java.net.URL bgImage = null; - - private SimpleUniverse u = null; + private BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0); public BranchGroup createSceneGraph() { @@ -153,47 +153,32 @@ public class BackgroundGeometry extends Applet { lgt2.setInfluencingBounds(bounds); objScale.addChild(lgt1); objScale.addChild(lgt2); - return objRoot; } - public BackgroundGeometry (){ - } + private Canvas3D createUniverse() { + // Get the preferred graphics configuration for the default screen + GraphicsConfiguration config = + SimpleUniverse.getPreferredConfiguration(); - public BackgroundGeometry(java.net.URL bgurl) { - bgImage = bgurl; - } + // Create a Canvas3D using the preferred configuration + Canvas3D c = new Canvas3D(config); - public void init() { + // Create simple universe with view branch + univ = new SimpleUniverse(c); - if (bgImage == null) { - // the path to the image for an applet - bgImage = Resources.getResource("resources/images/bg.jpg"); - if (bgImage == null) { - System.err.println("resources/images/bg.jpg not found"); - System.exit(1); - } - - } - setLayout(new BorderLayout()); - GraphicsConfiguration config = - SimpleUniverse.getPreferredConfiguration(); + // This will move the ViewPlatform back a bit so the + // objects in the scene can be viewed. + univ.getViewingPlatform().setNominalViewingTransform(); - Canvas3D c = new Canvas3D(config); - add("Center", c); - - BranchGroup scene = createSceneGraph(); - u = new SimpleUniverse(c); - - // This will move the ViewPlatform back a bit so the - // objects in the scene can be viewed. - u.getViewingPlatform().setNominalViewingTransform(); + // Ensure at least 5 msec per frame (i.e., < 200Hz) + univ.getViewer().getView().setMinimumFrameCycleTime(5); TransformGroup viewTrans = - u.getViewingPlatform().getViewPlatformTransform(); - - // Create the rotate behavior node + univ.getViewingPlatform().getViewPlatformTransform(); + + // Create the rotate behavior node MouseRotate behavior1 = new MouseRotate(viewTrans); scene.addChild(behavior1); behavior1.setSchedulingBounds(bounds); @@ -208,28 +193,74 @@ public class BackgroundGeometry extends Applet { scene.addChild(behavior3); behavior3.setSchedulingBounds(bounds); + return c; + } + + /** + * Creates new form HelloUniverse + */ + public BackgroundGeometry() { + + if (bgImage == null) { + // the path to the image for an applet + bgImage = Resources.getResource("resources/images/bg.jpg"); + if (bgImage == null) { + System.err.println("resources/images/bg.jpg not found"); + System.exit(1); + } + } + + // Initialize the GUI components + initComponents(); + + // Create the content branch and add it to the universe + scene = createSceneGraph(); + + // Create Canvas3D and SimpleUniverse; add canvas to drawing panel + Canvas3D c = createUniverse(); + drawingPanel.add(c, java.awt.BorderLayout.CENTER); + // Let Java 3D perform optimizations on this scene graph. scene.compile(); - u.addBranchGraph(scene); + univ.addBranchGraph(scene); } - public void destroy() { - u.cleanup(); - } - - public static void main(String argv[]) { - System.out.println("Usage: mouse buttons to rotate, zoom or translate the view platform transform"); - System.out.println(" Note that the background geometry only changes with rotation"); - // the path to the image file for an application - java.net.URL bgurl = null; - - bgurl = Resources.getResource("resources/images/bg.jpg"); - if (bgurl == null) { - System.err.println("resources/images/bg.jpg not found"); - System.exit(1); - } - new MainFrame(new BackgroundGeometry(bgurl), 750, 750); + // ---------------------------------------------------------------- + + /** 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("BackgroundGeometry"); + drawingPanel.setLayout(new java.awt.BorderLayout()); + + drawingPanel.setOpaque(false); + 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(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new BackgroundGeometry().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/collision/TickTockCollision.form b/src/classes/org/jdesktop/j3d/examples/collision/TickTockCollision.form new file mode 100644 index 0000000..5a555b4 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/collision/TickTockCollision.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="TickTockCollision"/> + </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="[700, 700]"/> + </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/collision/TickTockCollision.java b/src/classes/org/jdesktop/j3d/examples/collision/TickTockCollision.java index 731dff7..5a85067 100644 --- a/src/classes/org/jdesktop/j3d/examples/collision/TickTockCollision.java +++ b/src/classes/org/jdesktop/j3d/examples/collision/TickTockCollision.java @@ -44,19 +44,22 @@ package org.jdesktop.j3d.examples.collision; -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 com.sun.j3d.utils.geometry.ColorCube; import javax.media.j3d.*; import javax.vecmath.*; +import java.awt.GraphicsConfiguration; -public class TickTockCollision extends Applet { +/** + * Simple Java 3D example program to display a spinning cube. + */ +public class TickTockCollision extends javax.swing.JFrame { + + private SimpleUniverse univ = null; + private BranchGroup scene = null; - private SimpleUniverse u = null; - public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); @@ -149,7 +152,6 @@ public class TickTockCollision extends Applet { return objRoot; } - private Group createBox(double scale, Vector3d pos) { // Create a transform group node to scale and position the object. Transform3D t = new Transform3D(); @@ -182,38 +184,77 @@ public class TickTockCollision extends Applet { return objTrans; } + private Canvas3D createUniverse() { + // Get the preferred graphics configuration for the default screen + GraphicsConfiguration config = + SimpleUniverse.getPreferredConfiguration(); - public TickTockCollision() { - } - - public void init() { - setLayout(new BorderLayout()); - GraphicsConfiguration config = - SimpleUniverse.getPreferredConfiguration(); + // Create a Canvas3D using the preferred configuration + Canvas3D c = new Canvas3D(config); - Canvas3D c = new Canvas3D(config); - add("Center", c); + // Create simple universe with view branch + univ = new SimpleUniverse(c); - // Create a simple scene and attach it to the virtual universe - BranchGroup scene = createSceneGraph(); - u = new SimpleUniverse(c); + // This will move the ViewPlatform back a bit so the + // objects in the scene can be viewed. + univ.getViewingPlatform().setNominalViewingTransform(); - // This will move the ViewPlatform back a bit so the - // objects in the scene can be viewed. - u.getViewingPlatform().setNominalViewingTransform(); + // Ensure at least 5 msec per frame (i.e., < 200Hz) + univ.getViewer().getView().setMinimumFrameCycleTime(5); - u.addBranchGraph(scene); + return c; } - public void destroy() { - u.cleanup(); + /** + * Creates new form HelloUniverse + */ + public TickTockCollision() { + // 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); } - // - // The following allows TickTockCollision to be run as an application - // as well as an applet - // - public static void main(String[] args) { - new MainFrame(new TickTockCollision(), 700, 700); + // ---------------------------------------------------------------- + + /** 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("TickTockCollision"); + 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(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new TickTockCollision().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/configured_universe/ConfigObjLoad.java b/src/classes/org/jdesktop/j3d/examples/configured_universe/ConfigObjLoad.java index f96b2ed..fb94bfd 100644 --- a/src/classes/org/jdesktop/j3d/examples/configured_universe/ConfigObjLoad.java +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/ConfigObjLoad.java @@ -48,9 +48,7 @@ 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.*; import java.awt.event.*; -import com.sun.j3d.utils.applet.MainFrame; import com.sun.j3d.utils.universe.*; import javax.media.j3d.*; import javax.vecmath.*; @@ -60,6 +58,7 @@ import com.sun.j3d.utils.behaviors.sensor.Mouse6DPointerBehavior; import java.net.URL; import java.net.MalformedURLException; import java.util.Map; +import org.jdesktop.j3d.examples.Resources; public class ConfigObjLoad { @@ -181,19 +180,17 @@ public class ConfigObjLoad { public void init() { if (filename == null) { - try { - filename = new URL("file:../geometry/galleon.obj"); + filename = Resources.getResource("resources/geometry/galleon.obj"); + if (filename == null) { + System.err.println("resources/geometry/galleon.obj not found"); + System.exit(1); } - catch (MalformedURLException e) { - System.err.println(e); - System.exit(1); - } - } + } // Get the config file URL from the j3d.configURL property or use the // default config file "j3d1x1-window" in the current directory. - URL configURL = ConfiguredUniverse.getConfigURL("file:j3d1x1-window"); - + //URL configURL = ConfiguredUniverse.getConfigURL("file:j3d1x1-window"); + URL configURL = Resources.getResource("configured_universe/j3d1x1-windows.cfg"); // Create a simple scene and attach it to the virtual universe BranchGroup scene = createSceneGraph(); u = new ConfiguredUniverse(configURL); diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/README.txt b/src/classes/org/jdesktop/j3d/examples/configured_universe/README.txt index fd2af8e..5aa2197 100644 --- a/src/classes/org/jdesktop/j3d/examples/configured_universe/README.txt +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/README.txt @@ -72,7 +72,7 @@ It also differs in the following other respects: into their own user interfaces. The configuration file to load is specified by the j3d.configURL - property. If one is not specified, it will load the file j3d1x1-window + property. If one is not specified, it will load the file j3d1x1-window.cfg in this directory. Alternative custom view platform behaviors other than OrbitBehavior can @@ -89,44 +89,44 @@ command line: java -Dj3d.configURL=<URL string> ConfigObjLoad <args> <obj file> -For example, to load j3d1x2-rot30 in the current directory, run +For example, to load j3d1x2-rot30.cfg in the current directory, run - java -Dj3d.configURL=file:j3d1x2-rot30 ConfigObjLoad <args> <obj file> + java -Dj3d.configURL=file:j3d1x2-rot30.cfg ConfigObjLoad <args> <obj file> This directory includes the following sample configuration files. Normally a configuration file is site-specific but many of these can used as-is. Others may need customization for screen sizes, available input devices, and PhysicalBody parameters. - j3d1x1: single fullscreen desktop configuration. + j3d1x1.cfg: single fullscreen desktop configuration. - j3d1x1-behavior: single fullscreen desktop configuration with a + j3d1x1-behavior.cfg: single fullscreen desktop configuration with a configurable view platform behavior. - j3d1x1-stereo: single fullscreen desktop configuration with stereo + j3d1x1-stereo.cfg: single fullscreen desktop configuration with stereo viewing. - j3d1x1-vr: single fullscreen desktop configuration with stereo viewing, + j3d1x1-vr.cfg: single fullscreen desktop configuration with stereo viewing, head tracker, and 6DOF mouse. - j3d1x1-window: single screen windowed desktop configuration. + j3d1x1-window.cfg: single screen windowed desktop configuration. - j3d1x2-flat: dual-screen flat desktop configuration. + j3d1x2-flat.cfg: dual-screen flat desktop configuration. - j3d1x2-rot30: dual-screen desktop configuration with each screen rotated + j3d1x2-rot30.cfg: dual-screen desktop configuration with each screen rotated toward the other by 30 degrees about Y. - j3d1x3-cave: 3-projector configuration with screens to the left, front, + j3d1x3-cave.cfg: 3-projector configuration with screens to the left, front, and right of the user. - j3d1x3-cave-vr: 3-projector configuration with screens to the left, + j3d1x3-cave-vr.cfg: 3-projector configuration with screens to the left, front, and right of the user. Includes head tracking and stereo viewing. - j3d1x3-rot45: 3-screen desktop configuration with left and right screens + j3d1x3-rot45.cfg: 3-screen desktop configuration with left and right screens angled by 45 degrees from the center screen. - j3d2x2-flat: 4-screen projector configuration arranged in a 2x2 power + j3d2x2-flat.cfg: 4-screen projector configuration arranged in a 2x2 power wall. Note: JDK 1.4 or newer is required when configuring multiple screens if the diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-behavior b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-behavior.cfg index d291913..d291913 100644 --- a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-behavior +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-behavior.cfg diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-stereo b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-stereo.cfg index 3db4070..3db4070 100644 --- a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-stereo +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-stereo.cfg diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-vr b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-vr.cfg index 587f481..587f481 100644 --- a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-vr +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-vr.cfg diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-window b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-window.cfg index eec0e31..eec0e31 100644 --- a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-window +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-window.cfg diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1 b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1.cfg index 41173e3..41173e3 100644 --- a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1 +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1.cfg diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x2-flat b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x2-flat.cfg index 667ea52..667ea52 100644 --- a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x2-flat +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x2-flat.cfg diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x2-rot30 b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x2-rot30.cfg index 68f4a6e..68f4a6e 100644 --- a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x2-rot30 +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x2-rot30.cfg diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-cave-vr b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-cave-vr.cfg index 029decf..029decf 100644 --- a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-cave-vr +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-cave-vr.cfg diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-cave b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-cave.cfg index afc532c..afc532c 100644 --- a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-cave +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-cave.cfg diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-rot45 b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-rot45.cfg index d221e74..d221e74 100644 --- a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-rot45 +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-rot45.cfg diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d2x2-flat b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d2x2-flat.cfg index 46df9a3..46df9a3 100644 --- a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d2x2-flat +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d2x2-flat.cfg |