From cd09b499eb9069dc5f7a83d229c318ccf144b56c Mon Sep 17 00:00:00 2001 From: jada Date: Fri, 3 Mar 2006 03:23:40 +0000 Subject: 1) Added VertexAttrTestCg and converted more programs to use JFrame instead of MainFrame 2) Cleanup and rename. --- src/classes/org/jdesktop/j3d/examples/lod/LOD.form | 36 +++++++ src/classes/org/jdesktop/j3d/examples/lod/LOD.java | 107 +++++++++++++++------ 2 files changed, 111 insertions(+), 32 deletions(-) create mode 100644 src/classes/org/jdesktop/j3d/examples/lod/LOD.form (limited to 'src/classes/org/jdesktop/j3d/examples/lod') diff --git a/src/classes/org/jdesktop/j3d/examples/lod/LOD.form b/src/classes/org/jdesktop/j3d/examples/lod/LOD.form new file mode 100644 index 0000000..7bba785 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/lod/LOD.form @@ -0,0 +1,36 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/classes/org/jdesktop/j3d/examples/lod/LOD.java b/src/classes/org/jdesktop/j3d/examples/lod/LOD.java index 45381f4..0d50284 100644 --- a/src/classes/org/jdesktop/j3d/examples/lod/LOD.java +++ b/src/classes/org/jdesktop/j3d/examples/lod/LOD.java @@ -44,20 +44,21 @@ package org.jdesktop.j3d.examples.lod; -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.behaviors.vp.*; import com.sun.j3d.utils.universe.*; import javax.media.j3d.*; import javax.vecmath.*; +import java.awt.GraphicsConfiguration; -public class LOD extends Applet { +/** + * Simple Java 3D example program to display a spinning cube. + */ +public class LOD 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(); @@ -129,24 +130,19 @@ public class LOD extends Applet { graphRoot.addChild(lgt1); } + private Canvas3D createUniverse() { + // Get the preferred graphics configuration for the default screen + GraphicsConfiguration config = + SimpleUniverse.getPreferredConfiguration(); - public LOD() { - } - - public void init() { - setLayout(new BorderLayout()); - GraphicsConfiguration config = - SimpleUniverse.getPreferredConfiguration(); - - Canvas3D c = new Canvas3D(config); - add("Center", c); + // Create a Canvas3D using the preferred configuration + Canvas3D c = new Canvas3D(config); - // Create a simple scene and attach it to the virtual universe - BranchGroup scene = createSceneGraph(); - u = new SimpleUniverse(c); + // Create simple universe with view branch + univ = new SimpleUniverse(c); - // only add zoom mouse behavior to viewingPlatform - ViewingPlatform viewingPlatform = u.getViewingPlatform(); + // only add zoom mouse behavior to viewingPlatform + ViewingPlatform viewingPlatform = univ.getViewingPlatform(); // This will move the ViewPlatform back a bit so the // objects in the scene can be viewed. @@ -161,21 +157,68 @@ public class LOD extends Applet { BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); orbit.setSchedulingBounds(bounds); - viewingPlatform.setViewPlatformBehavior(orbit); + viewingPlatform.setViewPlatformBehavior(orbit); + + // 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); - u.addBranchGraph(scene); + return c; } - public void destroy() { - u.cleanup(); + /** + * Creates new form LOD + */ + public LOD() { + // 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 LOD to be run as an application - // as well as an applet - // - public static void main(String[] args) { - new MainFrame(new LOD(), 512, 512); + // ---------------------------------------------------------------- + + /** 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("LOD"); + 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 LOD().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