aboutsummaryrefslogtreecommitdiffstats
path: root/src/classes/org/jdesktop/j3d/examples/collision
diff options
context:
space:
mode:
Diffstat (limited to 'src/classes/org/jdesktop/j3d/examples/collision')
-rw-r--r--src/classes/org/jdesktop/j3d/examples/collision/TickTockCollision.form36
-rw-r--r--src/classes/org/jdesktop/j3d/examples/collision/TickTockCollision.java103
2 files changed, 108 insertions, 31 deletions
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
+
}