diff --git a/objects/emptyroom.mtl b/objects/emptyroom.mtl index d8a5a9d..b25e7bb 100644 --- a/objects/emptyroom.mtl +++ b/objects/emptyroom.mtl @@ -4,43 +4,9 @@ newmtl Material.013 Ns 250.000000 Ka 1.000000 1.000000 1.000000 -Kd 0.479768 0.619469 0.800000 Ks 0.500000 0.500000 0.500000 Ke 0.000000 0.000000 0.000000 Ni 1.450000 d 1.000000 illum 2 -map_Bump -bm 1.000000 Tiles29_NRM_3K.jpg - -newmtl Material.014 -Ns 250.000000 -Ka 1.000000 1.000000 1.000000 -Kd 0.510093 0.616853 0.800000 -Ks 0.500000 0.500000 0.500000 -Ke 0.000000 0.000000 0.000000 -Ni 1.450000 -d 1.000000 -illum 2 -map_Bump -bm 1.000000 Tiles29_NRM_3K.jpg - -newmtl Material.015 -Ns 250.000000 -Ka 1.000000 1.000000 1.000000 -Kd 0.421705 0.469708 0.548851 -Ks 0.500000 0.500000 0.500000 -Ke 0.000000 0.000000 0.000000 -Ni 1.450000 -d 1.000000 -illum 2 -map_Bump -bm 1.000000 Tiles29_NRM_3K.jpg - -newmtl Material.016 -Ns 250.000000 -Ka 1.000000 1.000000 1.000000 -Ks 0.500000 0.500000 0.500000 -Ke 0.000000 0.000000 0.000000 -Ni 1.450000 -d 1.000000 -illum 2 -map_Kd DrywallPopcornTexture001_COL_VAR1_3K.jpg -map_Bump -bm 1.000000 DrywallPopcornTexture001_NRM_3K.jpg +map_Kd images/walls.jpg diff --git a/objects/floor.mtl b/objects/floor.mtl new file mode 100644 index 0000000..60aebb8 --- /dev/null +++ b/objects/floor.mtl @@ -0,0 +1,12 @@ +# Blender 3.4.1 MTL File: 'Escape Java.blend' +# www.blender.org + +newmtl Material +Ns 250.000000 +Ka 1.000000 1.000000 1.000000 +Ks 0.500000 0.500000 0.500000 +Ke 0.000000 0.000000 0.000000 +Ni 1.450000 +d 1.000000 +illum 2 +map_Kd images/floor.jpg diff --git a/objects/floor.obj b/objects/floor.obj new file mode 100644 index 0000000..4a786b4 --- /dev/null +++ b/objects/floor.obj @@ -0,0 +1,18 @@ +# Blender 3.4.1 +# www.blender.org +mtllib floor.mtl +g Plane.001_Mesh +v -8.169656 -1.545984 9.487365 +v 4.913880 -1.545984 9.487365 +v -8.169656 -1.545984 -10.168003 +v 4.913880 -1.545984 -10.168003 +vn -0.0000 1.0000 -0.0000 +vt 0.000000 0.000000 +vt 1.000000 0.000000 +vt 0.000000 1.000000 +vt 1.000000 1.000000 +s 0 +g Plane.001_Material +usemtl Material +f 2/2/1 3/3/1 1/1/1 +f 2/2/1 4/4/1 3/3/1 diff --git a/objects/hightable.mtl b/objects/hightable.mtl index 8e476da..1e20f80 100644 --- a/objects/hightable.mtl +++ b/objects/hightable.mtl @@ -1,16 +1,6 @@ # Blender 3.4.1 MTL File: 'hightable.blend' # www.blender.org -newmtl Material.005 -Ns 250.000000 -Ka 0.300000 0.300000 0.300000 -Kd 0.504844 0.527711 0.373799 -Ks 0.500000 0.500000 0.500000 -Ke 0.000000 0.000000 0.000000 -Ni 1.450000 -d 1.000000 -illum 3 - newmtl Material.007 Ns 250.000000 Ka 1.000000 1.000000 1.000000 @@ -19,4 +9,4 @@ Ke 0.000000 0.000000 0.000000 Ni 1.450000 d 1.000000 illum 2 -map_Kd wood.jpg +map_Kd images/wood.jpg diff --git a/objects/images/Tiles29_COL_VAR1_3K.jpg b/objects/images/Tiles29_COL_VAR1_3K.jpg deleted file mode 100644 index f6f75d6..0000000 Binary files a/objects/images/Tiles29_COL_VAR1_3K.jpg and /dev/null differ diff --git a/objects/images/Tiles29_NRM_3K.jpg b/objects/images/Tiles29_NRM_3K.jpg deleted file mode 100644 index fb1f9ef..0000000 Binary files a/objects/images/Tiles29_NRM_3K.jpg and /dev/null differ diff --git a/objects/images/WoodQuarteredChiffon001_COL_3K.jpg b/objects/images/WoodQuarteredChiffon001_COL_3K.jpg deleted file mode 100644 index d363616..0000000 Binary files a/objects/images/WoodQuarteredChiffon001_COL_3K.jpg and /dev/null differ diff --git a/objects/images/collision.jpg b/objects/images/collision.jpg index 1bc8b57..ef1e829 100644 Binary files a/objects/images/collision.jpg and b/objects/images/collision.jpg differ diff --git a/objects/images/floor.jpg b/objects/images/floor.jpg new file mode 100644 index 0000000..c9b719e Binary files /dev/null and b/objects/images/floor.jpg differ diff --git a/objects/images/walls.jpg b/objects/images/walls.jpg new file mode 100644 index 0000000..6e59c1c Binary files /dev/null and b/objects/images/walls.jpg differ diff --git a/src/Controls.java b/src/Controls.java index 22f26f9..bc471d6 100644 --- a/src/Controls.java +++ b/src/Controls.java @@ -147,6 +147,57 @@ public void setCursorVisible(JFrame frame, boolean visible) { } } + private void pickObject() { + PickTool pickTool = new PickTool(EscapeRoom.sceneBG); + pickTool.setMode(PickTool.GEOMETRY); + + int x = canvas.getWidth()/2; + int y = canvas.getHeight()/2; // mouse coordinates + Point3d point3d = new Point3d(), center = new Point3d(); + canvas.getPixelLocationInImagePlate(x, y, point3d);// obtain AWT pixel in ImagePlate coordinates + canvas.getCenterEyeInImagePlate(center); // obtain eye's position in IP coordinates + + Transform3D transform3D = new Transform3D(); // matrix to relate ImagePlate coordinates~ + canvas.getImagePlateToVworld(transform3D); // to Virtual World coordinates + transform3D.transform(point3d); // transform 'point3d' with 'transform3D' + transform3D.transform(center); // transform 'center' with 'transform3D' + + Vector3d mouseVec = new Vector3d(); + mouseVec.sub(point3d, center); + mouseVec.normalize(); + pickTool.setShapeRay(point3d, mouseVec); // send a PickRay for intersection + + if (pickTool.pickClosest() != null) { + TransformGroup clickTG = (TransformGroup)pickTool.pickClosest().getNode(PickResult.SHAPE3D).getParent().getParent(); + + if(clickTG.getName().charAt(0) == '+') + focus(clickTG); + else if(clickTG.getName().charAt(0) == '-') + unfocus(clickTG); + + System.out.println(clickTG.getName()); // For debug purposes + } + } + + private void focus(TransformGroup focusTG) { + focusedGroup = focusTG; + Transform3D popup = new Transform3D(); + popup.setTranslation(new Vector3d(centerPoint.x*0.1, centerPoint.y*0.1, centerPoint.z*0.1)); + popup.setRotation(new AxisAngle4d(0, 1, 0, Math.PI - Math.toRadians(Controls.direction()))); + popup.setScale(((Transform3D)focusTG.getUserData()).getScale()); + + focusTG.setTransform(popup); + focusTG.setName("-"+focusTG.getName().substring(1)); + EscapeRoom.gameState = EscapeRoom.GameState.FOCUSED; + } + + private void unfocus(TransformGroup focusTG) { + focusTG.setTransform((Transform3D)focusTG.getUserData()); + focusTG.setName("+"+focusTG.getName().substring(1)); + resetMouse(); + EscapeRoom.gameState = EscapeRoom.GameState.PLAYING; + } + @Override public void mouseMoved(MouseEvent e) { if (!escapeRoom.isPlaying()) { @@ -287,74 +338,19 @@ public void keyReleased(KeyEvent e) { @Override public void keyTyped(KeyEvent e) {} - private void pickObject() { - PickTool pickTool = new PickTool(EscapeRoom.sceneBG); - pickTool.setMode(PickTool.GEOMETRY); - - int x = canvas.getWidth()/2; - int y = canvas.getHeight()/2; // mouse coordinates - Point3d point3d = new Point3d(), center = new Point3d(); - canvas.getPixelLocationInImagePlate(x, y, point3d);// obtain AWT pixel in ImagePlate coordinates - canvas.getCenterEyeInImagePlate(center); // obtain eye's position in IP coordinates - - Transform3D transform3D = new Transform3D(); // matrix to relate ImagePlate coordinates~ - canvas.getImagePlateToVworld(transform3D); // to Virtual World coordinates - transform3D.transform(point3d); // transform 'point3d' with 'transform3D' - transform3D.transform(center); // transform 'center' with 'transform3D' - - Vector3d mouseVec = new Vector3d(); - mouseVec.sub(point3d, center); - mouseVec.normalize(); - pickTool.setShapeRay(point3d, mouseVec); // send a PickRay for intersection - - if (pickTool.pickClosest() != null) { - TransformGroup clickTG = (TransformGroup)pickTool.pickClosest().getNode(PickResult.SHAPE3D).getParent().getParent(); - - if(clickTG.getName().charAt(0) == '+') - focus(clickTG); - else if(clickTG.getName().charAt(0) == '-') - unfocus(clickTG); - - System.out.println(clickTG.getName()); // For debug purposes - } - } - - private void focus(TransformGroup focusTG) { - focusedGroup = focusTG; - Transform3D popup = new Transform3D(); - popup.setTranslation(new Vector3d(centerPoint.x*0.1, centerPoint.y*0.1, centerPoint.z*0.1)); - popup.setRotation(new AxisAngle4d(0, 1, 0, Math.PI - Math.toRadians(Controls.direction()))); - popup.setScale(((Transform3D)focusTG.getUserData()).getScale()); - - focusTG.setTransform(popup); - focusTG.setName("-"+focusTG.getName().substring(1)); - EscapeRoom.gameState = EscapeRoom.GameState.FOCUSED; - } - - private void unfocus(TransformGroup focusTG) { - focusTG.setTransform((Transform3D)focusTG.getUserData()); - focusTG.setName("+"+focusTG.getName().substring(1)); - resetMouse(); - EscapeRoom.gameState = EscapeRoom.GameState.PLAYING; - } - @Override public void mouseClicked(MouseEvent e) {} @Override - public void mousePressed(MouseEvent e) { - } + public void mousePressed(MouseEvent e) {} @Override - public void mouseReleased(MouseEvent e) { - } + public void mouseReleased(MouseEvent e) {} @Override - public void mouseEntered(MouseEvent e) { - } + public void mouseEntered(MouseEvent e) {} @Override - public void mouseExited(MouseEvent e) { - } + public void mouseExited(MouseEvent e) {} } diff --git a/src/LoadObject.java b/src/LoadObject.java index 4c82fdd..960d441 100644 --- a/src/LoadObject.java +++ b/src/LoadObject.java @@ -85,7 +85,7 @@ public static BranchGroup loadObject(String objName) { e.printStackTrace(); } - for (int i = 0; i < objGroup.numChildren(); i++) { + for (int i = objGroup.numChildren()-1; i >= 0; i--) { Shape3D shape = (Shape3D) objGroup.getChild(i); shape.setAppearance(obj_Appearance(objName)); } diff --git a/src/createObjects.java b/src/createObjects.java index 6b7d9a7..c552f00 100644 --- a/src/createObjects.java +++ b/src/createObjects.java @@ -47,6 +47,7 @@ public static BranchGroup room() { 1.122)); roomBG.addChild(createObject("!ceiling", new AxisAngle4d(0, 0, 0, 0), new Vector3d(0, 0.13, 0), 1.122)); + roomBG.addChild(createObject("!floor", new AxisAngle4d(0, 0, 0, 0), new Vector3d(0, -0.0535, 0), 1.122)); roomBG.addChild(createObject("!windows", new AxisAngle4d(0, 0, 0, 0), new Vector3d(0.028, 0.04, 0.118), 0.82)); @@ -59,35 +60,32 @@ public static BranchGroup room() { roomBG.addChild(createObject("@doorKnob2", new AxisAngle4d(0, 0, 0, 0), new Vector3d(-0.153, -0.045, -0.352), 0.36)); - roomBG.addChild(createObject("!whiteboard", new AxisAngle4d(0, 0, 0, 0), + roomBG.addChild(createObject("+whiteboard", new AxisAngle4d(0, 0, 0, 0), new Vector3d(-0.1, 0.04, -0.348), 0.344)); - roomBG.addChild(createObject("!whiteboardFrame", new AxisAngle4d(0, 0, 0, 0), + roomBG.addChild(createObject("+whiteboardFrame", new AxisAngle4d(0, 0, 0, 0), new Vector3d(-0.1, 0.04, -0.355), 0.35)); - - roomBG.addChild(createObject("!whiteboardHolder", new AxisAngle4d(0, 0, 0, 0), + roomBG.addChild(createObject("+whiteboardHolder", new AxisAngle4d(0, 0, 0, 0), new Vector3d(-0.095, -0.042, -0.343), 0.35)); - roomBG.addChild(createObject("+couch", new AxisAngle4d(0, -1, 0, Math.PI / 2), + + roomBG.addChild(createObject("!couch", new AxisAngle4d(0, -1, 0, Math.PI / 2), new Vector3d(0.05, -0.103, -0.648), 0.05)); - roomBG.addChild(createObject("+couch", new AxisAngle4d(0, -1, 0, Math.PI / 2), + roomBG.addChild(createObject("!couch", new AxisAngle4d(0, -1, 0, Math.PI / 2), new Vector3d(0.15, -0.103, -0.648), 0.05)); - roomBG.addChild(createObject("+couch", new AxisAngle4d(0, -1, 0, Math.PI / 2), + roomBG.addChild(createObject("!couch", new AxisAngle4d(0, -1, 0, Math.PI / 2), new Vector3d(0.25, -0.103, -0.648), 0.05)); - roomBG.addChild(createObject("+couch", new AxisAngle4d(0, 1, 0, Math.PI), + roomBG.addChild(createObject("!couch", new AxisAngle4d(0, 1, 0, Math.PI), new Vector3d(0.382, -0.103, -0.62), 0.05)); - roomBG.addChild(createObject("+couch", new AxisAngle4d(0, 1, 0, Math.PI), + roomBG.addChild(createObject("!couch", new AxisAngle4d(0, 1, 0, Math.PI), new Vector3d(0.382, -0.103, -0.52), 0.05)); - roomBG.addChild(createObject("+couch", new AxisAngle4d(0, 1, 0, Math.PI), + roomBG.addChild(createObject("!couch", new AxisAngle4d(0, 1, 0, Math.PI), new Vector3d(-0.01, -0.103, 0.844), 0.05)); - roomBG.addChild(createObject("+couch", new AxisAngle4d(0, 1, 0, Math.PI / 2), + roomBG.addChild(createObject("!couch", new AxisAngle4d(0, 1, 0, Math.PI / 2), new Vector3d(-0.13, -0.103, 0.884), 0.05)); - roomBG.addChild(createObject("+couch", new AxisAngle4d(0, 1, 0, Math.PI / 2), + roomBG.addChild(createObject("!couch", new AxisAngle4d(0, 1, 0, Math.PI / 2), new Vector3d(-0.23, -0.103, 0.884), 0.05)); - roomBG.addChild(createObject("!whiteboard", new AxisAngle4d(0, 0, 0, 0), - new Vector3d(-0.1, 0.04, -0.35), 0.35)); - roomBG.addChild(bins(0, 0, 0)); roomBG.addChild(tvs(0, 0, 0)); roomBG.addChild(computers(0, 0, 0)); @@ -284,39 +282,39 @@ public static BranchGroup highStuff(double x, double y, double z) { public static BranchGroup middleStuff(double x, double y, double z) { BranchGroup BG = new BranchGroup(); - BG.addChild(createObject("+middletable", new AxisAngle4d(0, 1, 0, Math.PI / 2), + BG.addChild(createObject("!middletable", new AxisAngle4d(0, 1, 0, Math.PI / 2), new Vector3d(0.16 + x, -0.10 + y, -0.2 + z), 0.06)); - BG.addChild(createObject("+middletable", new AxisAngle4d(0, 1, 0, Math.PI / 2), + BG.addChild(createObject("!middletable", new AxisAngle4d(0, 1, 0, Math.PI / 2), new Vector3d(0.16 + x, -0.10 + y, 0.125 + z), 0.06)); - BG.addChild(createObject("+middletable", new AxisAngle4d(0, 1, 0, Math.PI / 2), + BG.addChild(createObject("!middletable", new AxisAngle4d(0, 1, 0, Math.PI / 2), new Vector3d(0.16 + x, -0.10 + y, 0.45 + z), 0.06)); - BG.addChild(createObject("+middlechair", new AxisAngle4d(0, 1, 0, Math.PI * .90), + BG.addChild(createObject("!middlechair", new AxisAngle4d(0, 1, 0, Math.PI * .90), new Vector3d(0.17 + x, -0.09 + y, -0.16 + z), 0.07)); - BG.addChild(createObject("+middlechair", new AxisAngle4d(0, 1, 0, Math.PI * .90), + BG.addChild(createObject("!middlechair", new AxisAngle4d(0, 1, 0, Math.PI * .90), new Vector3d(0.17 + x, -0.09 + y, 0.165 + z), 0.07)); - BG.addChild(createObject("+middlechair", new AxisAngle4d(0, 1, 0, Math.PI * .90), + BG.addChild(createObject("!middlechair", new AxisAngle4d(0, 1, 0, Math.PI * .90), new Vector3d(0.17 + x, -0.09 + y, 0.49 + z), 0.07)); - BG.addChild(createObject("+middlechair", new AxisAngle4d(0, 1, 0, Math.PI / 2 * .80), + BG.addChild(createObject("!middlechair", new AxisAngle4d(0, 1, 0, Math.PI / 2 * .80), new Vector3d(0.13 + x, -0.09 + y, -0.19 + z), 0.07)); - BG.addChild(createObject("+middlechair", new AxisAngle4d(0, 1, 0, Math.PI / 2 * .80), + BG.addChild(createObject("!middlechair", new AxisAngle4d(0, 1, 0, Math.PI / 2 * .80), new Vector3d(0.13 + x, -0.09 + y, 0.135 + z), 0.07)); - BG.addChild(createObject("+middlechair", new AxisAngle4d(0, 1, 0, Math.PI / 2 * .80), + BG.addChild(createObject("!middlechair", new AxisAngle4d(0, 1, 0, Math.PI / 2 * .80), new Vector3d(0.13 + x, -0.09 + y, 0.46 + z), 0.07)); - BG.addChild(createObject("+middlechair", new AxisAngle4d(0, 1, 0, Math.PI * 1.90), + BG.addChild(createObject("!middlechair", new AxisAngle4d(0, 1, 0, Math.PI * 1.90), new Vector3d(0.15 + x, -0.09 + y, -0.23 + z), 0.07)); - BG.addChild(createObject("+middlechair", new AxisAngle4d(0, 1, 0, Math.PI * 1.90), + BG.addChild(createObject("!middlechair", new AxisAngle4d(0, 1, 0, Math.PI * 1.90), new Vector3d(0.15 + x, -0.09 + y, 0.095 + z), 0.07)); - BG.addChild(createObject("+middlechair", new AxisAngle4d(0, 1, 0, Math.PI * 1.90), + BG.addChild(createObject("!middlechair", new AxisAngle4d(0, 1, 0, Math.PI * 1.90), new Vector3d(0.15 + x, -0.09 + y, 0.42 + z), 0.07)); - BG.addChild(createObject("+middlechair", new AxisAngle4d(0, 1, 0, Math.PI * 1.40), + BG.addChild(createObject("!middlechair", new AxisAngle4d(0, 1, 0, Math.PI * 1.40), new Vector3d(0.20 + x, -0.09 + y, -0.21 + z), 0.07)); - BG.addChild(createObject("+middlechair", new AxisAngle4d(0, 1, 0, Math.PI * 1.40), + BG.addChild(createObject("!middlechair", new AxisAngle4d(0, 1, 0, Math.PI * 1.40), new Vector3d(0.20 + x, -0.09 + y, 0.115 + z), 0.07)); - BG.addChild(createObject("+middlechair", new AxisAngle4d(0, 1, 0, Math.PI * 1.40), + BG.addChild(createObject("!middlechair", new AxisAngle4d(0, 1, 0, Math.PI * 1.40), new Vector3d(0.20 + x, -0.09 + y, 0.44 + z), 0.07)); return BG;