diff options
author | Steve <steveb9@u.washington.edu> | 2011-03-16 07:22:34 +0000 |
---|---|---|
committer | Steve <steveb9@u.washington.edu> | 2011-03-16 07:22:34 +0000 |
commit | 193f32ea17126b20bbbbe7ad92eb37594efdc73b (patch) | |
tree | e9c08f3b52f1c3eb6262ba5ac3a9c8c80e8c62d1 /src/tesseract | |
parent | e3f6a4acb207064a1bc3fa87cb393bdfdd5acd62 (diff) |
Added background image, added getter for boundingBox in World and the rest is in the UI.
Diffstat (limited to 'src/tesseract')
-rw-r--r-- | src/tesseract/TesseractUI.java | 21 | ||||
-rw-r--r-- | src/tesseract/World.java | 9 | ||||
-rw-r--r-- | src/tesseract/objects/blimp/Blimp.java | 2 |
3 files changed, 30 insertions, 2 deletions
diff --git a/src/tesseract/TesseractUI.java b/src/tesseract/TesseractUI.java index 4a45c25..33acf37 100644 --- a/src/tesseract/TesseractUI.java +++ b/src/tesseract/TesseractUI.java @@ -15,7 +15,11 @@ import java.awt.event.MouseWheelListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import javax.media.j3d.Background; import javax.media.j3d.BoundingBox; +import javax.media.j3d.BoundingLeaf; +import javax.media.j3d.BoundingSphere; +import javax.media.j3d.BranchGroup; import javax.media.j3d.Canvas3D; import javax.media.j3d.Node; import javax.media.j3d.Transform3D; @@ -29,6 +33,7 @@ import javax.swing.JOptionPane; import javax.swing.JPopupMenu; import javax.swing.SwingUtilities; import javax.swing.Timer; +import javax.vecmath.Color3f; import javax.vecmath.Point3d; import javax.vecmath.Point3f; import javax.vecmath.Vector3f; @@ -55,6 +60,7 @@ import tesseract.objects.PhysicalObject; import tesseract.objects.blimp.Blimp; import tesseract.objects.remote.RemoteObjectMenu; +import com.sun.j3d.utils.image.TextureLoader; import com.sun.j3d.utils.picking.PickCanvas; import com.sun.j3d.utils.picking.PickResult; import com.sun.j3d.utils.universe.SimpleUniverse; @@ -158,8 +164,21 @@ public class TesseractUI extends JFrame { new Point3d(UNIT / 2, UNIT / 2, UNIT / 2)), myPeer); - Blimp blimp = new Blimp(new Vector3f(0,0,0), .5f); + //Set Background + BoundingBox bounds = myWorld.getBounds(); + TextureLoader t = new TextureLoader("Alien.jpg", myCanvas); + Background background = new Background(t.getImage()); + background.setImageScaleMode(Background.SCALE_FIT_MAX); // Tiles the image + background.setApplicationBounds(bounds); + BranchGroup bg = new BranchGroup(); + bg.addChild(background); + + BranchGroup scene = myWorld.getScene(); + scene.addChild(bg); + + Blimp blimp = new Blimp(new Vector3f(0,0,0), .7f); myWorld.addObject(blimp); + myCurrentObject = null; myObjectMenuItems = new JMenuItem[] { diff --git a/src/tesseract/World.java b/src/tesseract/World.java index 3611806..7b8d7cb 100644 --- a/src/tesseract/World.java +++ b/src/tesseract/World.java @@ -333,6 +333,15 @@ public class World implements Observer { } /** + * Used for the background. Returns the BoundingBox. + * + * @return BoundingBox used for background. + */ + public BoundingBox getBounds() { + return myVirtualWorldBounds; + } + + /** * Add a new object to the world. * * @param obj The object to add diff --git a/src/tesseract/objects/blimp/Blimp.java b/src/tesseract/objects/blimp/Blimp.java index e81be38..28cc9e8 100644 --- a/src/tesseract/objects/blimp/Blimp.java +++ b/src/tesseract/objects/blimp/Blimp.java @@ -131,7 +131,7 @@ public class Blimp extends PhysicalObject { Material box_surface = new Material();
box_surface.setDiffuseColor(new Color3f(.7f, .6f, .4f));
boxApp.setMaterial(box_surface);
- BlimpBox box = new BlimpBox(100, .05f * my_scale, .03f * my_scale, .1f * my_scale,
+ BlimpBox box = new BlimpBox(10, .05f * my_scale, .03f * my_scale, .1f * my_scale,
new Vector3f(0f * my_scale, -.08f * my_scale, 0f * my_scale), boxApp);
TransformGroup tgBox = new TransformGroup();
tgBox.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
|