From 5ac8b22022c4c7401d1df4366da51a882dd4cbcc Mon Sep 17 00:00:00 2001 From: jada Date: Fri, 3 Mar 2006 22:02:03 +0000 Subject: 1) Updated README-build.html 2) Updated TickTockPicking to use JFrame instead of MainFrame. 3) Removed apimage.jpg and updated programs to stone.jpg instead of apimage.jpg. 4) Modified Dot3Demo to use a compressed image. --- .../j3d/examples/appearance/AppearanceMixed.java | 8 +- .../j3d/examples/appearance/AppearanceTest.java | 4 +- .../org/jdesktop/j3d/examples/dot3/Dot3Demo.java | 2 +- .../j3d/examples/picking/TickTockPicking.form | 36 ++++++ .../j3d/examples/picking/TickTockPicking.java | 136 ++++++++++++--------- 5 files changed, 120 insertions(+), 66 deletions(-) create mode 100644 src/classes/org/jdesktop/j3d/examples/picking/TickTockPicking.form (limited to 'src/classes/org/jdesktop/j3d/examples') diff --git a/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java index b6f76c1..598f5cb 100644 --- a/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java +++ b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java @@ -451,7 +451,7 @@ public class AppearanceMixed extends javax.swing.JFrame { } /** - * Creates new form AppearanceTest + * Creates new form AppearanceMixed */ public AppearanceMixed() { @@ -466,9 +466,9 @@ public class AppearanceMixed extends javax.swing.JFrame { if (texImage == null) { // the path to the image for an applet - texImage = Resources.getResource("resources/images/apimage.jpg"); + texImage = Resources.getResource("resources/images/stone.jpg"); if (texImage == null) { - System.err.println("resources/images/apimage.jpg not found"); + System.err.println("resources/images/stone.jpg not found"); System.exit(1); } } @@ -497,7 +497,7 @@ public class AppearanceMixed extends javax.swing.JFrame { drawingPanel = new javax.swing.JPanel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - setTitle("AppearanceTest"); + setTitle("AppearanceMixed"); drawingPanel.setLayout(new java.awt.BorderLayout()); drawingPanel.setPreferredSize(new java.awt.Dimension(700, 700)); diff --git a/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.java b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.java index f53c24d..fa25921 100644 --- a/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.java +++ b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.java @@ -339,9 +339,9 @@ public class AppearanceTest extends javax.swing.JFrame { if (texImage == null) { // the path to the image for an applet - texImage = Resources.getResource("resources/images/apimage.jpg"); + texImage = Resources.getResource("resources/images/stone.jpg"); if (texImage == null) { - System.err.println("resources/images/apimage.jpg not found"); + System.err.println("resources/images/stone.jpg not found"); System.exit(1); } } diff --git a/src/classes/org/jdesktop/j3d/examples/dot3/Dot3Demo.java b/src/classes/org/jdesktop/j3d/examples/dot3/Dot3Demo.java index f47eb4e..8dbaada 100644 --- a/src/classes/org/jdesktop/j3d/examples/dot3/Dot3Demo.java +++ b/src/classes/org/jdesktop/j3d/examples/dot3/Dot3Demo.java @@ -136,7 +136,7 @@ public class Dot3Demo extends JFrame { // default texture names used String textureColorName= "resources/images/wood.jpg"; - String textureDOT3NormalMapName = "resources/images/Java3Ddot3.png"; + String textureDOT3NormalMapName = "resources/images/Java3Ddot3.jpg"; /** * Constructor. diff --git a/src/classes/org/jdesktop/j3d/examples/picking/TickTockPicking.form b/src/classes/org/jdesktop/j3d/examples/picking/TickTockPicking.form new file mode 100644 index 0000000..8d60ac0 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/picking/TickTockPicking.form @@ -0,0 +1,36 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/classes/org/jdesktop/j3d/examples/picking/TickTockPicking.java b/src/classes/org/jdesktop/j3d/examples/picking/TickTockPicking.java index 29eaec0..6828d6a 100644 --- a/src/classes/org/jdesktop/j3d/examples/picking/TickTockPicking.java +++ b/src/classes/org/jdesktop/j3d/examples/picking/TickTockPicking.java @@ -44,22 +44,20 @@ package org.jdesktop.j3d.examples.picking; -import java.applet.Applet; -import java.awt.*; -import java.awt.event.*; -import com.sun.j3d.utils.applet.MainFrame; import com.sun.j3d.utils.universe.*; -import com.sun.j3d.utils.image.TextureLoader; import javax.media.j3d.*; import javax.vecmath.*; +import com.sun.j3d.utils.image.TextureLoader; +import java.awt.GraphicsConfiguration; +import org.jdesktop.j3d.examples.Resources; -public class TickTockPicking extends Applet { +public class TickTockPicking extends javax.swing.JFrame { + private SimpleUniverse univ = null; + private BranchGroup scene = null; // path the the texture map image private java.net.URL texImage = null; - private SimpleUniverse u = null; - public BranchGroup createSceneGraph(Canvas3D c) { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); @@ -384,65 +382,85 @@ public class TickTockPicking extends Applet { return objTrans; } + + private Canvas3D createUniverse() { + // Get the preferred graphics configuration for the default screen + GraphicsConfiguration config = + SimpleUniverse.getPreferredConfiguration(); + // Create a Canvas3D using the preferred configuration + Canvas3D c = new Canvas3D(config); - public TickTockPicking() { - } - - public TickTockPicking(java.net.URL url) { - texImage = url; - } - - public void init() { - if (texImage == null) { - // the path to the image for an applet - try { - texImage = new java.net.URL(getCodeBase().toString() + - "../images/apimage.jpg"); - } - catch (java.net.MalformedURLException ex) { - System.out.println(ex.getMessage()); - System.exit(1); - } - } - - setLayout(new BorderLayout()); - GraphicsConfiguration config = - SimpleUniverse.getPreferredConfiguration(); - - Canvas3D c = new Canvas3D(config); - add("Center", c); - - // Create a simple scene and attach it to the virtual universe - BranchGroup scene = createSceneGraph(c); - u = new SimpleUniverse(c); + // 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. - u.getViewingPlatform().setNominalViewingTransform(); + // This will move the ViewPlatform back a bit so the + // objects in the scene can be viewed. + univ.getViewingPlatform().setNominalViewingTransform(); - u.addBranchGraph(scene); + // Ensure at least 5 msec per frame (i.e., < 200Hz) + univ.getViewer().getView().setMinimumFrameCycleTime(5); + return c; } - public void destroy() { - u.cleanup(); + /** + * Creates new form HelloUniverse + */ + public TickTockPicking() { + + // the path to the image for an applet + texImage = Resources.getResource("resources/images/stone.jpg"); + if (texImage == null) { + System.err.println("resources/images/stone.jpg 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(c); + univ.addBranchGraph(scene); } + + // ---------------------------------------------------------------- - // - // The following allows TickTockPicking to be run as an application - // as well as an applet - // - public static void main(String[] args) { - // the path the the texture map for an application - java.net.URL url = null; - try { - url = new java.net.URL("file:../images/apimage.jpg"); - } - catch (java.net.MalformedURLException ex) { - System.out.println(ex.getMessage()); - System.exit(1); - } - new MainFrame(new TickTockPicking(url), 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. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + drawingPanel = new javax.swing.JPanel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("TickTockPicking"); + drawingPanel.setLayout(new java.awt.BorderLayout()); + + drawingPanel.setPreferredSize(new java.awt.Dimension(700, 700)); + getContentPane().add(drawingPanel, java.awt.BorderLayout.CENTER); + + pack(); + }// //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 TickTockPicking().setVisible(true); + } + }); } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel drawingPanel; + // End of variables declaration//GEN-END:variables + } -- cgit v1.2.3