├── 3DModelingTool ├── mathlib3D │ ├── javadoc │ │ ├── package-list │ │ ├── resources │ │ │ └── inherit.gif │ │ ├── allclasses-noframe.html │ │ ├── allclasses-frame.html │ │ ├── stylesheet.css │ │ ├── index.html │ │ ├── mathlib3D │ │ │ └── package-frame.html │ │ ├── deprecated-list.html │ │ └── constant-values.html │ ├── META-INF │ │ └── MANIFEST.MF │ ├── mathlib3D.jar │ └── Readme.txt ├── graphicslib3D │ ├── javadoc │ │ ├── package-list │ │ ├── resources │ │ │ └── inherit.gif │ │ ├── stylesheet.css │ │ ├── index.html │ │ ├── allclasses-noframe.html │ │ ├── allclasses-frame.html │ │ ├── graphicslib3D │ │ │ └── package-frame.html │ │ └── deprecated-list.html │ ├── META-INF │ │ └── MANIFEST.MF │ ├── graphicslib3D.jar │ └── Readme.txt ├── Starter.java ├── AmbientLight.java ├── Teapot.java ├── DistantLight.java ├── Group.java ├── WorldObject.java ├── Light.java ├── MouseInput.java ├── KeyboardInput.java ├── SpotLight.java ├── SlerpAction.java ├── QuarterPatch.java ├── PositionalLight.java ├── Material.java ├── Visual.java ├── Texture.java ├── SurfacePatch.java ├── Shader.java ├── Camera.java ├── GLCanvasListener.java └── Quaternion.java ├── 3DGameEngine ├── 100.wav ├── Back.bmp ├── Left.bmp ├── Top.bmp ├── add.wav ├── Bottom.bmp ├── Front.bmp ├── Right.bmp ├── music.wav ├── pickup.wav ├── Shape1.ms3d ├── Shape2.ms3d ├── bin │ ├── a1 │ │ └── Starter.class │ ├── a2 │ │ └── Starter.class │ ├── a3 │ │ └── Starter.class │ ├── futureEngine │ │ ├── scene │ │ │ ├── Leaf.class │ │ │ ├── Group.class │ │ │ ├── Plane.class │ │ │ ├── SkyBox.class │ │ │ ├── MS3DGroup.class │ │ │ ├── MS3DModel.class │ │ │ ├── SceneNode.class │ │ │ ├── Controller.class │ │ │ ├── MS3DVertex.class │ │ │ ├── BoundingSphere.class │ │ │ ├── BoundingVolume.class │ │ │ ├── MS3DTriangle.class │ │ │ ├── BouncingController.class │ │ │ ├── RotationController.class │ │ │ └── NonCullableBoundingVolume.class │ │ ├── timing │ │ │ ├── Game.class │ │ │ └── FixedFrameRateGame.class │ │ ├── camera │ │ │ ├── Camera.class │ │ │ └── ICamera.class │ │ ├── renderer │ │ │ ├── Renderer.class │ │ │ ├── IRenderer.class │ │ │ └── joglRenderer │ │ │ │ ├── JOGLSkyBox.class │ │ │ │ └── JOGLRenderer.class │ │ └── displaySystem │ │ │ ├── DisplaySystem.class │ │ │ └── IDisplaySystem.class │ └── apps │ │ └── games │ │ └── treasureHunt │ │ ├── Box.class │ │ ├── Sky.class │ │ ├── Score.class │ │ ├── Shape1.class │ │ ├── Shape2.class │ │ ├── Crystal.class │ │ ├── Treasure.class │ │ └── TreasureHunt.class ├── src │ ├── futureEngine │ │ ├── displaySystem │ │ │ ├── DisplaySystem.java │ │ │ └── IDisplaySystem.java │ │ ├── renderer │ │ │ ├── joglRenderer │ │ │ │ ├── JOGLRenderer.java │ │ │ │ └── JOGLSkyBox.java │ │ │ ├── IRenderer.java │ │ │ └── Renderer.java │ │ ├── scene │ │ │ ├── BoundingVolume.java │ │ │ ├── RotationController.java │ │ │ ├── Controller.java │ │ │ ├── NonCullableBoundingVolume.java │ │ │ ├── Leaf.java │ │ │ ├── BouncingController.java │ │ │ ├── SkyBox.java │ │ │ ├── Plane.java │ │ │ ├── MS3DVertex.java │ │ │ ├── MS3DTriangle.java │ │ │ ├── MS3DGroup.java │ │ │ ├── Group.java │ │ │ └── BoundingSphere.java │ │ ├── timing │ │ │ ├── Game.java │ │ │ └── FixedFrameRateGame.java │ │ └── camera │ │ │ ├── ICamera.java │ │ │ └── Camera.java │ ├── a3 │ │ └── Starter.java │ └── apps │ │ └── games │ │ └── treasureHunt │ │ ├── Sky.java │ │ ├── Shape1.java │ │ ├── Shape2.java │ │ ├── Score.java │ │ ├── Treasure.java │ │ ├── Box.java │ │ └── Crystal.java ├── .project ├── .settings │ └── org.eclipse.jdt.core.prefs └── .classpath └── LunarLander ├── bin ├── domain │ ├── Bomb.class │ ├── Flame.class │ ├── Lander.class │ ├── Meteor.class │ ├── Point.class │ ├── Target.class │ ├── ICollider.class │ ├── IDrawable.class │ ├── IMoveable.class │ ├── Mountain.class │ ├── FixedTarget.class │ ├── GameObject.class │ ├── ISelectable.class │ ├── LandingPad.class │ ├── MovingObject.class │ ├── MovingTarget.class │ └── SpaceStation.class ├── game │ ├── Player.class │ ├── GameWorld.class │ ├── MapView.class │ ├── Starter.class │ ├── LanderGame.class │ ├── Scoreboard.class │ ├── GameController.class │ ├── ScoreboardView.class │ ├── LanderGameRandom.class │ ├── EndOfGameException.class │ ├── LanderGame$KeyHandler.class │ ├── LanderGameCollection.class │ └── LanderGameCollection$LanderGameIterator.class └── commands │ ├── AboutCommand.class │ ├── DockCommand.class │ ├── HelpCommand.class │ ├── QuitCommand.class │ ├── SaveCommand.class │ ├── DeleteCommand.class │ ├── DownJetCommand.class │ ├── LeftJetCommand.class │ ├── NewGameCommand.class │ ├── RightJetCommand.class │ ├── AddMeteorCommand.class │ ├── StartGameCommand.class │ ├── ExplodeBombCommand.class │ └── LanderGameAbstractAction.class ├── src ├── domain │ ├── Bomb.java │ ├── IMoveable.java │ ├── ISelectable.java │ ├── IDrawable.java │ ├── ICollider.java │ ├── FixedTarget.java │ ├── Target.java │ ├── MovingTarget.java │ ├── Flame.java │ ├── MovingObject.java │ ├── Point.java │ ├── SpaceStation.java │ ├── Mountain.java │ ├── GameObject.java │ ├── Meteor.java │ └── LandingPad.java ├── game │ ├── Starter.java │ ├── Player.java │ ├── EndOfGameException.java │ ├── LanderGameRandom.java │ ├── ScoreboardView.java │ ├── GameController.java │ ├── Scoreboard.java │ ├── LanderGame.java │ ├── MapView.java │ └── LanderGameCollection.java └── commands │ ├── SaveCommand.java │ ├── DeleteCommand.java │ ├── DockCommand.java │ ├── NewGameCommand.java │ ├── AddMeteorCommand.java │ ├── QuitCommand.java │ ├── DownJetCommand.java │ ├── RightJetCommand.java │ ├── AboutCommand.java │ ├── ExplodeBombCommand.java │ ├── LeftJetCommand.java │ ├── StartGameCommand.java │ ├── LanderGameAbstractAction.java │ └── HelpCommand.java ├── .classpath └── .project /3DModelingTool/mathlib3D/javadoc/package-list: -------------------------------------------------------------------------------- 1 | mathlib3D 2 | -------------------------------------------------------------------------------- /3DModelingTool/graphicslib3D/javadoc/package-list: -------------------------------------------------------------------------------- 1 | graphicslib3D 2 | -------------------------------------------------------------------------------- /3DGameEngine/100.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/100.wav -------------------------------------------------------------------------------- /3DGameEngine/Back.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/Back.bmp -------------------------------------------------------------------------------- /3DGameEngine/Left.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/Left.bmp -------------------------------------------------------------------------------- /3DGameEngine/Top.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/Top.bmp -------------------------------------------------------------------------------- /3DGameEngine/add.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/add.wav -------------------------------------------------------------------------------- /3DGameEngine/Bottom.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/Bottom.bmp -------------------------------------------------------------------------------- /3DGameEngine/Front.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/Front.bmp -------------------------------------------------------------------------------- /3DGameEngine/Right.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/Right.bmp -------------------------------------------------------------------------------- /3DGameEngine/music.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/music.wav -------------------------------------------------------------------------------- /3DGameEngine/pickup.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/pickup.wav -------------------------------------------------------------------------------- /3DGameEngine/Shape1.ms3d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/Shape1.ms3d -------------------------------------------------------------------------------- /3DGameEngine/Shape2.ms3d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/Shape2.ms3d -------------------------------------------------------------------------------- /3DGameEngine/bin/a1/Starter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/a1/Starter.class -------------------------------------------------------------------------------- /3DGameEngine/bin/a2/Starter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/a2/Starter.class -------------------------------------------------------------------------------- /3DGameEngine/bin/a3/Starter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/a3/Starter.class -------------------------------------------------------------------------------- /LunarLander/bin/domain/Bomb.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/domain/Bomb.class -------------------------------------------------------------------------------- /LunarLander/bin/game/Player.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/game/Player.class -------------------------------------------------------------------------------- /LunarLander/src/domain/Bomb.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/src/domain/Bomb.java -------------------------------------------------------------------------------- /3DModelingTool/mathlib3D/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Created-By: 1.5.0_03 (Sun Microsystems Inc.) 3 | 4 | -------------------------------------------------------------------------------- /LunarLander/bin/domain/Flame.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/domain/Flame.class -------------------------------------------------------------------------------- /LunarLander/bin/domain/Lander.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/domain/Lander.class -------------------------------------------------------------------------------- /LunarLander/bin/domain/Meteor.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/domain/Meteor.class -------------------------------------------------------------------------------- /LunarLander/bin/domain/Point.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/domain/Point.class -------------------------------------------------------------------------------- /LunarLander/bin/domain/Target.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/domain/Target.class -------------------------------------------------------------------------------- /LunarLander/bin/game/GameWorld.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/game/GameWorld.class -------------------------------------------------------------------------------- /LunarLander/bin/game/MapView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/game/MapView.class -------------------------------------------------------------------------------- /LunarLander/bin/game/Starter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/game/Starter.class -------------------------------------------------------------------------------- /3DModelingTool/graphicslib3D/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Created-By: 1.5.0_03 (Sun Microsystems Inc.) 3 | 4 | -------------------------------------------------------------------------------- /3DModelingTool/mathlib3D/mathlib3D.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DModelingTool/mathlib3D/mathlib3D.jar -------------------------------------------------------------------------------- /LunarLander/bin/domain/ICollider.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/domain/ICollider.class -------------------------------------------------------------------------------- /LunarLander/bin/domain/IDrawable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/domain/IDrawable.class -------------------------------------------------------------------------------- /LunarLander/bin/domain/IMoveable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/domain/IMoveable.class -------------------------------------------------------------------------------- /LunarLander/bin/domain/Mountain.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/domain/Mountain.class -------------------------------------------------------------------------------- /LunarLander/bin/game/LanderGame.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/game/LanderGame.class -------------------------------------------------------------------------------- /LunarLander/bin/game/Scoreboard.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/game/Scoreboard.class -------------------------------------------------------------------------------- /LunarLander/bin/domain/FixedTarget.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/domain/FixedTarget.class -------------------------------------------------------------------------------- /LunarLander/bin/domain/GameObject.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/domain/GameObject.class -------------------------------------------------------------------------------- /LunarLander/bin/domain/ISelectable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/domain/ISelectable.class -------------------------------------------------------------------------------- /LunarLander/bin/domain/LandingPad.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/domain/LandingPad.class -------------------------------------------------------------------------------- /LunarLander/bin/domain/MovingObject.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/domain/MovingObject.class -------------------------------------------------------------------------------- /LunarLander/bin/domain/MovingTarget.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/domain/MovingTarget.class -------------------------------------------------------------------------------- /LunarLander/bin/domain/SpaceStation.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/domain/SpaceStation.class -------------------------------------------------------------------------------- /LunarLander/bin/game/GameController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/game/GameController.class -------------------------------------------------------------------------------- /LunarLander/bin/game/ScoreboardView.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/game/ScoreboardView.class -------------------------------------------------------------------------------- /LunarLander/bin/commands/AboutCommand.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/commands/AboutCommand.class -------------------------------------------------------------------------------- /LunarLander/bin/commands/DockCommand.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/commands/DockCommand.class -------------------------------------------------------------------------------- /LunarLander/bin/commands/HelpCommand.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/commands/HelpCommand.class -------------------------------------------------------------------------------- /LunarLander/bin/commands/QuitCommand.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/commands/QuitCommand.class -------------------------------------------------------------------------------- /LunarLander/bin/commands/SaveCommand.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/commands/SaveCommand.class -------------------------------------------------------------------------------- /LunarLander/bin/game/LanderGameRandom.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/game/LanderGameRandom.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/scene/Leaf.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/scene/Leaf.class -------------------------------------------------------------------------------- /3DModelingTool/graphicslib3D/graphicslib3D.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DModelingTool/graphicslib3D/graphicslib3D.jar -------------------------------------------------------------------------------- /LunarLander/bin/commands/DeleteCommand.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/commands/DeleteCommand.class -------------------------------------------------------------------------------- /LunarLander/bin/commands/DownJetCommand.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/commands/DownJetCommand.class -------------------------------------------------------------------------------- /LunarLander/bin/commands/LeftJetCommand.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/commands/LeftJetCommand.class -------------------------------------------------------------------------------- /LunarLander/bin/commands/NewGameCommand.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/commands/NewGameCommand.class -------------------------------------------------------------------------------- /LunarLander/bin/commands/RightJetCommand.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/commands/RightJetCommand.class -------------------------------------------------------------------------------- /LunarLander/bin/game/EndOfGameException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/game/EndOfGameException.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/scene/Group.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/scene/Group.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/scene/Plane.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/scene/Plane.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/scene/SkyBox.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/scene/SkyBox.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/timing/Game.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/timing/Game.class -------------------------------------------------------------------------------- /LunarLander/bin/commands/AddMeteorCommand.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/commands/AddMeteorCommand.class -------------------------------------------------------------------------------- /LunarLander/bin/commands/StartGameCommand.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/commands/StartGameCommand.class -------------------------------------------------------------------------------- /LunarLander/bin/game/LanderGame$KeyHandler.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/game/LanderGame$KeyHandler.class -------------------------------------------------------------------------------- /LunarLander/bin/game/LanderGameCollection.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/game/LanderGameCollection.class -------------------------------------------------------------------------------- /LunarLander/src/domain/IMoveable.java: -------------------------------------------------------------------------------- 1 | package domain; 2 | 3 | public interface IMoveable 4 | { 5 | void move (int elapsedMilliSecs); 6 | } 7 | -------------------------------------------------------------------------------- /3DGameEngine/bin/apps/games/treasureHunt/Box.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/apps/games/treasureHunt/Box.class -------------------------------------------------------------------------------- /3DGameEngine/bin/apps/games/treasureHunt/Sky.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/apps/games/treasureHunt/Sky.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/camera/Camera.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/camera/Camera.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/camera/ICamera.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/camera/ICamera.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/scene/MS3DGroup.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/scene/MS3DGroup.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/scene/MS3DModel.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/scene/MS3DModel.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/scene/SceneNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/scene/SceneNode.class -------------------------------------------------------------------------------- /LunarLander/bin/commands/ExplodeBombCommand.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/commands/ExplodeBombCommand.class -------------------------------------------------------------------------------- /3DGameEngine/bin/apps/games/treasureHunt/Score.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/apps/games/treasureHunt/Score.class -------------------------------------------------------------------------------- /3DGameEngine/bin/apps/games/treasureHunt/Shape1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/apps/games/treasureHunt/Shape1.class -------------------------------------------------------------------------------- /3DGameEngine/bin/apps/games/treasureHunt/Shape2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/apps/games/treasureHunt/Shape2.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/renderer/Renderer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/renderer/Renderer.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/scene/Controller.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/scene/Controller.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/scene/MS3DVertex.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/scene/MS3DVertex.class -------------------------------------------------------------------------------- /3DGameEngine/bin/apps/games/treasureHunt/Crystal.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/apps/games/treasureHunt/Crystal.class -------------------------------------------------------------------------------- /3DGameEngine/bin/apps/games/treasureHunt/Treasure.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/apps/games/treasureHunt/Treasure.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/renderer/IRenderer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/renderer/IRenderer.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/scene/BoundingSphere.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/scene/BoundingSphere.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/scene/BoundingVolume.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/scene/BoundingVolume.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/scene/MS3DTriangle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/scene/MS3DTriangle.class -------------------------------------------------------------------------------- /3DModelingTool/mathlib3D/javadoc/resources/inherit.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DModelingTool/mathlib3D/javadoc/resources/inherit.gif -------------------------------------------------------------------------------- /LunarLander/bin/commands/LanderGameAbstractAction.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/commands/LanderGameAbstractAction.class -------------------------------------------------------------------------------- /3DModelingTool/graphicslib3D/javadoc/resources/inherit.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DModelingTool/graphicslib3D/javadoc/resources/inherit.gif -------------------------------------------------------------------------------- /3DGameEngine/bin/apps/games/treasureHunt/TreasureHunt.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/apps/games/treasureHunt/TreasureHunt.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/scene/BouncingController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/scene/BouncingController.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/scene/RotationController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/scene/RotationController.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/timing/FixedFrameRateGame.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/timing/FixedFrameRateGame.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/displaySystem/DisplaySystem.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/displaySystem/DisplaySystem.class -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/displaySystem/DisplaySystem.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/src/futureEngine/displaySystem/DisplaySystem.java -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/displaySystem/IDisplaySystem.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/displaySystem/IDisplaySystem.class -------------------------------------------------------------------------------- /LunarLander/bin/game/LanderGameCollection$LanderGameIterator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/LunarLander/bin/game/LanderGameCollection$LanderGameIterator.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/renderer/joglRenderer/JOGLSkyBox.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/renderer/joglRenderer/JOGLSkyBox.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/scene/NonCullableBoundingVolume.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/scene/NonCullableBoundingVolume.class -------------------------------------------------------------------------------- /3DGameEngine/bin/futureEngine/renderer/joglRenderer/JOGLRenderer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/bin/futureEngine/renderer/joglRenderer/JOGLRenderer.class -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/renderer/joglRenderer/JOGLRenderer.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nathanlrivera/OpenGL/HEAD/3DGameEngine/src/futureEngine/renderer/joglRenderer/JOGLRenderer.java -------------------------------------------------------------------------------- /LunarLander/src/domain/ISelectable.java: -------------------------------------------------------------------------------- 1 | package domain; 2 | 3 | public interface ISelectable 4 | { 5 | boolean contains (int x, int y); 6 | void setSelected (boolean newVal); 7 | boolean isSelected (); 8 | } 9 | -------------------------------------------------------------------------------- /LunarLander/src/game/Starter.java: -------------------------------------------------------------------------------- 1 | package game; 2 | 3 | /** 4 | * Starts the game 5 | * 6 | */ 7 | public class Starter { 8 | public static void main(String[] args) 9 | { 10 | new LanderGame(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /LunarLander/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /LunarLander/src/domain/IDrawable.java: -------------------------------------------------------------------------------- 1 | package domain; 2 | 3 | import java.awt.Graphics; 4 | 5 | public interface IDrawable 6 | { 7 | /** 8 | * Draws the GameObject 9 | * 10 | * @param g The Graphics object to render upon 11 | */ 12 | void draw (Graphics g); 13 | } 14 | -------------------------------------------------------------------------------- /3DGameEngine/src/a3/Starter.java: -------------------------------------------------------------------------------- 1 | package a3; 2 | 3 | import apps.games.treasureHunt.TreasureHunt; 4 | 5 | public class Starter { 6 | 7 | /** 8 | * @param args 9 | */ 10 | public static void main(String[] args) { 11 | TreasureHunt t = new TreasureHunt(args); 12 | t.start(); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /3DModelingTool/Starter.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | /** 4 | * Loads an instance of the main display frame. 5 | * 6 | * @author Nathan Rivera 7 | */ 8 | public class Starter 9 | { 10 | /** 11 | * @param args Not used. 12 | */ 13 | public static void main(String[] args) 14 | { 15 | new DisplayFrame().setVisible(true); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /3DGameEngine/src/apps/games/treasureHunt/Sky.java: -------------------------------------------------------------------------------- 1 | package apps.games.treasureHunt; 2 | 3 | import futureEngine.scene.SkyBox; 4 | 5 | public class Sky extends SkyBox { 6 | 7 | public Sky() 8 | { 9 | setFront("Front.bmp"); 10 | setBack("Back.bmp"); 11 | setLeft("Left.bmp"); 12 | setRight("Right.bmp"); 13 | setTop("Top.bmp"); 14 | setBottom("Bottom.bmp"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /LunarLander/src/domain/ICollider.java: -------------------------------------------------------------------------------- 1 | package domain; 2 | 3 | import game.EndOfGameException; 4 | 5 | import java.awt.Rectangle; 6 | import java.math.BigDecimal; 7 | 8 | public interface ICollider 9 | { 10 | boolean collidesWith(ICollider otherObject); 11 | void handleCollision(ICollider otherObject) throws EndOfGameException; 12 | Rectangle getBounds(); 13 | BigDecimal getX(); 14 | BigDecimal getY(); 15 | } -------------------------------------------------------------------------------- /3DGameEngine/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | FutureEngine 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /LunarLander/src/commands/SaveCommand.java: -------------------------------------------------------------------------------- 1 | package commands; 2 | 3 | import java.awt.event.ActionEvent; 4 | 5 | public class SaveCommand extends LanderGameAbstractAction 6 | { 7 | /** 8 | * 9 | */ 10 | private static final long serialVersionUID = 1L; 11 | 12 | public SaveCommand() 13 | { 14 | super("Save"); 15 | } 16 | 17 | public void actionPerformed(ActionEvent arg0) 18 | { 19 | //System.out.println("Save command invoked"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /LunarLander/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | CSC 133 Assignment 5 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /LunarLander/src/commands/DeleteCommand.java: -------------------------------------------------------------------------------- 1 | package commands; 2 | 3 | import java.awt.event.ActionEvent; 4 | 5 | public class DeleteCommand extends LanderGameAbstractAction 6 | { 7 | 8 | public DeleteCommand() 9 | { 10 | super("Delete"); 11 | } 12 | 13 | /** 14 | * 15 | */ 16 | private static final long serialVersionUID = 1L; 17 | 18 | public void actionPerformed(ActionEvent arg0) 19 | { 20 | gameModel.deleteSelectedObjects(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/scene/BoundingVolume.java: -------------------------------------------------------------------------------- 1 | package futureEngine.scene; 2 | 3 | import graphicslib3D.Matrix3D; 4 | import graphicslib3D.Point3D; 5 | 6 | public abstract class BoundingVolume { 7 | public abstract void computeFromPoints(Point3D[] points); 8 | public abstract boolean contains(Point3D p); 9 | public abstract BoundingVolume transformBy(Matrix3D mat); 10 | public abstract boolean isOnPositiveSide(Plane p); 11 | public abstract BoundingVolume merge(BoundingVolume bv); 12 | } 13 | -------------------------------------------------------------------------------- /LunarLander/src/commands/DockCommand.java: -------------------------------------------------------------------------------- 1 | package commands; 2 | 3 | import java.awt.event.ActionEvent; 4 | 5 | public class DockCommand extends LanderGameAbstractAction 6 | { 7 | /** 8 | * Default serialVersionUID 9 | */ 10 | private static final long serialVersionUID = 1L; 11 | 12 | public DockCommand() 13 | { 14 | super("Dock"); 15 | } 16 | 17 | public void actionPerformed(ActionEvent e) 18 | { 19 | gameModel.dock(); 20 | gameModel.notifyObservers(); 21 | scoreboard.notifyObservers(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LunarLander/src/commands/NewGameCommand.java: -------------------------------------------------------------------------------- 1 | package commands; 2 | 3 | import game.LanderGame; 4 | 5 | import java.awt.event.ActionEvent; 6 | 7 | public class NewGameCommand extends LanderGameAbstractAction 8 | { 9 | /** 10 | * 11 | */ 12 | private static final long serialVersionUID = 1L; 13 | private LanderGame game; 14 | 15 | public NewGameCommand(LanderGame l) 16 | { 17 | super("New Game"); 18 | game = l; 19 | } 20 | 21 | public void actionPerformed(ActionEvent arg0) 22 | { 23 | game.newGame(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /LunarLander/src/commands/AddMeteorCommand.java: -------------------------------------------------------------------------------- 1 | package commands; 2 | 3 | import java.awt.event.ActionEvent; 4 | 5 | public class AddMeteorCommand extends LanderGameAbstractAction 6 | { 7 | 8 | /** 9 | * Default serialVersionUID 10 | */ 11 | private static final long serialVersionUID = 1L; 12 | 13 | public AddMeteorCommand() 14 | { 15 | super("Add Meteor"); 16 | } 17 | 18 | public void actionPerformed(ActionEvent e) 19 | { 20 | gameModel.addMeteor(); 21 | gameModel.notifyObservers(); 22 | scoreboard.notifyObservers(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/scene/RotationController.java: -------------------------------------------------------------------------------- 1 | package futureEngine.scene; 2 | 3 | import java.util.Iterator; 4 | 5 | import graphicslib3D.Matrix3D; 6 | 7 | public class RotationController extends Controller { 8 | 9 | @Override 10 | void update(long time) { 11 | Iterator iterator = getControlledNodes(); 12 | SceneNode n; 13 | while (iterator.hasNext()) { 14 | n = iterator.next(); 15 | Matrix3D rot = n.getLocalRotation(); 16 | rot.rotateY(time / 300000000d); 17 | n.setLocalRotation(rot); 18 | } 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/timing/Game.java: -------------------------------------------------------------------------------- 1 | package futureEngine.timing; 2 | 3 | public abstract class Game { 4 | public abstract void start(); 5 | 6 | protected abstract void initSystem(); 7 | 8 | protected abstract void initGame(); 9 | 10 | protected abstract void mainLoop(); 11 | 12 | protected abstract void update(); 13 | 14 | protected abstract void render(); 15 | 16 | protected abstract void setGameOver(boolean gameState); 17 | 18 | protected abstract boolean isGameOver(); 19 | 20 | protected abstract void shutDown(); 21 | 22 | protected abstract void exit(); 23 | } 24 | -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/displaySystem/IDisplaySystem.java: -------------------------------------------------------------------------------- 1 | package futureEngine.displaySystem; 2 | 3 | import futureEngine.renderer.IRenderer; 4 | 5 | public interface IDisplaySystem { 6 | int getWidth(); 7 | 8 | int getHeight(); 9 | 10 | int getBitDepth(); 11 | 12 | int getRefreshRate(); 13 | 14 | void setWidth(int width); 15 | 16 | void setHeight(int height); 17 | 18 | void setBitDepth(int numBits); 19 | 20 | void setRefreshRate(int rate); 21 | 22 | void setTitle(String title); 23 | 24 | IRenderer getRenderer(); 25 | 26 | boolean isRealized(); 27 | 28 | void close(); 29 | } 30 | -------------------------------------------------------------------------------- /LunarLander/src/commands/QuitCommand.java: -------------------------------------------------------------------------------- 1 | package commands; 2 | 3 | import java.awt.event.ActionEvent; 4 | 5 | import javax.swing.JOptionPane; 6 | 7 | public class QuitCommand extends LanderGameAbstractAction 8 | { 9 | 10 | /** 11 | * 12 | */ 13 | private static final long serialVersionUID = 1L; 14 | 15 | public QuitCommand() 16 | { 17 | super("Quit"); 18 | } 19 | 20 | public void actionPerformed(ActionEvent e) 21 | { 22 | int result = JOptionPane.showConfirmDialog(null, "Abort mission?", "Confirm", JOptionPane.YES_NO_OPTION); 23 | if (result == JOptionPane.YES_OPTION) 24 | quit(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/scene/Controller.java: -------------------------------------------------------------------------------- 1 | package futureEngine.scene; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Iterator; 5 | 6 | public abstract class Controller { 7 | private ArrayList controllees = new ArrayList(); 8 | 9 | public void addControlledNode(SceneNode node) { 10 | controllees.add(node); 11 | } 12 | 13 | public void removeControlledNode(SceneNode node) { 14 | controllees.remove(node); 15 | } 16 | 17 | public Iterator getControlledNodes() { 18 | return controllees.iterator(); 19 | } 20 | 21 | abstract void update(long time); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /LunarLander/src/game/Player.java: -------------------------------------------------------------------------------- 1 | package game; 2 | 3 | import java.util.*; 4 | 5 | /** 6 | * Player is resposible for getting input from the human. 7 | * 8 | */ 9 | public class Player { 10 | 11 | /** 12 | * A Scanner for reading input. 13 | */ 14 | Scanner scan; 15 | 16 | /** 17 | * Initialize the Scanner with console input. 18 | */ 19 | public Player() 20 | { 21 | scan = new Scanner(System.in); 22 | } 23 | 24 | /** 25 | * @return The character the human typed on the keyboard 26 | */ 27 | public char getCommand() 28 | { 29 | String s = scan.next(); 30 | return s.charAt(0); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /3DModelingTool/AmbientLight.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | import java.awt.Color; 4 | 5 | public class AmbientLight 6 | { 7 | static AmbientLight instance; 8 | 9 | private Color intensity; 10 | 11 | private AmbientLight() 12 | { 13 | intensity = Color.darkGray; 14 | } 15 | 16 | public static synchronized AmbientLight getInstance() 17 | { 18 | if(instance == null) 19 | instance = new AmbientLight(); 20 | return instance; 21 | } 22 | 23 | public synchronized Color getIntensity() 24 | { 25 | return intensity; 26 | } 27 | 28 | public synchronized void setIntensity(Color newIntensity) 29 | { 30 | intensity = newIntensity; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /LunarLander/src/commands/DownJetCommand.java: -------------------------------------------------------------------------------- 1 | package commands; 2 | 3 | import java.awt.event.ActionEvent; 4 | 5 | public class DownJetCommand extends LanderGameAbstractAction 6 | { 7 | /** 8 | * Default serialVersionUID 9 | */ 10 | private static final long serialVersionUID = 1L; 11 | 12 | public DownJetCommand() 13 | { 14 | super("Down Jet"); 15 | } 16 | 17 | /* (non-Javadoc) 18 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) 19 | */ 20 | public void actionPerformed(ActionEvent e) 21 | { 22 | gameModel.fireBottomJet(); 23 | gameModel.notifyObservers(); 24 | scoreboard.notifyObservers(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LunarLander/src/commands/RightJetCommand.java: -------------------------------------------------------------------------------- 1 | package commands; 2 | 3 | import java.awt.event.ActionEvent; 4 | 5 | public class RightJetCommand extends LanderGameAbstractAction 6 | { 7 | /** 8 | * Default serialVersionUID 9 | */ 10 | private static final long serialVersionUID = 1L; 11 | 12 | public RightJetCommand() 13 | { 14 | super("Right Jet"); 15 | } 16 | 17 | /* (non-Javadoc) 18 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) 19 | */ 20 | public void actionPerformed(ActionEvent e) 21 | { 22 | gameModel.fireRightJet(); 23 | gameModel.notifyObservers(); 24 | scoreboard.notifyObservers(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LunarLander/src/game/EndOfGameException.java: -------------------------------------------------------------------------------- 1 | package game; 2 | 3 | public class EndOfGameException extends Exception { 4 | 5 | /** 6 | * Use the default serialVersionUID 7 | */ 8 | private static final long serialVersionUID = 1L; 9 | 10 | /** 11 | * @param s The message to be displayed at the end of the game 12 | */ 13 | public EndOfGameException(String s) 14 | { 15 | super(s); 16 | } 17 | 18 | /** 19 | * @param s The message to be displayed at the end of the game 20 | * @param inner An inner exception to wrap this exception with 21 | */ 22 | public EndOfGameException(String s, Exception inner) 23 | { 24 | super(s, inner); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /LunarLander/src/commands/AboutCommand.java: -------------------------------------------------------------------------------- 1 | package commands; 2 | 3 | import java.awt.event.ActionEvent; 4 | 5 | import javax.swing.JOptionPane; 6 | 7 | public class AboutCommand extends LanderGameAbstractAction 8 | { 9 | 10 | /** 11 | * 12 | */ 13 | private static final long serialVersionUID = 1L; 14 | 15 | public AboutCommand() 16 | { 17 | super("About"); 18 | } 19 | 20 | public void actionPerformed(ActionEvent e) 21 | { 22 | String commandList = ""; 23 | commandList += "Author: Nathan Rivera\n\n"; 24 | commandList += "Class: CSC 133\n\n"; 25 | commandList += "Section: 1"; 26 | JOptionPane.showMessageDialog(null, commandList); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /LunarLander/src/domain/FixedTarget.java: -------------------------------------------------------------------------------- 1 | package domain; 2 | 3 | import java.awt.Color; 4 | 5 | 6 | /** 7 | * Represents a fixed object in the game, such as a Landing Pad. 8 | * 9 | */ 10 | public abstract class FixedTarget extends Target 11 | { 12 | /** 13 | * @param color The color of the Target 14 | * @param position The initial position of the Target 15 | * @param points The point value of the Target 16 | */ 17 | public FixedTarget(Color color, Point position, int points) 18 | { 19 | super(color, position, points); 20 | } 21 | 22 | /* 23 | * Do nothing because fixed targets cannot be moved 24 | */ 25 | public void setPosition(Point p) 26 | { 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /3DGameEngine/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | #Sun Oct 18 15:16:11 PDT 2009 2 | eclipse.preferences.version=1 3 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.6 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.source=1.6 13 | -------------------------------------------------------------------------------- /LunarLander/src/commands/ExplodeBombCommand.java: -------------------------------------------------------------------------------- 1 | package commands; 2 | 3 | import game.EndOfGameException; 4 | 5 | import java.awt.event.ActionEvent; 6 | 7 | public class ExplodeBombCommand extends LanderGameAbstractAction 8 | { 9 | /** 10 | * 11 | */ 12 | private static final long serialVersionUID = 1L; 13 | 14 | public ExplodeBombCommand() 15 | { 16 | super("Explode Bomb"); 17 | } 18 | 19 | public void actionPerformed(ActionEvent e) 20 | { 21 | try 22 | { 23 | gameModel.explode(); 24 | } 25 | catch (EndOfGameException ex) 26 | { 27 | printEndOfGame(ex); 28 | } 29 | gameModel.notifyObservers(); 30 | scoreboard.notifyObservers(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/scene/NonCullableBoundingVolume.java: -------------------------------------------------------------------------------- 1 | package futureEngine.scene; 2 | 3 | import graphicslib3D.Matrix3D; 4 | import graphicslib3D.Point3D; 5 | 6 | public class NonCullableBoundingVolume extends BoundingVolume { 7 | 8 | @Override 9 | public void computeFromPoints(Point3D[] points) { 10 | } 11 | 12 | @Override 13 | public boolean contains(Point3D p) { 14 | return false; 15 | } 16 | 17 | @Override 18 | public boolean isOnPositiveSide(Plane p) { 19 | return false; 20 | } 21 | 22 | @Override 23 | public BoundingVolume merge(BoundingVolume bv) { 24 | return bv; 25 | } 26 | 27 | @Override 28 | public BoundingVolume transformBy(Matrix3D mat) { 29 | return this; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/scene/Leaf.java: -------------------------------------------------------------------------------- 1 | package futureEngine.scene; 2 | 3 | import graphicslib3D.Matrix3D; 4 | 5 | public abstract class Leaf extends SceneNode { 6 | private BoundingVolume localBound; 7 | 8 | public void updateWorldBound() { 9 | Matrix3D worldTransform = new Matrix3D(); 10 | worldTransform.concatenate(getWorldTranslation()); 11 | worldTransform.concatenate(getWorldRotation()); 12 | worldTransform.concatenate(getWorldScale()); 13 | worldBound = this.localBound.transformBy(worldTransform); 14 | } 15 | 16 | public void updateLocalBound() { 17 | // Calculate local bound from model data 18 | } 19 | 20 | public void setLocalBound(BoundingVolume newBound) { 21 | localBound = newBound; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LunarLander/src/commands/LeftJetCommand.java: -------------------------------------------------------------------------------- 1 | package commands; 2 | 3 | import java.awt.event.ActionEvent; 4 | 5 | /** 6 | * Command class for firing the left jet on the Lander 7 | */ 8 | public class LeftJetCommand extends LanderGameAbstractAction 9 | { 10 | /** 11 | * Default serialVersionUID 12 | */ 13 | private static final long serialVersionUID = 1L; 14 | 15 | public LeftJetCommand() 16 | { 17 | super("Left Jet"); 18 | } 19 | 20 | /* (non-Javadoc) 21 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) 22 | */ 23 | public void actionPerformed(ActionEvent e) 24 | { 25 | gameModel.fireLeftJet(); 26 | gameModel.notifyObservers(); 27 | scoreboard.notifyObservers(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /3DGameEngine/src/apps/games/treasureHunt/Shape1.java: -------------------------------------------------------------------------------- 1 | package apps.games.treasureHunt; 2 | 3 | import java.io.IOException; 4 | import java.util.Random; 5 | 6 | import futureEngine.renderer.IRenderer; 7 | import futureEngine.scene.MS3DModel; 8 | import graphicslib3D.Matrix3D; 9 | 10 | public class Shape1 extends MS3DModel { 11 | 12 | public Shape1() { 13 | try { 14 | load("Shape1.ms3d"); 15 | } catch (IOException e) { 16 | e.printStackTrace(); 17 | } 18 | 19 | setRenderQueueMode(IRenderer.RENDERMODE_OPAQUE); 20 | setLocalBound(getBoundingSphere()); 21 | 22 | Random r = new Random(); 23 | Matrix3D loc = new Matrix3D(); 24 | loc.translate(r.nextInt(60) - 30, r.nextInt(60) - 30, r.nextInt(60) - 30); 25 | setLocalTranslation(loc); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /3DGameEngine/src/apps/games/treasureHunt/Shape2.java: -------------------------------------------------------------------------------- 1 | package apps.games.treasureHunt; 2 | 3 | import java.io.IOException; 4 | import java.util.Random; 5 | 6 | import futureEngine.renderer.IRenderer; 7 | import futureEngine.scene.MS3DModel; 8 | import graphicslib3D.Matrix3D; 9 | 10 | public class Shape2 extends MS3DModel { 11 | 12 | public Shape2() { 13 | try { 14 | load("Shape2.ms3d"); 15 | } catch (IOException e) { 16 | e.printStackTrace(); 17 | } 18 | 19 | setRenderQueueMode(IRenderer.RENDERMODE_OPAQUE); 20 | setLocalBound(getBoundingSphere()); 21 | 22 | Random r = new Random(); 23 | Matrix3D loc = new Matrix3D(); 24 | loc.translate(r.nextInt(60) - 30, r.nextInt(60) - 30, r.nextInt(60) - 30); 25 | setLocalTranslation(loc); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /3DGameEngine/src/apps/games/treasureHunt/Score.java: -------------------------------------------------------------------------------- 1 | package apps.games.treasureHunt; 2 | 3 | import futureEngine.renderer.IRenderer; 4 | import futureEngine.scene.Leaf; 5 | import futureEngine.scene.NonCullableBoundingVolume; 6 | 7 | public class Score extends Leaf { 8 | 9 | private String score; 10 | 11 | public Score() 12 | { 13 | setRenderQueueMode(IRenderer.RENDERMODE_ORTHO); 14 | NonCullableBoundingVolume bv = new NonCullableBoundingVolume(); 15 | setLocalBound(bv); 16 | } 17 | 18 | public void setScore(String newScore) 19 | { 20 | score = newScore; 21 | } 22 | 23 | public String getScore() 24 | { 25 | return score; 26 | } 27 | 28 | @Override 29 | public void draw(IRenderer renderer) { 30 | renderer.draw(this); 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /3DGameEngine/src/apps/games/treasureHunt/Treasure.java: -------------------------------------------------------------------------------- 1 | package apps.games.treasureHunt; 2 | 3 | import java.util.Random; 4 | 5 | import futureEngine.scene.Group; 6 | import graphicslib3D.Matrix3D; 7 | 8 | public class Treasure extends Group { 9 | 10 | public Treasure() 11 | { 12 | Random r = new Random(); 13 | Matrix3D loc = new Matrix3D(); 14 | loc.translate(r.nextInt(60) - 30, r.nextInt(60) - 30, r.nextInt(60) - 30); 15 | setLocalTranslation(loc); 16 | 17 | Crystal c = new Crystal(); 18 | byte[] crystalColor = new byte[3]; 19 | r.nextBytes(crystalColor); 20 | c.setColor(crystalColor); 21 | 22 | byte[] boxColor = new byte[3]; 23 | r.nextBytes(boxColor); 24 | Box b = new Box(); 25 | b.setColor(boxColor); 26 | 27 | addChild(c); 28 | addChild(b); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /3DGameEngine/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /LunarLander/src/domain/Target.java: -------------------------------------------------------------------------------- 1 | package domain; 2 | import java.awt.*; 3 | 4 | 5 | /** 6 | * Base class for all Targets in the game world. 7 | * 8 | */ 9 | public abstract class Target extends GameObject 10 | { 11 | /** 12 | * How much the Target is worth. 13 | */ 14 | protected int pointValue; 15 | 16 | /** 17 | * @param color The color of the Target 18 | * @param position The initial position of the Target 19 | * @param points The point value of the Target 20 | */ 21 | public Target(Color color, Point position, int points) 22 | { 23 | super(color, position); 24 | pointValue = points; 25 | } 26 | 27 | /** 28 | * @return The value of the target if the Lander interacts with it 29 | */ 30 | public int getPointValue() 31 | { 32 | return pointValue; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /3DGameEngine/src/apps/games/treasureHunt/Box.java: -------------------------------------------------------------------------------- 1 | package apps.games.treasureHunt; 2 | 3 | import futureEngine.renderer.IRenderer; 4 | import futureEngine.scene.BoundingSphere; 5 | import futureEngine.scene.Leaf; 6 | import graphicslib3D.Point3D; 7 | 8 | public class Box extends Leaf { 9 | 10 | private byte[] myColor; 11 | 12 | public Box() { 13 | setRenderQueueMode(IRenderer.RENDERMODE_OPAQUE); 14 | setLocalBound(new BoundingSphere(new Point3D(0,0,0), 1.0)); 15 | } 16 | 17 | @Override 18 | public void draw(IRenderer renderer) { 19 | renderer.draw(this); 20 | 21 | } 22 | 23 | /** 24 | * @param myColor the myColor to set 25 | */ 26 | public void setColor(byte[] myColor) { 27 | this.myColor = myColor; 28 | } 29 | 30 | /** 31 | * @return the myColor 32 | */ 33 | public byte[] getColor() { 34 | return myColor; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /3DGameEngine/src/apps/games/treasureHunt/Crystal.java: -------------------------------------------------------------------------------- 1 | package apps.games.treasureHunt; 2 | 3 | import futureEngine.renderer.IRenderer; 4 | import futureEngine.scene.BoundingSphere; 5 | import futureEngine.scene.Leaf; 6 | import graphicslib3D.Point3D; 7 | 8 | public class Crystal extends Leaf { 9 | 10 | private byte[] myColor; 11 | 12 | public Crystal() { 13 | setRenderQueueMode(IRenderer.RENDERMODE_OPAQUE); 14 | setLocalBound(new BoundingSphere(new Point3D(0,0,0), 1.0)); 15 | } 16 | 17 | @Override 18 | public void draw(IRenderer renderer) { 19 | renderer.draw(this); 20 | 21 | } 22 | 23 | /** 24 | * @param myColor the myColor to set 25 | */ 26 | public void setColor(byte[] myColor) { 27 | this.myColor = myColor; 28 | } 29 | 30 | /** 31 | * @return the myColor 32 | */ 33 | public byte[] getColor() { 34 | return myColor; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /3DModelingTool/Teapot.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | import java.util.Vector; 4 | import javax.media.opengl.GLAutoDrawable; 5 | import com.sun.opengl.util.GLUT; 6 | import mathlib3D.Matrix3D; 7 | import graphicslib3D.Shape3D; 8 | 9 | public class Teapot extends Shape3D 10 | { 11 | private static final long serialVersionUID = 1L; 12 | 13 | private double scale; 14 | 15 | public Teapot() 16 | { 17 | scale = 100.0; 18 | } 19 | 20 | @Override 21 | public void draw(GLAutoDrawable drawable) 22 | { 23 | GLUT glut = new GLUT(); 24 | glut.glutSolidTeapot(scale); 25 | } 26 | 27 | @Override 28 | public Vector getPolygons(Matrix3D arg0) 29 | { 30 | // TODO Auto-generated method stub 31 | return null; 32 | } 33 | 34 | public double getScale() 35 | { 36 | return scale; 37 | } 38 | 39 | public void setScale(double newScale) 40 | { 41 | scale = newScale; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /LunarLander/src/domain/MovingTarget.java: -------------------------------------------------------------------------------- 1 | package domain; 2 | 3 | import java.awt.Color; 4 | 5 | public abstract class MovingTarget extends Target implements IMoveable 6 | { 7 | protected Point myPath; 8 | 9 | public MovingTarget(Color color, Point position, int points, Point path) 10 | { 11 | super(color, position, points); 12 | myPath = path; 13 | } 14 | 15 | public void move(int timeTaken) 16 | { 17 | //Displace the MovingTarget by the amount of the trajectory. 18 | Point currPosition = getPosition(); 19 | currPosition.add(myPath); 20 | setPosition(currPosition); 21 | } 22 | 23 | /** 24 | * @return The current speed of the object 25 | */ 26 | public double getSpeed() 27 | { 28 | //The velocity is just the length of the hypotenuse of the triangle formed by the X and Y magnitudes 29 | return Math.sqrt(myPath.getX().pow(2).add(myPath.getY().pow(2)).doubleValue()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /LunarLander/src/commands/StartGameCommand.java: -------------------------------------------------------------------------------- 1 | package commands; 2 | 3 | import game.GameController; 4 | 5 | import java.awt.event.ActionEvent; 6 | 7 | import javax.swing.JButton; 8 | 9 | public class StartGameCommand extends LanderGameAbstractAction 10 | { 11 | /** 12 | * 13 | */ 14 | private static final long serialVersionUID = 1L; 15 | private JButton myButton; 16 | private GameController controller; 17 | 18 | public StartGameCommand(JButton button, GameController gc) 19 | { 20 | super("Play"); 21 | myButton = button; 22 | controller = gc; 23 | } 24 | 25 | public void actionPerformed(ActionEvent arg0) 26 | { 27 | controller.toggleEditButtons(); 28 | if (myButton.getText() == "Play") 29 | { 30 | gameModel.startAnimation(); 31 | myButton.setText("Stop"); 32 | } 33 | else 34 | { 35 | gameModel.stopAnimation(); 36 | myButton.setText("Play"); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /3DModelingTool/DistantLight.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | import javax.media.opengl.GL; 4 | import javax.media.opengl.GLAutoDrawable; 5 | import mathlib3D.Vector3D; 6 | 7 | public class DistantLight extends Light 8 | { 9 | private static final long serialVersionUID = 1L; 10 | 11 | private Vector3D direction; 12 | 13 | public DistantLight() 14 | { 15 | direction = new Vector3D(-400, -400, -400); 16 | } 17 | 18 | @Override 19 | public void draw(GLAutoDrawable drawable, int glLightNum) 20 | { 21 | GL gl = drawable.getGL(); 22 | float[] dir = new float[] { -(float) direction.getX(), -(float) direction.getY(), -(float) direction.getZ(), 0.0f }; 23 | gl.glLightfv(glLightNum, GL.GL_POSITION, dir, 0); 24 | drawBaseLight(gl, glLightNum); 25 | } 26 | 27 | public Vector3D getDirection() 28 | { 29 | return direction; 30 | } 31 | 32 | public void setDirection(Vector3D newDirection) 33 | { 34 | direction = newDirection; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/scene/BouncingController.java: -------------------------------------------------------------------------------- 1 | package futureEngine.scene; 2 | 3 | import java.util.Iterator; 4 | 5 | import graphicslib3D.Matrix3D; 6 | 7 | public class BouncingController extends Controller { 8 | private int direction; 9 | private double totalAmount; 10 | 11 | public BouncingController() { 12 | direction = 1; 13 | totalAmount = 0; 14 | } 15 | 16 | @Override 17 | void update(long time) { 18 | double amount = (time / 500000000d) * direction; 19 | totalAmount += amount; 20 | 21 | Iterator iterator = getControlledNodes(); 22 | SceneNode n; 23 | while (iterator.hasNext()) { 24 | n = iterator.next(); 25 | Matrix3D trans = n.getLocalTranslation(); 26 | trans.setElementAt(1, 3, amount + trans.elementAt(1, 3)); 27 | n.setLocalTranslation(trans); 28 | } 29 | 30 | if (totalAmount >= 1) 31 | direction = -1; 32 | else if (totalAmount <= 0) 33 | direction = 1; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /LunarLander/src/commands/LanderGameAbstractAction.java: -------------------------------------------------------------------------------- 1 | package commands; 2 | 3 | import javax.swing.AbstractAction; 4 | import game.GameWorld; 5 | import game.EndOfGameException; 6 | import game.Scoreboard; 7 | 8 | public abstract class LanderGameAbstractAction extends AbstractAction 9 | { 10 | 11 | 12 | public LanderGameAbstractAction(String str) 13 | { 14 | super(str); 15 | } 16 | 17 | protected GameWorld gameModel; 18 | public void setGameWorld(GameWorld gw) 19 | { 20 | gameModel = gw; 21 | } 22 | 23 | protected Scoreboard scoreboard; 24 | public void setScoreboard(Scoreboard s) 25 | { 26 | scoreboard = s; 27 | } 28 | 29 | protected void printEndOfGame(EndOfGameException e) 30 | { 31 | System.out.println(e.getMessage()); 32 | Throwable cause = e.getCause(); 33 | if (cause != null) 34 | System.out.println(cause.getMessage()); 35 | quit(); 36 | } 37 | 38 | protected void quit() 39 | { 40 | System.exit(0); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /3DModelingTool/Group.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | import java.util.Vector; 4 | import javax.media.opengl.GL; 5 | import javax.media.opengl.GLAutoDrawable; 6 | 7 | /** 8 | * @author n8 9 | * 10 | */ 11 | public class Group extends WorldObject 12 | { 13 | private static final long serialVersionUID = -4331296825864772714L; 14 | 15 | private Vector myObjects; 16 | 17 | public Group() 18 | { 19 | super(); 20 | myObjects = new Vector(); 21 | } 22 | 23 | /* 24 | * (non-Javadoc) 25 | * 26 | * @see a3.WorldObject#draw(javax.media.opengl.GLAutoDrawable) 27 | */ 28 | @Override 29 | public void draw(GLAutoDrawable drawable, boolean lighting) 30 | { 31 | GL gl = drawable.getGL(); 32 | gl.glMatrixMode(GL.GL_MODELVIEW); 33 | gl.glPushMatrix(); 34 | gl.glMultMatrixd(getTransform().getValues(), 0); 35 | for(WorldObject obj : myObjects) 36 | obj.draw(drawable, lighting); 37 | gl.glPopMatrix(); 38 | } 39 | 40 | /** 41 | * @param obj 42 | */ 43 | public void add(WorldObject obj) 44 | { 45 | myObjects.add(obj); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /LunarLander/src/game/LanderGameRandom.java: -------------------------------------------------------------------------------- 1 | package game; 2 | 3 | import java.util.Random; 4 | 5 | /** 6 | * Implements the Singleton pattern for the generation of random numbers 7 | * 8 | */ 9 | public class LanderGameRandom 10 | { 11 | /** 12 | * The java.util.Random used to generate the random numbers 13 | */ 14 | private Random rnd; 15 | /** 16 | * The Singleton instance of LanderGameRandom 17 | */ 18 | private static LanderGameRandom me = new LanderGameRandom(); 19 | 20 | /** 21 | * Since this is a Singleton we do not allow external callers to construct the object. 22 | */ 23 | private LanderGameRandom() 24 | { 25 | rnd = new Random(); 26 | } 27 | 28 | /** 29 | * @param n The maximum value of the random number desired 30 | * @return A random integer between 0 and n 31 | */ 32 | public int nextInt(int n) 33 | { 34 | return rnd.nextInt(n); 35 | } 36 | 37 | /** 38 | * @return A reference to the Singleton instance of LanderGameRandom 39 | */ 40 | public static LanderGameRandom getLanderGameRandom() 41 | { 42 | return me; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /3DModelingTool/mathlib3D/Readme.txt: -------------------------------------------------------------------------------- 1 | This zip file contains the "mathlib3D" library, consisting of 2 | classes designed to support development of 3D graphics systems and games. 3 | 4 | To use the library, extract the file "mathlib3D.jar" and add it to your 5 | "CLASSPATH" variable. (For example, in a Windows system if you store 6 | the extracted mathlib3D.jar file at the root of the C: drive as "C:\mathlib3D.jar", then add "C:\mathlib3D.jar" to your CLASSPATH variable.) 7 | 8 | The classes in the mathlib3D library are contained in a Java "package" named "mathlib3D"; you will need to add a statement like "import mathlib3D.*" to your classes to access the mathlib3D classes. 9 | 10 | Be sure to note that the last character in the library name is an UPPER CASE 'D', not a lower-case 'd'; your CLASSPATH and "import" statements must use the proper case. 11 | 12 | Documentation for the mathlib3D classes is contained in HTML pages in the "javadoc" 13 | directory. To use the documentation pages, extract the "javadoc" directory 14 | and open the file "index.html" in that directory in a browswer. 15 | 16 | 17 | Last update: February 23, 2007 18 | 19 | -------------------------------------------------------------------------------- /LunarLander/src/game/ScoreboardView.java: -------------------------------------------------------------------------------- 1 | package game; 2 | 3 | import java.awt.FlowLayout; 4 | import java.util.Observable; 5 | import java.util.Observer; 6 | 7 | import javax.swing.JLabel; 8 | import javax.swing.JPanel; 9 | 10 | /** 11 | * Implements a View of the Scoreboard in the game. 12 | * 13 | * Represents the View part of the Model View Controller architecture. 14 | */ 15 | public class ScoreboardView extends JPanel implements Observer 16 | { 17 | /** 18 | * 19 | */ 20 | private static final long serialVersionUID = 1L; 21 | 22 | private JLabel theLabel; 23 | 24 | public ScoreboardView() 25 | { 26 | setLayout(new FlowLayout(FlowLayout.CENTER)); 27 | theLabel = new JLabel(); 28 | add(theLabel); 29 | } 30 | 31 | /* (non-Javadoc) 32 | * @see java.util.Observer#update(java.util.Observable, java.lang.Object) 33 | */ 34 | public void update(Observable o, Object arg) 35 | { 36 | Scoreboard score = (Scoreboard)o; 37 | theLabel.setText("Elapsed time: " + score.getTimeElapsed() + " Remaining lives: " + score.getLivesRemaining() + " Score: " + score.getPointsEarned()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/scene/SkyBox.java: -------------------------------------------------------------------------------- 1 | package futureEngine.scene; 2 | 3 | public class SkyBox { 4 | 5 | public String frontPath, backPath, leftPath, rightPath, topPath, bottomPath; 6 | 7 | public String getFront() { 8 | return frontPath; 9 | } 10 | 11 | public void setFront(String fileName) { 12 | frontPath = fileName; 13 | } 14 | 15 | public String getBack() { 16 | return backPath; 17 | } 18 | 19 | public void setBack(String fileName) { 20 | backPath = fileName; 21 | } 22 | 23 | public String getLeft() { 24 | return leftPath; 25 | } 26 | 27 | public void setLeft(String fileName) { 28 | leftPath = fileName; 29 | } 30 | 31 | public String getRight() { 32 | return rightPath; 33 | } 34 | 35 | public void setRight(String fileName) { 36 | rightPath = fileName; 37 | } 38 | 39 | public String getTop() { 40 | return topPath; 41 | } 42 | 43 | public void setTop(String fileName) { 44 | topPath = fileName; 45 | } 46 | 47 | public String getBottom() { 48 | return bottomPath; 49 | } 50 | 51 | public void setBottom(String fileName) { 52 | bottomPath = fileName; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /LunarLander/src/domain/Flame.java: -------------------------------------------------------------------------------- 1 | package domain; 2 | 3 | import java.awt.Color; 4 | import java.awt.Graphics2D; 5 | import java.awt.geom.AffineTransform; 6 | 7 | public class Flame 8 | { 9 | private Color color; 10 | private AffineTransform myAT; 11 | private int myHeight, myWidth; 12 | private Point myPosition; 13 | 14 | public Flame(Point position, int width, int height) 15 | { 16 | myHeight = height; 17 | myWidth = width; 18 | color = Color.orange; 19 | myAT = new AffineTransform(); 20 | myPosition = position; 21 | } 22 | 23 | public void scale(double tx, double ty) 24 | { 25 | myAT.scale(tx, ty); 26 | } 27 | 28 | public void translate(double tx, double ty) 29 | { 30 | myAT.translate(tx, ty); 31 | } 32 | 33 | public void resetTransform() 34 | { 35 | myAT.setToIdentity(); 36 | } 37 | 38 | public void draw(Graphics2D g2d) 39 | { 40 | g2d.setColor(color); 41 | AffineTransform old = (AffineTransform) g2d.getTransform().clone(); 42 | g2d.transform(myAT); 43 | g2d.fillOval(myPosition.getX().intValue(), myPosition.getY().intValue(), myWidth, myHeight); 44 | g2d.setTransform(old); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /3DModelingTool/graphicslib3D/Readme.txt: -------------------------------------------------------------------------------- 1 | This zip file contains the "graphicslib3D" library, consisting of 2 | classes designed to support development of 3D graphics systems and games. 3 | 4 | To use the library, extract the file "graphicslib3D.jar" and add it to your 5 | "CLASSPATH" variable. (For example, in a Windows system if you store 6 | the extracted graphicslib3D.jar file at the root of the C: drive as "C:\graphicslib3D.jar", then add "C:\graphicslib3D.jar" to your CLASSPATH variable.) 7 | 8 | The classes in the graphicslib3D library are contained in a Java "package" named "graphicslib3D"; you will need to add a statement like "import graphicslib3D.*" to your classes to access the graphicslib3D classes. 9 | 10 | Be sure to note that the last character in the library name is an UPPER CASE 'D', not a lower-case 'd'; your CLASSPATH and "import" statements must use the proper case. 11 | 12 | Documentation for the graphicslib3D classes is contained in HTML pages in the "javadoc" 13 | directory. To use the documentation pages, extract the "javadoc" directory 14 | and open the file "index.html" in that directory in a browswer. 15 | 16 | 17 | Last update: February 21, 2007 18 | 19 | 20 | -------------------------------------------------------------------------------- /3DModelingTool/mathlib3D/javadoc/allclasses-noframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | All Classes 19 |
20 | 21 | 22 | 23 | 34 | 35 |
Matrix3D 24 |
25 | MatrixInvert 26 |
27 | Point3D 28 |
29 | Vector3D 30 |
31 | Vertex3D 32 |
33 |
36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/camera/ICamera.java: -------------------------------------------------------------------------------- 1 | package futureEngine.camera; 2 | 3 | import futureEngine.scene.BoundingVolume; 4 | import futureEngine.scene.Plane; 5 | import graphicslib3D.*; 6 | 7 | public interface ICamera { 8 | Vector3D getRightAxis(); 9 | Vector3D getUpAxis(); 10 | Vector3D getViewDirection(); 11 | Point3D getLocation(); 12 | 13 | void setRightAxis(Vector3D right); 14 | void setUpAxis(Vector3D up); 15 | void setViewDirection(Vector3D dir); 16 | void setLocation(Point3D loc); 17 | void setAxes(Vector3D right, Vector3D up, Vector3D viewDir); 18 | 19 | void lookAt(Point3D pos, Vector3D upDir); 20 | void setPerspectiveFrustum(double fovY, double aspect, double near, double far); 21 | 22 | void update(long time); 23 | 24 | void yaw(double mouseDeltaX); 25 | void pitch(double mouseDeltaY); 26 | void setStrafeMotion(double strafeMotion); 27 | void setForwardMotion(double forwardMotion); 28 | 29 | double[] getOrientation(); 30 | 31 | public final double SPEED = .00000002; 32 | 33 | // returns true if bound intersects current frustum 34 | public boolean intersects(BoundingVolume bound); 35 | public void setFrustrumPlanes(Plane[] newPlanes); 36 | } 37 | -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/renderer/IRenderer.java: -------------------------------------------------------------------------------- 1 | package futureEngine.renderer; 2 | 3 | import java.awt.Canvas; 4 | 5 | import apps.games.treasureHunt.Box; 6 | import apps.games.treasureHunt.Crystal; 7 | import apps.games.treasureHunt.Score; 8 | import futureEngine.camera.ICamera; 9 | import futureEngine.scene.MS3DModel; 10 | import futureEngine.scene.SceneNode; 11 | import futureEngine.scene.SkyBox; 12 | 13 | public interface IRenderer { 14 | 15 | public final int RENDERMODE_OPAQUE = 0; 16 | public final int RENDERMODE_TRANSPARENT = 1; 17 | public final int RENDERMODE_ORTHO = 2; 18 | 19 | public void addToRenderQueue(SceneNode s, int renderMode); 20 | public void addToRenderQueue(SceneNode s); 21 | public void processRenderQueue(); 22 | public void clearRenderQueue(); 23 | 24 | public ICamera getCamera(); 25 | 26 | public void enableOrthoMode(boolean enable); 27 | public boolean isInOrthoMode(); 28 | 29 | public Canvas getCanvas(); 30 | 31 | public void draw(Score score); 32 | 33 | public void setSkyBox(SkyBox sky); 34 | 35 | public long getPrimitiveCount(); 36 | public void draw(Crystal crystal); 37 | public void draw(Box box); 38 | public void draw(MS3DModel ms3dModel); 39 | } 40 | -------------------------------------------------------------------------------- /3DModelingTool/mathlib3D/javadoc/allclasses-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | All Classes 19 |
20 | 21 | 22 | 23 | 34 | 35 |
Matrix3D 24 |
25 | MatrixInvert 26 |
27 | Point3D 28 |
29 | Vector3D 30 |
31 | Vertex3D 32 |
33 |
36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /LunarLander/src/commands/HelpCommand.java: -------------------------------------------------------------------------------- 1 | package commands; 2 | 3 | import java.awt.event.ActionEvent; 4 | 5 | import javax.swing.JOptionPane; 6 | 7 | public class HelpCommand extends LanderGameAbstractAction 8 | { 9 | /** 10 | * 11 | */ 12 | private static final long serialVersionUID = 1L; 13 | 14 | public HelpCommand() 15 | { 16 | super("Help"); 17 | } 18 | 19 | public void actionPerformed(ActionEvent e) 20 | { 21 | String commandList = ""; 22 | commandList += "Press 'Arrow Down' on your keyboard to fire the down jet on the Lander.\n"; 23 | commandList += "Press 'Arrow Left' on your keyboard to the left jet on the Lander.\n"; 24 | commandList += "Press 'Arrow Right' on your keyboard to right jet on the Lander.\n"; 25 | commandList += "Click with the left mouse button to select an object.\n"; 26 | commandList += "Drag with the right mouse button to select a group of objects.\n"; 27 | commandList += "'New Game' Starts a new game.\n"; 28 | commandList += "'Add Meteor' Adds a new Meteor to the game.\n"; 29 | commandList += "'Delete' Deletes the currently selected objects.\n"; 30 | commandList += "'Play' Begins playing the game.\n"; 31 | commandList += "'Help' Shows this dialog.\n"; 32 | commandList += "'Quit' Quits the game.\n"; 33 | JOptionPane.showMessageDialog(null, commandList); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /3DModelingTool/graphicslib3D/javadoc/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* Javadoc style sheet */ 2 | 3 | /* Define colors, fonts and other style attributes here to override the defaults */ 4 | 5 | /* Page background color */ 6 | body { background-color: #FFFFFF } 7 | 8 | /* Headings */ 9 | h1 { font-size: 145% } 10 | 11 | /* Table colors */ 12 | .TableHeadingColor { background: #CCCCFF } /* Dark mauve */ 13 | .TableSubHeadingColor { background: #EEEEFF } /* Light mauve */ 14 | .TableRowColor { background: #FFFFFF } /* White */ 15 | 16 | /* Font used in left-hand frame lists */ 17 | .FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif } 18 | .FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif } 19 | .FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif } 20 | 21 | /* Navigation bar fonts and colors */ 22 | .NavBarCell1 { background-color:#EEEEFF;} /* Light mauve */ 23 | .NavBarCell1Rev { background-color:#00008B;} /* Dark Blue */ 24 | .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;} 25 | .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} 26 | 27 | .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} 28 | .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} 29 | 30 | -------------------------------------------------------------------------------- /3DModelingTool/mathlib3D/javadoc/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* Javadoc style sheet */ 2 | 3 | /* Define colors, fonts and other style attributes here to override the defaults */ 4 | 5 | /* Page background color */ 6 | body { background-color: #FFFFFF } 7 | 8 | /* Headings */ 9 | h1 { font-size: 145% } 10 | 11 | /* Table colors */ 12 | .TableHeadingColor { background: #CCCCFF } /* Dark mauve */ 13 | .TableSubHeadingColor { background: #EEEEFF } /* Light mauve */ 14 | .TableRowColor { background: #FFFFFF } /* White */ 15 | 16 | /* Font used in left-hand frame lists */ 17 | .FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif } 18 | .FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif } 19 | .FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif } 20 | 21 | /* Navigation bar fonts and colors */ 22 | .NavBarCell1 { background-color:#EEEEFF;} /* Light mauve */ 23 | .NavBarCell1Rev { background-color:#00008B;} /* Dark Blue */ 24 | .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;} 25 | .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} 26 | 27 | .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} 28 | .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} 29 | 30 | -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/scene/Plane.java: -------------------------------------------------------------------------------- 1 | package futureEngine.scene; 2 | 3 | import graphicslib3D.Point3D; 4 | 5 | public class Plane { 6 | private double a, b, c, d; 7 | 8 | public Plane(double aValue, double bValue, double cValue, double dValue) { 9 | a = aValue; 10 | b = bValue; 11 | c = cValue; 12 | d = dValue; 13 | } 14 | 15 | /** 16 | * @param a the a to set 17 | */ 18 | public void setA(double a) { 19 | this.a = a; 20 | } 21 | 22 | /** 23 | * @return the a 24 | */ 25 | public double getA() { 26 | return a; 27 | } 28 | 29 | /** 30 | * @param b the b to set 31 | */ 32 | public void setB(double b) { 33 | this.b = b; 34 | } 35 | 36 | /** 37 | * @return the b 38 | */ 39 | public double getB() { 40 | return b; 41 | } 42 | 43 | /** 44 | * @param c the c to set 45 | */ 46 | public void setC(double c) { 47 | this.c = c; 48 | } 49 | 50 | /** 51 | * @return the c 52 | */ 53 | public double getC() { 54 | return c; 55 | } 56 | 57 | /** 58 | * @param d the d to set 59 | */ 60 | public void setD(double d) { 61 | this.d = d; 62 | } 63 | 64 | /** 65 | * @return the d 66 | */ 67 | public double getD() { 68 | return d; 69 | } 70 | 71 | public double distanceTo(Point3D p) { 72 | return (p.getX() * a) + (p.getY() * b) + (p.getZ() * c) + d; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /3DModelingTool/mathlib3D/javadoc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Generated Documentation (Untitled) 8 | 9 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | <H2> 26 | Frame Alert</H2> 27 | 28 | <P> 29 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. 30 | <BR> 31 | Link to<A HREF="mathlib3D/package-summary.html">Non-frame version.</A> 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/scene/MS3DVertex.java: -------------------------------------------------------------------------------- 1 | package futureEngine.scene; 2 | /* 3 | * This class describes a model vertex in an MS3D file. 4 | */ 5 | public class MS3DVertex { 6 | private byte flags; 7 | private float[] geometry = new float[3]; //vertex XYZ geometry values 8 | private byte boneID = -1; 9 | private byte refCount; 10 | 11 | /** 12 | * @param flags the flags to set 13 | */ 14 | public void setFlags(byte flags) { 15 | this.flags = flags; 16 | } 17 | /** 18 | * @return the flags 19 | */ 20 | public byte getFlags() { 21 | return flags; 22 | } 23 | /** 24 | * @param geometry the geometry to set 25 | */ 26 | public void setGeometry(float[] geometry) { 27 | this.geometry = geometry; 28 | } 29 | /** 30 | * @return the geometry 31 | */ 32 | public float[] getGeometry() { 33 | return geometry; 34 | } 35 | /** 36 | * @param boneID the boneID to set 37 | */ 38 | public void setBoneID(byte boneID) { 39 | this.boneID = boneID; 40 | } 41 | /** 42 | * @return the boneID 43 | */ 44 | public byte getBoneID() { 45 | return boneID; 46 | } 47 | /** 48 | * @param refCount the refCount to set 49 | */ 50 | public void setRefCount(byte refCount) { 51 | this.refCount = refCount; 52 | } 53 | /** 54 | * @return the refCount 55 | */ 56 | public byte getRefCount() { 57 | return refCount; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /3DModelingTool/graphicslib3D/javadoc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Generated Documentation (Untitled) 8 | 9 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | <H2> 26 | Frame Alert</H2> 27 | 28 | <P> 29 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. 30 | <BR> 31 | Link to<A HREF="graphicslib3D/package-summary.html">Non-frame version.</A> 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /LunarLander/src/domain/MovingObject.java: -------------------------------------------------------------------------------- 1 | package domain; 2 | 3 | import java.awt.Color; 4 | import java.math.BigDecimal; 5 | 6 | /** 7 | * Represents a moving object. 8 | * 9 | */ 10 | public abstract class MovingObject extends GameObject implements IMoveable 11 | { 12 | protected Point myPath; 13 | private static final double gravity = -1.622; // Gravity on the Moon is 1.622 N/m 14 | 15 | public MovingObject(Color color, Point position, Point path) 16 | { 17 | super(color, position); 18 | myPath = path; 19 | } 20 | 21 | /** 22 | * @return The current speed of the object 23 | */ 24 | public double getSpeed() 25 | { 26 | //The velocity is just the length of the hypotenuse of the triangle formed by the X and Y magnitudes 27 | return Math.sqrt(myPath.getX().pow(2).add(myPath.getY().pow(2)).doubleValue()); 28 | } 29 | 30 | protected final void moveWithGravity(int time) 31 | { 32 | BigDecimal timeTaken = new BigDecimal(time).divide(new BigDecimal(1000)); 33 | BigDecimal ySpeed = myPath.getY(); 34 | ySpeed = ySpeed.add(new BigDecimal(gravity).multiply(timeTaken)); 35 | myPath = new Point(myPath.getX(), ySpeed); 36 | BigDecimal yPos = myPath.getY(); 37 | yPos = yPos.add(ySpeed.multiply(timeTaken)); 38 | yPos = yPos.add(new BigDecimal(gravity / 2.0).multiply(timeTaken).multiply(timeTaken)); 39 | myPosition.add(new Point(myPath.getX(), yPos)); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /3DModelingTool/mathlib3D/javadoc/mathlib3D/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | mathlib3D 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | mathlib3D 20 | 21 | 22 | 35 | 36 |
23 | Classes  24 | 25 |
26 | Matrix3D 27 |
28 | MatrixInvert 29 |
30 | Point3D 31 |
32 | Vector3D 33 |
34 | Vertex3D
37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /3DModelingTool/WorldObject.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | import java.io.Serializable; 4 | import javax.media.opengl.GLAutoDrawable; 5 | import mathlib3D.Matrix3D; 6 | import mathlib3D.Vector3D; 7 | 8 | public abstract class WorldObject implements Serializable 9 | { 10 | public abstract void draw(GLAutoDrawable drawable, boolean lighting); 11 | 12 | private Vector3D myScale; 13 | 14 | private Vector3D myRotation; 15 | 16 | private Vector3D myTranslation; 17 | 18 | public WorldObject() 19 | { 20 | myScale = new Vector3D(1, 1, 1); 21 | myRotation = new Vector3D(0, 0, 0); 22 | myTranslation = new Vector3D(0, 0, 0); 23 | } 24 | 25 | public Matrix3D getTransform() 26 | { 27 | Matrix3D m = new Matrix3D(); 28 | m.setToIdentity(); 29 | m.translate(myTranslation.getX(), myTranslation.getY(), myTranslation.getZ()); 30 | m.rotate(myRotation.getX(), myRotation.getY(), myRotation.getZ()); 31 | m.scale(myScale.getX(), myScale.getY(), myScale.getZ()); 32 | return m; 33 | } 34 | 35 | public Vector3D getRotation() 36 | { 37 | return myRotation; 38 | } 39 | 40 | public void setRotation(Vector3D newRotation) 41 | { 42 | myRotation = newRotation; 43 | } 44 | 45 | public Vector3D getScale() 46 | { 47 | return myScale; 48 | } 49 | 50 | public void setScale(Vector3D newScale) 51 | { 52 | myScale = newScale; 53 | } 54 | 55 | public Vector3D getTranslation() 56 | { 57 | return myTranslation; 58 | } 59 | 60 | public void setTranslation(Vector3D newTranslation) 61 | { 62 | myTranslation = newTranslation; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /LunarLander/src/domain/Point.java: -------------------------------------------------------------------------------- 1 | package domain; 2 | 3 | import java.math.BigDecimal; 4 | 5 | /** 6 | * A Point represented as an (X,Y) Cartesian coordinate. 7 | * 8 | */ 9 | public class Point { 10 | 11 | /** 12 | * The horizontal component. 13 | */ 14 | private BigDecimal myX; 15 | /** 16 | * The vertical component. 17 | */ 18 | private BigDecimal myY; 19 | 20 | /** 21 | * The default point is at (0,0) 22 | */ 23 | public Point() 24 | { 25 | myX = new BigDecimal(0); 26 | myY = new BigDecimal(0); 27 | } 28 | 29 | /** 30 | * @param x The initial X position 31 | * @param y The initial Y position 32 | */ 33 | public Point(double x, double y) 34 | { 35 | myX = new BigDecimal(x); 36 | myY = new BigDecimal(y); 37 | } 38 | 39 | public Point(BigDecimal x, BigDecimal y) 40 | { 41 | myX = x; 42 | myY = y; 43 | } 44 | 45 | /** 46 | * @param p The Point object to copy 47 | */ 48 | public Point(Point p) 49 | { 50 | myX = p.getX(); 51 | myY = p.getY(); 52 | } 53 | 54 | /** 55 | * @param v The Point to add to this Point. 56 | */ 57 | public void add(Point v) 58 | { 59 | myX = myX.add(v.getX()); 60 | myY = myY.add(v.getY()); 61 | } 62 | 63 | /** 64 | * @return The vertical component 65 | */ 66 | public BigDecimal getY() { 67 | return myY; 68 | } 69 | 70 | /** 71 | * @return The horizontal component 72 | */ 73 | public BigDecimal getX() { 74 | return myX; 75 | } 76 | 77 | /* (non-Javadoc) 78 | * @see java.lang.Object#toString() 79 | */ 80 | public String toString() 81 | { 82 | return myX + "," + myY; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /LunarLander/src/domain/SpaceStation.java: -------------------------------------------------------------------------------- 1 | package domain; 2 | 3 | import java.awt.Color; 4 | import java.awt.Graphics; 5 | import java.awt.Rectangle; 6 | 7 | 8 | /** 9 | * The Space Station is a fixed target that the Lander can dock with. 10 | * It protects the Lander from Meteors. 11 | */ 12 | public class SpaceStation extends FixedTarget 13 | { 14 | /** 15 | * The diameter of the SpaceStation 16 | */ 17 | private int myDiameter; 18 | 19 | /** 20 | * @param color The color of the Space Station 21 | * @param position The (fixed) position of the Space Station 22 | * @param points The point value for the Space Station 23 | */ 24 | public SpaceStation(Color color, Point position, int points, int diameter) 25 | { 26 | super(color, position, points); 27 | myDiameter = diameter; 28 | } 29 | 30 | /** 31 | * @return The diameter of the SpaceStation 32 | */ 33 | public int getDiameter() 34 | { 35 | return myDiameter; 36 | } 37 | 38 | /* (non-Javadoc) 39 | * @see java.lang.Object#toString() 40 | */ 41 | public String toString() 42 | { 43 | return String.format("SpaceStation: pos=%1$s color=%2$s ptVal=%3$d diameter=%4$d", getPosition(), myColor, pointValue, myDiameter); 44 | } 45 | 46 | public void draw(Graphics g) 47 | { 48 | g.setColor(getColor()); 49 | g.drawOval(getPosition().getX().intValue(), getPosition().getY().intValue(), getDiameter(), getDiameter()); 50 | } 51 | 52 | public Rectangle getBounds() 53 | { 54 | return new Rectangle(myDiameter, myDiameter); 55 | } 56 | 57 | public void handleCollision(ICollider otherObject) 58 | { 59 | // TODO Auto-generated method stub 60 | 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /3DModelingTool/Light.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | import java.awt.Color; 4 | import java.io.Serializable; 5 | import java.nio.FloatBuffer; 6 | import javax.media.opengl.GL; 7 | import javax.media.opengl.GLAutoDrawable; 8 | 9 | public abstract class Light implements Serializable 10 | { 11 | private String myName; 12 | 13 | protected Color ambient; 14 | 15 | protected Color diffuse; 16 | 17 | protected Color specular; 18 | 19 | public Light() 20 | { 21 | myName = ""; 22 | ambient = Color.black; 23 | diffuse = Color.white; 24 | specular = Color.white; 25 | } 26 | 27 | public String getName() 28 | { 29 | return myName; 30 | } 31 | 32 | public void setName(String newName) 33 | { 34 | myName = newName; 35 | } 36 | 37 | public Color getAmbient() 38 | { 39 | return ambient; 40 | } 41 | 42 | public void setAmbient(Color newAmbient) 43 | { 44 | ambient = newAmbient; 45 | } 46 | 47 | public Color getDiffuse() 48 | { 49 | return diffuse; 50 | } 51 | 52 | public void setDiffuse(Color newDiffuse) 53 | { 54 | diffuse = newDiffuse; 55 | } 56 | 57 | public Color getSpecular() 58 | { 59 | return specular; 60 | } 61 | 62 | public void setSpecular(Color newSpecular) 63 | { 64 | specular = newSpecular; 65 | } 66 | 67 | abstract void draw(GLAutoDrawable drawable, int glLightNum); 68 | 69 | protected void drawBaseLight(GL gl, int glLightNum) 70 | { 71 | gl.glLightfv(glLightNum, GL.GL_AMBIENT, FloatBuffer.wrap(ambient.getRGBComponents(null))); 72 | gl.glLightfv(glLightNum, GL.GL_DIFFUSE, FloatBuffer.wrap(diffuse.getRGBComponents(null))); 73 | gl.glLightfv(glLightNum, GL.GL_SPECULAR, FloatBuffer.wrap(specular.getRGBComponents(null))); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/scene/MS3DTriangle.java: -------------------------------------------------------------------------------- 1 | package futureEngine.scene; 2 | 3 | public class MS3DTriangle { 4 | private short flags; 5 | private short[] vertexIndices; 6 | private float[][] vertexNormals; 7 | private float[] sTexCoord; 8 | private float[] tTexCoord; 9 | /** 10 | * @param flags the flags to set 11 | */ 12 | public void setFlags(short flags) { 13 | this.flags = flags; 14 | } 15 | /** 16 | * @return the flags 17 | */ 18 | public short getFlags() { 19 | return flags; 20 | } 21 | /** 22 | * @param vertexIndices the vertexIndices to set 23 | */ 24 | public void setVertexIndices(short[] vertexIndices) { 25 | this.vertexIndices = vertexIndices; 26 | } 27 | /** 28 | * @return the vertexIndices 29 | */ 30 | public short[] getVertexIndices() { 31 | return vertexIndices; 32 | } 33 | /** 34 | * @param vertexNormals the vertexNormals to set 35 | */ 36 | public void setVertexNormals(float[][] vertexNormals) { 37 | this.vertexNormals = vertexNormals; 38 | } 39 | /** 40 | * @return the vertexNormals 41 | */ 42 | public float[][] getVertexNormals() { 43 | return vertexNormals; 44 | } 45 | /** 46 | * @param sTexCoord the sTexCoord to set 47 | */ 48 | public void setSTexCoord(float[] sTexCoord) { 49 | this.sTexCoord = sTexCoord; 50 | } 51 | /** 52 | * @return the sTexCoord 53 | */ 54 | public float[] getSTexCoord() { 55 | return sTexCoord; 56 | } 57 | /** 58 | * @param tTexCoord the tTexCoord to set 59 | */ 60 | public void setTTexCoord(float[] tTexCoord) { 61 | this.tTexCoord = tTexCoord; 62 | } 63 | /** 64 | * @return the tTexCoord 65 | */ 66 | public float[] getTTexCoord() { 67 | return tTexCoord; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /3DModelingTool/MouseInput.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | import java.awt.Point; 4 | import java.awt.event.MouseEvent; 5 | import java.awt.event.MouseWheelEvent; 6 | import javax.swing.event.MouseInputAdapter; 7 | 8 | /** 9 | * Handles mouse interaction GLCanvas. 10 | * 11 | * @author Nathan Rivera 12 | */ 13 | public class MouseInput extends MouseInputAdapter 14 | { 15 | private Camera myCamera; 16 | 17 | Point prevPoint = null; 18 | 19 | /** 20 | * @param canvas The GLCanvas that the user will click/drag on. 21 | */ 22 | public MouseInput(Camera camera) 23 | { 24 | myCamera = camera; 25 | } 26 | 27 | /* 28 | * (non-Javadoc) 29 | * 30 | * @see javax.swing.event.MouseInputAdapter#mouseDragged(java.awt.event.MouseEvent) 31 | */ 32 | @Override 33 | public void mouseDragged(MouseEvent e) 34 | { 35 | if(prevPoint != null) 36 | { 37 | Point currentPoint = e.getPoint(); 38 | myCamera.changeYaw(currentPoint.getX() - prevPoint.getX()); 39 | myCamera.changePitch(currentPoint.getY() - prevPoint.getY()); 40 | prevPoint = currentPoint; 41 | } 42 | } 43 | 44 | /* 45 | * (non-Javadoc) 46 | * 47 | * @see javax.swing.event.MouseInputAdapter#mousePressed(java.awt.event.MouseEvent) 48 | */ 49 | @Override 50 | public void mousePressed(MouseEvent e) 51 | { 52 | prevPoint = e.getPoint(); 53 | } 54 | 55 | /* 56 | * (non-Javadoc) 57 | * 58 | * @see javax.swing.event.MouseInputAdapter#mouseReleased(java.awt.event.MouseEvent) 59 | */ 60 | @Override 61 | public void mouseReleased(MouseEvent e) 62 | { 63 | prevPoint = null; 64 | } 65 | 66 | @Override 67 | public void mouseWheelMoved(MouseWheelEvent e) 68 | { 69 | myCamera.changeZ(e.getWheelRotation() * 5.0); 70 | } 71 | } -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/scene/MS3DGroup.java: -------------------------------------------------------------------------------- 1 | package futureEngine.scene; 2 | 3 | public class MS3DGroup { 4 | private byte flags; 5 | private String groupName; 6 | private short numTriangles; 7 | private short[] triangleIndices; 8 | private short materialIndex; 9 | /** 10 | * @param flags the flags to set 11 | */ 12 | public void setFlags(byte flags) { 13 | this.flags = flags; 14 | } 15 | /** 16 | * @return the flags 17 | */ 18 | public byte getFlags() { 19 | return flags; 20 | } 21 | /** 22 | * @param groupName the groupName to set 23 | */ 24 | public void setGroupName(String groupName) { 25 | this.groupName = groupName; 26 | } 27 | /** 28 | * @return the groupName 29 | */ 30 | public String getGroupName() { 31 | return groupName; 32 | } 33 | /** 34 | * @param numTriangles the numTriangles to set 35 | */ 36 | public void setNumTriangles(short numTriangles) { 37 | this.numTriangles = numTriangles; 38 | } 39 | /** 40 | * @return the numTriangles 41 | */ 42 | public short getNumTriangles() { 43 | return numTriangles; 44 | } 45 | /** 46 | * @param triangleIndexes the triangleIndexes to set 47 | */ 48 | public void setTriangleIndices(short[] triangleIndices) { 49 | this.triangleIndices = triangleIndices; 50 | } 51 | /** 52 | * @return the triangleIndexes 53 | */ 54 | public short[] getTriangleIndices() { 55 | return triangleIndices; 56 | } 57 | /** 58 | * @param materialIndex the materialIndex to set 59 | */ 60 | public void setMaterialIndex(short materialIndex) { 61 | this.materialIndex = materialIndex; 62 | } 63 | /** 64 | * @return the materialIndex 65 | */ 66 | public short getMaterialIndex() { 67 | return materialIndex; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /3DModelingTool/KeyboardInput.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | import java.awt.event.KeyAdapter; 4 | import java.awt.event.KeyEvent; 5 | 6 | public class KeyboardInput extends KeyAdapter 7 | { 8 | private Camera myCamera; 9 | 10 | /** 11 | * @param canvas The GLCanvas that the user will click/drag on. 12 | */ 13 | public KeyboardInput(Camera camera) 14 | { 15 | myCamera = camera; 16 | } 17 | 18 | @Override 19 | public void keyPressed(KeyEvent e) 20 | { 21 | if(!myCamera.getRelativeMode()) 22 | return; 23 | double increment = 5.0; 24 | double angleIncrement = 2.5; 25 | switch(e.getKeyCode()) 26 | { 27 | case KeyEvent.VK_ESCAPE: 28 | System.exit(0); 29 | break; 30 | case KeyEvent.VK_A: 31 | myCamera.changeX(-increment); 32 | break; 33 | case KeyEvent.VK_D: 34 | myCamera.changeX(increment); 35 | break; 36 | case KeyEvent.VK_W: 37 | myCamera.changeY(-increment); 38 | break; 39 | case KeyEvent.VK_S: 40 | myCamera.changeY(increment); 41 | break; 42 | case KeyEvent.VK_Q: 43 | myCamera.changeZ(-increment); 44 | break; 45 | case KeyEvent.VK_E: 46 | myCamera.changeZ(increment); 47 | break; 48 | case KeyEvent.VK_UP: 49 | myCamera.changePitch(-angleIncrement); 50 | break; 51 | case KeyEvent.VK_DOWN: 52 | myCamera.changePitch(angleIncrement); 53 | break; 54 | case KeyEvent.VK_LEFT: 55 | myCamera.changeYaw(-angleIncrement); 56 | break; 57 | case KeyEvent.VK_RIGHT: 58 | myCamera.changeYaw(angleIncrement); 59 | break; 60 | case KeyEvent.VK_INSERT: 61 | myCamera.changeRoll(-angleIncrement); 62 | break; 63 | case KeyEvent.VK_PAGE_UP: 64 | myCamera.changeRoll(angleIncrement); 65 | break; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /3DModelingTool/SpotLight.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | import javax.media.opengl.GL; 4 | import javax.media.opengl.GLAutoDrawable; 5 | import mathlib3D.Point3D; 6 | import mathlib3D.Vector3D; 7 | 8 | public class SpotLight extends PositionalLight 9 | { 10 | private static final long serialVersionUID = 1L; 11 | 12 | private Vector3D direction; 13 | 14 | private float cutoffAngle; 15 | 16 | private float exponent; 17 | 18 | public SpotLight() 19 | { 20 | direction = new Vector3D(0, 0, -300); 21 | setPosition(new Point3D(0, 0, 300)); 22 | cutoffAngle = 90; 23 | exponent = 45; 24 | } 25 | 26 | public float getCutoffAngle() 27 | { 28 | return cutoffAngle; 29 | } 30 | 31 | public void setCutoffAngle(float cutoffAngle) 32 | { 33 | this.cutoffAngle = cutoffAngle; 34 | } 35 | 36 | public float getExponent() 37 | { 38 | return exponent; 39 | } 40 | 41 | public void setExponent(float exponent) 42 | { 43 | this.exponent = exponent; 44 | } 45 | 46 | @Override 47 | public void draw(GLAutoDrawable drawable, int glLightNum) 48 | { 49 | float[] dir = new float[] { (float) getDirection().getX(), (float) getDirection().getY(), (float) getDirection().getZ() }; 50 | float[] pos = new float[] { (float) getPosition().getX(), (float) getPosition().getY(), (float) getPosition().getZ(), 1.0f }; 51 | GL gl = drawable.getGL(); 52 | drawBaseLight(gl, glLightNum); 53 | gl.glLightfv(glLightNum, GL.GL_POSITION, pos, 0); 54 | gl.glLightfv(glLightNum, GL.GL_SPOT_DIRECTION, dir, 0); 55 | gl.glLightf(glLightNum, GL.GL_SPOT_CUTOFF, getCutoffAngle()); 56 | gl.glLightf(glLightNum, GL.GL_SPOT_EXPONENT, getExponent()); 57 | drawAttenuation(glLightNum, gl); 58 | gl.glEnable(glLightNum); 59 | } 60 | 61 | public Vector3D getDirection() 62 | { 63 | return direction; 64 | } 65 | 66 | public void setDirection(Vector3D newDirection) 67 | { 68 | direction = newDirection; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /3DModelingTool/SlerpAction.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.awt.event.ActionListener; 5 | import javax.swing.Timer; 6 | import mathlib3D.Point3D; 7 | 8 | /** 9 | * ActionListener to handle the timer events for SLERP 10 | */ 11 | public class SlerpAction implements ActionListener 12 | { 13 | private double maxIterations, 14 | currentIterations; 15 | 16 | private Timer theTimer; 17 | 18 | private Point3D startPoint, 19 | endPoint; 20 | 21 | private double xDist, 22 | yDist, 23 | zDist; 24 | 25 | private Quaternion startQuaternion, 26 | endQuaternion; 27 | 28 | private Camera myCamera; 29 | 30 | public SlerpAction(Camera camera, Point3D start, Quaternion startQ, Point3D end, Quaternion endQ, double time) 31 | { 32 | myCamera = camera; 33 | maxIterations = time * 60.0; 34 | currentIterations = 0; 35 | startPoint = start; 36 | endPoint = end; 37 | xDist = (endPoint.getX() - startPoint.getX()) / maxIterations; 38 | yDist = (endPoint.getY() - startPoint.getY()) / maxIterations; 39 | zDist = (endPoint.getZ() - startPoint.getZ()) / maxIterations; 40 | startQuaternion = startQ; 41 | endQuaternion = endQ; 42 | startQuaternion.normalize(); 43 | endQuaternion.normalize(); 44 | } 45 | 46 | public void setTimer(Timer timer) 47 | { 48 | theTimer = timer; 49 | } 50 | 51 | /* 52 | * (non-Javadoc) 53 | * 54 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) 55 | */ 56 | public void actionPerformed(ActionEvent arg0) 57 | { 58 | if(currentIterations < maxIterations) 59 | { 60 | myCamera.changeX(xDist); 61 | myCamera.changeY(yDist); 62 | myCamera.changeZ(zDist); 63 | Quaternion slerp = Quaternion.Slerp(startQuaternion, endQuaternion, currentIterations / maxIterations); 64 | myCamera.setOrientation(slerp); 65 | ++currentIterations; 66 | } 67 | else 68 | theTimer.stop(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /LunarLander/src/domain/Mountain.java: -------------------------------------------------------------------------------- 1 | package domain; 2 | 3 | import java.awt.*; 4 | import java.awt.geom.*; 5 | 6 | 7 | /** 8 | * A Mountain is a fixed target which stays on the ground. 9 | * When the lander runs into a Mountain, the Lander will be destroyed. 10 | * 11 | */ 12 | public class Mountain extends FixedTarget 13 | { 14 | /** 15 | * The height of the Mountain. 16 | */ 17 | private int leftHeight; 18 | /** 19 | * The width of the Mountain. 20 | */ 21 | private int myWidth; 22 | private int rightHeight; 23 | 24 | /** 25 | * @param color The color of the Mountain 26 | * @param position The position of the Mountain 27 | * @param points The point value for the Mountain 28 | */ 29 | public Mountain(Color color, Point position, int points, int width, int left, int right) 30 | { 31 | super(color, position, points); 32 | myWidth = width; 33 | leftHeight = left; 34 | rightHeight = right; 35 | } 36 | 37 | /* (non-Javadoc) 38 | * @see java.lang.Object#toString() 39 | */ 40 | public String toString() 41 | { 42 | return String.format("Mountain: pos=%1$s color=%2$s ptVal=%3$d", getPosition(), myColor, pointValue); 43 | } 44 | 45 | /** 46 | * @return The width of the LandingPad 47 | */ 48 | public int getWidth() 49 | { 50 | return myWidth; 51 | } 52 | 53 | private Polygon getPolygon() 54 | { 55 | int x = getX().intValue(); 56 | int y = getY().intValue(); 57 | int xPoints[] = {x, x + getWidth(), x + getWidth(), x}; 58 | int yPoints[] = {y, y, rightHeight, leftHeight}; 59 | return new Polygon(xPoints, yPoints, 4); 60 | } 61 | 62 | public void draw(Graphics g) 63 | { 64 | g.setColor(getColor()); 65 | 66 | g.fillPolygon(getPolygon()); 67 | } 68 | 69 | public Rectangle getBounds() 70 | { 71 | return new Rectangle(myWidth, Math.max(rightHeight, leftHeight)); 72 | } 73 | 74 | public void handleCollision(ICollider otherObject) 75 | { 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/timing/FixedFrameRateGame.java: -------------------------------------------------------------------------------- 1 | package futureEngine.timing; 2 | 3 | public abstract class FixedFrameRateGame extends Game { 4 | 5 | private boolean gameOver; 6 | private int frameCount; 7 | private long startTime; 8 | private int desiredFPS; 9 | protected long desiredFrameDuration; 10 | 11 | @Override 12 | public final void start() { 13 | initSystem(); 14 | initGame(); 15 | mainLoop(); 16 | shutDown(); 17 | exit(); 18 | } 19 | 20 | @Override 21 | protected final void mainLoop() { 22 | long frameStartTime, frameEndTime, frameDuration, sleepTimeMSec; 23 | while (!isGameOver()) { 24 | frameStartTime = System.nanoTime(); 25 | update(); 26 | render(); 27 | ++frameCount; 28 | frameEndTime = System.nanoTime(); 29 | frameDuration = frameEndTime - frameStartTime; 30 | while (frameDuration < desiredFrameDuration) { 31 | sleepTimeMSec = (desiredFrameDuration - frameDuration) / 1000000; 32 | try { 33 | Thread.sleep(sleepTimeMSec); 34 | } catch (InterruptedException e) { 35 | e.printStackTrace(); 36 | return; 37 | } 38 | frameDuration = System.nanoTime() - frameStartTime; 39 | } 40 | Thread.yield(); 41 | } 42 | } 43 | 44 | @Override 45 | protected final void setGameOver(boolean gameState) { 46 | gameOver = gameState; 47 | } 48 | 49 | @Override 50 | protected final boolean isGameOver() { 51 | return gameOver; 52 | } 53 | 54 | @Override 55 | protected void exit() { 56 | System.exit(0); 57 | } 58 | 59 | public final void setMaxFrameRate(int rate) { 60 | desiredFPS = rate; 61 | desiredFrameDuration = 1000000000 / desiredFPS; 62 | } 63 | 64 | public final float getFramesPerSec() { 65 | long currentTime = System.nanoTime(); 66 | float elapsedSeconds = (currentTime - startTime) / (float) 1000000000L; 67 | float fps = frameCount / elapsedSeconds; 68 | startTime = currentTime; 69 | frameCount = 0; 70 | return fps; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /3DModelingTool/QuarterPatch.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | import java.util.Vector; 4 | import javax.media.opengl.GL; 5 | import javax.media.opengl.GLAutoDrawable; 6 | import mathlib3D.*; 7 | import graphicslib3D.*; 8 | 9 | /** 10 | * @author n8 11 | * 12 | */ 13 | public class QuarterPatch extends SurfacePatch implements IQuarterPatch 14 | { 15 | private static final long serialVersionUID = -1251013713498008203L; 16 | 17 | private Vector myControlPoints; 18 | 19 | @SuppressWarnings("unchecked") 20 | public QuarterPatch() 21 | { 22 | myControlPoints = new Vector(); 23 | myControlPoints.add(new Point3D(0, 50, 0)); 24 | myControlPoints.add(new Point3D(0, 25, 0)); 25 | myControlPoints.add(new Point3D(0, -25, 0)); 26 | myControlPoints.add(new Point3D(0, -50, 0)); 27 | } 28 | 29 | /* 30 | * (non-Javadoc) 31 | * 32 | * @see graphicslib3D.IQuarterPatch#getControlPointVector() 33 | */ 34 | public Vector getControlPointVector() 35 | { 36 | return myControlPoints; 37 | } 38 | 39 | /* 40 | * (non-Javadoc) 41 | * 42 | * @see graphicslib3D.IQuarterPatch#setControlPointVector(java.util.Vector) 43 | */ 44 | public void setControlPointVector(Vector newVector) 45 | { 46 | myControlPoints = newVector; 47 | ControlMesh mesh = getControlMesh(); 48 | for(int i = 0; i < 4; ++i) 49 | { 50 | Point3D currentPoint = (Point3D) myControlPoints.get(i); 51 | double x = currentPoint.getX(); 52 | double y = currentPoint.getY(); 53 | mesh.addElement((Point3D) currentPoint.clone(), i, 0); 54 | mesh.addElement(new Point3D(x, y, x * -0.5523), i, 1); 55 | mesh.addElement(new Point3D(x * 0.5523, y, -x), i, 2); 56 | mesh.addElement(new Point3D(0, y, -x), i, 3); 57 | } 58 | } 59 | 60 | /* 61 | * (non-Javadoc) 62 | * 63 | * @see a3.SurfacePatch#draw(javax.media.opengl.GLAutoDrawable) 64 | */ 65 | @Override 66 | public void draw(GLAutoDrawable drawable) 67 | { 68 | GL gl = drawable.getGL(); 69 | for(int i = 0; i < 4; ++i) 70 | { 71 | gl.glPushMatrix(); 72 | gl.glRotated(i * 90.0, 0.0, 1.0, 0.0); 73 | super.draw(drawable); 74 | gl.glPopMatrix(); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /LunarLander/src/domain/GameObject.java: -------------------------------------------------------------------------------- 1 | package domain; 2 | import java.awt.Color; 3 | import java.math.BigDecimal; 4 | 5 | /** 6 | * Represents an object in the game world. 7 | * 8 | */ 9 | public abstract class GameObject implements IDrawable, ICollider 10 | { 11 | /** 12 | * The position of the GameObject, represented as an (x,y) Cartesian coordinate in the first quadrant. 13 | */ 14 | protected Point myPosition; 15 | /** 16 | * The color of the GameObject. 17 | */ 18 | protected Color myColor; 19 | 20 | /** 21 | * @param color The color of the GameObject 22 | * @param position The initial position of the GameObject 23 | */ 24 | public GameObject(Color color, Point position) 25 | { 26 | myColor = color; 27 | myPosition = new Point(position); 28 | } 29 | 30 | 31 | /** 32 | * @return The color of the GameObject 33 | */ 34 | public java.awt.Color getColor() 35 | { 36 | return myColor; 37 | } 38 | 39 | /** 40 | * @return The current position of the GameObject 41 | */ 42 | public Point getPosition() 43 | { 44 | return new Point(myPosition); 45 | } 46 | 47 | /** 48 | * @param p The position to place the GameObject 49 | */ 50 | public void setPosition(Point p) 51 | { 52 | myPosition = new Point(p); 53 | } 54 | 55 | public boolean collidesWith(ICollider obj) 56 | { 57 | double myXMax = getX().doubleValue() + getBounds().width; 58 | double myYMax = getY().doubleValue() + getBounds().height; 59 | double otherXMax = obj.getX().doubleValue() + obj.getBounds().width; 60 | double otherYMax = obj.getY().doubleValue() + obj.getBounds().height; 61 | 62 | return ((getX().doubleValue() <= otherXMax) && (myXMax >= obj.getX().doubleValue()) && (getY().doubleValue() <= otherYMax) && (myYMax >= obj.getY().doubleValue())); 63 | } 64 | 65 | public BigDecimal getX() 66 | { 67 | return myPosition.getX(); 68 | } 69 | 70 | public BigDecimal getY() 71 | { 72 | return myPosition.getY(); 73 | } 74 | 75 | public boolean contains (int x, int y) 76 | { 77 | return getBounds().contains(x - myPosition.getX().intValue(), y - myPosition.getY().intValue()); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /LunarLander/src/game/GameController.java: -------------------------------------------------------------------------------- 1 | package game; 2 | 3 | import javax.swing.*; 4 | import commands.*; 5 | 6 | /** 7 | * Controls input from the Player and calls the appropriate commands on the Game Model. 8 | * 9 | * Represents the Controller part of the Model View Controller architecture. 10 | */ 11 | public class GameController extends JPanel 12 | { 13 | /** 14 | * Default serialVersionUID 15 | */ 16 | private static final long serialVersionUID = 1L; 17 | private NewGameCommand ng; 18 | private AddMeteorCommand addMeteor; 19 | private DeleteCommand delete; 20 | 21 | public GameController(GameWorld gameModel, Scoreboard scoreboard, HelpCommand help, QuitCommand quit, NewGameCommand newGame) 22 | { 23 | setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); 24 | buildButton(newGame, gameModel, scoreboard); 25 | addMeteor = new AddMeteorCommand(); 26 | buildButton(addMeteor, gameModel, scoreboard); 27 | delete = new DeleteCommand(); 28 | buildButton(delete, gameModel, scoreboard); 29 | JButton button = new JButton(); 30 | StartGameCommand startGame = new StartGameCommand(button, this); 31 | startGame.setGameWorld(gameModel); 32 | startGame.setScoreboard(scoreboard); 33 | button.setAction(startGame); 34 | add(button); 35 | gameModel.setStartCommand(startGame); 36 | buildButton(help, gameModel, scoreboard); 37 | buildButton(quit, gameModel, scoreboard); 38 | ng = newGame; 39 | gameModel.setNewGameCommand(newGame); 40 | } 41 | 42 | /** 43 | * Builds a JButton and adds it to this JPanel. 44 | * 45 | * @param action The LanderGameAbstractAction to bind to the button 46 | * @param gameModel The GameWorld that the command will operate on 47 | */ 48 | private void buildButton(LanderGameAbstractAction action, GameWorld gameModel, Scoreboard scoreboard) 49 | { 50 | action.setGameWorld(gameModel); 51 | action.setScoreboard(scoreboard); 52 | JButton button = new JButton(); 53 | button.setAction(action); 54 | add(button); 55 | } 56 | 57 | public void toggleEditButtons() 58 | { 59 | ng.setEnabled(!ng.isEnabled()); 60 | addMeteor.setEnabled(!addMeteor.isEnabled()); 61 | delete.setEnabled(!delete.isEnabled()); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/scene/Group.java: -------------------------------------------------------------------------------- 1 | package futureEngine.scene; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Iterator; 5 | 6 | import futureEngine.renderer.IRenderer; 7 | 8 | public class Group extends SceneNode { 9 | 10 | private ArrayList children; 11 | 12 | public Group() { 13 | children = new ArrayList(); 14 | } 15 | 16 | public void addChild(SceneNode node) { 17 | node.setParent(this); 18 | children.add(node); 19 | } 20 | 21 | public void removeChild(SceneNode node) { 22 | children.remove(node); 23 | node.setParent(null); 24 | } 25 | 26 | public Iterator getChildren() { 27 | return children.iterator(); 28 | } 29 | 30 | @Override 31 | public void draw(IRenderer renderer) { 32 | Iterator sceneIterator = getChildren(); 33 | SceneNode child; 34 | while (sceneIterator.hasNext()) { 35 | child = sceneIterator.next(); 36 | child.draw(renderer); 37 | } 38 | } 39 | 40 | @Override 41 | protected void updateTransforms(long time) { 42 | super.updateTransforms(time); 43 | 44 | Iterator sceneIterator = getChildren(); 45 | SceneNode child; 46 | while (sceneIterator.hasNext()) { 47 | child = sceneIterator.next(); 48 | child.updateGeometricState(time, false); 49 | } 50 | } 51 | 52 | @Override 53 | public void setLocalBound(BoundingVolume bv) { 54 | Iterator sceneIterator = getChildren(); 55 | SceneNode child; 56 | while (sceneIterator.hasNext()) { 57 | child = sceneIterator.next(); 58 | child.setLocalBound(bv); 59 | } 60 | } 61 | 62 | @Override 63 | public void updateLocalBound() { 64 | Iterator sceneIterator = getChildren(); 65 | SceneNode child; 66 | while (sceneIterator.hasNext()) { 67 | child = sceneIterator.next(); 68 | child.updateLocalBound(); 69 | } 70 | } 71 | 72 | @Override 73 | public void updateWorldBound() { 74 | this.worldBound = null; 75 | Iterator sceneIterator = getChildren(); 76 | SceneNode child; 77 | while (sceneIterator.hasNext()) { 78 | child = sceneIterator.next(); 79 | BoundingVolume childBV = child.getWorldBound(); 80 | worldBound = childBV.merge(this.worldBound); 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /3DModelingTool/PositionalLight.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | import javax.media.opengl.GL; 4 | import javax.media.opengl.GLAutoDrawable; 5 | import mathlib3D.Point3D; 6 | 7 | public class PositionalLight extends Light 8 | { 9 | private static final long serialVersionUID = 1L; 10 | 11 | private Point3D position; 12 | 13 | private float constantAttenuation; 14 | 15 | private float linearAttenuation; 16 | 17 | private float quadraticAttenuation; 18 | 19 | public PositionalLight() 20 | { 21 | position = new Point3D(-300, 300, 100); 22 | constantAttenuation = 1; 23 | linearAttenuation = 0; 24 | quadraticAttenuation = 0; 25 | } 26 | 27 | @Override 28 | public void draw(GLAutoDrawable drawable, int glLightNum) 29 | { 30 | GL gl = drawable.getGL(); 31 | float[] pos = new float[] { (float) position.getX(), (float) position.getY(), (float) position.getZ(), 1.0f }; 32 | gl.glLightfv(glLightNum, GL.GL_POSITION, pos, 0); 33 | drawAttenuation(glLightNum, gl); 34 | drawBaseLight(gl, glLightNum); 35 | } 36 | 37 | protected void drawAttenuation(int glLightNum, GL gl) 38 | { 39 | gl.glLightf(glLightNum, GL.GL_CONSTANT_ATTENUATION, getConstantAttenuation()); 40 | gl.glLightf(glLightNum, GL.GL_LINEAR_ATTENUATION, getLinearAttenuation()); 41 | gl.glLightf(glLightNum, GL.GL_QUADRATIC_ATTENUATION, getQuadraticAttenuation()); 42 | } 43 | 44 | public Point3D getPosition() 45 | { 46 | return position; 47 | } 48 | 49 | public void setPosition(Point3D newPosition) 50 | { 51 | position = newPosition; 52 | } 53 | 54 | public float getConstantAttenuation() 55 | { 56 | return constantAttenuation; 57 | } 58 | 59 | public void setConstantAttenuation(float constantAttenuation) 60 | { 61 | this.constantAttenuation = constantAttenuation; 62 | } 63 | 64 | public float getLinearAttenuation() 65 | { 66 | return linearAttenuation; 67 | } 68 | 69 | public void setLinearAttenuation(float linearAttenuation) 70 | { 71 | this.linearAttenuation = linearAttenuation; 72 | } 73 | 74 | public float getQuadraticAttenuation() 75 | { 76 | return quadraticAttenuation; 77 | } 78 | 79 | public void setQuadraticAttenuation(float quadraticAttenuation) 80 | { 81 | this.quadraticAttenuation = quadraticAttenuation; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /3DModelingTool/graphicslib3D/javadoc/allclasses-noframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | All Classes 19 |
20 | 21 | 22 | 23 | 52 | 53 |
BezierPoint 24 |
25 | CameraSettingsDialog 26 |
27 | ControlMesh 28 |
29 | GLSLUtils 30 |
31 | IQuarterPatch 32 |
33 | ISurfacePatch 34 |
35 | Polygon3D 36 |
37 | QuarterPatchDialog 38 |
39 | QuarterPatchDialogPanel 40 |
41 | QuarterPatchLimitsDialog 42 |
43 | Shape3D 44 |
45 | SurfacePatchDialog 46 |
47 | SurfacePatchDialogPanel 48 |
49 | SurfacePatchLimitsDialog 50 |
51 |
54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /LunarLander/src/domain/Meteor.java: -------------------------------------------------------------------------------- 1 | package domain; 2 | 3 | import java.awt.Color; 4 | import java.awt.Graphics; 5 | import java.awt.Rectangle; 6 | 7 | 8 | /** 9 | * Represents a circular Meteor. 10 | * 11 | */ 12 | public class Meteor extends MovingTarget implements ISelectable 13 | { 14 | /** 15 | * The diameter of the Meteor 16 | */ 17 | private int myDiameter; 18 | 19 | /** 20 | * @param color The color of the Meteor 21 | * @param position The intial position of the Meteor 22 | * @param points The point value of the Meteor 23 | * @param diameter The diameter of the Meteor 24 | * @param path The trajectory of the Meteor 25 | */ 26 | public Meteor(Color color, Point position, int points, int diameter, Point path) 27 | { 28 | super(color, position, points, path); 29 | myDiameter = diameter; 30 | } 31 | 32 | public void handleCollision(ICollider otherObject) 33 | { 34 | 35 | } 36 | 37 | /** 38 | * @return The diameter of the Meteor 39 | */ 40 | public int getDiameter() 41 | { 42 | return myDiameter; 43 | } 44 | 45 | /* (non-Javadoc) 46 | * @see java.lang.Object#toString() 47 | */ 48 | public String toString() 49 | { 50 | return String.format("Meteor: pos=%1$s color=%2$s ptVal=%3$d diameter=%4$d speed=%5$f direction=%6$s", getPosition(), myColor, pointValue, myDiameter, getSpeed(), myPath); 51 | } 52 | 53 | public void draw(Graphics g) 54 | { 55 | g.setColor(getColor()); 56 | if(selected) 57 | { 58 | Color save = g.getColor(); 59 | g.setColor(Color.yellow); 60 | g.fillOval(getPosition().getX().intValue(), getPosition().getY().intValue(), getDiameter() + 5, getDiameter() + 5); 61 | g.setColor(save); 62 | g.fillOval(getPosition().getX().intValue() + 5, getPosition().getY().intValue() + 5, getDiameter() - 5, getDiameter() - 5); 63 | } 64 | else 65 | { 66 | g.fillOval(getPosition().getX().intValue(), getPosition().getY().intValue(), getDiameter(), getDiameter()); 67 | } 68 | } 69 | 70 | public Rectangle getBounds() 71 | { 72 | return new Rectangle(getDiameter(), getDiameter()); 73 | } 74 | 75 | public void setSelected (boolean newVal) 76 | { 77 | selected = newVal; 78 | } 79 | 80 | protected boolean selected = false; 81 | public boolean isSelected() 82 | { 83 | return selected; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /3DModelingTool/Material.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | import java.awt.Color; 4 | import java.io.Serializable; 5 | import javax.media.opengl.GL; 6 | 7 | public class Material implements Serializable 8 | { 9 | private static final long serialVersionUID = 1L; 10 | 11 | private Color ambient; 12 | 13 | private Color diffuse; 14 | 15 | private Color specular; 16 | 17 | private Color emission; 18 | 19 | private float shininess; 20 | 21 | private String name; 22 | 23 | public Material() 24 | { 25 | ambient = Color.blue; 26 | diffuse = Color.green; 27 | specular = Color.white; 28 | emission = Color.black; 29 | shininess = 32.0f; 30 | } 31 | 32 | public void makeCurrent(GL gl) 33 | { 34 | gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, getAmbient().getRGBComponents(null), 0); 35 | gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_DIFFUSE, getDiffuse().getRGBComponents(null), 0); 36 | gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, getSpecular().getRGBComponents(null), 0); 37 | gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_EMISSION, getEmission().getRGBComponents(null), 0); 38 | gl.glMaterialf(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, getShininess()); 39 | } 40 | 41 | public Color getAmbient() 42 | { 43 | return ambient; 44 | } 45 | 46 | public void setAmbient(Color newAmbient) 47 | { 48 | ambient = newAmbient; 49 | } 50 | 51 | public Color getDiffuse() 52 | { 53 | return diffuse; 54 | } 55 | 56 | public void setDiffuse(Color newDiffuse) 57 | { 58 | diffuse = newDiffuse; 59 | } 60 | 61 | public Color getEmission() 62 | { 63 | return emission; 64 | } 65 | 66 | public void setEmission(Color newEmission) 67 | { 68 | emission = newEmission; 69 | } 70 | 71 | public float getShininess() 72 | { 73 | return shininess; 74 | } 75 | 76 | public void setShininess(float newShininess) 77 | { 78 | shininess = newShininess; 79 | } 80 | 81 | public Color getSpecular() 82 | { 83 | return specular; 84 | } 85 | 86 | public void setSpecular(Color newSpecular) 87 | { 88 | specular = newSpecular; 89 | } 90 | 91 | public String getName() 92 | { 93 | return name; 94 | } 95 | 96 | public void setName(String newName) 97 | { 98 | name = newName; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /3DModelingTool/graphicslib3D/javadoc/allclasses-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | All Classes 19 |
20 | 21 | 22 | 23 | 52 | 53 |
BezierPoint 24 |
25 | CameraSettingsDialog 26 |
27 | ControlMesh 28 |
29 | GLSLUtils 30 |
31 | IQuarterPatch 32 |
33 | ISurfacePatch 34 |
35 | Polygon3D 36 |
37 | QuarterPatchDialog 38 |
39 | QuarterPatchDialogPanel 40 |
41 | QuarterPatchLimitsDialog 42 |
43 | Shape3D 44 |
45 | SurfacePatchDialog 46 |
47 | SurfacePatchDialogPanel 48 |
49 | SurfacePatchLimitsDialog 50 |
51 |
54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /3DModelingTool/Visual.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | import java.nio.FloatBuffer; 4 | import graphicslib3D.Shape3D; 5 | import javax.media.opengl.GL; 6 | import javax.media.opengl.GLAutoDrawable; 7 | 8 | /** 9 | * Represents a visible/drawable world object. 10 | * 11 | */ 12 | public class Visual extends WorldObject 13 | { 14 | private static final long serialVersionUID = 1779477872770420365L; 15 | 16 | private Shape3D myShape; 17 | 18 | private Material myMaterial; 19 | 20 | private Shader myShader; 21 | 22 | /** 23 | * @param shape The Shape3D to encapsulate 24 | */ 25 | public Visual(Shape3D shape) 26 | { 27 | super(); 28 | setShape(shape); 29 | setMaterial(new Material()); 30 | } 31 | 32 | /* 33 | * (non-Javadoc) 34 | * 35 | * @see a3.WorldObject#draw(javax.media.opengl.GLAutoDrawable) 36 | */ 37 | @Override 38 | public void draw(GLAutoDrawable drawable, boolean lighting) 39 | { 40 | GL gl = drawable.getGL(); 41 | 42 | Shader s = getShader(); 43 | if (s != null) 44 | { 45 | gl.glUseProgramObjectARB(s.getProgramID(gl)); 46 | if(s.isParameterized()) 47 | gl.glUniform1fARB(s.getParameterID(gl), s.getParameterValue()); 48 | } 49 | else 50 | gl.glUseProgramObjectARB(0); 51 | 52 | if(lighting) 53 | getMaterial().makeCurrent(gl); 54 | else 55 | gl.glColor3fv(FloatBuffer.wrap(getMaterial().getDiffuse().getRGBColorComponents(null))); 56 | 57 | gl.glPushMatrix(); 58 | gl.glMultMatrixd(getTransform().getValues(), 0); 59 | getShape().draw(drawable); 60 | gl.glPopMatrix(); 61 | gl.glDisable(GL.GL_TEXTURE_2D); 62 | } 63 | 64 | /** 65 | * Gets the name of this Visual 66 | * 67 | * @return The name of this Visual 68 | */ 69 | public String getName() 70 | { 71 | return getShape().getName(); 72 | } 73 | 74 | /** 75 | * @param myShape the new Shape3D to set 76 | */ 77 | public void setShape(Shape3D newShape) 78 | { 79 | myShape = newShape; 80 | } 81 | 82 | /** 83 | * @return the Shape3D contained in this object 84 | */ 85 | public Shape3D getShape() 86 | { 87 | return myShape; 88 | } 89 | 90 | public Material getMaterial() 91 | { 92 | return myMaterial; 93 | } 94 | 95 | public void setMaterial(Material newMaterial) 96 | { 97 | myMaterial = newMaterial; 98 | } 99 | 100 | public Shader getShader() 101 | { 102 | return myShader; 103 | } 104 | 105 | public void setShader(Shader newShader) 106 | { 107 | myShader = newShader; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/scene/BoundingSphere.java: -------------------------------------------------------------------------------- 1 | package futureEngine.scene; 2 | 3 | import graphicslib3D.Matrix3D; 4 | import graphicslib3D.Point3D; 5 | import graphicslib3D.Vector3D; 6 | 7 | public class BoundingSphere extends BoundingVolume { 8 | 9 | private Point3D center; 10 | private double radius; 11 | 12 | public BoundingSphere(Point3D location, double rad) { 13 | center = location; 14 | radius = rad; 15 | } 16 | 17 | public BoundingSphere(Point3D[] points) { 18 | computeFromPoints(points); 19 | } 20 | 21 | @Override 22 | public void computeFromPoints(Point3D[] points) { 23 | double x = 0, y = 0, z = 0; 24 | int numPoints = points.length; 25 | for (int i = 0; i < numPoints; ++i) { 26 | x += points[i].getX(); 27 | y += points[i].getY(); 28 | z += points[i].getZ(); 29 | } 30 | center = new Point3D(x / numPoints, y / numPoints, z / numPoints); 31 | radius = 0; 32 | double distance = 0; 33 | for (int j = 0; j < numPoints; ++j) { 34 | distance = center.distanceTo(points[j]); 35 | if (distance > radius) { 36 | radius = distance; 37 | } 38 | } 39 | 40 | } 41 | 42 | @Override 43 | public boolean contains(Point3D p) { 44 | return center.distanceTo(p) <= radius; 45 | } 46 | 47 | @Override 48 | public boolean isOnPositiveSide(Plane p) { 49 | double dist = p.distanceTo(center); 50 | return dist < -radius; 51 | } 52 | 53 | @Override 54 | public BoundingVolume merge(BoundingVolume bv) { 55 | if (bv == null) return this; 56 | 57 | BoundingSphere S2 = (BoundingSphere)bv; 58 | double L = center.distanceTo(S2.center); 59 | if (L + S2.radius <= radius) { 60 | //this contains S2 61 | return this; 62 | } 63 | else if (L + radius <= S2.radius) { 64 | //S2 contains this 65 | return S2; 66 | } 67 | else { 68 | //overlap or disjoint case 69 | double newRadius = (L + radius + S2.radius) / 2; 70 | Vector3D C1 = new Vector3D(center); 71 | Vector3D C2 = new Vector3D(S2.center); 72 | double tCenter = ((L + S2.radius - radius) / 2) * (1 / L); 73 | Vector3D newC = C1.add(C2.minus(C1).mult(tCenter)); 74 | Point3D newLocation = new Point3D(newC.getX(), newC.getY(), newC.getZ()); 75 | return new BoundingSphere(newLocation, newRadius); 76 | } 77 | } 78 | 79 | @Override 80 | public BoundingVolume transformBy(Matrix3D mat) { 81 | Point3D newCenter = center.mult(mat); 82 | Point3D edge = new Point3D(center.getX() + radius, center.getY() + radius, center.getZ() + radius); 83 | Point3D newEdge = edge.mult(mat); 84 | double newRadius = newCenter.distanceTo(newEdge); 85 | return new BoundingSphere(newCenter, newRadius); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /3DModelingTool/graphicslib3D/javadoc/graphicslib3D/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | graphicslib3D 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | graphicslib3D 20 | 21 | 22 | 29 | 30 |
23 | Interfaces  24 | 25 |
26 | IQuarterPatch 27 |
28 | ISurfacePatch
31 | 32 | 33 | 34 | 35 | 62 | 63 |
36 | Classes  37 | 38 |
39 | BezierPoint 40 |
41 | CameraSettingsDialog 42 |
43 | ControlMesh 44 |
45 | GLSLUtils 46 |
47 | Polygon3D 48 |
49 | QuarterPatchDialog 50 |
51 | QuarterPatchDialogPanel 52 |
53 | QuarterPatchLimitsDialog 54 |
55 | Shape3D 56 |
57 | SurfacePatchDialog 58 |
59 | SurfacePatchDialogPanel 60 |
61 | SurfacePatchLimitsDialog
64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /LunarLander/src/game/Scoreboard.java: -------------------------------------------------------------------------------- 1 | package game; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.awt.event.ActionListener; 5 | import java.util.Observable; 6 | 7 | /** 8 | * Keeps track of the lives remaining, points earned, and time elapsed. 9 | * 10 | */ 11 | public class Scoreboard extends Observable implements ActionListener 12 | { 13 | /** 14 | * The amound of Landers that the Player has left. 15 | */ 16 | private int livesRemaining; 17 | /** 18 | * The amount of points that the Player has earned. 19 | */ 20 | private int pointsEarned; 21 | /** 22 | * The amount of ticks that have passed since the game started. 23 | */ 24 | private int timeElapsed; 25 | 26 | /** 27 | * The default Scoreboard has 3 Landers left, zero points, and initial time zero. 28 | */ 29 | public Scoreboard() 30 | { 31 | livesRemaining = 3; 32 | pointsEarned = 0; 33 | timeElapsed = 0; 34 | super.setChanged(); 35 | } 36 | 37 | /** 38 | * Signal that a Lander was destroyed. 39 | */ 40 | public void loseLife() { 41 | setLivesRemaining(getLivesRemaining() - 1); 42 | } 43 | 44 | /** 45 | * @return The amount of Landers left in the game 46 | */ 47 | public int getLivesRemaining() { 48 | return livesRemaining; 49 | } 50 | 51 | /** 52 | * @param The new value for lives remaining 53 | */ 54 | private void setLivesRemaining(int value) 55 | { 56 | livesRemaining = value; 57 | super.setChanged(); 58 | } 59 | 60 | /** 61 | * @param pointsEarned The amount of points to add to the score 62 | */ 63 | public void earnPoints(int points) { 64 | setPointsEarned(getPointsEarned() + points); 65 | } 66 | 67 | /** 68 | * @return The current score 69 | */ 70 | public int getPointsEarned() { 71 | return pointsEarned; 72 | } 73 | 74 | /** 75 | * @param The new value for points earned 76 | */ 77 | private void setPointsEarned(int value) 78 | { 79 | pointsEarned = value; 80 | super.setChanged(); 81 | } 82 | 83 | /** 84 | * Signal that a turn has passed. 85 | */ 86 | public void addTurn() 87 | { 88 | setTimeElapsed(getTimeElapsed() + 1); 89 | } 90 | 91 | /** 92 | * @param The new value for amount of turns passed 93 | */ 94 | private void setTimeElapsed(int value) 95 | { 96 | timeElapsed = value; 97 | super.setChanged(); 98 | } 99 | 100 | /** 101 | * @return The amount of ticks elapsed in the game 102 | */ 103 | public int getTimeElapsed() 104 | { 105 | return timeElapsed; 106 | } 107 | 108 | /* (non-Javadoc) 109 | * @see java.lang.Object#toString() 110 | */ 111 | public String toString() 112 | { 113 | return String.format("Score: livesRemaining=%1$d pointsEarned=%2$d timeElapsed=%3$d", livesRemaining, pointsEarned, timeElapsed); 114 | } 115 | 116 | public void actionPerformed(ActionEvent e) 117 | { 118 | addTurn(); 119 | notifyObservers(); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /3DModelingTool/Texture.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | import java.awt.Graphics2D; 4 | import java.awt.geom.AffineTransform; 5 | import java.awt.image.*; 6 | import java.awt.color.*; 7 | import java.io.BufferedInputStream; 8 | import java.io.FileInputStream; 9 | import java.io.FileNotFoundException; 10 | import java.io.IOException; 11 | import java.io.Serializable; 12 | import java.nio.ByteBuffer; 13 | import javax.imageio.ImageIO; 14 | import javax.media.opengl.GL; 15 | 16 | public class Texture implements Serializable 17 | { 18 | private static final long serialVersionUID = 1L; 19 | private byte[] imgRGBA; 20 | private int textureID; 21 | private int width; 22 | private int height; 23 | 24 | public Texture() 25 | { 26 | resetID(); 27 | } 28 | 29 | public void loadFromFile(String filePath) throws FileNotFoundException, IOException 30 | { 31 | BufferedImage textureImage = ImageIO.read(new BufferedInputStream(new FileInputStream(filePath))); 32 | loadRGBAPixelData(textureImage); 33 | } 34 | 35 | private void loadRGBAPixelData(BufferedImage img) 36 | { 37 | height = img.getHeight(null); 38 | width = img.getWidth(null); 39 | 40 | WritableRaster raster = Raster.createInterleavedRaster( 41 | DataBuffer.TYPE_BYTE, 42 | width, 43 | height, 44 | 4, 45 | null); 46 | 47 | ComponentColorModel colorModel = new ComponentColorModel( 48 | ColorSpace.getInstance(ColorSpace.CS_sRGB), 49 | new int[] {8,8,8,8}, 50 | true, 51 | false, 52 | ComponentColorModel.TRANSLUCENT, 53 | DataBuffer.TYPE_BYTE); 54 | 55 | BufferedImage newImage = new BufferedImage(colorModel, raster, false, null); 56 | 57 | AffineTransform gt = new AffineTransform(); 58 | gt.translate(0, height); 59 | gt.scale(1, -1d); 60 | 61 | Graphics2D g = newImage.createGraphics(); 62 | g.transform(gt); 63 | 64 | g.drawImage(img, null, null); 65 | g.dispose(); 66 | 67 | DataBufferByte dataBuf = (DataBufferByte)raster.getDataBuffer(); 68 | imgRGBA = dataBuf.getData(); 69 | } 70 | 71 | private void installTexture(GL gl) 72 | { 73 | int[] textureIDs = new int[1]; 74 | gl.glGenTextures(1, textureIDs, 0); 75 | textureID = textureIDs[0]; 76 | 77 | gl.glBindTexture(GL.GL_TEXTURE_2D, textureID); 78 | ByteBuffer wrappedRGBA = ByteBuffer.wrap(imgRGBA); 79 | gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, width, height, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, wrappedRGBA); 80 | gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR); 81 | } 82 | 83 | public void makeCurrent(GL gl) 84 | { 85 | gl.glEnable(GL.GL_TEXTURE_2D); 86 | gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_REPLACE); 87 | gl.glBindTexture(GL.GL_TEXTURE_2D, getTextureID(gl)); 88 | } 89 | 90 | private int getTextureID(GL gl) 91 | { 92 | if(textureID == -1) 93 | installTexture(gl); 94 | return textureID; 95 | } 96 | 97 | public void resetID() 98 | { 99 | textureID = -1; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/renderer/Renderer.java: -------------------------------------------------------------------------------- 1 | package futureEngine.renderer; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Iterator; 5 | 6 | import futureEngine.camera.Camera; 7 | import futureEngine.camera.ICamera; 8 | import futureEngine.scene.BoundingVolume; 9 | import futureEngine.scene.Group; 10 | import futureEngine.scene.SceneNode; 11 | 12 | public abstract class Renderer implements IRenderer { 13 | 14 | protected ArrayList opaqueQueue; 15 | protected ArrayList transparentQueue; 16 | protected ArrayList orthoQueue; 17 | protected ICamera myCamera = new Camera(); 18 | 19 | public void addToRenderQueue(SceneNode n) { 20 | if (n instanceof Group) { 21 | Group g = (Group) n; 22 | Iterator sceneIterator = g.getChildren(); 23 | SceneNode child; 24 | while (sceneIterator.hasNext()) { 25 | child = sceneIterator.next(); 26 | addToRenderQueue(child); 27 | } 28 | } else { 29 | int mode = n.getRenderQueueMode(); 30 | addToRenderQueue(n, mode); 31 | } 32 | } 33 | 34 | public void addToRenderQueue(SceneNode s, int renderMode) { 35 | switch (renderMode) { 36 | case RENDERMODE_OPAQUE: 37 | opaqueQueue.add(s); 38 | break; 39 | case RENDERMODE_TRANSPARENT: 40 | transparentQueue.add(s); 41 | break; 42 | case RENDERMODE_ORTHO: 43 | orthoQueue.add(s); 44 | break; 45 | default: 46 | throw new RuntimeException("Illegal render mode"); 47 | } 48 | } 49 | 50 | public void clearRenderQueue() { 51 | opaqueQueue.clear(); 52 | transparentQueue.clear(); 53 | orthoQueue.clear(); 54 | } 55 | 56 | private void drawQueue(ArrayList queue) { 57 | Iterator sceneIterator = queue.iterator(); 58 | SceneNode node; 59 | while (sceneIterator.hasNext()) { 60 | node = sceneIterator.next(); 61 | if (!boundLiesOutsideViewFrustum(node.getWorldBound())) { 62 | node.draw(this); 63 | } 64 | } 65 | } 66 | 67 | protected void renderOrthographics() { 68 | // orthoQueue.sort(); //insure closest to camera is first 69 | this.enableOrthoMode(true); // set orthographic projection mode 70 | /* 71 | * for (each node in orthoQueue) { node.draw(this); //tell node to draw 72 | * itself using this renderer } 73 | */ 74 | drawQueue(orthoQueue); 75 | this.enableOrthoMode(false); // return to perspective projection 76 | } 77 | 78 | protected void renderOpaques() { 79 | // opaqueQueue.sort(); //insure closest-to-camera is first in list 80 | /* 81 | * for (each node in opaqueQueue) { node draw(this); //tell node node.to 82 | * draw itself using this renderer } 83 | */ 84 | drawQueue(opaqueQueue); 85 | } 86 | 87 | protected void renderTransparents() { 88 | // transparentQueue.sort(); // insure farthest from camera is first in 89 | // list 90 | /* 91 | * for (each node in transparentQueue) { node.draw(this); // tell node 92 | * to draw itself using this renderer } 93 | */ 94 | drawQueue(transparentQueue); 95 | } 96 | 97 | private boolean boundLiesOutsideViewFrustum(BoundingVolume bound) { 98 | return myCamera.intersects(bound); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /3DModelingTool/SurfacePatch.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | import java.util.Vector; 4 | import javax.media.opengl.GL; 5 | import javax.media.opengl.GLAutoDrawable; 6 | import mathlib3D.Matrix3D; 7 | import mathlib3D.Point3D; 8 | import graphicslib3D.ControlMesh; 9 | import graphicslib3D.ISurfacePatch; 10 | import graphicslib3D.Shape3D; 11 | 12 | /** 13 | * Implements a Bezier surface patch 14 | * 15 | */ 16 | public class SurfacePatch extends Shape3D implements ISurfacePatch 17 | { 18 | private static final long serialVersionUID = -3117618629156125250L; 19 | 20 | private ControlMesh myControlMesh; 21 | 22 | private int myMaxRecursionLevel; 23 | 24 | public SurfacePatch() 25 | { 26 | super(); 27 | myControlMesh = new ControlMesh(); 28 | myMaxRecursionLevel = 3; 29 | } 30 | 31 | /* 32 | * (non-Javadoc) 33 | * 34 | * @see graphicslib3D.Shape3D#draw(javax.media.opengl.GLAutoDrawable) 35 | */ 36 | @Override 37 | public void draw(GLAutoDrawable drawable) 38 | { 39 | double[] controlPoints = new double[48]; 40 | for(int i = 0; i < 16; ++i) 41 | { 42 | Point3D p = myControlMesh.elementAt(i / 4, i % 4); 43 | int baseIndex = i * 3; 44 | controlPoints[baseIndex] = p.getX(); 45 | controlPoints[baseIndex + 1] = p.getY(); 46 | controlPoints[baseIndex + 2] = p.getZ(); 47 | } 48 | double uMin = 0.0, uMax = 1.0, vMin = 0.0, vMax = 1.0; 49 | int uStride = 3, vStride = 12, nSteps = 20, curveDegree = 3; 50 | GL gl = drawable.getGL(); 51 | gl.glMap2d(GL.GL_MAP2_VERTEX_3, uMin, uMax, uStride, curveDegree + 1, vMin, vMax, vStride, curveDegree + 1, controlPoints, 0); 52 | gl.glEnable(GL.GL_MAP2_VERTEX_3); 53 | gl.glMapGrid2d(nSteps, uMin, uMax, nSteps, vMin, vMax); 54 | gl.glEvalMesh2(GL.GL_FILL, 0, 20, 0, 20); 55 | } 56 | 57 | /* 58 | * (non-Javadoc) 59 | * 60 | * @see graphicslib3D.Shape3D#getPolygons(mathlib3D.Matrix3D) 61 | */ 62 | @Override 63 | public Vector getPolygons(Matrix3D transMatrix) 64 | { 65 | // TODO 66 | return new Vector(); 67 | } 68 | 69 | /* 70 | * (non-Javadoc) 71 | * 72 | * @see graphicslib3D.ISurfacePatch#getControlMesh() 73 | */ 74 | public ControlMesh getControlMesh() 75 | { 76 | return myControlMesh; 77 | } 78 | 79 | /* 80 | * (non-Javadoc) 81 | * 82 | * @see graphicslib3D.ISurfacePatch#getMaxRecursionLevel() 83 | */ 84 | public int getMaxRecursionLevel() 85 | { 86 | return myMaxRecursionLevel; 87 | } 88 | 89 | /* 90 | * (non-Javadoc) 91 | * 92 | * @see graphicslib3D.ISurfacePatch#getPatchName() 93 | */ 94 | public String getPatchName() 95 | { 96 | return getName(); 97 | } 98 | 99 | /* 100 | * (non-Javadoc) 101 | * 102 | * @see graphicslib3D.ISurfacePatch#setControlMesh(graphicslib3D.ControlMesh) 103 | */ 104 | public void setControlMesh(ControlMesh newMesh) 105 | { 106 | myControlMesh = newMesh; 107 | } 108 | 109 | /* 110 | * (non-Javadoc) 111 | * 112 | * @see graphicslib3D.ISurfacePatch#setMaxRecursionLevel(int) 113 | */ 114 | public void setMaxRecursionLevel(int newLevel) 115 | { 116 | myMaxRecursionLevel = newLevel; 117 | } 118 | 119 | /* 120 | * (non-Javadoc) 121 | * 122 | * @see graphicslib3D.ISurfacePatch#setPatchName(java.lang.String) 123 | */ 124 | public void setPatchName(String newName) 125 | { 126 | setName(newName); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /LunarLander/src/domain/LandingPad.java: -------------------------------------------------------------------------------- 1 | package domain; 2 | 3 | import java.awt.Color; 4 | import java.awt.Graphics; 5 | import java.awt.Rectangle; 6 | import java.math.BigDecimal; 7 | 8 | 9 | /** 10 | * Represents a Landing Pad that the Player can land the Lander on. 11 | * 12 | */ 13 | public class LandingPad extends FixedTarget 14 | { 15 | /** 16 | * The height of the LandingPad. 17 | */ 18 | private int myHeight; 19 | /** 20 | * The width of the LandingPad. 21 | */ 22 | private int myWidth; 23 | /** 24 | * The strength of the LandingPad. 25 | */ 26 | private int myStrength; 27 | /** 28 | * The amount of fuel stored in the LandingPad. 29 | */ 30 | private int myStorage; 31 | /** 32 | * The bomb that moves up the LandingPad. 33 | */ 34 | private Bomb myBomb; 35 | 36 | /** 37 | * @param color The color of the LandingPad 38 | * @param position The (fixed) position of the LandingPad 39 | * @param points The amount of points the LandingPad is worth 40 | * @param height The height of the LandingPad 41 | * @param width The width of the LandingPad 42 | * @param strength The strength of the LandingPad 43 | */ 44 | public LandingPad(Color color, Point position, int points, int height, int width, int strength) 45 | { 46 | super(color, position, points); 47 | myHeight = height; 48 | myWidth = width; 49 | myStrength = strength; 50 | myStorage = 30; 51 | myBomb = new Bomb(Color.orange, new Point(getPosition().getX(), new BigDecimal(0)), -30, new Point(0,0)); 52 | } 53 | 54 | /** 55 | * Explode the Bomb that travels up the LandingPad. 56 | */ 57 | public void explodeBomb() 58 | { 59 | myBomb = new Bomb(Color.yellow, new Point(getPosition().getX(), new BigDecimal(0)), -30, new Point(0,0)); 60 | } 61 | 62 | /** 63 | * @return The Bomb that is on this LandingPad 64 | */ 65 | public Bomb getBomb() 66 | { 67 | return myBomb; 68 | } 69 | 70 | /** 71 | * @return The height of the LandingPad 72 | */ 73 | public int getHeight() 74 | { 75 | return myHeight; 76 | } 77 | 78 | /** 79 | * @return The width of the LandingPad 80 | */ 81 | public int getWidth() 82 | { 83 | return myWidth; 84 | } 85 | 86 | /** 87 | * Refuels a Lander until the Lander is full, or the stored fuel on the LandingPad runs out. 88 | * @param theLander The Lander to refuel 89 | */ 90 | public void fuelLander(Lander theLander) 91 | { 92 | while(theLander.needsFuel() && myStorage > 0) 93 | { 94 | --myStorage; 95 | theLander.refuel(1); 96 | } 97 | } 98 | 99 | /** 100 | * @param l The Lander that landed on the pad 101 | * @return True if the Lander didn't destroy the pad 102 | */ 103 | public boolean landedSuccessfully(Lander l) 104 | { 105 | return l.getSpeed() <= myStrength; 106 | } 107 | 108 | /* (non-Javadoc) 109 | * @see java.lang.Object#toString() 110 | */ 111 | public String toString() 112 | { 113 | return String.format("LandingPad: pos=%1$s color=%2$s ptVal=%3$d size=%4$dx%5$d strength=%6$d storage=%7$d", getPosition(), myColor, pointValue, myHeight, myWidth, myStrength, myStorage); 114 | } 115 | 116 | public void draw(Graphics g) 117 | { 118 | g.setColor(getColor()); 119 | g.drawRect(getPosition().getX().intValue(), getPosition().getY().intValue(), getWidth(), getHeight()); 120 | } 121 | 122 | public Rectangle getBounds() 123 | { 124 | return new Rectangle(myWidth, myHeight); 125 | } 126 | 127 | public void handleCollision(ICollider otherObject) 128 | { 129 | 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /3DModelingTool/Shader.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | import java.io.Serializable; 4 | import javax.media.opengl.GL; 5 | 6 | public class Shader implements Serializable 7 | { 8 | private static final long serialVersionUID = 1L; 9 | 10 | private String[] vertexSourceCode; 11 | 12 | private String[] fragmentSourceCode; 13 | 14 | private int programID; 15 | 16 | private String name; 17 | 18 | private int[] vertexSourceLengths; 19 | 20 | private int[] fragmentSourceLengths; 21 | 22 | private String parameterName; 23 | 24 | private int parameterID; 25 | 26 | private float parameterValue; 27 | 28 | private Texture texture; 29 | 30 | public Shader() 31 | { 32 | parameterName = null; 33 | parameterValue = 0; 34 | texture = null; 35 | resetIDs(); 36 | } 37 | 38 | public float getParameterValue() 39 | { 40 | return parameterValue; 41 | } 42 | 43 | public void setParameterValue(float parameterValue) 44 | { 45 | this.parameterValue = parameterValue; 46 | } 47 | 48 | public String getParameterName() 49 | { 50 | return parameterName; 51 | } 52 | 53 | public void setParameterName(String parameterName) 54 | { 55 | this.parameterName = parameterName; 56 | } 57 | 58 | public int getParameterID(GL gl) 59 | { 60 | checkInstallState(gl); 61 | return parameterID; 62 | } 63 | 64 | public void loadFromSource(String[] vertexSource, String[] fragmentSource) 65 | { 66 | vertexSourceCode = vertexSource; 67 | vertexSourceLengths = new int[vertexSourceCode.length]; 68 | for(int i = 0; i < vertexSourceLengths.length; ++i) 69 | vertexSourceLengths[i] = vertexSourceCode[i].length(); 70 | 71 | fragmentSourceCode = fragmentSource; 72 | fragmentSourceLengths = new int[fragmentSourceCode.length]; 73 | for(int i = 0; i < fragmentSourceLengths.length; ++i) 74 | fragmentSourceLengths[i] = fragmentSourceCode[i].length(); 75 | } 76 | 77 | public void install(GL gl) 78 | { 79 | int vertexShaderID = gl.glCreateShaderObjectARB(GL.GL_VERTEX_SHADER_ARB); 80 | int fragmentShaderID = gl.glCreateShaderObjectARB(GL.GL_FRAGMENT_SHADER_ARB); 81 | programID = gl.glCreateProgramObjectARB(); 82 | 83 | gl.glShaderSourceARB(vertexShaderID, vertexSourceCode.length, vertexSourceCode, vertexSourceLengths, 0); 84 | gl.glCompileShaderARB(vertexShaderID); 85 | gl.glAttachObjectARB(programID, vertexShaderID); 86 | 87 | gl.glShaderSourceARB(fragmentShaderID, fragmentSourceCode.length, fragmentSourceCode, fragmentSourceLengths, 0); 88 | gl.glCompileShaderARB(fragmentShaderID); 89 | gl.glAttachObjectARB(programID, fragmentShaderID); 90 | 91 | gl.glLinkProgramARB(programID); 92 | 93 | if(isParameterized()) 94 | parameterID = gl.glGetUniformLocationARB(programID, parameterName); 95 | 96 | if(texture != null) 97 | { 98 | texture.makeCurrent(gl); 99 | int texLoc = gl.glGetUniformLocationARB(programID, "theTexture"); 100 | gl.glUniform1i(texLoc, 0); 101 | } 102 | } 103 | 104 | public boolean isParameterized() 105 | { 106 | return parameterName != null && parameterName.trim().length() > 0; 107 | } 108 | 109 | public int getProgramID(GL gl) 110 | { 111 | checkInstallState(gl); 112 | return programID; 113 | } 114 | 115 | private void checkInstallState(GL gl) 116 | { 117 | if(programID == -1) 118 | install(gl); 119 | } 120 | 121 | public void resetIDs() 122 | { 123 | programID = -1; 124 | parameterID = -1; 125 | if(texture != null) 126 | texture.resetID(); 127 | } 128 | 129 | public String getName() 130 | { 131 | return name; 132 | } 133 | 134 | public void setName(String newName) 135 | { 136 | name = newName; 137 | } 138 | 139 | public Texture getTexture() 140 | { 141 | return texture; 142 | } 143 | 144 | public void setTexture(Texture texture) 145 | { 146 | this.texture = texture; 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /LunarLander/src/game/LanderGame.java: -------------------------------------------------------------------------------- 1 | package game; 2 | import javax.swing.*; 3 | import javax.swing.border.LineBorder; 4 | 5 | import commands.AboutCommand; 6 | import commands.HelpCommand; 7 | import commands.NewGameCommand; 8 | import commands.QuitCommand; 9 | import commands.SaveCommand; 10 | 11 | 12 | import java.awt.*; 13 | import java.awt.event.KeyEvent; 14 | import java.awt.event.WindowEvent; 15 | import java.awt.event.WindowListener; 16 | 17 | /** 18 | * Starts a new game of Lunar Lander. 19 | * 20 | */ 21 | public class LanderGame extends JFrame implements WindowListener 22 | { 23 | /** 24 | * Default serialVersionUID 25 | */ 26 | private static final long serialVersionUID = 1L; 27 | 28 | private QuitCommand quitCommand; 29 | 30 | private GameWorld gw; 31 | 32 | /** 33 | * Create a LanderGame object with an empty world. 34 | */ 35 | public LanderGame() 36 | { 37 | newGame(); 38 | } 39 | 40 | public void newGame() 41 | { 42 | this.getContentPane().removeAll(); 43 | gw = new GameWorld(); 44 | Scoreboard sb = new Scoreboard(); 45 | MapView map = new MapView(); 46 | gw.addObserver(map); 47 | ScoreboardView score = new ScoreboardView(); 48 | sb.addObserver(score); 49 | 50 | setTitle("Lunar Lander"); 51 | setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); 52 | addWindowListener(this); 53 | setResizable(false); 54 | setBounds(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds()); 55 | setLayout(new BorderLayout()); 56 | 57 | quitCommand = new QuitCommand(); 58 | HelpCommand helpCommand = new HelpCommand(); 59 | NewGameCommand newGameCommand = new NewGameCommand(this); 60 | GameController gameController = new GameController(gw, sb, helpCommand, quitCommand, newGameCommand); 61 | getContentPane().add(gameController, BorderLayout.WEST); 62 | score.setBackground(Color.white); 63 | score.setBorder(new LineBorder(Color.blue)); 64 | getContentPane().add(score, BorderLayout.NORTH); 65 | map.setBackground(Color.black); 66 | getContentPane().add(map, BorderLayout.CENTER); 67 | 68 | JMenuBar menuBar = new JMenuBar(); 69 | 70 | JMenu fileMenu = new JMenu("File"); 71 | fileMenu.add(new JMenuItem(newGameCommand)); 72 | fileMenu.add(new JMenuItem(new SaveCommand())); 73 | 74 | fileMenu.add(new JMenuItem(quitCommand)); 75 | menuBar.add(fileMenu); 76 | 77 | JMenu helpMenu = new JMenu("Help"); 78 | 79 | helpMenu.add(new JMenuItem(helpCommand)); 80 | helpMenu.add(new JMenuItem(new AboutCommand())); 81 | 82 | menuBar.add(fileMenu); 83 | menuBar.add(helpMenu); 84 | 85 | setJMenuBar(menuBar); 86 | KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyHandler()); 87 | 88 | setVisible(true); 89 | 90 | gw.initializeWorld(sb); 91 | 92 | gw.notifyObservers(); 93 | sb.notifyObservers(); 94 | } 95 | 96 | public void windowActivated(WindowEvent e) 97 | { 98 | } 99 | 100 | public void windowClosed(WindowEvent e) 101 | { 102 | } 103 | 104 | public void windowClosing(WindowEvent e) 105 | { 106 | quitCommand.actionPerformed(null); 107 | } 108 | 109 | public void windowDeactivated(WindowEvent e) 110 | { 111 | } 112 | 113 | public void windowDeiconified(WindowEvent e) 114 | { 115 | } 116 | 117 | public void windowIconified(WindowEvent e) 118 | { 119 | } 120 | 121 | public void windowOpened(WindowEvent e) 122 | { 123 | } 124 | 125 | private class KeyHandler implements KeyEventDispatcher 126 | { 127 | public boolean dispatchKeyEvent(KeyEvent arg0) 128 | { 129 | switch (arg0.getKeyCode()) 130 | { 131 | case KeyEvent.VK_DOWN: 132 | gw.fireBottomJet(); 133 | break; 134 | case KeyEvent.VK_LEFT: 135 | gw.fireLeftJet(); 136 | break; 137 | case KeyEvent.VK_RIGHT: 138 | gw.fireRightJet(); 139 | break; 140 | } 141 | return false; 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /3DModelingTool/Camera.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | import mathlib3D.*; 4 | 5 | /** 6 | * Camera class for representing camera location/orientation 7 | */ 8 | public class Camera 9 | { 10 | private Point3D cameraLocation; 11 | 12 | private Point3D lookAtPoint; 13 | 14 | private Point3D upDirection; 15 | 16 | private boolean relativeMode; 17 | 18 | private Quaternion orientation; 19 | 20 | /** 21 | * Constructs the defaul camera location and orientation 22 | */ 23 | public Camera() 24 | { 25 | cameraLocation = new Point3D(0, 0, 500); 26 | lookAtPoint = new Point3D(0, 0, 0); 27 | upDirection = new Point3D(0, 1, 0); 28 | relativeMode = true; 29 | orientation = new Quaternion(0, 0, 0, 1); 30 | } 31 | 32 | /** 33 | * @return True if the camera is in relative mode. 34 | */ 35 | public boolean getRelativeMode() 36 | { 37 | return relativeMode; 38 | } 39 | 40 | /** 41 | * @param value Sets the camera relative mode. 42 | */ 43 | public void setRelativeMode(boolean value) 44 | { 45 | relativeMode = value; 46 | } 47 | 48 | /** 49 | * @param amt Change the camera location in the X axis. 50 | */ 51 | public void changeX(double amt) 52 | { 53 | cameraLocation.setX(cameraLocation.getX() + amt); 54 | } 55 | 56 | /** 57 | * @param amt Change the camera location in the Y axis. 58 | */ 59 | public void changeY(double amt) 60 | { 61 | cameraLocation.setY(cameraLocation.getY() + amt); 62 | } 63 | 64 | /** 65 | * @param amt Change the camera location in the Z axis. 66 | */ 67 | public void changeZ(double amt) 68 | { 69 | cameraLocation.setZ(cameraLocation.getZ() + amt); 70 | } 71 | 72 | /** 73 | * @param amt Change the pitch of the camera. 74 | */ 75 | public void changePitch(double amt) 76 | { 77 | Quaternion q = Quaternion.FromAngleAxis(new Vector3D(1, 0, 0), amt); 78 | orientation = q.multiply(orientation); 79 | orientation.normalize(); 80 | } 81 | 82 | /** 83 | * @param amt Change the yaw of the camera. 84 | */ 85 | public void changeYaw(double amt) 86 | { 87 | Quaternion q = Quaternion.FromAngleAxis(new Vector3D(0, 1, 0), amt); 88 | orientation = q.multiply(orientation); 89 | orientation.normalize(); 90 | } 91 | 92 | /** 93 | * @param amt Change the roll of the camera. 94 | */ 95 | public void changeRoll(double amt) 96 | { 97 | Quaternion q = Quaternion.FromAngleAxis(new Vector3D(0, 0, 1), amt); 98 | orientation = q.multiply(orientation); 99 | orientation.normalize(); 100 | } 101 | 102 | /** 103 | * @return The point that is the center of the camera 104 | */ 105 | public Point3D getLocation() 106 | { 107 | return (Point3D) cameraLocation.clone(); 108 | } 109 | 110 | /** 111 | * @return The point that the camera is looking at in absolute mode 112 | */ 113 | public Point3D getLookAtPoint() 114 | { 115 | return (Point3D) lookAtPoint.clone(); 116 | } 117 | 118 | /** 119 | * @return The up vecotr for absolute mode 120 | */ 121 | public Point3D getUpDirection() 122 | { 123 | return (Point3D) upDirection.clone(); 124 | } 125 | 126 | /** 127 | * @param newValue Changes the camera's location 128 | */ 129 | public void setLocation(Point3D newValue) 130 | { 131 | cameraLocation = (Point3D) newValue.clone(); 132 | } 133 | 134 | /** 135 | * @param newValue Changes the camera's look-at point 136 | */ 137 | public void setLookAtPoint(Point3D newValue) 138 | { 139 | lookAtPoint = (Point3D) newValue.clone(); 140 | } 141 | 142 | /** 143 | * @param newValue Changes the camera's up vector 144 | */ 145 | public void setUpDirection(Point3D newValue) 146 | { 147 | upDirection = (Point3D) newValue.clone(); 148 | } 149 | 150 | /** 151 | * @return The angle/axis representation of the camera orientation 152 | */ 153 | public Vector3D getOrientation() 154 | { 155 | return orientation.getAngleAxis(); 156 | } 157 | 158 | /** 159 | * @param q Sets the internal Quaternion to a new value 160 | */ 161 | public void setOrientation(Quaternion q) 162 | { 163 | orientation = q; 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/renderer/joglRenderer/JOGLSkyBox.java: -------------------------------------------------------------------------------- 1 | package futureEngine.renderer.joglRenderer; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.nio.DoubleBuffer; 6 | 7 | import javax.media.opengl.GL; 8 | import javax.media.opengl.GLException; 9 | 10 | import com.sun.opengl.util.texture.Texture; 11 | import com.sun.opengl.util.texture.TextureIO; 12 | 13 | import futureEngine.scene.SkyBox; 14 | 15 | public class JOGLSkyBox { 16 | 17 | private Texture front, back, left, right, top, bottom; 18 | private boolean texturesLoaded = false; 19 | private SkyBox mySkyBox; 20 | 21 | public JOGLSkyBox(SkyBox sky) { 22 | mySkyBox = sky; 23 | } 24 | 25 | private void loadTextures() { 26 | try { 27 | front = TextureIO.newTexture(new File(mySkyBox.getFront()), false); 28 | back = TextureIO.newTexture(new File(mySkyBox.getBack()), false); 29 | left = TextureIO.newTexture(new File(mySkyBox.getLeft()), false); 30 | right = TextureIO.newTexture(new File(mySkyBox.getRight()), false); 31 | top = TextureIO.newTexture(new File(mySkyBox.getTop()), false); 32 | bottom = TextureIO.newTexture(new File(mySkyBox.getBottom()), false); 33 | } catch (GLException e) { 34 | e.printStackTrace(); 35 | } catch (IOException e) { 36 | e.printStackTrace(); 37 | } 38 | 39 | texturesLoaded = true; 40 | } 41 | 42 | public void draw(GL gl) { 43 | if (!texturesLoaded) 44 | loadTextures(); 45 | 46 | gl.glDisable(GL.GL_CULL_FACE); 47 | gl.glDepthMask(false); 48 | gl.glDisable(GL.GL_DEPTH_TEST); 49 | 50 | gl.glMatrixMode(GL.GL_MODELVIEW); 51 | gl.glPushMatrix(); 52 | 53 | // remove camera translation from MV 54 | DoubleBuffer modelView = DoubleBuffer.allocate(16); 55 | gl.glGetDoublev(GL.GL_MODELVIEW_MATRIX, modelView); 56 | double[] mat = modelView.array(); 57 | mat[12] = mat[13] = mat[14] = 0; 58 | gl.glLoadMatrixd(mat, 0); 59 | 60 | gl.glEnable(GL.GL_TEXTURE_2D); 61 | 62 | drawFront(gl); 63 | drawBack(gl); 64 | drawLeft(gl); 65 | drawRight(gl); 66 | drawTop(gl); 67 | drawBottom(gl); 68 | 69 | gl.glDisable(GL.GL_TEXTURE_2D); 70 | gl.glPopMatrix(); 71 | 72 | gl.glEnable(GL.GL_CULL_FACE); 73 | gl.glDepthMask(true); 74 | gl.glEnable(GL.GL_DEPTH_TEST); 75 | } 76 | 77 | private void drawBottom(GL gl) { 78 | bottom.bind(); 79 | bottom.enable(); 80 | 81 | gl.glPushMatrix(); 82 | gl.glRotatef(-90f, 1f, 0f, 0f); 83 | gl.glScalef(1f, -1f, 1f); 84 | drawTexture(gl); 85 | gl.glPopMatrix(); 86 | } 87 | 88 | private void drawTop(GL gl) { 89 | top.bind(); 90 | top.enable(); 91 | 92 | gl.glPushMatrix(); 93 | gl.glRotatef(90f, 1f, 0f, 0f); 94 | gl.glScalef(1f, -1f, 1f); 95 | drawTexture(gl); 96 | gl.glPopMatrix(); 97 | } 98 | 99 | private void drawRight(GL gl) { 100 | right.bind(); 101 | right.enable(); 102 | 103 | gl.glPushMatrix(); 104 | gl.glRotatef(-90f, 0f, 1f, 0f); 105 | gl.glScalef(1f, -1f, 1f); 106 | drawTexture(gl); 107 | gl.glPopMatrix(); 108 | } 109 | 110 | private void drawLeft(GL gl) { 111 | left.bind(); 112 | left.enable(); 113 | 114 | gl.glPushMatrix(); 115 | gl.glRotatef(90f, 0f, 1f, 0f); 116 | gl.glScalef(1f, -1f, 1f); 117 | drawTexture(gl); 118 | gl.glPopMatrix(); 119 | } 120 | 121 | private void drawBack(GL gl) { 122 | back.bind(); 123 | back.enable(); 124 | 125 | gl.glPushMatrix(); 126 | gl.glRotatef(180f, 0f, 1f, 0f); 127 | gl.glScalef(1f, -1f, 1f); 128 | drawTexture(gl); 129 | gl.glPopMatrix(); 130 | } 131 | 132 | private void drawFront(GL gl) { 133 | front.bind(); 134 | front.enable(); 135 | 136 | gl.glPushMatrix(); 137 | gl.glScalef(1f, -1f, 1f); 138 | drawTexture(gl); 139 | gl.glPopMatrix(); 140 | } 141 | 142 | private void drawTexture(GL gl) { 143 | gl.glBegin(GL.GL_QUADS); 144 | 145 | gl.glTexCoord2d(1.0, 1.0); 146 | gl.glVertex3d(1.0, 1.0, -1.0); 147 | 148 | gl.glTexCoord2d(0.0, 1.0); 149 | gl.glVertex3d(-1.0, 1.0, -1.0); 150 | 151 | gl.glTexCoord2d(0.0, 0.0); 152 | gl.glVertex3d(-1.0, -1.0, -1.0); 153 | 154 | gl.glTexCoord2d(1.0, 0.0); 155 | gl.glVertex3d(1.0, -1.0, -1.0); 156 | 157 | gl.glEnd(); 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /3DGameEngine/src/futureEngine/camera/Camera.java: -------------------------------------------------------------------------------- 1 | package futureEngine.camera; 2 | 3 | import futureEngine.scene.BoundingVolume; 4 | import futureEngine.scene.Plane; 5 | import graphicslib3D.Matrix3D; 6 | import graphicslib3D.Point3D; 7 | import graphicslib3D.Quaternion; 8 | import graphicslib3D.Vector3D; 9 | 10 | public class Camera implements ICamera { 11 | 12 | private double forwardMotion; 13 | private double strafeMotion; 14 | private Vector3D location; 15 | private Quaternion rotation; 16 | private Plane[] planes; 17 | 18 | public Camera() { 19 | location = new Vector3D(0, 0, 0); 20 | rotation = new Quaternion(1, new Vector3D(0, 1, 0)); 21 | rotation.normalize(); 22 | forwardMotion = 0; 23 | strafeMotion = 0; 24 | } 25 | 26 | @Override 27 | public void update(long time) { 28 | double[] angleAxis = rotation.getAngleAxis(); 29 | Matrix3D mat = new Matrix3D(angleAxis[0], new Vector3D(angleAxis[1], angleAxis[2], angleAxis[3])); 30 | 31 | if (forwardMotion != 0) { 32 | double distance = time * SPEED * forwardMotion; 33 | Vector3D forward = mat.getRow(2); 34 | forward.scale(distance); 35 | location = location.add(forward); 36 | } 37 | 38 | if (strafeMotion != 0) { 39 | double distance = time * SPEED * strafeMotion; 40 | Vector3D strafe = mat.getRow(0); 41 | strafe.scale(distance); 42 | location = location.add(strafe); 43 | } 44 | } 45 | 46 | @Override 47 | public void pitch(double mouseDeltaY) { 48 | Quaternion nrot = new Quaternion(mouseDeltaY, new Vector3D(1, 0, 0)); 49 | nrot.normalize(); 50 | rotation = nrot.multiplyBy(rotation); 51 | rotation.normalize(); 52 | } 53 | 54 | @Override 55 | public void yaw(double mouseDeltaX) { 56 | Quaternion nrot = new Quaternion(mouseDeltaX, new Vector3D(0, 1, 0)); 57 | nrot.normalize(); 58 | rotation = rotation.multiplyBy(nrot); 59 | 60 | rotation.normalize(); 61 | } 62 | 63 | @Override 64 | public Point3D getLocation() { 65 | return new Point3D(location.getX(), location.getY(), location.getZ()); 66 | } 67 | 68 | @Override 69 | public Vector3D getRightAxis() { 70 | // TODO Auto-generated method stub 71 | return null; 72 | } 73 | 74 | @Override 75 | public Vector3D getUpAxis() { 76 | // TODO Auto-generated method stub 77 | return null; 78 | } 79 | 80 | @Override 81 | public Vector3D getViewDirection() { 82 | return new Vector3D(); 83 | } 84 | 85 | @Override 86 | public double[] getOrientation() { 87 | return rotation.getAngleAxis(); 88 | } 89 | 90 | @Override 91 | public void lookAt(Point3D pos, Vector3D upDir) { 92 | // TODO Auto-generated method stub 93 | 94 | } 95 | 96 | @Override 97 | public void setAxes(Vector3D right, Vector3D up, Vector3D viewDir) { 98 | // TODO Auto-generated method stub 99 | 100 | } 101 | 102 | @Override 103 | public void setLocation(Point3D loc) { 104 | // TODO Auto-generated method stub 105 | 106 | } 107 | 108 | @Override 109 | public void setPerspectiveFrustum(double fovY, double aspect, double near, 110 | double far) { 111 | // TODO Auto-generated method stub 112 | 113 | } 114 | 115 | @Override 116 | public void setRightAxis(Vector3D right) { 117 | // TODO Auto-generated method stub 118 | 119 | } 120 | 121 | @Override 122 | public void setUpAxis(Vector3D up) { 123 | // TODO Auto-generated method stub 124 | 125 | } 126 | 127 | @Override 128 | public void setViewDirection(Vector3D dir) { 129 | // TODO Auto-generated method stub 130 | 131 | } 132 | 133 | /** 134 | * @param forwardMotion 135 | * the forwardMotion to set 136 | */ 137 | public void setForwardMotion(double forwardMotion) { 138 | this.forwardMotion = forwardMotion; 139 | } 140 | 141 | /** 142 | * @return the forwardMotion 143 | */ 144 | public double getForwardMotion() { 145 | return forwardMotion; 146 | } 147 | 148 | /** 149 | * @param strafeMotion 150 | * the strafeMotion to set 151 | */ 152 | public void setStrafeMotion(double strafeMotion) { 153 | this.strafeMotion = strafeMotion; 154 | } 155 | 156 | /** 157 | * @return the strafeMotion 158 | */ 159 | public double getStrafeMotion() { 160 | return strafeMotion; 161 | } 162 | 163 | @Override 164 | public boolean intersects(BoundingVolume bound) { 165 | for (Plane p : planes) { 166 | if (bound.isOnPositiveSide(p)) { 167 | return true; 168 | } 169 | } 170 | return false; 171 | } 172 | 173 | public void setFrustrumPlanes(Plane[] newPlanes) { 174 | planes = newPlanes; 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /3DModelingTool/mathlib3D/javadoc/deprecated-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Deprecated List 8 | 9 | 10 | 11 | 12 | 13 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 45 | 48 | 49 | 50 | 51 | 54 | 70 | 71 |
46 | 47 |
72 | 73 | 74 | 75 |
76 |
77 |

78 | Deprecated API

79 |
80 |
81 | Contents
    82 |
83 | 84 |
85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 105 | 108 | 109 | 110 | 111 | 114 | 130 | 131 |
106 | 107 |
132 | 133 | 134 | 135 |
136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /3DModelingTool/graphicslib3D/javadoc/deprecated-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Deprecated List 8 | 9 | 10 | 11 | 12 | 13 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 45 | 48 | 49 | 50 | 51 | 54 | 70 | 71 |
46 | 47 |
72 | 73 | 74 | 75 |
76 |
77 |

78 | Deprecated API

79 |
80 |
81 | Contents
    82 |
83 | 84 |
85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 105 | 108 | 109 | 110 | 111 | 114 | 130 | 131 |
106 | 107 |
132 | 133 | 134 | 135 |
136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /3DModelingTool/mathlib3D/javadoc/constant-values.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Constant Field Values 8 | 9 | 10 | 11 | 12 | 13 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 45 | 48 | 49 | 50 | 51 | 54 | 70 | 71 |
46 | 47 |
72 | 73 | 74 | 75 |
76 |
77 |

78 | Constant Field Values

79 |
80 |
81 | Contents
    82 |
83 | 84 |
85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 105 | 108 | 109 | 110 | 111 | 114 | 130 | 131 |
106 | 107 |
132 | 133 | 134 | 135 |
136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /LunarLander/src/game/MapView.java: -------------------------------------------------------------------------------- 1 | package game; 2 | 3 | import java.awt.Color; 4 | import java.awt.Graphics; 5 | import java.awt.Graphics2D; 6 | import java.awt.Point; 7 | import java.awt.Rectangle; 8 | import java.awt.event.MouseEvent; 9 | import java.awt.event.MouseListener; 10 | import java.awt.event.MouseMotionListener; 11 | import java.awt.geom.AffineTransform; 12 | import java.awt.geom.NoninvertibleTransformException; 13 | import java.awt.geom.Point2D; 14 | import java.util.Observable; 15 | import java.util.Observer; 16 | 17 | import javax.swing.JPanel; 18 | import javax.swing.SwingUtilities; 19 | 20 | import domain.GameObject; 21 | 22 | /** 23 | * Implements a View of the map in the game. 24 | * 25 | * Represents the View part of the Model View Controller architecture. 26 | */ 27 | public class MapView extends JPanel implements Observer, MouseListener, MouseMotionListener 28 | { 29 | /** 30 | * Default serialVersionUID 31 | */ 32 | private static final long serialVersionUID = 1L; 33 | 34 | private GameWorld gameData; 35 | private boolean selecting; 36 | private java.awt.Point startPoint; 37 | private java.awt.Point currentPoint; 38 | 39 | private AffineTransform currentAT; 40 | 41 | private Point startScreenPoint; 42 | 43 | private Point currentScreenPoint; 44 | 45 | public MapView() 46 | { 47 | selecting = false; 48 | addMouseListener(this); 49 | addMouseMotionListener(this); 50 | } 51 | 52 | /* (non-Javadoc) 53 | * @see java.util.Observer#update(java.util.Observable, java.lang.Object) 54 | */ 55 | public void update(Observable o, Object arg) 56 | { 57 | gameData = (GameWorld)o; 58 | repaint(); 59 | } 60 | 61 | private AffineTransform getVTM() 62 | { 63 | AffineTransform VTM = new AffineTransform(); 64 | VTM.scale(1, -1); 65 | VTM.translate(0, -getHeight()); 66 | return VTM; 67 | } 68 | 69 | public void paintComponent(Graphics g) 70 | { 71 | super.paintComponent(g); 72 | if (gameData == null) return; 73 | 74 | Graphics2D g2d = (Graphics2D)g; 75 | AffineTransform previousTransform = g2d.getTransform(); 76 | 77 | g2d.transform(getVTM()); 78 | 79 | double visibleWorldY = gameData.getLanderPosition().getY().doubleValue() * 1.33; 80 | double zoomFactor = (double)getHeight() / visibleWorldY; 81 | 82 | if (zoomFactor < 1) 83 | { 84 | g2d.translate(-(gameData.getLanderPosition().getX().intValue() * zoomFactor - (getWidth() / 2)), 0); 85 | g2d.scale(zoomFactor, zoomFactor); 86 | } 87 | else 88 | { 89 | g2d.translate(-(gameData.getLanderPosition().getX().intValue() - (getWidth() / 2)), 0); 90 | } 91 | 92 | for (GameObject gameObj: gameData.getGameObjects()) 93 | { 94 | gameObj.draw(g2d); 95 | } 96 | 97 | currentAT = g2d.getTransform(); 98 | g2d.setTransform(previousTransform); 99 | 100 | if (selecting) 101 | { 102 | Color save = g.getColor(); 103 | g.setColor(Color.yellow); 104 | g.drawRect(startScreenPoint.x, startScreenPoint.y, currentScreenPoint.x - startScreenPoint.x, currentScreenPoint.y - startScreenPoint.y); 105 | g.setColor(save); 106 | } 107 | } 108 | 109 | public void mouseClicked(MouseEvent arg0) 110 | { 111 | if (SwingUtilities.isLeftMouseButton(arg0)) 112 | { 113 | try { 114 | Point worldPoint = getWorldPoint(arg0.getPoint()); 115 | gameData.selectAt(worldPoint); 116 | repaint(); 117 | } catch (NoninvertibleTransformException e) { 118 | // TODO Auto-generated catch block 119 | e.printStackTrace(); 120 | } 121 | } 122 | } 123 | 124 | private Point getWorldPoint(Point point) throws NoninvertibleTransformException { 125 | AffineTransform invVTM; 126 | invVTM = currentAT.createInverse(); 127 | Point2D temp = invVTM.transform(point, null); 128 | return new java.awt.Point((int)temp.getX(), (int)temp.getY()); 129 | } 130 | 131 | public void mouseEntered(MouseEvent arg0) { 132 | // TODO Auto-generated method stub 133 | 134 | } 135 | 136 | public void mouseExited(MouseEvent arg0) { 137 | // TODO Auto-generated method stub 138 | 139 | } 140 | 141 | public void mousePressed(MouseEvent arg0) 142 | { 143 | if (SwingUtilities.isRightMouseButton(arg0)) 144 | { 145 | selecting = false; 146 | startScreenPoint = arg0.getPoint(); 147 | try { 148 | startPoint = getWorldPoint(arg0.getPoint()); 149 | } catch (NoninvertibleTransformException e) { 150 | // TODO Auto-generated catch block 151 | e.printStackTrace(); 152 | } 153 | } 154 | } 155 | 156 | public void mouseReleased(MouseEvent arg0) 157 | { 158 | if (SwingUtilities.isRightMouseButton(arg0)) 159 | { 160 | if (selecting) 161 | { 162 | gameData.unselectAll(); 163 | gameData.selectAt(new Rectangle(startPoint.x, currentPoint.y, currentPoint.x - startPoint.x, startPoint.y - currentPoint.y)); 164 | selecting = false; 165 | repaint(); 166 | } 167 | } 168 | } 169 | 170 | public void mouseDragged(MouseEvent arg0) 171 | { 172 | if (SwingUtilities.isRightMouseButton(arg0)) 173 | { 174 | selecting = true; 175 | currentScreenPoint = arg0.getPoint(); 176 | try { 177 | currentPoint = getWorldPoint(arg0.getPoint()); 178 | } catch (NoninvertibleTransformException e) { 179 | // TODO Auto-generated catch block 180 | e.printStackTrace(); 181 | } 182 | repaint(); 183 | } 184 | } 185 | 186 | public void mouseMoved(MouseEvent arg0) 187 | { 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /LunarLander/src/game/LanderGameCollection.java: -------------------------------------------------------------------------------- 1 | package game; 2 | 3 | import java.util.*; 4 | 5 | import domain.IMoveable; 6 | import domain.LandingPad; 7 | import domain.Meteor; 8 | 9 | /** 10 | * Implements a generic collection of objects for the Lunar Lander game. 11 | * 12 | * @param The type of object to store in the collection. 13 | */ 14 | public class LanderGameCollection implements java.util.Collection 15 | { 16 | /** 17 | * The internal collection of items. 18 | */ 19 | ArrayList gameObjects; 20 | 21 | public LanderGameCollection() 22 | { 23 | gameObjects = new ArrayList(); 24 | } 25 | 26 | /** 27 | * Implements the Iterator interface for the LanderGameCollection. 28 | * 29 | * @param The type of object that will be iterated over. 30 | */ 31 | private class LanderGameIterator implements Iterator 32 | { 33 | /** 34 | * A reference to the internal list of objects from the GameObjectCollection. 35 | */ 36 | private ArrayList myList; 37 | /** 38 | * Keeps track of the current place within the ArrayList. 39 | */ 40 | private int currentIndex; 41 | 42 | /** 43 | * @param list A list of objects from the GameObjectCollection. 44 | */ 45 | public LanderGameIterator(ArrayList list) 46 | { 47 | myList = list; 48 | currentIndex = -1; 49 | } 50 | 51 | /* (non-Javadoc) 52 | * @see java.util.Iterator#hasNext() 53 | */ 54 | public boolean hasNext() 55 | { 56 | return (currentIndex + 1) < myList.size(); 57 | } 58 | 59 | /* (non-Javadoc) 60 | * @see java.util.Iterator#next() 61 | */ 62 | public T next() 63 | { 64 | if (hasNext()) 65 | { 66 | ++currentIndex; 67 | return myList.get(currentIndex); 68 | } 69 | else 70 | throw new NoSuchElementException(); 71 | } 72 | 73 | /* (non-Javadoc) 74 | * @see java.util.Iterator#remove() 75 | */ 76 | public void remove() 77 | { 78 | if (currentIndex > -1) 79 | myList.remove(currentIndex); 80 | else 81 | throw new NoSuchElementException(); 82 | } 83 | 84 | } 85 | 86 | /* (non-Javadoc) 87 | * @see java.util.Collection#add(java.lang.Object) 88 | */ 89 | public boolean add(E o) 90 | { 91 | return gameObjects.add(o); 92 | } 93 | 94 | /* (non-Javadoc) 95 | * @see java.util.Collection#addAll(java.util.Collection) 96 | */ 97 | public boolean addAll(Collection c) 98 | { 99 | return gameObjects.addAll(c); 100 | } 101 | 102 | /* (non-Javadoc) 103 | * @see java.util.Collection#clear() 104 | */ 105 | public void clear() 106 | { 107 | gameObjects.clear(); 108 | } 109 | 110 | /* (non-Javadoc) 111 | * @see java.util.Collection#contains(java.lang.Object) 112 | */ 113 | public boolean contains(Object o) 114 | { 115 | return gameObjects.contains(o); 116 | } 117 | 118 | /* (non-Javadoc) 119 | * @see java.util.Collection#containsAll(java.util.Collection) 120 | */ 121 | public boolean containsAll(Collection c) 122 | { 123 | return gameObjects.containsAll(c); 124 | } 125 | 126 | /* (non-Javadoc) 127 | * @see java.util.Collection#isEmpty() 128 | */ 129 | public boolean isEmpty() 130 | { 131 | return gameObjects.isEmpty(); 132 | } 133 | 134 | /* (non-Javadoc) 135 | * @see java.util.Collection#iterator() 136 | */ 137 | public Iterator iterator() 138 | { 139 | return new LanderGameIterator(gameObjects); 140 | } 141 | 142 | public LanderGameCollection meteors() 143 | { 144 | LanderGameCollection result = new LanderGameCollection(); 145 | for (E gameObject : gameObjects) 146 | { 147 | if (gameObject instanceof Meteor) 148 | result.add((Meteor)gameObject); 149 | } 150 | return result; 151 | } 152 | 153 | public LanderGameCollection landingPads() 154 | { 155 | LanderGameCollection result = new LanderGameCollection(); 156 | for (E gameObject : gameObjects) 157 | { 158 | if (gameObject instanceof LandingPad) 159 | result.add((LandingPad)gameObject); 160 | } 161 | return result; 162 | } 163 | 164 | public LanderGameCollection movingObjects() 165 | { 166 | LanderGameCollection result = new LanderGameCollection(); 167 | for (E gameObject : gameObjects) 168 | { 169 | if (gameObject instanceof IMoveable) 170 | result.add((IMoveable)gameObject); 171 | } 172 | return result; 173 | } 174 | 175 | /* (non-Javadoc) 176 | * @see java.util.Collection#remove(java.lang.Object) 177 | */ 178 | public boolean remove(Object o) 179 | { 180 | return gameObjects.remove(o); 181 | } 182 | 183 | /* (non-Javadoc) 184 | * @see java.util.Collection#removeAll(java.util.Collection) 185 | */ 186 | public boolean removeAll(Collection c) 187 | { 188 | return gameObjects.removeAll(c); 189 | } 190 | 191 | /* (non-Javadoc) 192 | * @see java.util.Collection#retainAll(java.util.Collection) 193 | */ 194 | public boolean retainAll(Collection c) 195 | { 196 | return gameObjects.retainAll(c); 197 | } 198 | 199 | /* (non-Javadoc) 200 | * @see java.util.Collection#size() 201 | */ 202 | public int size() 203 | { 204 | return gameObjects.size(); 205 | } 206 | 207 | /* (non-Javadoc) 208 | * @see java.util.Collection#toArray() 209 | */ 210 | public Object[] toArray() 211 | { 212 | return gameObjects.toArray(); 213 | } 214 | 215 | /* (non-Javadoc) 216 | * @see java.util.Collection#toArray(T[]) 217 | */ 218 | public T[] toArray(T[] a) 219 | { 220 | return gameObjects.toArray(a); 221 | } 222 | 223 | } 224 | -------------------------------------------------------------------------------- /3DModelingTool/GLCanvasListener.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | import java.awt.event.ActionEvent; 4 | import java.awt.event.ActionListener; 5 | import java.nio.FloatBuffer; 6 | import java.util.Hashtable; 7 | import javax.media.opengl.GL; 8 | import javax.media.opengl.GLAutoDrawable; 9 | import javax.media.opengl.GLEventListener; 10 | import javax.media.opengl.glu.GLU; 11 | import javax.swing.JCheckBoxMenuItem; 12 | import javax.swing.Timer; 13 | import mathlib3D.Point3D; 14 | import mathlib3D.Vector3D; 15 | 16 | public class GLCanvasListener implements GLEventListener, ActionListener 17 | { 18 | private GLU glu; 19 | 20 | private Camera myCamera; 21 | 22 | private Hashtable worldObjects; 23 | 24 | private Hashtable lights; 25 | 26 | private JCheckBoxMenuItem enableLight; 27 | 28 | private JCheckBoxMenuItem smoothShading; 29 | 30 | private float elapsedTime; 31 | 32 | private float timeIncrement; 33 | 34 | public GLCanvasListener(Camera camera, Hashtable world, JCheckBoxMenuItem enableLightItem, JCheckBoxMenuItem shadingMenuitem, Hashtable theLights) 35 | { 36 | myCamera = camera; 37 | worldObjects = world; 38 | enableLight = enableLightItem; 39 | smoothShading = shadingMenuitem; 40 | lights = theLights; 41 | Timer timer = new Timer(20, this); 42 | elapsedTime = 0.0f; 43 | timeIncrement = 2.0f; 44 | timer.start(); 45 | } 46 | 47 | /* 48 | * (non-Javadoc) 49 | * 50 | * @see javax.media.opengl.GLEventListener#display(javax.media.opengl.GLAutoDrawable) 51 | */ 52 | public void display(GLAutoDrawable drawable) 53 | { 54 | GL gl = drawable.getGL(); 55 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); 56 | for(int i = 0; i < 8; ++i) 57 | gl.glDisable(getGLLightNum(i)); 58 | if(enableLight.isSelected()) 59 | { 60 | gl.glLightModelfv(GL.GL_LIGHT_MODEL_AMBIENT, FloatBuffer.wrap(AmbientLight.getInstance().getIntensity().getRGBComponents(null))); 61 | int i = 0; 62 | for(Light l : lights.values()) 63 | { 64 | l.draw(drawable, getGLLightNum(i)); 65 | gl.glEnable(getGLLightNum(i)); 66 | ++i; 67 | } 68 | gl.glEnable(GL.GL_LIGHTING); 69 | } 70 | else 71 | gl.glDisable(GL.GL_LIGHTING); 72 | if(smoothShading.isSelected()) 73 | gl.glShadeModel(GL.GL_SMOOTH); 74 | else 75 | gl.glShadeModel(GL.GL_FLAT); 76 | gl.glMatrixMode(GL.GL_PROJECTION); 77 | gl.glLoadIdentity(); 78 | glu.gluPerspective(60.0f, (float) drawable.getWidth() / (float) drawable.getHeight(), 0.01f, 5000.0f); 79 | Point3D cameraLocation = myCamera.getLocation(); 80 | if(myCamera.getRelativeMode()) 81 | { 82 | Vector3D angleAxis = myCamera.getOrientation(); 83 | gl.glRotated(Math.toDegrees(angleAxis.getW()), angleAxis.getX(), angleAxis.getY(), angleAxis.getZ()); 84 | gl.glTranslated(-cameraLocation.getX(), -cameraLocation.getY(), -cameraLocation.getZ()); 85 | } 86 | else 87 | { 88 | Point3D lookAtPoint = myCamera.getLookAtPoint(); 89 | Point3D upDirection = myCamera.getUpDirection(); 90 | glu.gluLookAt(cameraLocation.getX(), cameraLocation.getY(), cameraLocation.getZ(), lookAtPoint.getX(), lookAtPoint.getY(), lookAtPoint.getZ(), upDirection.getX(), upDirection.getY(), upDirection.getZ()); 91 | } 92 | gl.glMatrixMode(GL.GL_MODELVIEW); 93 | gl.glLoadIdentity(); 94 | for(Visual v : worldObjects.values()) 95 | { 96 | Shader s = v.getShader(); 97 | if(s != null && s.isParameterized()) 98 | s.setParameterValue(elapsedTime); 99 | v.draw(drawable, enableLight.isSelected()); 100 | } 101 | checkForErrors(gl); 102 | } 103 | 104 | /* 105 | * (non-Javadoc) 106 | * 107 | * @see javax.media.opengl.GLEventListener#displayChanged(javax.media.opengl.GLAutoDrawable, 108 | * boolean, boolean) 109 | */ 110 | public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) 111 | { 112 | } 113 | 114 | /* 115 | * (non-Javadoc) 116 | * 117 | * @see javax.media.opengl.GLEventListener#init(javax.media.opengl.GLAutoDrawable) 118 | */ 119 | public void init(GLAutoDrawable drawable) 120 | { 121 | System.out.println("OpenGL Version " + GLU.getCurrentGL().glGetString(GL.GL_VERSION)); 122 | glu = new GLU(); 123 | GL gl = drawable.getGL(); 124 | gl.glEnable(GL.GL_AUTO_NORMAL); 125 | gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); 126 | gl.glClearDepth(1.0); 127 | gl.glDepthFunc(GL.GL_LEQUAL); 128 | gl.glEnable(GL.GL_DEPTH_TEST); 129 | gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); 130 | } 131 | 132 | /* 133 | * (non-Javadoc) 134 | * 135 | * @see javax.media.opengl.GLEventListener#reshape(javax.media.opengl.GLAutoDrawable, 136 | * int, int, int, int) 137 | */ 138 | public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) 139 | { 140 | } 141 | 142 | /** 143 | * Checks for errors that may have occurred. 144 | * 145 | * @param gl The GL object to be used for drawing. 146 | */ 147 | private void checkForErrors(GL gl) 148 | { 149 | int errorCode = gl.glGetError(); 150 | if(errorCode != GL.GL_NO_ERROR) 151 | { 152 | String errorString = glu.gluErrorString(errorCode); 153 | if(errorString == null) 154 | System.out.println("GLU returned null error string (invalid error code?)"); 155 | else 156 | System.out.println(errorString); 157 | } 158 | } 159 | 160 | private int getGLLightNum(int index) 161 | { 162 | switch(index) 163 | { 164 | case 0: 165 | return GL.GL_LIGHT0; 166 | case 1: 167 | return GL.GL_LIGHT1; 168 | case 2: 169 | return GL.GL_LIGHT2; 170 | case 3: 171 | return GL.GL_LIGHT3; 172 | case 4: 173 | return GL.GL_LIGHT4; 174 | case 5: 175 | return GL.GL_LIGHT5; 176 | case 6: 177 | return GL.GL_LIGHT6; 178 | case 7: 179 | return GL.GL_LIGHT7; 180 | default: 181 | return GL.GL_LIGHT0; 182 | } 183 | } 184 | 185 | public void actionPerformed(ActionEvent e) 186 | { 187 | elapsedTime = (elapsedTime += timeIncrement) % 1024; 188 | 189 | } 190 | } 191 | -------------------------------------------------------------------------------- /3DModelingTool/Quaternion.java: -------------------------------------------------------------------------------- 1 | package a5; 2 | 3 | import java.math.BigDecimal; 4 | import mathlib3D.*; 5 | 6 | /** 7 | * Quaternion operations and algorithms for camera orientations 8 | */ 9 | public class Quaternion 10 | { 11 | private Vector3D axis; 12 | 13 | private double angle; 14 | 15 | /** 16 | * Creates a Quaternion from an angle/axis representation 17 | * 18 | * @param theAxis The axis of rotation, x,y,z 19 | * @param theAngle The angle of rotation, w 20 | * @return The Quaternion representing the angle/axis 21 | */ 22 | public static Quaternion FromAngleAxis(Vector3D theAxis, double theAngle) 23 | { 24 | double x, y, z, w; 25 | double halfAngleInRadians = Math.toRadians(theAngle * 0.5); 26 | double sinPart = Math.sin(halfAngleInRadians); 27 | w = Math.cos(halfAngleInRadians); 28 | x = sinPart * theAxis.getX(); 29 | y = sinPart * theAxis.getY(); 30 | z = sinPart * theAxis.getZ(); 31 | return new Quaternion(x, y, z, w); 32 | } 33 | 34 | /** 35 | * Constructs a default (unit) Quaternion 36 | */ 37 | public Quaternion() 38 | { 39 | this(0, 0, 0, 1); 40 | } 41 | 42 | /** 43 | * Constructs a Quaternion based on x,y,z, and w values 44 | * 45 | * @param x 46 | * @param y 47 | * @param z 48 | * @param w 49 | */ 50 | public Quaternion(double x, double y, double z, double w) 51 | { 52 | axis = new Vector3D(x, y, z); 53 | angle = w; 54 | } 55 | 56 | /** 57 | * Constructs a Quaternion from an axis Vector3D and angle of rotation about 58 | * that axis. 59 | * 60 | * @param v The Vector3D of the axis 61 | * @param w The rotation about the axis 62 | */ 63 | public Quaternion(Vector3D v, double w) 64 | { 65 | axis = v; 66 | angle = w; 67 | } 68 | 69 | /** 70 | * Multiples two Quaternions 71 | * 72 | * @param q The left-hand Quaternion to multiply by. 73 | * @return The Quaternion that represents the reult of the multiplication 74 | */ 75 | public Quaternion multiply(Quaternion q) 76 | { 77 | double qT, qX, qY, qZ; 78 | double aT, aX, aY, aZ; 79 | double bT, bX, bY, bZ; 80 | aT = angle; 81 | aX = axis.getX(); 82 | aY = axis.getY(); 83 | aZ = axis.getZ(); 84 | bT = q.getW(); 85 | bX = q.getX(); 86 | bY = q.getY(); 87 | bZ = q.getZ(); 88 | qT = (aT * bT) - (aX * bX) - (aY * bY) - (aZ * bZ); 89 | qX = (aT * bX) + (aX * bT) + (aY * bZ) - (aZ * bY); 90 | qY = (aT * bY) - (aX * bZ) + (aY * bT) + (aZ * bX); 91 | qZ = (aT * bZ) + (aX * bY) - (aY * bX) + (aZ * bT); 92 | return new Quaternion(qX, qY, qZ, qT); 93 | } 94 | 95 | /** 96 | * Gets the angle/axis representation of the Quaternion 97 | * 98 | * @return The angle/axis representation stored in a Vector3D object. 99 | */ 100 | public Vector3D getAngleAxis() 101 | { 102 | BigDecimal w = new BigDecimal(Math.acos(angle)); 103 | BigDecimal sinW = new BigDecimal(Math.sin(w.doubleValue())); 104 | if(sinW.compareTo(new BigDecimal(0)) != 0) 105 | { 106 | BigDecimal x = new BigDecimal(axis.getX()).divide(sinW, BigDecimal.ROUND_HALF_EVEN); 107 | BigDecimal y = new BigDecimal(axis.getY()).divide(sinW, BigDecimal.ROUND_HALF_EVEN); 108 | BigDecimal z = new BigDecimal(axis.getZ()).divide(sinW, BigDecimal.ROUND_HALF_EVEN); 109 | return new Vector3D(x.doubleValue(), y.doubleValue(), z.doubleValue(), w.multiply(new BigDecimal(2)).doubleValue()); 110 | } 111 | else 112 | return new Vector3D(0, 0, 0, w.multiply(new BigDecimal(2)).doubleValue()); 113 | } 114 | 115 | /** 116 | * Normalizes the Quaternion into a unit Quaternion. 117 | */ 118 | public void normalize() 119 | { 120 | double x = axis.getX() * axis.getX(); 121 | double y = axis.getY() * axis.getY(); 122 | double z = axis.getZ() * axis.getZ(); 123 | double w = angle * angle; 124 | double magnitude = Math.sqrt(x + y + z + w); 125 | if(magnitude != 0) 126 | { 127 | axis.setX(axis.getX() / magnitude); 128 | axis.setY(axis.getY() / magnitude); 129 | axis.setZ(axis.getZ() / magnitude); 130 | angle = angle / magnitude; 131 | } 132 | else 133 | // magnitude was zero, set to identity to avoid divide by zero 134 | { 135 | axis.setX(0); 136 | axis.setY(0); 137 | axis.setZ(0); 138 | // Preserve the sign of the angle 139 | if(angle > 0) 140 | angle = 1; 141 | else 142 | angle = -1; 143 | } 144 | } 145 | 146 | public double getW() 147 | { 148 | return angle; 149 | } 150 | 151 | public double getX() 152 | { 153 | return axis.getX(); 154 | } 155 | 156 | public double getY() 157 | { 158 | return axis.getY(); 159 | } 160 | 161 | public double getZ() 162 | { 163 | return axis.getZ(); 164 | } 165 | 166 | /** 167 | * Slerp Algorithm (Largely modeled after the implementation in the Generic 168 | * Graphics Toolkit see http://ggt.sourceforge.net/html/group__Interp.html 169 | * 170 | * @param q0 171 | * @param q1 172 | * @param t 173 | * @return 174 | */ 175 | public static Quaternion Slerp(Quaternion q0, Quaternion q1, double t) 176 | { 177 | double cosom = q0.getX() * q1.getX() + q0.getY() * q1.getY() + q0.getZ() * q1.getZ() + q0.getW() * q1.getW(); 178 | double tmp0, tmp1, tmp2, tmp3; 179 | if(cosom < 0.0) 180 | { 181 | cosom = -cosom; 182 | tmp0 = -q1.getX(); 183 | tmp1 = -q1.getY(); 184 | tmp2 = -q1.getZ(); 185 | tmp3 = -q1.getW(); 186 | } 187 | else 188 | { 189 | tmp0 = q1.getX(); 190 | tmp1 = q1.getY(); 191 | tmp2 = q1.getZ(); 192 | tmp3 = q1.getW(); 193 | } 194 | /* calc coeffs */ 195 | double scale0, scale1; 196 | if((1.0 - cosom) > 0.0001) 197 | { 198 | // standard case (slerp) 199 | double omega = Math.acos(cosom); 200 | double sinom = Math.sin(omega); 201 | scale0 = Math.sin((1.0 - t) * omega) / sinom; 202 | scale1 = Math.sin(t * omega) / sinom; 203 | } 204 | else 205 | { 206 | /* just lerp */ 207 | scale0 = 1.0 - t; 208 | scale1 = t; 209 | } 210 | return new Quaternion(scale0 * q0.getX() + scale1 * tmp0, scale0 * q0.getY() + scale1 * tmp1, scale0 * q0.getZ() + scale1 * tmp2, scale0 * q0.getW() + scale1 * tmp3); 211 | } 212 | } 213 | --------------------------------------------------------------------------------