summaryrefslogtreecommitdiff
path: root/src/tesseract/menuitems
diff options
context:
space:
mode:
Diffstat (limited to 'src/tesseract/menuitems')
-rw-r--r--src/tesseract/menuitems/EllipsoidMenuItem.java50
-rw-r--r--src/tesseract/menuitems/PlanarPolygonMenuItem.java49
-rw-r--r--src/tesseract/menuitems/TesseractMenuItem.java9
3 files changed, 105 insertions, 3 deletions
diff --git a/src/tesseract/menuitems/EllipsoidMenuItem.java b/src/tesseract/menuitems/EllipsoidMenuItem.java
new file mode 100644
index 0000000..69ed038
--- /dev/null
+++ b/src/tesseract/menuitems/EllipsoidMenuItem.java
@@ -0,0 +1,50 @@
+package tesseract.menuitems;
+
+import java.awt.Color;
+import java.awt.event.ActionEvent;
+
+import javax.swing.JColorChooser;
+import javax.swing.JOptionPane;
+import javax.vecmath.Color3f;
+import javax.vecmath.Vector3f;
+
+import tesseract.World;
+import tesseract.objects.Ellipsoid;
+import tesseract.objects.PlanarPolygon;
+
+/**
+ * Planar Polygon Menu Item.
+ *
+ * @author Steve Bradshaw
+ */
+public class EllipsoidMenuItem extends TesseractMenuItem {
+
+ /**
+ * Serial ID.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructor for the menu item.
+ *
+ * @param theWorld The world into which we add.
+ */
+ public EllipsoidMenuItem(final World theWorld) {
+ super(theWorld, "Ellipsoid");
+ }
+
+ /**
+ * Action handler.
+ *
+ * @param arg0 Unused event info.
+ */
+ public void actionPerformed(final ActionEvent arg0) {
+ //Color c = JColorChooser.showDialog(null, "Ellipsoid", Color.RED);
+ Vector3f pos =
+ parseVector(JOptionPane.showInputDialog("Enter the position"));
+ float radius =
+ Float.parseFloat(JOptionPane.showInputDialog("Enter the radius"));
+
+ myWorld.addObject(new Ellipsoid(pos, radius));
+ }
+}
diff --git a/src/tesseract/menuitems/PlanarPolygonMenuItem.java b/src/tesseract/menuitems/PlanarPolygonMenuItem.java
new file mode 100644
index 0000000..fec7a55
--- /dev/null
+++ b/src/tesseract/menuitems/PlanarPolygonMenuItem.java
@@ -0,0 +1,49 @@
+package tesseract.menuitems;
+
+import java.awt.Color;
+import java.awt.event.ActionEvent;
+
+import javax.swing.JColorChooser;
+import javax.swing.JOptionPane;
+import javax.vecmath.Color3f;
+import javax.vecmath.Vector3f;
+
+import tesseract.World;
+import tesseract.objects.PlanarPolygon;
+
+/**
+ * Planar Polygon Menu Item.
+ *
+ * @author Steve Bradshaw
+ */
+public class PlanarPolygonMenuItem extends TesseractMenuItem {
+
+ /**
+ * Serial ID.
+ */
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Constructor for the menu item.
+ *
+ * @param theWorld The world into which we add.
+ */
+ public PlanarPolygonMenuItem(final World theWorld) {
+ super(theWorld, "Planar Polygon");
+ }
+
+ /**
+ * Action handler.
+ *
+ * @param arg0 Unused event info.
+ */
+ public void actionPerformed(final ActionEvent arg0) {
+ //Color c = JColorChooser.showDialog(null, "Planar Polygon Color", Color.RED);
+ Vector3f pos =
+ parseVector(JOptionPane.showInputDialog("Enter the position"));
+ float radius =
+ Float.parseFloat(JOptionPane.showInputDialog("Enter the radius"));
+
+ myWorld.addObject(new PlanarPolygon(pos, radius));
+ }
+}
diff --git a/src/tesseract/menuitems/TesseractMenuItem.java b/src/tesseract/menuitems/TesseractMenuItem.java
index 16925d7..724b988 100644
--- a/src/tesseract/menuitems/TesseractMenuItem.java
+++ b/src/tesseract/menuitems/TesseractMenuItem.java
@@ -46,9 +46,12 @@ public abstract class TesseractMenuItem
* @return A vector3f.
*/
protected Vector3f parseVector(final String input) {
+ String[] split = input.split(",");
-
- return new Vector3f();
- }
+ float x = Float.parseFloat(split[0]);
+ float y = Float.parseFloat(split[0]);
+ float z = Float.parseFloat(split[0]);
+ return new Vector3f(x, y, z);
+ }
}