diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..d50d7c8
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 0000000..f660fd7
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+
+
+ CarrotServerMongo
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/.settings/CVS/Entries b/.settings/CVS/Entries
new file mode 100644
index 0000000..a9df93b
--- /dev/null
+++ b/.settings/CVS/Entries
@@ -0,0 +1 @@
+/org.eclipse.jdt.core.prefs/1.2/Thu Jun 2 05:55:26 2016//
diff --git a/.settings/CVS/Repository b/.settings/CVS/Repository
new file mode 100644
index 0000000..5e848fe
--- /dev/null
+++ b/.settings/CVS/Repository
@@ -0,0 +1 @@
+CarrotServer/.settings
diff --git a/.settings/CVS/Root b/.settings/CVS/Root
new file mode 100644
index 0000000..c36e9d0
--- /dev/null
+++ b/.settings/CVS/Root
@@ -0,0 +1 @@
+:pserver:guest@nitta-lab-www.is.konan-u.ac.jp:\CVSProject
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..980b98c
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,12 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/CVS/Entries b/CVS/Entries
new file mode 100644
index 0000000..d322489
--- /dev/null
+++ b/CVS/Entries
@@ -0,0 +1,8 @@
+/.classpath/1.1/Tue Apr 26 05:52:41 2016//
+/.project/1.2/Tue Dec 13 06:22:05 2016//
+D/.settings////
+D/WEB-INF////
+D/bin////
+/build.xml/1.1/Wed Dec 28 04:24:09 2016//
+D/lib////
+D/src////
diff --git a/CVS/Repository b/CVS/Repository
new file mode 100644
index 0000000..c50d225
--- /dev/null
+++ b/CVS/Repository
@@ -0,0 +1 @@
+CarrotServer
diff --git a/CVS/Root b/CVS/Root
new file mode 100644
index 0000000..c36e9d0
--- /dev/null
+++ b/CVS/Root
@@ -0,0 +1 @@
+:pserver:guest@nitta-lab-www.is.konan-u.ac.jp:\CVSProject
diff --git a/WEB-INF/CVS/Entries b/WEB-INF/CVS/Entries
new file mode 100644
index 0000000..a93a0e0
--- /dev/null
+++ b/WEB-INF/CVS/Entries
@@ -0,0 +1 @@
+/web.xml/1.3/Fri Jan 13 06:53:28 2017//
diff --git a/WEB-INF/CVS/Repository b/WEB-INF/CVS/Repository
new file mode 100644
index 0000000..e4a31db
--- /dev/null
+++ b/WEB-INF/CVS/Repository
@@ -0,0 +1 @@
+CarrotServer/WEB-INF
diff --git a/WEB-INF/CVS/Root b/WEB-INF/CVS/Root
new file mode 100644
index 0000000..c36e9d0
--- /dev/null
+++ b/WEB-INF/CVS/Root
@@ -0,0 +1 @@
+:pserver:guest@nitta-lab-www.is.konan-u.ac.jp:\CVSProject
diff --git a/WEB-INF/web.xml b/WEB-INF/web.xml
new file mode 100644
index 0000000..aa26329
--- /dev/null
+++ b/WEB-INF/web.xml
@@ -0,0 +1,52 @@
+
+
+
+
+ RegistServlet
+ servlet.RegistServlet
+
+
+ RegistServlet
+ /RegistrationServlet
+
+
+
+ LoginServlet
+ servlet.LoginServlet
+
+
+ LoginServlet
+ /LoginServlet
+
+
+
+ RoomCreateServlet
+ servlet.RoomCreateServlet
+
+
+ RoomCreateServlet
+ /RoomCreateServlet
+
+
+
+ RoomListServlet
+ servlet.RoomListServlet
+
+
+ RoomListServlet
+ /RoomListServlet
+
+
+
+ TestServlet
+ servlet.TestServlet
+
+
+ TestServlet
+ /TestServlet
+
+
+
diff --git a/bin/CVS/Entries b/bin/CVS/Entries
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/bin/CVS/Entries
diff --git a/bin/CVS/Repository b/bin/CVS/Repository
new file mode 100644
index 0000000..6a60529
--- /dev/null
+++ b/bin/CVS/Repository
@@ -0,0 +1 @@
+CarrotServer/bin
diff --git a/bin/CVS/Root b/bin/CVS/Root
new file mode 100644
index 0000000..c36e9d0
--- /dev/null
+++ b/bin/CVS/Root
@@ -0,0 +1 @@
+:pserver:guest@nitta-lab-www.is.konan-u.ac.jp:\CVSProject
diff --git a/bin/account/Account.class b/bin/account/Account.class
new file mode 100644
index 0000000..f263f1e
--- /dev/null
+++ b/bin/account/Account.class
Binary files differ
diff --git a/bin/account/AccountManager.class b/bin/account/AccountManager.class
new file mode 100644
index 0000000..f054d4c
--- /dev/null
+++ b/bin/account/AccountManager.class
Binary files differ
diff --git a/bin/framework/animation/Animation3D.class b/bin/framework/animation/Animation3D.class
new file mode 100644
index 0000000..f357c88
--- /dev/null
+++ b/bin/framework/animation/Animation3D.class
Binary files differ
diff --git a/bin/framework/animation/DefaultPose3D.class b/bin/framework/animation/DefaultPose3D.class
new file mode 100644
index 0000000..bb88736
--- /dev/null
+++ b/bin/framework/animation/DefaultPose3D.class
Binary files differ
diff --git a/bin/framework/animation/KeyFrame.class b/bin/framework/animation/KeyFrame.class
new file mode 100644
index 0000000..6c3ea00
--- /dev/null
+++ b/bin/framework/animation/KeyFrame.class
Binary files differ
diff --git a/bin/framework/animation/PartAnimation.class b/bin/framework/animation/PartAnimation.class
new file mode 100644
index 0000000..380d8b8
--- /dev/null
+++ b/bin/framework/animation/PartAnimation.class
Binary files differ
diff --git a/bin/framework/animation/PartPose.class b/bin/framework/animation/PartPose.class
new file mode 100644
index 0000000..7bd6828
--- /dev/null
+++ b/bin/framework/animation/PartPose.class
Binary files differ
diff --git a/bin/framework/animation/Pose3D$1.class b/bin/framework/animation/Pose3D$1.class
new file mode 100644
index 0000000..1f4c625
--- /dev/null
+++ b/bin/framework/animation/Pose3D$1.class
Binary files differ
diff --git a/bin/framework/animation/Pose3D.class b/bin/framework/animation/Pose3D.class
new file mode 100644
index 0000000..589b1ef
--- /dev/null
+++ b/bin/framework/animation/Pose3D.class
Binary files differ
diff --git a/bin/framework/gameMain/Actor.class b/bin/framework/gameMain/Actor.class
new file mode 100644
index 0000000..3fba4f9
--- /dev/null
+++ b/bin/framework/gameMain/Actor.class
Binary files differ
diff --git a/bin/framework/gameMain/ActorModel.class b/bin/framework/gameMain/ActorModel.class
new file mode 100644
index 0000000..613a997
--- /dev/null
+++ b/bin/framework/gameMain/ActorModel.class
Binary files differ
diff --git a/bin/framework/gameMain/Animatable.class b/bin/framework/gameMain/Animatable.class
new file mode 100644
index 0000000..73e43ec
--- /dev/null
+++ b/bin/framework/gameMain/Animatable.class
Binary files differ
diff --git a/bin/framework/gameMain/GameModel.class b/bin/framework/gameMain/GameModel.class
new file mode 100644
index 0000000..d54e417
--- /dev/null
+++ b/bin/framework/gameMain/GameModel.class
Binary files differ
diff --git a/bin/framework/gameMain/Mode.class b/bin/framework/gameMain/Mode.class
new file mode 100644
index 0000000..5c4f263
--- /dev/null
+++ b/bin/framework/gameMain/Mode.class
Binary files differ
diff --git a/bin/framework/gameMain/ModeFreeFall.class b/bin/framework/gameMain/ModeFreeFall.class
new file mode 100644
index 0000000..ae0bf36
--- /dev/null
+++ b/bin/framework/gameMain/ModeFreeFall.class
Binary files differ
diff --git a/bin/framework/gameMain/ModeOnGround.class b/bin/framework/gameMain/ModeOnGround.class
new file mode 100644
index 0000000..2b6d5a8
--- /dev/null
+++ b/bin/framework/gameMain/ModeOnGround.class
Binary files differ
diff --git a/bin/framework/gameMain/Movable.class b/bin/framework/gameMain/Movable.class
new file mode 100644
index 0000000..8ed6f33
--- /dev/null
+++ b/bin/framework/gameMain/Movable.class
Binary files differ
diff --git a/bin/framework/gameMain/OvergroundActor.class b/bin/framework/gameMain/OvergroundActor.class
new file mode 100644
index 0000000..3787e4c
--- /dev/null
+++ b/bin/framework/gameMain/OvergroundActor.class
Binary files differ
diff --git a/bin/framework/model3D/BackgroundBox.class b/bin/framework/model3D/BackgroundBox.class
new file mode 100644
index 0000000..4ab65f3
--- /dev/null
+++ b/bin/framework/model3D/BackgroundBox.class
Binary files differ
diff --git a/bin/framework/model3D/BaseObject3D.class b/bin/framework/model3D/BaseObject3D.class
new file mode 100644
index 0000000..0f75941
--- /dev/null
+++ b/bin/framework/model3D/BaseObject3D.class
Binary files differ
diff --git a/bin/framework/model3D/BoundingSurface.class b/bin/framework/model3D/BoundingSurface.class
new file mode 100644
index 0000000..fc8f7be
--- /dev/null
+++ b/bin/framework/model3D/BoundingSurface.class
Binary files differ
diff --git a/bin/framework/model3D/CollisionResult.class b/bin/framework/model3D/CollisionResult.class
new file mode 100644
index 0000000..fe0dffe
--- /dev/null
+++ b/bin/framework/model3D/CollisionResult.class
Binary files differ
diff --git a/bin/framework/model3D/GeometryUtility.class b/bin/framework/model3D/GeometryUtility.class
new file mode 100644
index 0000000..e160c4f
--- /dev/null
+++ b/bin/framework/model3D/GeometryUtility.class
Binary files differ
diff --git a/bin/framework/model3D/Model3D.class b/bin/framework/model3D/Model3D.class
new file mode 100644
index 0000000..d2b882f
--- /dev/null
+++ b/bin/framework/model3D/Model3D.class
Binary files differ
diff --git a/bin/framework/model3D/OBB.class b/bin/framework/model3D/OBB.class
new file mode 100644
index 0000000..7646a7f
--- /dev/null
+++ b/bin/framework/model3D/OBB.class
Binary files differ
diff --git a/bin/framework/model3D/Object3D$AxisResult.class b/bin/framework/model3D/Object3D$AxisResult.class
new file mode 100644
index 0000000..03b65a6
--- /dev/null
+++ b/bin/framework/model3D/Object3D$AxisResult.class
Binary files differ
diff --git a/bin/framework/model3D/Object3D.class b/bin/framework/model3D/Object3D.class
new file mode 100644
index 0000000..2eb8053
--- /dev/null
+++ b/bin/framework/model3D/Object3D.class
Binary files differ
diff --git a/bin/framework/model3D/ObjectVisitor.class b/bin/framework/model3D/ObjectVisitor.class
new file mode 100644
index 0000000..0afce47
--- /dev/null
+++ b/bin/framework/model3D/ObjectVisitor.class
Binary files differ
diff --git a/bin/framework/model3D/Placeable.class b/bin/framework/model3D/Placeable.class
new file mode 100644
index 0000000..ca8554a
--- /dev/null
+++ b/bin/framework/model3D/Placeable.class
Binary files differ
diff --git a/bin/framework/model3D/Position3D.class b/bin/framework/model3D/Position3D.class
new file mode 100644
index 0000000..189ab04
--- /dev/null
+++ b/bin/framework/model3D/Position3D.class
Binary files differ
diff --git a/bin/framework/model3D/ProjectionResult.class b/bin/framework/model3D/ProjectionResult.class
new file mode 100644
index 0000000..443348f
--- /dev/null
+++ b/bin/framework/model3D/ProjectionResult.class
Binary files differ
diff --git a/bin/framework/model3D/Property3D.class b/bin/framework/model3D/Property3D.class
new file mode 100644
index 0000000..ecb4d80
--- /dev/null
+++ b/bin/framework/model3D/Property3D.class
Binary files differ
diff --git a/bin/framework/model3D/Quaternion3D.class b/bin/framework/model3D/Quaternion3D.class
new file mode 100644
index 0000000..b8c0c43
--- /dev/null
+++ b/bin/framework/model3D/Quaternion3D.class
Binary files differ
diff --git a/bin/framework/model3D/Terrain3D.class b/bin/framework/model3D/Terrain3D.class
new file mode 100644
index 0000000..77d99ea
--- /dev/null
+++ b/bin/framework/model3D/Terrain3D.class
Binary files differ
diff --git a/bin/framework/model3D/UndoBuffer.class b/bin/framework/model3D/UndoBuffer.class
new file mode 100644
index 0000000..ed161fc
--- /dev/null
+++ b/bin/framework/model3D/UndoBuffer.class
Binary files differ
diff --git a/bin/framework/model3D/Universe.class b/bin/framework/model3D/Universe.class
new file mode 100644
index 0000000..5625e4c
--- /dev/null
+++ b/bin/framework/model3D/Universe.class
Binary files differ
diff --git a/bin/framework/physics/AngularVelocity3D.class b/bin/framework/physics/AngularVelocity3D.class
new file mode 100644
index 0000000..7160adc
--- /dev/null
+++ b/bin/framework/physics/AngularVelocity3D.class
Binary files differ
diff --git a/bin/framework/physics/BoundingBoxVisitor.class b/bin/framework/physics/BoundingBoxVisitor.class
new file mode 100644
index 0000000..073d4b1
--- /dev/null
+++ b/bin/framework/physics/BoundingBoxVisitor.class
Binary files differ
diff --git a/bin/framework/physics/BoundingSurfaceVisitor.class b/bin/framework/physics/BoundingSurfaceVisitor.class
new file mode 100644
index 0000000..27813ef
--- /dev/null
+++ b/bin/framework/physics/BoundingSurfaceVisitor.class
Binary files differ
diff --git a/bin/framework/physics/Force3D.class b/bin/framework/physics/Force3D.class
new file mode 100644
index 0000000..2e403c3
--- /dev/null
+++ b/bin/framework/physics/Force3D.class
Binary files differ
diff --git a/bin/framework/physics/Ground.class b/bin/framework/physics/Ground.class
new file mode 100644
index 0000000..82978d4
--- /dev/null
+++ b/bin/framework/physics/Ground.class
Binary files differ
diff --git a/bin/framework/physics/Inertia3D.class b/bin/framework/physics/Inertia3D.class
new file mode 100644
index 0000000..159e051
--- /dev/null
+++ b/bin/framework/physics/Inertia3D.class
Binary files differ
diff --git a/bin/framework/physics/PhysicalSystem.class b/bin/framework/physics/PhysicalSystem.class
new file mode 100644
index 0000000..1ee0b71
--- /dev/null
+++ b/bin/framework/physics/PhysicalSystem.class
Binary files differ
diff --git a/bin/framework/physics/PhysicsUtility.class b/bin/framework/physics/PhysicsUtility.class
new file mode 100644
index 0000000..4e2a8df
--- /dev/null
+++ b/bin/framework/physics/PhysicsUtility.class
Binary files differ
diff --git a/bin/framework/physics/ProjectionResult.class b/bin/framework/physics/ProjectionResult.class
new file mode 100644
index 0000000..9bb6ff8
--- /dev/null
+++ b/bin/framework/physics/ProjectionResult.class
Binary files differ
diff --git a/bin/framework/physics/Solid3D.class b/bin/framework/physics/Solid3D.class
new file mode 100644
index 0000000..6732cbf
--- /dev/null
+++ b/bin/framework/physics/Solid3D.class
Binary files differ
diff --git a/bin/framework/physics/Velocity3D.class b/bin/framework/physics/Velocity3D.class
new file mode 100644
index 0000000..919cd03
--- /dev/null
+++ b/bin/framework/physics/Velocity3D.class
Binary files differ
diff --git a/bin/game/Bomb.class b/bin/game/Bomb.class
new file mode 100644
index 0000000..7fe886c
--- /dev/null
+++ b/bin/game/Bomb.class
Binary files differ
diff --git a/bin/game/Entity.class b/bin/game/Entity.class
new file mode 100644
index 0000000..805a7e2
--- /dev/null
+++ b/bin/game/Entity.class
Binary files differ
diff --git a/bin/game/Game.class b/bin/game/Game.class
new file mode 100644
index 0000000..bdc3e4b
--- /dev/null
+++ b/bin/game/Game.class
Binary files differ
diff --git a/bin/game/GameManager.class b/bin/game/GameManager.class
new file mode 100644
index 0000000..61c4d0d
--- /dev/null
+++ b/bin/game/GameManager.class
Binary files differ
diff --git a/bin/game/IGameElement.class b/bin/game/IGameElement.class
new file mode 100644
index 0000000..8148407
--- /dev/null
+++ b/bin/game/IGameElement.class
Binary files differ
diff --git a/bin/game/IGameElementVisitor.class b/bin/game/IGameElementVisitor.class
new file mode 100644
index 0000000..d1c8d4c
--- /dev/null
+++ b/bin/game/IGameElementVisitor.class
Binary files differ
diff --git a/bin/game/Item.class b/bin/game/Item.class
new file mode 100644
index 0000000..3ed909b
--- /dev/null
+++ b/bin/game/Item.class
Binary files differ
diff --git a/bin/game/Laser$1.class b/bin/game/Laser$1.class
new file mode 100644
index 0000000..e29a132
--- /dev/null
+++ b/bin/game/Laser$1.class
Binary files differ
diff --git a/bin/game/Laser.class b/bin/game/Laser.class
new file mode 100644
index 0000000..ce804ca
--- /dev/null
+++ b/bin/game/Laser.class
Binary files differ
diff --git a/bin/game/LaserTurret.class b/bin/game/LaserTurret.class
new file mode 100644
index 0000000..36aa03f
--- /dev/null
+++ b/bin/game/LaserTurret.class
Binary files differ
diff --git a/bin/game/Mirror.class b/bin/game/Mirror.class
new file mode 100644
index 0000000..762edf1
--- /dev/null
+++ b/bin/game/Mirror.class
Binary files differ
diff --git a/bin/game/Player.class b/bin/game/Player.class
new file mode 100644
index 0000000..e585efb
--- /dev/null
+++ b/bin/game/Player.class
Binary files differ
diff --git a/bin/game/PlayerSearchVisitor.class b/bin/game/PlayerSearchVisitor.class
new file mode 100644
index 0000000..c0fcc87
--- /dev/null
+++ b/bin/game/PlayerSearchVisitor.class
Binary files differ
diff --git a/bin/game/Stage.class b/bin/game/Stage.class
new file mode 100644
index 0000000..e1fe31e
--- /dev/null
+++ b/bin/game/Stage.class
Binary files differ
diff --git a/bin/game/StageStandard.class b/bin/game/StageStandard.class
new file mode 100644
index 0000000..efd8ce0
--- /dev/null
+++ b/bin/game/StageStandard.class
Binary files differ
diff --git a/bin/game/Team.class b/bin/game/Team.class
new file mode 100644
index 0000000..9c5d58b
--- /dev/null
+++ b/bin/game/Team.class
Binary files differ
diff --git a/bin/game/TestPlayerSearchVisitorjava.class b/bin/game/TestPlayerSearchVisitorjava.class
new file mode 100644
index 0000000..c1f1835
--- /dev/null
+++ b/bin/game/TestPlayerSearchVisitorjava.class
Binary files differ
diff --git a/bin/game/TestPlayerSearchVisitorjava2.class b/bin/game/TestPlayerSearchVisitorjava2.class
new file mode 100644
index 0000000..7eeb0f1
--- /dev/null
+++ b/bin/game/TestPlayerSearchVisitorjava2.class
Binary files differ
diff --git a/bin/java3d/Appearance.class b/bin/java3d/Appearance.class
new file mode 100644
index 0000000..242004f
--- /dev/null
+++ b/bin/java3d/Appearance.class
Binary files differ
diff --git a/bin/java3d/AxisAngle4d.class b/bin/java3d/AxisAngle4d.class
new file mode 100644
index 0000000..7d6136e
--- /dev/null
+++ b/bin/java3d/AxisAngle4d.class
Binary files differ
diff --git a/bin/java3d/Background.class b/bin/java3d/Background.class
new file mode 100644
index 0000000..0fce6de
--- /dev/null
+++ b/bin/java3d/Background.class
Binary files differ
diff --git a/bin/java3d/BoundingBox.class b/bin/java3d/BoundingBox.class
new file mode 100644
index 0000000..cb114cd
--- /dev/null
+++ b/bin/java3d/BoundingBox.class
Binary files differ
diff --git a/bin/java3d/BoundingPolytope.class b/bin/java3d/BoundingPolytope.class
new file mode 100644
index 0000000..e6df825
--- /dev/null
+++ b/bin/java3d/BoundingPolytope.class
Binary files differ
diff --git a/bin/java3d/BoundingSphere.class b/bin/java3d/BoundingSphere.class
new file mode 100644
index 0000000..54a0c04
--- /dev/null
+++ b/bin/java3d/BoundingSphere.class
Binary files differ
diff --git a/bin/java3d/Bounds.class b/bin/java3d/Bounds.class
new file mode 100644
index 0000000..07a6221
--- /dev/null
+++ b/bin/java3d/Bounds.class
Binary files differ
diff --git a/bin/java3d/Box.class b/bin/java3d/Box.class
new file mode 100644
index 0000000..fde6388
--- /dev/null
+++ b/bin/java3d/Box.class
Binary files differ
diff --git a/bin/java3d/BranchGroup.class b/bin/java3d/BranchGroup.class
new file mode 100644
index 0000000..4eb6146
--- /dev/null
+++ b/bin/java3d/BranchGroup.class
Binary files differ
diff --git a/bin/java3d/Color3f.class b/bin/java3d/Color3f.class
new file mode 100644
index 0000000..1770ed3
--- /dev/null
+++ b/bin/java3d/Color3f.class
Binary files differ
diff --git a/bin/java3d/Color4f.class b/bin/java3d/Color4f.class
new file mode 100644
index 0000000..d6a30bf
--- /dev/null
+++ b/bin/java3d/Color4f.class
Binary files differ
diff --git a/bin/java3d/Cone.class b/bin/java3d/Cone.class
new file mode 100644
index 0000000..060e254
--- /dev/null
+++ b/bin/java3d/Cone.class
Binary files differ
diff --git a/bin/java3d/Cylinder.class b/bin/java3d/Cylinder.class
new file mode 100644
index 0000000..d73a47b
--- /dev/null
+++ b/bin/java3d/Cylinder.class
Binary files differ
diff --git a/bin/java3d/DirectionalLight.class b/bin/java3d/DirectionalLight.class
new file mode 100644
index 0000000..8592149
--- /dev/null
+++ b/bin/java3d/DirectionalLight.class
Binary files differ
diff --git a/bin/java3d/Geometry.class b/bin/java3d/Geometry.class
new file mode 100644
index 0000000..443cd9b
--- /dev/null
+++ b/bin/java3d/Geometry.class
Binary files differ
diff --git a/bin/java3d/GeometryArray.class b/bin/java3d/GeometryArray.class
new file mode 100644
index 0000000..5f994e7
--- /dev/null
+++ b/bin/java3d/GeometryArray.class
Binary files differ
diff --git a/bin/java3d/GeometryStripArray.class b/bin/java3d/GeometryStripArray.class
new file mode 100644
index 0000000..1d8163a
--- /dev/null
+++ b/bin/java3d/GeometryStripArray.class
Binary files differ
diff --git a/bin/java3d/Group.class b/bin/java3d/Group.class
new file mode 100644
index 0000000..e45cecf
--- /dev/null
+++ b/bin/java3d/Group.class
Binary files differ
diff --git a/bin/java3d/ImageComponent.class b/bin/java3d/ImageComponent.class
new file mode 100644
index 0000000..850ee42
--- /dev/null
+++ b/bin/java3d/ImageComponent.class
Binary files differ
diff --git a/bin/java3d/IndexedGeometryArray.class b/bin/java3d/IndexedGeometryArray.class
new file mode 100644
index 0000000..9fb2f0c
--- /dev/null
+++ b/bin/java3d/IndexedGeometryArray.class
Binary files differ
diff --git a/bin/java3d/IndexedGeometryStripArray.class b/bin/java3d/IndexedGeometryStripArray.class
new file mode 100644
index 0000000..edaa6d0
--- /dev/null
+++ b/bin/java3d/IndexedGeometryStripArray.class
Binary files differ
diff --git a/bin/java3d/IndexedTriangleArray.class b/bin/java3d/IndexedTriangleArray.class
new file mode 100644
index 0000000..3e5c2bc
--- /dev/null
+++ b/bin/java3d/IndexedTriangleArray.class
Binary files differ
diff --git a/bin/java3d/IndexedTriangleFanArray.class b/bin/java3d/IndexedTriangleFanArray.class
new file mode 100644
index 0000000..18aa433
--- /dev/null
+++ b/bin/java3d/IndexedTriangleFanArray.class
Binary files differ
diff --git a/bin/java3d/IndexedTriangleStripArray.class b/bin/java3d/IndexedTriangleStripArray.class
new file mode 100644
index 0000000..9f25961
--- /dev/null
+++ b/bin/java3d/IndexedTriangleStripArray.class
Binary files differ
diff --git a/bin/java3d/Leaf.class b/bin/java3d/Leaf.class
new file mode 100644
index 0000000..24bc8ef
--- /dev/null
+++ b/bin/java3d/Leaf.class
Binary files differ
diff --git a/bin/java3d/Light.class b/bin/java3d/Light.class
new file mode 100644
index 0000000..43ce633
--- /dev/null
+++ b/bin/java3d/Light.class
Binary files differ
diff --git a/bin/java3d/Material.class b/bin/java3d/Material.class
new file mode 100644
index 0000000..124e526
--- /dev/null
+++ b/bin/java3d/Material.class
Binary files differ
diff --git a/bin/java3d/Matrix3d.class b/bin/java3d/Matrix3d.class
new file mode 100644
index 0000000..0845709
--- /dev/null
+++ b/bin/java3d/Matrix3d.class
Binary files differ
diff --git a/bin/java3d/Matrix4d.class b/bin/java3d/Matrix4d.class
new file mode 100644
index 0000000..4dc2b41
--- /dev/null
+++ b/bin/java3d/Matrix4d.class
Binary files differ
diff --git a/bin/java3d/Node.class b/bin/java3d/Node.class
new file mode 100644
index 0000000..1615ae6
--- /dev/null
+++ b/bin/java3d/Node.class
Binary files differ
diff --git a/bin/java3d/NodeComponent.class b/bin/java3d/NodeComponent.class
new file mode 100644
index 0000000..85c73be
--- /dev/null
+++ b/bin/java3d/NodeComponent.class
Binary files differ
diff --git a/bin/java3d/Point3d.class b/bin/java3d/Point3d.class
new file mode 100644
index 0000000..af383f1
--- /dev/null
+++ b/bin/java3d/Point3d.class
Binary files differ
diff --git a/bin/java3d/Primitive.class b/bin/java3d/Primitive.class
new file mode 100644
index 0000000..d98180f
--- /dev/null
+++ b/bin/java3d/Primitive.class
Binary files differ
diff --git a/bin/java3d/Quat4d.class b/bin/java3d/Quat4d.class
new file mode 100644
index 0000000..8a1b8c4
--- /dev/null
+++ b/bin/java3d/Quat4d.class
Binary files differ
diff --git a/bin/java3d/Shape3D.class b/bin/java3d/Shape3D.class
new file mode 100644
index 0000000..2bc6085
--- /dev/null
+++ b/bin/java3d/Shape3D.class
Binary files differ
diff --git a/bin/java3d/Sphere.class b/bin/java3d/Sphere.class
new file mode 100644
index 0000000..989112b
--- /dev/null
+++ b/bin/java3d/Sphere.class
Binary files differ
diff --git a/bin/java3d/TexCoordGeneration.class b/bin/java3d/TexCoordGeneration.class
new file mode 100644
index 0000000..ab6d42f
--- /dev/null
+++ b/bin/java3d/TexCoordGeneration.class
Binary files differ
diff --git a/bin/java3d/Texture.class b/bin/java3d/Texture.class
new file mode 100644
index 0000000..c28b0a5
--- /dev/null
+++ b/bin/java3d/Texture.class
Binary files differ
diff --git a/bin/java3d/Texture2D.class b/bin/java3d/Texture2D.class
new file mode 100644
index 0000000..aff311d
--- /dev/null
+++ b/bin/java3d/Texture2D.class
Binary files differ
diff --git a/bin/java3d/TextureAttributes.class b/bin/java3d/TextureAttributes.class
new file mode 100644
index 0000000..02094b5
--- /dev/null
+++ b/bin/java3d/TextureAttributes.class
Binary files differ
diff --git a/bin/java3d/TextureUnitState.class b/bin/java3d/TextureUnitState.class
new file mode 100644
index 0000000..29c631d
--- /dev/null
+++ b/bin/java3d/TextureUnitState.class
Binary files differ
diff --git a/bin/java3d/Transform3D.class b/bin/java3d/Transform3D.class
new file mode 100644
index 0000000..64da220
--- /dev/null
+++ b/bin/java3d/Transform3D.class
Binary files differ
diff --git a/bin/java3d/TransformGroup.class b/bin/java3d/TransformGroup.class
new file mode 100644
index 0000000..7240715
--- /dev/null
+++ b/bin/java3d/TransformGroup.class
Binary files differ
diff --git a/bin/java3d/TriangleArray.class b/bin/java3d/TriangleArray.class
new file mode 100644
index 0000000..c3591c1
--- /dev/null
+++ b/bin/java3d/TriangleArray.class
Binary files differ
diff --git a/bin/java3d/TriangleFanArray.class b/bin/java3d/TriangleFanArray.class
new file mode 100644
index 0000000..c4d8553
--- /dev/null
+++ b/bin/java3d/TriangleFanArray.class
Binary files differ
diff --git a/bin/java3d/TriangleStripArray.class b/bin/java3d/TriangleStripArray.class
new file mode 100644
index 0000000..968e6f3
--- /dev/null
+++ b/bin/java3d/TriangleStripArray.class
Binary files differ
diff --git a/bin/java3d/Tuple3d.class b/bin/java3d/Tuple3d.class
new file mode 100644
index 0000000..bbb0f4a
--- /dev/null
+++ b/bin/java3d/Tuple3d.class
Binary files differ
diff --git a/bin/java3d/Vector3d.class b/bin/java3d/Vector3d.class
new file mode 100644
index 0000000..d354d7b
--- /dev/null
+++ b/bin/java3d/Vector3d.class
Binary files differ
diff --git a/bin/java3d/Vector3f.class b/bin/java3d/Vector3f.class
new file mode 100644
index 0000000..3fb3a42
--- /dev/null
+++ b/bin/java3d/Vector3f.class
Binary files differ
diff --git a/bin/java3d/Vector4d.class b/bin/java3d/Vector4d.class
new file mode 100644
index 0000000..439c2d6
--- /dev/null
+++ b/bin/java3d/Vector4d.class
Binary files differ
diff --git a/bin/java3d/View.class b/bin/java3d/View.class
new file mode 100644
index 0000000..f3b68ad
--- /dev/null
+++ b/bin/java3d/View.class
Binary files differ
diff --git a/bin/room/Room.class b/bin/room/Room.class
new file mode 100644
index 0000000..c86d1ad
--- /dev/null
+++ b/bin/room/Room.class
Binary files differ
diff --git a/bin/room/RoomManager.class b/bin/room/RoomManager.class
new file mode 100644
index 0000000..3e40315
--- /dev/null
+++ b/bin/room/RoomManager.class
Binary files differ
diff --git a/bin/servlet/GameUpdateServlet.class b/bin/servlet/GameUpdateServlet.class
new file mode 100644
index 0000000..c2db5fe
--- /dev/null
+++ b/bin/servlet/GameUpdateServlet.class
Binary files differ
diff --git a/bin/servlet/LoginServlet.class b/bin/servlet/LoginServlet.class
new file mode 100644
index 0000000..e63a394
--- /dev/null
+++ b/bin/servlet/LoginServlet.class
Binary files differ
diff --git a/bin/servlet/RegistServlet.class b/bin/servlet/RegistServlet.class
new file mode 100644
index 0000000..c095f71
--- /dev/null
+++ b/bin/servlet/RegistServlet.class
Binary files differ
diff --git a/bin/servlet/RoomCreateServlet.class b/bin/servlet/RoomCreateServlet.class
new file mode 100644
index 0000000..923cfaa
--- /dev/null
+++ b/bin/servlet/RoomCreateServlet.class
Binary files differ
diff --git a/bin/servlet/RoomListServlet.class b/bin/servlet/RoomListServlet.class
new file mode 100644
index 0000000..03fbc73
--- /dev/null
+++ b/bin/servlet/RoomListServlet.class
Binary files differ
diff --git a/bin/servlet/RoomServlet.class b/bin/servlet/RoomServlet.class
new file mode 100644
index 0000000..01e5ba9
--- /dev/null
+++ b/bin/servlet/RoomServlet.class
Binary files differ
diff --git a/bin/vecmath/Matrix3d.class b/bin/vecmath/Matrix3d.class
new file mode 100644
index 0000000..21a50a5
--- /dev/null
+++ b/bin/vecmath/Matrix3d.class
Binary files differ
diff --git a/bin/vecmath/SingularMatrixException.class b/bin/vecmath/SingularMatrixException.class
new file mode 100644
index 0000000..cca67ae
--- /dev/null
+++ b/bin/vecmath/SingularMatrixException.class
Binary files differ
diff --git a/bin/vecmath/Tuple3d.class b/bin/vecmath/Tuple3d.class
new file mode 100644
index 0000000..ce2d5ab
--- /dev/null
+++ b/bin/vecmath/Tuple3d.class
Binary files differ
diff --git a/bin/vecmath/Tuple4d.class b/bin/vecmath/Tuple4d.class
new file mode 100644
index 0000000..ac949f4
--- /dev/null
+++ b/bin/vecmath/Tuple4d.class
Binary files differ
diff --git a/bin/vecmath/VecMathI18N.class b/bin/vecmath/VecMathI18N.class
new file mode 100644
index 0000000..45ad45c
--- /dev/null
+++ b/bin/vecmath/VecMathI18N.class
Binary files differ
diff --git a/bin/vecmath/Vector3d.class b/bin/vecmath/Vector3d.class
new file mode 100644
index 0000000..0a17056
--- /dev/null
+++ b/bin/vecmath/Vector3d.class
Binary files differ
diff --git a/bin/vecmath/Vector4d.class b/bin/vecmath/Vector4d.class
new file mode 100644
index 0000000..8ed92b0
--- /dev/null
+++ b/bin/vecmath/Vector4d.class
Binary files differ
diff --git a/build.xml b/build.xml
new file mode 100644
index 0000000..f81dbc4
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/CVS/Entries b/lib/CVS/Entries
new file mode 100644
index 0000000..7c72034
--- /dev/null
+++ b/lib/CVS/Entries
@@ -0,0 +1,26 @@
+/activation.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/ant-launcher.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/ant.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/commons-collections.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/commons-dbcp-1.1.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/commons-logging-api.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/commons-pool-1.1.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/cv97r140.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/j3dcore-d3d.dll/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/j3dcore-ogl-cg.dll/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/j3dcore-ogl-chk.dll/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/j3dcore-ogl.dll/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/j3dcore.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/j3dutils.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/jasper-compiler.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/jasper-runtime.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/jdbc2_0-stdext.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/jndi.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/jta.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/mail.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/naming-common.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/naming-factory.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/naming-resources.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/servlet.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/tools.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
+/vecmath.jar/1.1/Tue Apr 26 05:52:40 2016/-kb/
diff --git a/lib/CVS/Repository b/lib/CVS/Repository
new file mode 100644
index 0000000..849e2a2
--- /dev/null
+++ b/lib/CVS/Repository
@@ -0,0 +1 @@
+CarrotServer/lib
diff --git a/lib/CVS/Root b/lib/CVS/Root
new file mode 100644
index 0000000..c36e9d0
--- /dev/null
+++ b/lib/CVS/Root
@@ -0,0 +1 @@
+:pserver:guest@nitta-lab-www.is.konan-u.ac.jp:\CVSProject
diff --git a/lib/activation.jar b/lib/activation.jar
new file mode 100644
index 0000000..8cbef16
--- /dev/null
+++ b/lib/activation.jar
Binary files differ
diff --git a/lib/ant-launcher.jar b/lib/ant-launcher.jar
new file mode 100644
index 0000000..052fc4e
--- /dev/null
+++ b/lib/ant-launcher.jar
Binary files differ
diff --git a/lib/ant.jar b/lib/ant.jar
new file mode 100644
index 0000000..cf01339
--- /dev/null
+++ b/lib/ant.jar
Binary files differ
diff --git a/lib/commons-collections.jar b/lib/commons-collections.jar
new file mode 100644
index 0000000..f66c6d2
--- /dev/null
+++ b/lib/commons-collections.jar
Binary files differ
diff --git a/lib/commons-dbcp-1.1.jar b/lib/commons-dbcp-1.1.jar
new file mode 100644
index 0000000..c3c4d1f
--- /dev/null
+++ b/lib/commons-dbcp-1.1.jar
Binary files differ
diff --git a/lib/commons-logging-api.jar b/lib/commons-logging-api.jar
new file mode 100644
index 0000000..209bcdf
--- /dev/null
+++ b/lib/commons-logging-api.jar
Binary files differ
diff --git a/lib/commons-pool-1.1.jar b/lib/commons-pool-1.1.jar
new file mode 100644
index 0000000..c61bde6
--- /dev/null
+++ b/lib/commons-pool-1.1.jar
Binary files differ
diff --git a/lib/cv97r140.jar b/lib/cv97r140.jar
new file mode 100644
index 0000000..b742046
--- /dev/null
+++ b/lib/cv97r140.jar
Binary files differ
diff --git a/lib/j3dcore-d3d.dll b/lib/j3dcore-d3d.dll
new file mode 100644
index 0000000..e9a3901
--- /dev/null
+++ b/lib/j3dcore-d3d.dll
Binary files differ
diff --git a/lib/j3dcore-ogl-cg.dll b/lib/j3dcore-ogl-cg.dll
new file mode 100644
index 0000000..2ec07eb
--- /dev/null
+++ b/lib/j3dcore-ogl-cg.dll
Binary files differ
diff --git a/lib/j3dcore-ogl-chk.dll b/lib/j3dcore-ogl-chk.dll
new file mode 100644
index 0000000..37afe01
--- /dev/null
+++ b/lib/j3dcore-ogl-chk.dll
Binary files differ
diff --git a/lib/j3dcore-ogl.dll b/lib/j3dcore-ogl.dll
new file mode 100644
index 0000000..909cc05
--- /dev/null
+++ b/lib/j3dcore-ogl.dll
Binary files differ
diff --git a/lib/j3dcore.jar b/lib/j3dcore.jar
new file mode 100644
index 0000000..aea76e1
--- /dev/null
+++ b/lib/j3dcore.jar
Binary files differ
diff --git a/lib/j3dutils.jar b/lib/j3dutils.jar
new file mode 100644
index 0000000..0e2e9c7
--- /dev/null
+++ b/lib/j3dutils.jar
Binary files differ
diff --git a/lib/jasper-compiler.jar b/lib/jasper-compiler.jar
new file mode 100644
index 0000000..d529594
--- /dev/null
+++ b/lib/jasper-compiler.jar
Binary files differ
diff --git a/lib/jasper-runtime.jar b/lib/jasper-runtime.jar
new file mode 100644
index 0000000..e41a12d
--- /dev/null
+++ b/lib/jasper-runtime.jar
Binary files differ
diff --git a/lib/jdbc2_0-stdext.jar b/lib/jdbc2_0-stdext.jar
new file mode 100644
index 0000000..ddafa13
--- /dev/null
+++ b/lib/jdbc2_0-stdext.jar
Binary files differ
diff --git a/lib/jndi.jar b/lib/jndi.jar
new file mode 100644
index 0000000..52baa1c
--- /dev/null
+++ b/lib/jndi.jar
Binary files differ
diff --git a/lib/jta.jar b/lib/jta.jar
new file mode 100644
index 0000000..3d90c18
--- /dev/null
+++ b/lib/jta.jar
Binary files differ
diff --git a/lib/mail.jar b/lib/mail.jar
new file mode 100644
index 0000000..48088bd
--- /dev/null
+++ b/lib/mail.jar
Binary files differ
diff --git a/lib/naming-common.jar b/lib/naming-common.jar
new file mode 100644
index 0000000..d18292d
--- /dev/null
+++ b/lib/naming-common.jar
Binary files differ
diff --git a/lib/naming-factory.jar b/lib/naming-factory.jar
new file mode 100644
index 0000000..e9ae70e
--- /dev/null
+++ b/lib/naming-factory.jar
Binary files differ
diff --git a/lib/naming-resources.jar b/lib/naming-resources.jar
new file mode 100644
index 0000000..531392b
--- /dev/null
+++ b/lib/naming-resources.jar
Binary files differ
diff --git a/lib/servlet.jar b/lib/servlet.jar
new file mode 100644
index 0000000..7ed4be2
--- /dev/null
+++ b/lib/servlet.jar
Binary files differ
diff --git a/lib/tools.jar b/lib/tools.jar
new file mode 100644
index 0000000..a82946d
--- /dev/null
+++ b/lib/tools.jar
Binary files differ
diff --git a/lib/vecmath.jar b/lib/vecmath.jar
new file mode 100644
index 0000000..6d8b3a1
--- /dev/null
+++ b/lib/vecmath.jar
Binary files differ
diff --git a/src/CVS/Entries b/src/CVS/Entries
new file mode 100644
index 0000000..248e63d
--- /dev/null
+++ b/src/CVS/Entries
@@ -0,0 +1,7 @@
+D/account////
+D/framework////
+D/game////
+D/java3d////
+D/room////
+D/servlet////
+D/vecmath////
diff --git a/src/CVS/Repository b/src/CVS/Repository
new file mode 100644
index 0000000..06e7b42
--- /dev/null
+++ b/src/CVS/Repository
@@ -0,0 +1 @@
+CarrotServer/src
diff --git a/src/CVS/Root b/src/CVS/Root
new file mode 100644
index 0000000..c36e9d0
--- /dev/null
+++ b/src/CVS/Root
@@ -0,0 +1 @@
+:pserver:guest@nitta-lab-www.is.konan-u.ac.jp:\CVSProject
diff --git a/src/account/Account.java b/src/account/Account.java
new file mode 100644
index 0000000..b1af721
--- /dev/null
+++ b/src/account/Account.java
@@ -0,0 +1,100 @@
+package account;
+
+import java.util.ArrayList;
+import java.util.Date;
+
+import game.IGameElement;
+import game.IGameElementVisitor;
+import game.Player;
+import room.Room;
+
+public class Account implements IGameElement {
+ private String name;
+ private String pass;
+ private String sId;
+ private Room room;
+ private String wait = "no";
+ private int team;
+
+ private Date finalConnectTime;
+
+ private Player player;
+
+ //player
+ public Player getPlayer() {
+ return player;
+ }
+ public void setPlayer(Player player) {
+ this.player = player;
+ }
+
+ public void newPlayer() {
+System.out.println("Account newPlayer in");
+ this.player = new Player();
+System.out.println("Account newPlayer out");
+ }
+
+
+ //name
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ //pass
+ public String getPass() {
+ return pass;
+ }
+ public void setPass(String pass) {
+ this.pass = pass;
+ }
+
+ //sId
+ public String getsId() {
+ return sId;
+ }
+ public void setsId(String sId) {
+ this.sId = sId;
+ }
+
+ //room
+ public Room getRoom() {
+ return room;
+ }
+ public void setRoom(Room room) {
+ this.room = room;
+ }
+
+ //Wait
+ public String getWait() {
+ return wait;
+ }
+ public void setWait(String wait) {
+ this.wait = wait;
+ }
+
+ //team
+ public int getTeam() {
+ return team;
+ }
+ public void setTeam(int team) {
+ this.team = team;
+ }
+
+ //finalConnectTime
+ public Date getFinalConnectTime() {
+ return finalConnectTime;
+ }
+ public void setFinalConnectTime() {
+ finalConnectTime = new Date();
+ }
+
+ //visitor�ɂ�鏈���������
+ public boolean accept(IGameElementVisitor v) {
+ if(!v.visit(this)) return false;
+ return true;
+ }
+}
+
diff --git a/src/account/AccountManager.java b/src/account/AccountManager.java
new file mode 100644
index 0000000..1251841
--- /dev/null
+++ b/src/account/AccountManager.java
@@ -0,0 +1,107 @@
+package account;
+
+import java.util.ArrayList;
+
+public class AccountManager {
+
+ private ArrayList accountList = new ArrayList();
+ private static AccountManager theInstance;
+
+ private AccountManager() {
+ }
+
+ public static AccountManager getInstance() {
+ if(theInstance == null) {
+ theInstance = new AccountManager();
+ }
+ return theInstance;
+ }
+
+ //�A�J�E���g�o�^
+ public boolean registration(String name, String pass, String sId) {
+ Account account;
+
+ for (int i=0; i partList = new ArrayList();
+ private long maxKey = getMaxKey();
+
+ public Animation3D() {
+ time = 0;
+ }
+
+ public Animation3D(Animation3D a) {
+ time = 0;
+ partList = a.partList;
+ maxKey = a.maxKey;
+ }
+
+ public boolean equals(Animation3D a) {
+ return (partList == a.partList && maxKey == a.maxKey);
+ }
+
+ public void reset() {
+ time = 0;
+ }
+
+ public boolean progress(long interval) {
+ if (maxKey == 0)
+ return true; // ��̃A�j���[�V�����̏ꍇ�������Ȃ�
+ time += interval;
+ // System.out.println(time + "/" + maxKey);
+ if (time > maxKey) {
+ time = time % maxKey; // time���Ō�̗v�f��key�̒l�i�A�j���[�V�����̍Ō��key)���Ă���ꍇ�At���Ō��key�̒l�imaxKey)�Ŋ������]��Ƃ��Đݒ肷��
+ return false;
+ } else
+ return true;
+ }
+
+ public Pose3D getPose() {
+ if (maxKey == 0 || partList.size() == 0)
+ return new DefaultPose3D();
+
+ KeyFrame[] aroundKey = new KeyFrame[2];
+ Quaternion3D q;
+ Position3D p;
+ Quaternion3D tq;
+ Position3D tp;
+ Pose3D pose = new Pose3D();
+ for (int i = 0; i < partList.size(); i++) {
+ aroundKey = partList.get(i).getKey(time);
+
+ // �R�s�[�R���X�g���N�^�̍쐬
+ q = null;
+ p = null;
+ tq = null;
+ tp = null;
+ if (aroundKey[0].getPosition() != null) {
+ p = new Position3D(aroundKey[0].getPosition()); // getPosition()���Q�Ƃ�Ԃ��̂ŃR�s�[���Ă���ύX
+ }
+ if (aroundKey[0].getQuaternion() != null) {
+ q = new Quaternion3D(aroundKey[0].getQuaternion()); // getQuaternion()���A�h���X�i�Q�Ɓj��Ԃ��̂ŁA�R�s�[�i�����j���쐬���Ă������ύX���Ă���B
+ }
+ if (aroundKey[0].getTexturePosition() != null) {
+ tp = new Position3D(aroundKey[0].getTexturePosition()); // getPosition()���Q�Ƃ�Ԃ��̂ŃR�s�[���Ă���ύX
+ }
+ if (aroundKey[0].getTextureQuaternion() != null) {
+ tq = new Quaternion3D(aroundKey[0].getTextureQuaternion()); // getQuaternion()���A�h���X�i�Q�Ɓj��Ԃ��̂ŁA�R�s�[�i�����j���쐬���Ă������ύX���Ă���B
+ }
+
+ // time��key���̂��̂������ꍇ�i��Ԃ̌v�Z���s�v�ȏꍇ�j
+ if (aroundKey[1] != null) {
+ // t1 ��t�̑O��key�iaroundKey[0]�j�̃X�J���[�{
+ double t1 = aroundKey[1].key - time;
+ // t2 ��t�̌��key�iaroundKey[1]�j�̃X�J���[�{
+ double t2 = time - aroundKey[0].key;
+ double t3 = aroundKey[1].key - aroundKey[0].key;
+ double timealpha = t2 / t3;
+
+ // time�ɑ���Quaternion��Position�̌v�Z
+ if (p != null) {
+ Position3D p2 = new Position3D(aroundKey[1].getPosition());
+ p.mul(t1 / t3).add(p2.mul(t2 / t3));
+ }
+ if (q != null) {
+ Quaternion3D q2 = new Quaternion3D(aroundKey[1].getQuaternion());
+ q.getInterpolate(q2, timealpha);
+ }
+ if (tp != null) {
+ Position3D tp2 = new Position3D(aroundKey[1].getTexturePosition());
+ tp.mul(t1 / t3).add(tp2.mul(t2 / t3));
+ }
+ if (tq != null) {
+ Quaternion3D tq2 = new Quaternion3D(aroundKey[1].getTextureQuaternion());
+ tq.getInterpolate(tq2, timealpha);
+ }
+ }
+ pose.addPose(partList.get(i).getName(), p, q, aroundKey[0].getTexture(), tp, tq, partList.get(i).getTextureUnit());
+ }
+
+ return pose;
+ }
+
+ public Animation3D merge(Animation3D a) {
+ this.partList.addAll(a.partList);
+ maxKey = getMaxKey();
+ return this;
+ }
+
+ public void addPartAnimation(PartAnimation pa) {
+ partList.add(pa);
+ maxKey = getMaxKey();
+ }
+
+ // �A�j���[�V�������I���������肷�邽�߂�key�̍ő�l��T�����ĕԂ����\�b�h
+ private long getMaxKey() {
+ long maxKey = 0;
+ int i;
+
+ for (i = 0; i < partList.size(); i++) {
+ if (maxKey < partList.get(i).getLastKey()) {
+ maxKey = partList.get(i).getLastKey();
+ } else
+ continue;
+ }
+ return maxKey;
+ }
+}
diff --git a/src/framework/animation/CVS/Entries b/src/framework/animation/CVS/Entries
new file mode 100644
index 0000000..81d92c0
--- /dev/null
+++ b/src/framework/animation/CVS/Entries
@@ -0,0 +1,6 @@
+/Animation3D.java/1.1/Thu Jul 7 08:22:45 2016//
+/DefaultPose3D.java/1.1/Thu Jul 7 08:22:45 2016//
+/KeyFrame.java/1.1/Thu Jul 7 08:22:45 2016//
+/PartAnimation.java/1.1/Thu Jul 7 08:22:45 2016//
+/PartPose.java/1.1/Thu Jul 7 08:22:45 2016//
+/Pose3D.java/1.1/Thu Jul 7 08:22:45 2016//
diff --git a/src/framework/animation/CVS/Repository b/src/framework/animation/CVS/Repository
new file mode 100644
index 0000000..152379e
--- /dev/null
+++ b/src/framework/animation/CVS/Repository
@@ -0,0 +1 @@
+CarrotServer/src/framework/animation
diff --git a/src/framework/animation/CVS/Root b/src/framework/animation/CVS/Root
new file mode 100644
index 0000000..c36e9d0
--- /dev/null
+++ b/src/framework/animation/CVS/Root
@@ -0,0 +1 @@
+:pserver:guest@nitta-lab-www.is.konan-u.ac.jp:\CVSProject
diff --git a/src/framework/animation/DefaultPose3D.java b/src/framework/animation/DefaultPose3D.java
new file mode 100644
index 0000000..0338d86
--- /dev/null
+++ b/src/framework/animation/DefaultPose3D.java
@@ -0,0 +1,27 @@
+package framework.animation;
+import java3d.Transform3D;
+
+import framework.model3D.Object3D;
+
+/**
+ * ������Ԃ̎p��
+ * @author �V�c����
+ *
+ */
+public class DefaultPose3D extends Pose3D {
+ public void applyTo(Object3D obj) {
+ obj.scale.setTransform(new Transform3D());
+ for (int n = 0; n < obj.children.length; n++) {
+ subApplyTo((Object3D)obj.children[n]);
+ }
+ }
+
+ private void subApplyTo(Object3D obj) {
+ obj.pos.setTransform(new Transform3D());
+ obj.rot.setTransform(new Transform3D());
+ obj.scale.setTransform(new Transform3D());
+ for (int n = 0; n < obj.children.length; n++) {
+ subApplyTo((Object3D)obj.children[n]);
+ }
+ }
+}
diff --git a/src/framework/animation/KeyFrame.java b/src/framework/animation/KeyFrame.java
new file mode 100644
index 0000000..22d6317
--- /dev/null
+++ b/src/framework/animation/KeyFrame.java
@@ -0,0 +1,42 @@
+package framework.animation;
+
+import java3d.Texture;
+
+import framework.model3D.Position3D;
+import framework.model3D.Quaternion3D;
+
+
+/**
+ * �A�j���[�V�������ŃL�[�t���[���P�ʂɒ�`�������i�L�[�l�j
+ * @author �V�c����
+ *
+ */
+public class KeyFrame {
+ long key = 0;
+ Position3D keyValuePosition = null;
+ Quaternion3D keyValueQuaternion = null;
+ Texture keyValueTexture = null;
+ Position3D keyValueTexturePosition = null;
+ Quaternion3D keyValueTextureQuaternion = null;
+
+ Position3D getPosition() {
+ return keyValuePosition;
+ }
+
+ Quaternion3D getQuaternion() {
+ return keyValueQuaternion;
+ }
+
+ Texture getTexture() {
+ return keyValueTexture;
+ }
+
+ Position3D getTexturePosition() {
+ return keyValueTexturePosition;
+ }
+
+ Quaternion3D getTextureQuaternion() {
+ return keyValueTextureQuaternion;
+ }
+}
+
diff --git a/src/framework/animation/PartAnimation.java b/src/framework/animation/PartAnimation.java
new file mode 100644
index 0000000..21c8067
--- /dev/null
+++ b/src/framework/animation/PartAnimation.java
@@ -0,0 +1,177 @@
+package framework.animation;
+
+import java.util.ArrayList;
+
+
+import framework.model3D.Position3D;
+import framework.model3D.Quaternion3D;
+
+
+/**
+ * ���i�P�ʂ̃A�j���[�V��������ێ�����
+ * @author �V�c����
+ *
+ */
+public class PartAnimation {
+ private String name;
+ private int textureUnit;
+ private ArrayList keyList = new ArrayList();
+ public static final int SINGLE_TEXTURE = -1;
+
+ public PartAnimation(String name) {
+ this.name = name;
+ textureUnit = SINGLE_TEXTURE;
+ }
+
+ public PartAnimation(String name, int textureUnit) {
+ this.name = name;
+ this.textureUnit = textureUnit;
+ }
+
+ String getName() {
+ return name;
+ }
+
+ int getTextureUnit() {
+ return textureUnit;
+ }
+
+ //�A�j���[�V�����̌o�ߎ��Ԃ̑O���key��KeyFrame�^�̔z��Ŏ擾���郁�\�b�h
+ KeyFrame[] getKey(long t){
+ int i;
+ KeyFrame[] aroundKey = new KeyFrame[2];
+
+ for(i=1;i partPoseList = new ArrayList();
+
+ public Pose3D() {
+ }
+
+ public Pose3D(Pose3D p) {
+ partPoseList = new ArrayList(p.partPoseList);
+ }
+
+ public void applyTo(Object3D obj) {
+ // obj.rotate(part, vx, vy, vz, a);
+ int n = partPoseList.size();
+ for (int i = 0; i < n; i++) {
+ final PartPose partpose = (PartPose) partPoseList.get(i);
+ Object3D partObj = obj.getPart(partpose.name);
+ if (partObj != null) {
+ // �ʒu
+ if (partpose.position != null)
+ partObj.apply(partpose.position, false);
+ // ����
+ if (partpose.quaternion != null)
+ partObj.apply(partpose.quaternion, false);
+ // �e�N�X�`��
+ if (partpose.texture != null
+ || partpose.texturePosition != null
+ || partpose.textureQuaternion != null) {
+ ObjectVisitor v = new ObjectVisitor() {
+ @Override
+ public void postVisit(Object3D obj) {
+ Appearance appearance = null;
+ Node node = obj.getPrimitiveNode();
+ if (node != null && node instanceof Shape3D) {
+ appearance = ((Shape3D)node).getAppearance();
+ } else if (node != null && node instanceof Primitive) {
+ appearance = ((Primitive)node).getAppearance();
+ }
+ if (appearance != null) {
+ TextureUnitState tu = null;
+ if (partpose.texture != null) {
+ if (partpose.textureUnit == PartAnimation.SINGLE_TEXTURE) {
+ appearance.setTexture(partpose.texture);
+ } else {
+ tu = appearance.getTextureUnitState(partpose.textureUnit);
+ tu.setTexture(partpose.texture);
+ appearance.setTextureUnitState(partpose.textureUnit, tu);
+ }
+ }
+ if ((partpose.texturePosition != null || partpose.textureQuaternion != null)
+ && obj.hasAppearancePrepared()) { // Appearance ������̃����_�����O�̒��O�ōX�V�����\�������邽��
+ TextureAttributes ta;
+ if (partpose.textureUnit == PartAnimation.SINGLE_TEXTURE) {
+ ta = appearance.getTextureAttributes();
+ } else {
+ tu = appearance.getTextureUnitState(partpose.textureUnit);
+ ta = tu.getTextureAttributes();
+ }
+ if (ta == null) {
+ ta = new TextureAttributes();
+ }
+ Transform3D t = new Transform3D();
+ if (partpose.texturePosition != null) {
+ t.set(new Vector3d(partpose.texturePosition.getVector3d()));
+ }
+ if (partpose.textureQuaternion != null) {
+ Transform3D t2 = new Transform3D();
+ t2.set(partpose.textureQuaternion.getQuat());
+ t.mul(t2);
+ }
+// shape.getAppearance().getTextureAttributes().setTextureTransform(t);
+ ta.setTextureTransform(t);
+ if (partpose.textureUnit == PartAnimation.SINGLE_TEXTURE) {
+ appearance.setTextureAttributes(ta);
+ } else {
+ tu.setTextureAttributes(ta);
+ appearance.setTextureUnitState(partpose.textureUnit, tu);
+ }
+ }
+ }
+ }
+ @Override
+ public void preVisit(Object3D obj) {
+ }
+ };
+ partObj.accept(v);
+ }
+ }
+ }
+ }
+
+ public void addPose(String name, Position3D p, Quaternion3D q, Texture texture, Position3D tp, Quaternion3D tq, int textureUnit) {
+ PartPose partpose = new PartPose(name, p, q, texture, tp, tq, textureUnit);
+ partPoseList.add(partpose);
+ }
+
+ @Override
+ public Property3D clone() {
+ // TODO Auto-generated method stub
+ return new Pose3D(this);
+ }
+}
diff --git a/src/framework/gameMain/Actor.java b/src/framework/gameMain/Actor.java
new file mode 100644
index 0000000..382ad9d
--- /dev/null
+++ b/src/framework/gameMain/Actor.java
@@ -0,0 +1,329 @@
+package framework.gameMain;
+
+
+import java.util.ArrayList;
+
+import framework.animation.Animation3D;
+import framework.model3D.CollisionResult;
+import framework.model3D.GeometryUtility;
+import framework.model3D.Object3D;
+import framework.model3D.Position3D;
+import framework.model3D.Quaternion3D;
+import framework.physics.Force3D;
+import framework.physics.Ground;
+import framework.physics.PhysicsUtility;
+import framework.physics.Solid3D;
+import framework.physics.Velocity3D;
+import java3d.AxisAngle4d;
+import java3d.Transform3D;
+import java3d.Vector3d;
+
+
+/**
+ * �Q�[�����̓o�ꕨ�S��
+ * @author �V�c����
+ *
+ */
+public abstract class Actor extends Animatable implements Movable {
+ protected Vector3d direction = new Vector3d(1.0, 0.0, 0.0);
+ protected Mode mode;
+ // �ȉ��ȃ��������̂��ߗ\�߃C���X�^���X��
+ protected Mode modeFreeFall = new ModeFreeFall();
+ protected Mode modeOnGround = new ModeOnGround();
+ private static final Vector3d Y_AXIS = new Vector3d(0.0, 1.0, 0.0);
+
+ public Actor(Object3D body, Animation3D animation) {
+ super(new Solid3D(body), animation);
+ mode = modeOnGround;
+ }
+
+ public Actor(Solid3D body, Animation3D animation) {
+ super(body, animation);
+ mode = modeOnGround;
+ }
+
+// public Actor(ActorModel model) {
+// super(model.createBody(), model.getAnimation());
+// mode = modeOnGround;
+// }
+
+ /**
+ * �P�ʎ��Ԃ��Ƃ̓���i�Փ˔��菈���͍s��Ȃ��j
+ * @param interval --- �O��Ăяo���ꂽ�Ƃ�����̌o�ߎ��ԁi�~���b�P�ʁj
+ */
+ public void motion(long interval){
+ // 1. �ʒu����
+ ((Solid3D)body).move(interval, getGravity(), getGravityCenter());
+ super.motion(interval);
+ }
+
+ /**
+ * �P�ʎ��Ԃ��Ƃ̓���i�Փ˔��菈�����s���j
+ * @param interval --- �O��Ăяo���ꂽ�Ƃ�����̌o�ߎ��ԁi�~���b�P�ʁj
+ * @param ground --- �n�ʁi�\�����j
+ */
+ public void motion(long interval, Ground ground) {
+
+ // 1. �ʒu����
+ ((Solid3D)body).move(interval, getGravity(), getGravityCenter());
+
+ if (animation != null) {
+ // 2. �A�j���[�V���������s
+ if (animation.progress(interval) == false) {
+ onEndAnimation();
+ }
+
+ // 3. �p�����
+ body.apply(animation.getPose(), false);
+ }
+
+ // 4. �Փ˔���
+ CollisionResult cr = PhysicsUtility.doesIntersect((Solid3D)body, ground);
+
+ // 5. �Փˉ���
+ if (cr != null) {
+ // �\�����ɂԂ������A�܂��͐ڐG���Ă��鎞
+ if (cr.normal.dot(PhysicsUtility.vertical) > GeometryUtility.TOLERANCE) {
+ // ������̖ʁi���n�ʁj�ɂԂ������A�܂��͐ڐG���Ă��鎞
+ if (cr.length <= GeometryUtility.TOLERANCE) {
+ // �n�ʂɏ���Ă���
+ if (!(mode instanceof ModeOnGround)) {
+ // �����Ă��Ē��x�����
+ mode = modeOnGround;
+ ((ModeOnGround)mode).setNormal(cr.normal);
+ onEndFall();
+ }
+ } else {
+ // �n�ʂɂ߂荞��
+ // 5.1. �����߂�
+ onIntersect(cr, interval);
+ if (!(mode instanceof ModeOnGround)) {
+ // �����Ă��Ă߂荞��
+ // 6. �n�ʃ��[�h�ɂ���
+ mode = modeOnGround;
+ ((ModeOnGround)mode).setNormal(cr.normal);
+ onEndFall();
+ } else {
+ // �����Ă���r���ŁA�A�j���[�V�����̊W�ň�u�����߂荞��
+ // �܂��́A�����Ă���r���ŎΖʂɍ����|������
+ ((ModeOnGround)mode).setNormal(cr.normal);
+ }
+ }
+ } else if (cr.normal.dot(PhysicsUtility.vertical) >= -GeometryUtility.TOLERANCE) {
+ // �����ǂɂ߂荞��
+ // 5.1. �����߂�
+ onIntersect(cr, interval);
+ } else {
+ // ������Ԃ������A�܂��͐ڐG����(�����Ԃ���)
+ if (cr.length > GeometryUtility.TOLERANCE) {
+ // 5.1. �����߂�
+ onIntersect(cr, interval);
+ }
+ }
+ cr = null;
+ } else {
+ // �n�ʂƂԂ����Ă��ڐG���Ă����Ȃ���
+ // 6. �������[�h�ɂ���
+ mode = modeFreeFall;
+ }
+ }
+
+ public void motion(long interval, Ground ground,ArrayList forces,
+ ArrayList appPoints) {
+
+ forces.add(getGravity());
+ appPoints.add(getGravityCenter());
+
+ // 1. �ʒu����
+ ((Solid3D)body).move(interval, forces, appPoints);
+
+ if (animation != null) {
+ // 2. �A�j���[�V���������s
+ if (animation.progress(interval) == false) {
+ onEndAnimation();
+ }
+
+ // 3. �p�����
+ body.apply(animation.getPose(), false);
+ }
+
+ // 4. �Փ˔���
+ CollisionResult cr = PhysicsUtility.doesIntersect((Solid3D)body, ground);
+
+ // 5. �Փˉ���
+ if (cr != null) {
+ // �\�����ɂԂ������A�܂��͐ڐG���Ă��鎞
+ if (cr.normal.dot(PhysicsUtility.vertical) > GeometryUtility.TOLERANCE) {
+ // ������̖ʁi���n�ʁj�ɂԂ������A�܂��͐ڐG���Ă��鎞
+ if (cr.length <= GeometryUtility.TOLERANCE) {
+ // �n�ʂɏ���Ă���
+ if (!(mode instanceof ModeOnGround)) {
+ // �����Ă��Ē��x�����
+ mode = modeOnGround;
+ ((ModeOnGround)mode).setNormal(cr.normal);
+ onEndFall();
+ }
+ } else {
+ // �n�ʂɂ߂荞��
+ // 5.1. �����߂�
+ onIntersect(cr, interval);
+ if (!(mode instanceof ModeOnGround)) {
+ // �����Ă��Ă߂荞��
+ // 6. �n�ʃ��[�h�ɂ���
+ mode = modeOnGround;
+ ((ModeOnGround)mode).setNormal(cr.normal);
+ onEndFall();
+ } else {
+ // �����Ă���r���ŁA�A�j���[�V�����̊W�ň�u�����߂荞��
+ // �܂��́A�����Ă���r���ŎΖʂɍ����|������
+ ((ModeOnGround)mode).setNormal(cr.normal);
+ }
+ }
+ } else if (cr.normal.dot(PhysicsUtility.vertical) >= -GeometryUtility.TOLERANCE) {
+ // �����ǂɂ߂荞��
+ // 5.1. �����߂�
+ onIntersect(cr, interval);
+ } else {
+ // ������Ԃ������A�܂��͐ڐG����(�����Ԃ���)
+ if (cr.length > GeometryUtility.TOLERANCE) {
+ // 5.1. �����߂�
+ onIntersect(cr, interval);
+ }
+ }
+ cr = null;
+ } else {
+ // �n�ʂƂԂ����Ă��ڐG���Ă����Ȃ���
+ // 6. �������[�h�ɂ���
+ mode = modeFreeFall;
+ }
+ }
+
+ public void setInitialDirection(Vector3d dir) {
+ direction = dir;
+ }
+
+ public Vector3d getInitialDirection(){
+ return direction;
+ }
+
+ /**
+ * �w�肵�������Ɍ�������
+ * @param vec �V��������
+ */
+ public void setDirection(Vector3d vec) {
+ Vector3d v1 = new Vector3d();
+ Vector3d v2 = new Vector3d();
+ v1.cross(direction, GeometryUtility.Y_AXIS);
+ v2.cross(vec, GeometryUtility.Y_AXIS);
+ if (v2.length() < GeometryUtility.TOLERANCE) return;
+ v1.normalize();
+ v2.normalize();
+ double cos = v1.dot(v2);
+ v1.cross(v1, v2);
+ double sin = v1.dot(GeometryUtility.Y_AXIS);
+ double angle = Math.atan2(sin, cos);
+ AxisAngle4d axisAngle = new AxisAngle4d(GeometryUtility.Y_AXIS, angle);
+ Quaternion3D quat = new Quaternion3D(axisAngle);
+ ((Solid3D)body).apply(quat, false);
+ }
+
+ /**
+ * �w�肵�������Ɍ�������
+ * @param vec �V��������
+ */
+ public void setDirection3D(Vector3d vec) {
+ Vector3d v1 = new Vector3d();
+ Vector3d v2 = new Vector3d();
+ v1.cross(direction, GeometryUtility.Y_AXIS);
+ double angle = Math.PI / 2.0 - Math.acos(vec.dot(GeometryUtility.Y_AXIS));
+ AxisAngle4d axisAngle2 = new AxisAngle4d(v1, angle);
+ v2.cross(vec, GeometryUtility.Y_AXIS);
+ if (v2.length() < GeometryUtility.TOLERANCE) return;
+ v1.normalize();
+ v2.normalize();
+ double cos = v1.dot(v2);
+ v1.cross(v1, v2);
+ double sin = v1.dot(GeometryUtility.Y_AXIS);
+ angle = Math.atan2(sin, cos);
+ AxisAngle4d axisAngle = new AxisAngle4d(GeometryUtility.Y_AXIS, angle);
+ Quaternion3D quat = new Quaternion3D(axisAngle);
+ Quaternion3D quat2 = new Quaternion3D(axisAngle2);
+ quat.mul(quat2);
+ ((Solid3D)body).apply(quat, false);
+ }
+
+ /**
+ * �������Ă���������擾����
+ * @return ���݂̌���
+ */
+ public Vector3d getDirection() {
+ Vector3d dir = new Vector3d(direction);
+ Transform3D trans = new Transform3D();
+ trans.set(((Solid3D)body).getQuaternion().getAxisAngle());
+ trans.transform(dir);
+ return dir;
+ }
+
+ /**
+ * �ړ����x�x�N�g����ݒ肷��
+ * @param vel �V�����ړ����x�x�N�g��
+ */
+ public void setVelocity(Velocity3D vel) {
+ ((Solid3D)body).apply(vel, false);
+ }
+
+ /**
+ * �ړ����x�x�N�g�����擾����
+ * @return ���݂̈ړ����x�x�N�g��
+ */
+ public Velocity3D getVelocity() {
+ return ((Solid3D)body).getVelocity();
+ }
+
+ /**
+ * Y���𒆐S�ɉ�]����
+ * @param angle ��]�p�i�����v���, �P��:���W�A���j
+ */
+ public void rotY(double angle) {
+ Quaternion3D curQuat = body.getQuaternion();
+ curQuat.add(new AxisAngle4d(Y_AXIS, angle));
+ body.apply(curQuat, false);
+ }
+
+ /**
+ * ������Ă���d�͂��擾����
+ * @return �d��
+ */
+ public Force3D getGravity() {
+ return mode.getForce((Solid3D)body);
+ }
+
+ /**
+ * �d�S���擾����
+ * @return �d�S�ʒu
+ */
+ public Position3D getGravityCenter() {
+ return ((Solid3D)body).getGravityCenter();
+ }
+
+ /**
+ * �n�ʂɏ���Ă����Ԃ��ۂ����擾����
+ * @return true --- �n�ʂɏ���Ă���, false --- �n�ʂɏ���Ă��Ȃ��i�ɂ���j
+ */
+ public boolean isOnGround() {
+ return (mode instanceof ModeOnGround);
+ }
+
+ /**
+ * �n�ʁi�\�����j�ɗ��������u�ԂɌĂяo�����
+ */
+ public abstract void onEndFall();
+
+ /**
+ * �n�ʁi�\�����j�ɏՓ˂����u�ԂɌĂяo�����
+ * @param normal --- �n�ʂ̖@�������x�N�g��
+ * @param interval --- �O��̓��삩��̌o�ߎ��ԁi�~���b�P�ʁj
+ */
+ public abstract void onIntersect(CollisionResult normal, long interval);
+
+}
diff --git a/src/framework/gameMain/ActorModel.java b/src/framework/gameMain/ActorModel.java
new file mode 100644
index 0000000..1ef7b5a
--- /dev/null
+++ b/src/framework/gameMain/ActorModel.java
@@ -0,0 +1,14 @@
+package framework.gameMain;
+import framework.physics.Solid3D;
+
+
+public abstract class ActorModel extends GameModel {
+
+ public ActorModel(String fileName) {
+ super(fileName);
+ }
+
+ public Solid3D createBody() {
+ return new Solid3D(getModel().createObject());
+ }
+}
diff --git a/src/framework/gameMain/Animatable.java b/src/framework/gameMain/Animatable.java
new file mode 100644
index 0000000..0007bd6
--- /dev/null
+++ b/src/framework/gameMain/Animatable.java
@@ -0,0 +1,58 @@
+package framework.gameMain;
+
+
+import java3d.TransformGroup;
+
+import framework.animation.Animation3D;
+import framework.model3D.BaseObject3D;
+import framework.model3D.Object3D;
+import framework.model3D.Position3D;
+import framework.model3D.Placeable;
+
+public abstract class Animatable implements Placeable {
+ public Object3D body;
+ public Animation3D animation;
+
+ public Animatable(Object3D body, Animation3D animation) {
+ this.body = body;
+ this.animation = animation;
+ }
+
+ /**
+ * �P�ʎ��Ԃ��Ƃ̓���i�A�j���[�V���������j
+ * @param interval --- �O��Ăяo���ꂽ�Ƃ�����̌o�ߎ��ԁi�~���b�P�ʁj
+ */
+ public void motion(long interval) {
+ if (animation != null) {
+ // 1. �A�j���[�V���������s
+ if (animation.progress(interval) == false) {
+ onEndAnimation();
+ }
+
+ // 2. �p�����
+ body.apply(animation.getPose(), false);
+ }
+ }
+
+ public TransformGroup getTransformGroupToPlace() {
+ return getBody().getTransformGroupToPlace();
+ }
+
+ public BaseObject3D getBody() {
+ return body;
+ }
+
+ /**
+ * �A�j���[�V�������I�����邽�тɌĂ��
+ */
+ public abstract void onEndAnimation();
+
+ public Position3D getPosition() {
+ return body.getPosition3D();
+ }
+
+ public void setPosition(Position3D p) {
+ body.apply(p, false);
+ }
+
+}
\ No newline at end of file
diff --git a/src/framework/gameMain/CVS/Entries b/src/framework/gameMain/CVS/Entries
new file mode 100644
index 0000000..5e46434
--- /dev/null
+++ b/src/framework/gameMain/CVS/Entries
@@ -0,0 +1,9 @@
+/Actor.java/1.2/Tue Nov 15 09:23:31 2016//
+/ActorModel.java/1.1/Thu Jul 7 08:22:45 2016//
+/Animatable.java/1.1/Thu Jul 7 08:22:45 2016//
+/GameModel.java/1.1/Thu Jul 7 08:22:45 2016//
+/Mode.java/1.1/Thu Jul 7 08:22:45 2016//
+/ModeFreeFall.java/1.1/Thu Jul 7 08:22:45 2016//
+/ModeOnGround.java/1.1/Thu Jul 7 08:22:45 2016//
+/Movable.java/1.1/Thu Jul 7 08:22:45 2016//
+/OvergroundActor.java/1.1/Thu Jul 7 08:22:45 2016//
diff --git a/src/framework/gameMain/CVS/Repository b/src/framework/gameMain/CVS/Repository
new file mode 100644
index 0000000..ce76d9b
--- /dev/null
+++ b/src/framework/gameMain/CVS/Repository
@@ -0,0 +1 @@
+CarrotServer/src/framework/gameMain
diff --git a/src/framework/gameMain/CVS/Root b/src/framework/gameMain/CVS/Root
new file mode 100644
index 0000000..c36e9d0
--- /dev/null
+++ b/src/framework/gameMain/CVS/Root
@@ -0,0 +1 @@
+:pserver:guest@nitta-lab-www.is.konan-u.ac.jp:\CVSProject
diff --git a/src/framework/gameMain/GameModel.java b/src/framework/gameMain/GameModel.java
new file mode 100644
index 0000000..ec2bc50
--- /dev/null
+++ b/src/framework/gameMain/GameModel.java
@@ -0,0 +1,28 @@
+package framework.gameMain;
+import framework.animation.Animation3D;
+import framework.model3D.Model3D;
+
+public class GameModel {
+
+ private Model3D model = null;
+ private String fileName;
+
+ public GameModel(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public Animation3D getAnimation() {
+ return new Animation3D();
+ }
+
+ public Model3D getModel() {
+ if(model == null && fileName != null) {
+// model = ModelFactory.loadModel(fileName, false, true);
+ }
+ return model;
+ }
+
+ public void clearModel(){
+ model = null;
+ }
+}
\ No newline at end of file
diff --git a/src/framework/gameMain/Mode.java b/src/framework/gameMain/Mode.java
new file mode 100644
index 0000000..e7ebe1a
--- /dev/null
+++ b/src/framework/gameMain/Mode.java
@@ -0,0 +1,10 @@
+package framework.gameMain;
+import framework.physics.Force3D;
+import framework.physics.Solid3D;
+
+
+public abstract class Mode {
+
+ abstract Force3D getForce(Solid3D body);
+
+}
diff --git a/src/framework/gameMain/ModeFreeFall.java b/src/framework/gameMain/ModeFreeFall.java
new file mode 100644
index 0000000..97c4b95
--- /dev/null
+++ b/src/framework/gameMain/ModeFreeFall.java
@@ -0,0 +1,11 @@
+package framework.gameMain;
+import framework.physics.Force3D;
+import framework.physics.PhysicsUtility;
+import framework.physics.Solid3D;
+
+
+public class ModeFreeFall extends Mode {
+ Force3D getForce(Solid3D body) {
+ return PhysicsUtility.getGravity(body);
+ }
+}
diff --git a/src/framework/gameMain/ModeOnGround.java b/src/framework/gameMain/ModeOnGround.java
new file mode 100644
index 0000000..acd606e
--- /dev/null
+++ b/src/framework/gameMain/ModeOnGround.java
@@ -0,0 +1,25 @@
+package framework.gameMain;
+
+
+import java3d.Vector3d;
+
+import framework.physics.Force3D;
+import framework.physics.PhysicsUtility;
+import framework.physics.Solid3D;
+
+
+public class ModeOnGround extends Mode {
+ private Vector3d normal = PhysicsUtility.vertical;
+
+ public Force3D getForce(Solid3D body) {
+ return Force3D.ZERO;
+ }
+
+ public void setNormal(Vector3d normal) {
+ this.normal = normal;
+ }
+
+ public Vector3d getNormal() {
+ return normal;
+ }
+}
diff --git a/src/framework/gameMain/Movable.java b/src/framework/gameMain/Movable.java
new file mode 100644
index 0000000..fc63e9d
--- /dev/null
+++ b/src/framework/gameMain/Movable.java
@@ -0,0 +1,8 @@
+package framework.gameMain;
+
+import framework.model3D.Placeable;
+import framework.physics.Ground;
+
+public interface Movable extends Placeable {
+ public void motion(long interval, Ground ground);
+}
diff --git a/src/framework/gameMain/OvergroundActor.java b/src/framework/gameMain/OvergroundActor.java
new file mode 100644
index 0000000..3bece8f
--- /dev/null
+++ b/src/framework/gameMain/OvergroundActor.java
@@ -0,0 +1,52 @@
+package framework.gameMain;
+
+
+import java3d.Vector3d;
+
+import framework.animation.Animation3D;
+import framework.model3D.CollisionResult;
+import framework.model3D.Object3D;
+import framework.model3D.Position3D;
+import framework.physics.Solid3D;
+import framework.physics.Velocity3D;
+
+/**
+ * �n�ʂ̏���ړ�������́i�W�����v�⎩�R���������邱�Ƃ��\�j
+ * @author �V�c����
+ *
+ */
+public class OvergroundActor extends Actor {
+
+ public OvergroundActor(Object3D body, Animation3D animation) {
+ super(body, animation);
+ }
+
+ public OvergroundActor(Solid3D body, Animation3D animation) {
+ super(body, animation);
+ }
+
+// public OvergroundActor(ActorModel model) {
+// super(model);
+// }
+
+ public void onIntersect(CollisionResult cr, long interval) {
+ // �߂荞��i�߂荞�ʂ̖@�������Ɂj�����߂�
+ Vector3d back = (Vector3d) cr.normal.clone();
+ back.scale(cr.length * 2.0);
+ body.apply(new Position3D(body.getPosition3D().add(back)), false);
+
+ // ���x�̖ʂ̖@�������̐����� 0 �ɂ���
+ Vector3d v = (Vector3d) ((Solid3D)body).getVelocity().getVector3d().clone();
+ double d = v.dot(cr.normal);
+ v.scaleAdd(-d, cr.normal, v);
+ body.apply(new Velocity3D(v), false);
+ }
+
+ @Override
+ public void onEndFall() {
+ }
+
+ @Override
+ public void onEndAnimation() {
+ }
+}
\ No newline at end of file
diff --git a/src/framework/model3D/BackgroundBox.java b/src/framework/model3D/BackgroundBox.java
new file mode 100644
index 0000000..9cc0bb3
--- /dev/null
+++ b/src/framework/model3D/BackgroundBox.java
@@ -0,0 +1,6 @@
+package framework.model3D;
+
+import java3d.Background;
+
+public class BackgroundBox extends Background {
+}
diff --git a/src/framework/model3D/BaseObject3D.java b/src/framework/model3D/BaseObject3D.java
new file mode 100644
index 0000000..18c17b8
--- /dev/null
+++ b/src/framework/model3D/BaseObject3D.java
@@ -0,0 +1,332 @@
+package framework.model3D;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+
+import java3d.BoundingPolytope;
+import java3d.Box;
+import java3d.Cone;
+import java3d.Cylinder;
+import java3d.IndexedTriangleArray;
+import java3d.IndexedTriangleFanArray;
+import java3d.IndexedTriangleStripArray;
+import java3d.Node;
+import java3d.TriangleStripArray;
+import java3d.Vector3d;
+import java3d.Vector4d;
+
+import java3d.Appearance;
+import java3d.Geometry;
+import java3d.Shape3D;
+import java3d.Sphere;
+import java3d.TransformGroup;
+import java3d.TriangleArray;
+import java3d.TriangleFanArray;
+
+public class BaseObject3D implements Placeable {
+ public TransformGroup center;
+
+ protected BoundingSurface[] boundingSurfaces = null;
+
+ public BaseObject3D() {
+ center = new TransformGroup();
+ }
+
+ public BaseObject3D(Geometry g, Appearance a) {
+ center = new TransformGroup();
+ Shape3D shape = new Shape3D(g, a);
+ center.addChild(shape);
+ }
+
+ @Override
+ public TransformGroup getTransformGroupToPlace() {
+ return getBody().center;
+ }
+
+ public BaseObject3D getBody() {
+ return this;
+ }
+
+ public Node getPrimitiveNode() {
+ return (Node)center.getChild(0);
+ }
+
+ public Enumeration getPrimitiveNodes() {
+ return (Enumeration)center.getAllChildren();
+ }
+
+ /**
+ * �Փ˔���p�̃{�����[���i�|���S���Ƒe������p�̑��p���j���擾����
+ * @return�@�Փ˔���p�̃{�����[����
+ */
+ public BoundingSurface[] getBoundingSurfaces() {
+ if (boundingSurfaces == null) {
+ Node node = getPrimitiveNode();
+ if (node == null) return null;
+
+ ArrayList vertex3DList = null;
+ if (node instanceof Box) {
+ // Box�̏ꍇ
+ Box box = ((Box)node);
+ // ���_����擾����
+ vertex3DList = getVertexList(box.getShape(Box.BACK).getGeometry());
+ vertex3DList.addAll(getVertexList(box.getShape(Box.BOTTOM).getGeometry()));
+ vertex3DList.addAll(getVertexList(box.getShape(Box.FRONT).getGeometry()));
+ vertex3DList.addAll(getVertexList(box.getShape(Box.LEFT).getGeometry()));
+ vertex3DList.addAll(getVertexList(box.getShape(Box.RIGHT).getGeometry()));
+ vertex3DList.addAll(getVertexList(box.getShape(Box.TOP).getGeometry()));
+ } else if (node instanceof Cylinder) {
+ // Cylinder�̏ꍇ
+ Cylinder cylinder = ((Cylinder)node);
+ // ���_����擾����
+ vertex3DList = getVertexList(cylinder.getShape(Cylinder.BODY).getGeometry());
+ vertex3DList.addAll(getVertexList(cylinder.getShape(Cylinder.BOTTOM).getGeometry()));
+ vertex3DList.addAll(getVertexList(cylinder.getShape(Cylinder.TOP).getGeometry()));
+ } else if (node instanceof Cone) {
+ // Cone�̏ꍇ
+ Cone cone = ((Cone)node);
+ // ���_����擾����
+ vertex3DList = getVertexList(cone.getShape(Cone.BODY).getGeometry());
+ vertex3DList.addAll(getVertexList(cone.getShape(Cone.CAP).getGeometry()));
+ } else if (node instanceof Sphere) {
+ // Sphere�̏ꍇ
+ Sphere sphere = ((Sphere)node);
+ // ���_����擾����
+ vertex3DList = getVertexList(sphere.getShape(Sphere.BODY).getGeometry());
+ } else if (node instanceof Shape3D) {
+ // Shape3D�̏ꍇ
+ Shape3D shape = (Shape3D)node;
+ // ���_����擾����
+ vertex3DList = getVertexList(shape.getGeometry());
+ }
+ if (vertex3DList == null) return null;
+
+ BoundingSurface[] surfaces = new BoundingSurface[vertex3DList.size() / 3];
+
+ for (int i = 0; i < vertex3DList.size(); i += 3) {
+ Vector3d v1 = vertex3DList.get(i);
+ Vector3d v2 = vertex3DList.get(i + 1);
+ Vector3d v3 = vertex3DList.get(i + 2);
+ BoundingSurface bSurface = new BoundingSurface();
+ bSurface.addVertex((Vector3d)v1.clone());
+ bSurface.addVertex((Vector3d)v2.clone());
+ bSurface.addVertex((Vector3d)v3.clone());
+ bSurface.setBounds(createBoundingPolytope(v1, v2, v3));
+ surfaces[i / 3] = bSurface;
+ }
+ boundingSurfaces = surfaces;
+ }
+ return boundingSurfaces;
+ }
+
+ private ArrayList getVertexList(Geometry g) {
+ ArrayList vertex3DList = new ArrayList();
+ double coordinate1[] = new double[3];
+ if (g instanceof IndexedTriangleArray) {
+ // IndexedTriangleArray �̏ꍇ
+ IndexedTriangleArray triArray = (IndexedTriangleArray)g;
+
+ // �S���_��3D��̒��_��vertex3DList�ɓ���Ă����B
+ for (int i = 0; i < triArray.getIndexCount(); i++) {
+ triArray.getCoordinates(triArray.getCoordinateIndex(i), coordinate1);
+ vertex3DList.add(new Vector3d(coordinate1));
+ }
+ } else if (g instanceof TriangleArray) {
+ // TriangleArray �̏ꍇ
+ TriangleArray triArray = (TriangleArray)g;
+
+ // �S���_��3D��̒��_��vertex3DList�ɓ���Ă����B
+ for (int i = 0; i < triArray.getVertexCount(); i++) {
+ triArray.getCoordinates(i, coordinate1);
+ vertex3DList.add(new Vector3d(coordinate1));
+ }
+ } else if (g instanceof IndexedTriangleStripArray) {
+ // IndexedTriangleStripArray �̏ꍇ
+ IndexedTriangleStripArray triStripAttay = (IndexedTriangleStripArray)g;
+ int stripVertexCounts[] = new int[triStripAttay.getNumStrips()];
+ triStripAttay.getStripIndexCounts(stripVertexCounts);
+ // �S���_��3D��̒��_��vertex3DList�ɓ���Ă���
+ int index = 0;
+ double coordinate2[] = new double[3];
+ double coordinate3[] = new double[3];
+ double coordinate4[] = new double[3];
+ for (int i = 0; i < triStripAttay.getNumStrips(); i++) {
+ for (int j = 0; j < stripVertexCounts[i]; j += 2) {
+ triStripAttay.getCoordinates(triStripAttay.getCoordinateIndex(index), coordinate1);
+ triStripAttay.getCoordinates(triStripAttay.getCoordinateIndex(index+1), coordinate2);
+ triStripAttay.getCoordinates(triStripAttay.getCoordinateIndex(index+2), coordinate3);
+ triStripAttay.getCoordinates(triStripAttay.getCoordinateIndex(index+3), coordinate4);
+ vertex3DList.add(new Vector3d(coordinate1)); //1�߂̎O�p�`
+ vertex3DList.add(new Vector3d(coordinate2));
+ vertex3DList.add(new Vector3d(coordinate3));
+ vertex3DList.add(new Vector3d(coordinate2)); //2�߂̎O�p�`
+ vertex3DList.add(new Vector3d(coordinate4));
+ vertex3DList.add(new Vector3d(coordinate3));
+ index += 2;
+ }
+ }
+ } else if (g instanceof TriangleStripArray) {
+ // TriangleStripArray �̏ꍇ
+ TriangleStripArray triStripAttay = (TriangleStripArray)g;
+ int stripVertexCounts[] = new int[triStripAttay.getNumStrips()];
+ triStripAttay.getStripVertexCounts(stripVertexCounts);
+ // �S���_��3D��̒��_��vertex3DList�ɓ���Ă���
+ int index = 0;
+ double coordinate2[] = new double[3];
+ double coordinate3[] = new double[3];
+ double coordinate4[] = new double[3];
+ for (int i = 0; i < triStripAttay.getNumStrips(); i++) {
+ for (int j = 0; j < stripVertexCounts[i]; j += 2) {
+ triStripAttay.getCoordinates(index, coordinate1);
+ triStripAttay.getCoordinates(index+1, coordinate2);
+ triStripAttay.getCoordinates(index+2, coordinate3);
+ triStripAttay.getCoordinates(index+3, coordinate4);
+ vertex3DList.add(new Vector3d(coordinate1)); //1�߂̎O�p�`
+ vertex3DList.add(new Vector3d(coordinate2));
+ vertex3DList.add(new Vector3d(coordinate3));
+ vertex3DList.add(new Vector3d(coordinate2)); //2�߂̎O�p�`
+ vertex3DList.add(new Vector3d(coordinate4));
+ vertex3DList.add(new Vector3d(coordinate3));
+ index += 2;
+ }
+ }
+ } else if (g instanceof IndexedTriangleFanArray) {
+ // IndexedTriangleFanArray �̏ꍇ
+ IndexedTriangleFanArray triFanAttay = (IndexedTriangleFanArray)g;
+ int stripVertexCounts[] = new int[triFanAttay.getNumStrips()];
+ triFanAttay.getStripIndexCounts(stripVertexCounts);
+ // �S���_��3D��̒��_��vertex3DList�ɓ���Ă���
+ int index = 0;
+ double coordinate2[] = new double[3];
+ double coordinate3[] = new double[3];
+ double coordinate4[] = null;
+ for (int i = 0; i < triFanAttay.getNumStrips(); i++) {
+ triFanAttay.getCoordinates(triFanAttay.getCoordinateIndex(index), coordinate1); // ���S�_
+ triFanAttay.getCoordinates(triFanAttay.getCoordinateIndex(index+1), coordinate2);
+ index += 2;
+ for (int j = 2; j < stripVertexCounts[i]; j++) {
+ triFanAttay.getCoordinates(triFanAttay.getCoordinateIndex(index), coordinate3);
+ vertex3DList.add(new Vector3d(coordinate1));
+ vertex3DList.add(new Vector3d(coordinate2));
+ vertex3DList.add(new Vector3d(coordinate3));
+ coordinate4 = coordinate2;
+ coordinate2 = coordinate3;
+ coordinate3 = coordinate4;
+ index++;
+ }
+ }
+ } else if (g instanceof TriangleFanArray) {
+ // TriangleFanArray �̏ꍇ
+ TriangleFanArray triFanAttay = (TriangleFanArray)g;
+ int stripVertexCounts[] = new int[triFanAttay.getNumStrips()];
+ triFanAttay.getStripVertexCounts(stripVertexCounts);
+ // �S���_��3D��̒��_��vertex3DList�ɓ���Ă���
+ int index = 0;
+ double coordinate2[] = new double[3];
+ double coordinate3[] = new double[3];
+ double coordinate4[] = null;
+ for (int i = 0; i < triFanAttay.getNumStrips(); i++) {
+ triFanAttay.getCoordinates(index, coordinate1); // ���S�_
+ triFanAttay.getCoordinates(index + 1, coordinate2);
+ index += 2;
+ for (int j = 2; j < stripVertexCounts[i]; j++) {
+ triFanAttay.getCoordinates(index, coordinate3);
+ vertex3DList.add(new Vector3d(coordinate1));
+ vertex3DList.add(new Vector3d(coordinate2));
+ vertex3DList.add(new Vector3d(coordinate3));
+ coordinate4 = coordinate2;
+ coordinate2 = coordinate3;
+ coordinate3 = coordinate4;
+ index++;
+ }
+ }
+ } else {
+ return null;
+ }
+ return vertex3DList;
+ }
+
+ protected BoundingPolytope createBoundingPolytope(Vector3d vertex1,
+ Vector3d vertex2, Vector3d vertex3) {
+ Vector3d v1 = new Vector3d();
+ Vector3d v2 = new Vector3d();
+ Vector3d v3 = new Vector3d();
+ Vector3d v4 = new Vector3d();
+ Vector3d v5 = new Vector3d();
+ Vector3d v6 = new Vector3d();
+ Vector3d cv1 = new Vector3d();
+ Vector3d cv2 = new Vector3d();
+ cv1.sub(vertex3, vertex1);
+ cv2.sub(vertex2, vertex1);
+ Vector3d cv = new Vector3d();
+ cv.cross(cv1, cv2);
+ cv.normalize();
+ cv.scale(0.01);
+ v1.set(vertex1);
+ v2.set(vertex2);
+ v3.set(vertex3);
+ v4.set(vertex1);
+ v4.add(cv);
+ v5.set(vertex2);
+ v5.add(cv);
+ v6.set(vertex3);
+ v6.add(cv);
+
+ Vector3d pv1 = new Vector3d();
+ Vector3d pv2 = new Vector3d();
+ Vector3d pv3 = new Vector3d();
+ Vector3d pn = new Vector3d();
+ Vector4d[] plane = new Vector4d[5];
+
+ // 0
+ pv1 = v1;
+ pv2.sub(v2, v1);
+ pv3.sub(v3, v1);
+
+ pn.cross(pv2, pv3);
+ pn.normalize();
+ plane[0] = new Vector4d(pn.x, pn.y, pn.z, -pn.dot(pv1));
+
+ // 1
+ pv1 = v1;
+ pv2.sub(v4, v1);
+ pv3.sub(v2, v1);
+
+ pn.cross(pv2, pv3);
+ pn.normalize();
+ plane[1] = new Vector4d(pn.x, pn.y, pn.z, -pn.dot(pv1));
+
+ // 2
+ pv1 = v1;
+ pv2.sub(v3, v1);
+ pv3.sub(v4, v1);
+
+ pn.cross(pv2, pv3);
+ pn.normalize();
+ plane[2] = new Vector4d(pn.x, pn.y, pn.z, -pn.dot(pv1));
+
+ // 3
+ pv1 = v6;
+ pv2.sub(v3, v6);
+ pv3.sub(v5, v6);
+
+ pn.cross(pv2, pv3);
+ pn.normalize();
+ plane[3] = new Vector4d(pn.x, pn.y, pn.z, -pn.dot(pv1));
+
+ // 4
+ pv1 = v6;
+ pv2.sub(v5, v6);
+ pv3.sub(v4, v6);
+
+ pn.cross(pv2, pv3);
+ pn.normalize();
+ plane[4] = new Vector4d(pn.x, pn.y, pn.z, -pn.dot(pv1));
+
+ return new BoundingPolytope(plane);
+ }
+
+ public boolean hasAppearancePrepared() {
+ return true;
+ }
+}
\ No newline at end of file
diff --git a/src/framework/model3D/BoundingSurface.java b/src/framework/model3D/BoundingSurface.java
new file mode 100644
index 0000000..2d149a1
--- /dev/null
+++ b/src/framework/model3D/BoundingSurface.java
@@ -0,0 +1,128 @@
+package framework.model3D;
+import java.util.ArrayList;
+
+import java3d.BoundingPolytope;
+import java3d.BoundingSphere;
+import java3d.Bounds;
+import java3d.Transform3D;
+import java3d.Matrix4d;
+import java3d.Point3d;
+import java3d.Vector3d;
+import java3d.Vector4d;
+
+
+public class BoundingSurface implements Cloneable {
+ private Bounds bounds = null; // �e���Փ˔���p�i�e���n�ʗp�j
+ private ArrayList children = new ArrayList();
+ private ArrayList vertexList = new ArrayList();
+ private static Vector4d plane[] = { new Vector4d(), new Vector4d(), new Vector4d(),
+ new Vector4d(), new Vector4d() };
+
+ public Object clone() {
+ BoundingSurface s = new BoundingSurface();
+ if (bounds != null) {
+ s.setBounds((Bounds)bounds.clone());
+ }
+ for (int i = 0; i < children.size(); i++) {
+ s.children.add((BoundingSurface)children.get(i).clone());
+ }
+ for (int i = 0; i < vertexList.size(); i++) {
+ s.vertexList.add((Vector3d)vertexList.get(i).clone());
+ }
+ return s;
+ }
+
+ public void setBounds(Bounds bounds) {
+ this.bounds = bounds;
+ }
+
+ public Bounds getBounds() {
+ return bounds;
+ }
+
+ public void addVertex(Vector3d v) {
+ vertexList.add(v);
+ }
+
+ public void addChild(BoundingSurface bs, boolean bCombineBounds) {
+ children.add(bs);
+ if (bCombineBounds) {
+ if (bounds == null) {
+ bounds = (Bounds)bs.bounds.clone();
+ } else {
+ bounds.combine(bs.bounds);
+ }
+ }
+ }
+
+ public void transform(Transform3D transform3D) {
+ bounds.transform(transform3D);
+ for (int i = 0; i < vertexList.size(); i++) {
+ Matrix4d mat4d = new Matrix4d();
+ transform3D.get(mat4d);
+ double x = mat4d.m00 * vertexList.get(i).x + mat4d.m01
+ * vertexList.get(i).y + mat4d.m02 * vertexList.get(i).z
+ + mat4d.m03;
+ double y = mat4d.m10 * vertexList.get(i).x + mat4d.m11
+ * vertexList.get(i).y + mat4d.m12 * vertexList.get(i).z
+ + mat4d.m13;
+ double z = mat4d.m20 * vertexList.get(i).x + mat4d.m21
+ * vertexList.get(i).y + mat4d.m22 * vertexList.get(i).z
+ + mat4d.m23;
+ vertexList.get(i).x = x;
+ vertexList.get(i).y = y;
+ vertexList.get(i).z = z;
+ }
+ }
+
+ /**
+ * BoundingSphere�Ƃ̑e���Փ˔���
+ * @param bs �Փ˔���̑Ώ�
+ * @return �Փ˂��Ă���BoundingSurface�̃��X�g�inull��Ԃ����Ƃ͂Ȃ��j
+ */
+ public ArrayList intersect(BoundingSphere bs) {
+ ArrayList results = new ArrayList();
+ if (children == null || children.size() == 0) {
+ if (bounds.intersect(bs)) {
+ results.add(this);
+ }
+ } else {
+ if (bounds == null || bounds.intersect(bs)) {
+ for (int n = 0; n < children.size(); n++) {
+ results.addAll(children.get(n).intersect(bs));
+ }
+ }
+ }
+ return results;
+ }
+
+ /**
+ * OBB�Ƃ̏ڍׂȏՓ˔���
+ * @param obb �Փ˔���̑Ώ�
+ * @return�@�Փ˔���̌���
+ */
+ public CollisionResult intersect(OBB obb) {
+ if (children == null || children.size() == 0) {
+ // �t�̏ꍇ�́A�ʃ|���S���𗧂��グ���������p��
+ if (bounds instanceof BoundingPolytope) {
+ ((BoundingPolytope)bounds).getPlanes(plane);
+ CollisionResult cr = obb.intersect(plane[0]); // obb����ʂ��܂ޖ������ʂƌ�����Ă��邩�H
+ if (cr != null) {
+ // �������ʂƌ�����Ă���ꍇ�A�������ʂƂ̏Փ˓_���ʃ|���S���̓����Ɉʒu���邩�H
+ if (GeometryUtility.inside(vertexList, cr.collisionPoint.getVector3d(), cr.normal)) {
+ return cr;
+ }
+ }
+ }
+ return null;
+ } else {
+ for (int n = 0; n < children.size(); n++) {
+ CollisionResult cr = children.get(n).intersect(obb);
+ if (cr != null) {
+ return cr;
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/src/framework/model3D/CVS/Entries b/src/framework/model3D/CVS/Entries
new file mode 100644
index 0000000..cb3804d
--- /dev/null
+++ b/src/framework/model3D/CVS/Entries
@@ -0,0 +1,17 @@
+/BackgroundBox.java/1.1/Thu Jul 7 08:22:45 2016//
+/BaseObject3D.java/1.2/Thu Dec 8 08:32:27 2016//
+/BoundingSurface.java/1.1/Thu Jul 7 08:22:45 2016//
+/CollisionResult.java/1.1/Thu Jul 7 08:22:45 2016//
+/GeometryUtility.java/1.1/Thu Jul 7 08:22:45 2016//
+/Model3D.java/1.1/Thu Jul 7 08:22:45 2016//
+/OBB.java/1.2/Thu Dec 8 08:32:27 2016//
+/Object3D.java/1.3/Thu Dec 8 08:32:27 2016//
+/ObjectVisitor.java/1.1/Thu Jul 7 08:22:45 2016//
+/Placeable.java/1.1/Thu Jul 7 08:22:45 2016//
+/Position3D.java/1.1/Thu Jul 7 08:22:45 2016//
+/ProjectionResult.java/1.1/Thu Jul 7 08:22:45 2016//
+/Property3D.java/1.1/Thu Jul 7 08:22:45 2016//
+/Quaternion3D.java/1.1/Thu Jul 7 08:22:45 2016//
+/Terrain3D.java/1.1/Thu Jul 7 08:22:45 2016//
+/UndoBuffer.java/1.1/Thu Jul 7 08:22:45 2016//
+/Universe.java/1.2/Thu Oct 13 07:59:00 2016//
diff --git a/src/framework/model3D/CVS/Repository b/src/framework/model3D/CVS/Repository
new file mode 100644
index 0000000..8835795
--- /dev/null
+++ b/src/framework/model3D/CVS/Repository
@@ -0,0 +1 @@
+CarrotServer/src/framework/model3D
diff --git a/src/framework/model3D/CVS/Root b/src/framework/model3D/CVS/Root
new file mode 100644
index 0000000..c36e9d0
--- /dev/null
+++ b/src/framework/model3D/CVS/Root
@@ -0,0 +1 @@
+:pserver:guest@nitta-lab-www.is.konan-u.ac.jp:\CVSProject
diff --git a/src/framework/model3D/CollisionResult.java b/src/framework/model3D/CollisionResult.java
new file mode 100644
index 0000000..0389bf3
--- /dev/null
+++ b/src/framework/model3D/CollisionResult.java
@@ -0,0 +1,12 @@
+package framework.model3D;
+import java.util.ArrayList;
+
+import java3d.Vector3d;
+
+
+
+public class CollisionResult {
+ public Position3D collisionPoint = new Position3D();
+ public Vector3d normal = new Vector3d();
+ public double length = 0.0;
+}
diff --git a/src/framework/model3D/GeometryUtility.java b/src/framework/model3D/GeometryUtility.java
new file mode 100644
index 0000000..fd0c58a
--- /dev/null
+++ b/src/framework/model3D/GeometryUtility.java
@@ -0,0 +1,267 @@
+package framework.model3D;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+
+import java3d.IndexedGeometryArray;
+import java3d.AxisAngle4d;
+import java3d.Matrix3d;
+import java3d.Point3d;
+import java3d.Vector3d;
+import java3d.Vector4d;
+
+public class GeometryUtility {
+ public static final double TOLERANCE = 0.0000002;
+ public static final Vector3d X_AXIS = new Vector3d(1.0, 0.0, 0.0);
+ public static final Vector3d Y_AXIS = new Vector3d(0.0, 1.0, 0.0);
+ public static final Vector3d Z_AXIS = new Vector3d(0.0, 0.0, 1.0);
+
+ public static ProjectionResult projection3D(
+ ArrayList vertex3Dlist, Vector3d axis) {
+ double k = 0.0;
+ int i = 0;
+
+ ProjectionResult pr = new ProjectionResult();
+
+ axis.normalize();
+
+ for (i = 0; i < vertex3Dlist.size(); i++) {
+ Vector3d p = vertex3Dlist.get(i);
+ Vector3d p1 = new Vector3d();
+
+ k = p.dot(axis);
+ p1.scaleAdd(-k, axis, p);
+
+ if (i == 0 || k >= pr.max) {
+ pr.max = k;
+ } else if (i == 0 || k <= pr.min) {
+ pr.min = k;
+ }
+ pr.vertexList.add(p1);
+ }
+ return pr;
+ }
+
+ public static ProjectionResult projection2D(
+ ArrayList vertex2Dlist, Vector3d axis) {
+ int i = 0;
+ double k = 0.0;
+ // System.out.println("point3�F"+axis);
+ if (axis.x != 0 || axis.y != 0 || axis.z != 0) {
+ axis.normalize();
+ }
+ // System.out.println("point3_1�F"+axis);
+ ProjectionResult pr = new ProjectionResult();
+
+ for (i = 0; i < vertex2Dlist.size(); i++) {
+ Vector3d p = vertex2Dlist.get(i);
+
+ k = p.dot(axis);
+ // System.out.println("k�F"+k);
+ // System.out.println("point3�F"+axis);
+ if (i == 0 || k >= pr.max) {
+ pr.max = k;
+ } else if (i == 0 || k <= pr.min) {
+ pr.min = k;
+ }
+ }
+ return pr;
+ }
+
+ // �ȉ��A���_�̕\���̔��胁�\�b�h
+ public static boolean inside(Vector3d v, Vector4d plane) {
+ // System.out.println("vertex:" + v.x + "," + v.y + "," + v.z);
+ // System.out.println("plane:" + plane.x + "," + plane.y + "," + plane.z
+ // + "," + plane.w);
+ Vector3d pv = new Vector3d(plane.x, plane.y, plane.z);
+ // Vector3d nv = (Vector3d)pv.clone();
+ // nv.scaleAdd(plane.w / pv.lengthSquared(),v);
+ if (pv.dot(v) + plane.w <= TOLERANCE) {
+ // System.out.println("��������I�I"+nv.dot(pv));
+ pv = null;
+ return true;
+ }
+ // System.out.println("�O������I�I"+nv.dot(pv));
+ pv = null;
+ return false;
+ }
+
+ /**
+ * 3�_��ʂ镽�ʂ��쐬����i�������Av1, v2, v3�̓��e��������������̂Œ��Ӂj
+ *
+ * @param v1
+ * --- 1�_�ڂ̍��W
+ * @param v2
+ * --- 2�_�ڂ̍��W
+ * @param v3
+ * --- 3�_�ڂ̍��W
+ * @return�@v1, v2, v3��ʂ镽��
+ */
+ public static Vector4d createPlane(Vector3d v1, Vector3d v2, Vector3d v3) {
+ v2.sub(v1);
+ v3.sub(v1);
+ v2.cross(v2, v3);
+ v2.normalize();
+ return new Vector4d(v2.x, v2.y, v2.z, -v2.dot(v1));
+ }
+
+ /**
+ *
+ * ���ʂƒ����̌�_�����߂�
+ *
+ * @param plane
+ * ����
+ * @param v1
+ * ������̓_1
+ * @param v2
+ * ������̓_2
+ * @return ��_
+ */
+ public static Vector3d intersect(Vector4d plane, Vector3d v1, Vector3d v2) {
+ Vector3d n = new Vector3d(plane.x, plane.y, plane.z);
+ Vector3d v21 = (Vector3d) v2.clone();
+ v21.sub(v1);
+ v21.scale((-plane.w - n.dot(v1)) / n.dot(v21));
+ v21.add(v1);
+ return v21;
+ }
+
+ /**
+ *
+ * �w�肳�ꂽ�_���ʃ|���S���̓����ɕ�܂���Ă��邩�H
+ *
+ * @param vertexList
+ * �ʃ|���S���̒��_��
+ * @param point
+ * �w��_
+ * @return true --- ��܂���Ă���, false --- ��܂���Ă��Ȃ�
+ */
+ public static boolean inside(ArrayList vertexList, Vector3d point, Vector3d normal) {
+ boolean inside = true;
+ for (int i = 0; i < vertexList.size(); i++) {
+ // �|���S���̊e�ӂɑ��ďՓ˓_���E�����������H
+ Vector3d center = (Vector3d) point.clone();
+ Vector3d v2 = (Vector3d) (vertexList.get((i + 1)
+ % vertexList.size()).clone());
+ Vector3d v1 = (Vector3d) vertexList.get(i).clone();
+ center.sub(v1);
+ v2.sub(v1);
+ v1.cross(v2, center);
+ if (normal.dot(v1) < -GeometryUtility.TOLERANCE) {
+ inside = false;
+ break;
+ }
+ }
+ // ���ׂĉE���A�܂��͂��ׂč����������ꍇ�A�ʃ|���S���̓����Ɉʒu�����ƍl����
+ return inside;
+ }
+
+ // IndexedGeometryArray�̃C���f�b�N�X�̂����A�������W�������C���f�b�N�X��u��������
+ public static void compressGeometry(IndexedGeometryArray g) {
+ // �@Hashtable�����Ȃ���Arepresentation[]�����
+ Hashtable> h = new Hashtable>();
+ Point3d p = new Point3d();
+ Point3d p2 = new Point3d();
+ double hash;
+ ArrayList list;
+ int[] representation = new int[g.getVertexCount()];
+
+ for (int i = 0; i < g.getVertexCount(); i++) {
+ g.getCoordinate(i, p);
+
+ hash = p.getX() + p.getY() + p.getZ();
+
+ list = h.get(new Double(hash));
+
+ if (list == null) {// hash�ɑΉ�����v�f���Ȃ��ꍇ
+ // Hashtable�����
+ list = new ArrayList();
+ list.add(new Integer(i));
+ h.put(new Double(hash), list);
+ // representation[]�����
+ representation[i] = i;
+ } else {
+ boolean bFound = false;
+ for (int j = 0; j < list.size(); j++) {
+ g.getCoordinate(list.get(j).intValue(), p2);
+ if (p.getX() == p2.getX() && p.getY() == p2.getY()
+ && p.getZ() == p2.getZ()) {
+ representation[i] = list.get(j).intValue();
+ bFound = true;
+ break;
+ }
+ }
+ if (!bFound) {
+ list.add(new Integer(i));
+ // representation[]�����
+ representation[i] = i;
+ }
+ }
+ }
+
+ // �Aindex�̒u������
+ for (int i = 0; i < g.getIndexCount(); i++) {
+ int index = representation[g.getCoordinateIndex(i)];
+ g.setCoordinateIndex(i, index);
+
+ }
+
+ }
+
+ public static Matrix3d calcRotationForView(Vector3d viewLine) {
+ Vector3d v1 = (Vector3d)viewLine.clone();
+ v1.normalize();
+ Vector3d v2 = new Vector3d();
+ v2.cross(v1, Y_AXIS);
+ double angle2 = Math.atan2(-v2.z, v2.x);
+ double angle1 = Math.PI / 2.0 - Math.acos(v1.dot(Y_AXIS));
+ Matrix3d rot1 = new Matrix3d();
+ rot1.rotX(angle1);
+ Matrix3d rot2 = new Matrix3d();
+ rot2.rotY(angle2);
+ rot2.mul(rot1);
+ return rot2;
+ }
+
+ public static Quaternion3D calcQuaternionForView(Vector3d viewLine) {
+ Vector3d v1 = (Vector3d)viewLine.clone();
+ v1.normalize();
+ Vector3d v2 = new Vector3d();
+ v2.cross(v1, Y_AXIS);
+ double angle2 = Math.atan2(-v2.z, v2.x);
+ double angle1 = Math.PI / 2.0 - Math.acos(v1.dot(Y_AXIS));
+ Quaternion3D quat1 = new Quaternion3D(new AxisAngle4d(X_AXIS, angle1));
+ Quaternion3D quat2 = new Quaternion3D(new AxisAngle4d(Y_AXIS, angle2));
+
+ return quat1.mul(quat2);
+ }
+
+ public static Quaternion3D calcQuaternionFromSrcToDst(Vector3d src, Vector3d dst) {
+ Vector3d v1 = new Vector3d();
+ Vector3d v2 = new Vector3d();
+ v1.cross(src, Y_AXIS);
+ v2.cross(dst, Y_AXIS);
+ Quaternion3D quat1;
+ Quaternion3D quat2;
+ double angle2 = Math.acos(Y_AXIS.dot(src) / src.length()) - Math.acos(Y_AXIS.dot(dst) / dst.length());
+ if (Math.abs(v2.length()) < TOLERANCE) {
+ v1.normalize();
+ quat1 = new Quaternion3D();
+ quat2 = new Quaternion3D(new AxisAngle4d(v1, angle2));
+ } else {
+ if (Math.abs(v1.length()) < TOLERANCE) {
+ quat1 = new Quaternion3D();
+ } else {
+ v1.normalize();
+ v2.normalize();
+ double cos1 = v1.dot(v2);
+ v1.cross(v1, v2);
+ double sin1 = v1.dot(Y_AXIS);
+ double angle1 = Math.atan2(sin1, cos1);
+ quat1 = new Quaternion3D(new AxisAngle4d(Y_AXIS, angle1));
+ }
+ quat2 = new Quaternion3D(new AxisAngle4d(v2, angle2));
+ }
+ return quat1.mul(quat2);
+ }
+}
\ No newline at end of file
diff --git a/src/framework/model3D/Model3D.java b/src/framework/model3D/Model3D.java
new file mode 100644
index 0000000..88dd9ff
--- /dev/null
+++ b/src/framework/model3D/Model3D.java
@@ -0,0 +1,9 @@
+package framework.model3D;
+
+
+
+public abstract class Model3D {
+ String name;
+ public abstract Object3D createObject();
+ public abstract Object3D createObjectSharingAppearance();
+}
diff --git a/src/framework/model3D/OBB.java b/src/framework/model3D/OBB.java
new file mode 100644
index 0000000..90b2530
--- /dev/null
+++ b/src/framework/model3D/OBB.java
@@ -0,0 +1,345 @@
+package framework.model3D;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+
+import java3d.BoundingPolytope;
+import java3d.BoundingSphere;
+import java3d.Transform3D;
+import java3d.Matrix4d;
+import java3d.Point3d;
+import java3d.Vector3d;
+import java3d.Vector4d;
+
+
+public class OBB implements Cloneable {
+ public ArrayList vertexList = new ArrayList();
+ public Vector4d[] plane = new Vector4d[6];
+ public BoundingPolytope bp = null;
+ public static int edges[][] = { { 0, 1 }, { 0, 2 }, { 1, 3 }, { 2, 3 },
+ { 0, 4 }, { 1, 5 }, { 3, 7 }, { 2, 6 }, { 4, 5 }, { 4, 6 },
+ { 5, 7 }, { 6, 7 } };
+ static boolean[][] inside = new boolean[8][6];
+ static boolean[] inside2 = new boolean[8];
+
+ public OBB() {
+ }
+
+ public OBB(Vector3d v1, Vector3d v2, Vector3d v3, Vector3d v4,
+ Vector3d v5, Vector3d v6, Vector3d v7, Vector3d v8) {
+ vertexList.add(v1);
+ vertexList.add(v2);
+ vertexList.add(v3);
+ vertexList.add(v4);
+ vertexList.add(v5);
+ vertexList.add(v6);
+ vertexList.add(v7);
+ vertexList.add(v8);
+ createPlanes();
+ }
+
+ public void addVertex(Vector3d v) {
+ vertexList.add(v);
+ }
+
+ public Vector3d getVertex(int i) {
+ return vertexList.get(i);
+ }
+
+ public BoundingSphere getBoundingSphere() {
+ double radius = 0.0;
+ Point3d p = new Point3d();
+ Vector3d cv = new Vector3d();
+ for (int i = 0; i < vertexList.size() - 1; i++) {
+ for (int j = i + 1; j < vertexList.size(); j++) {
+ Vector3d v = new Vector3d();
+ v.sub(vertexList.get(i), vertexList.get(j));
+ if (radius < v.length()) {
+ radius = v.length();
+ cv.add(vertexList.get(i), vertexList.get(j));
+ cv.scale(0.5);
+ p.x = cv.x;
+ p.y = cv.y;
+ p.z = cv.z;
+ }
+ }
+ }
+ BoundingSphere s = new BoundingSphere(p, radius / 2);
+ return s;
+ }
+
+ /**
+ * ���_�������ɖʂ���ы��E���ʑ̂�����
+ */
+ public void createPlanes() {
+ // �ʂ̍쐬
+ Vector3d v1 = new Vector3d();
+ Vector3d v2 = new Vector3d();
+ Vector3d v3 = new Vector3d();
+ Vector4d[] plane = new Vector4d[6];
+
+ // 0231
+ v1 = vertexList.get(0);
+ v2.sub(vertexList.get(2), vertexList.get(0));
+ v3.sub(vertexList.get(1), vertexList.get(0));
+ Vector3d n = new Vector3d();
+ n.cross(v2, v3);
+ n.normalize();
+ plane[0] = new Vector4d();
+ plane[0].set(n.x, n.y, n.z, -n.dot(v1));
+
+
+ // 0154
+ v1 = vertexList.get(0);
+ v2.sub(vertexList.get(1), vertexList.get(0));
+ v3.sub(vertexList.get(4), vertexList.get(0));
+ n = new Vector3d();
+ n.cross(v2, v3);
+ n.normalize();
+ plane[1] = new Vector4d();
+ plane[1].set(n.x, n.y, n.z, -n.dot(v1));
+
+ // 1375
+ v1 = vertexList.get(1);
+ v2.sub(vertexList.get(3), vertexList.get(1));
+ v3.sub(vertexList.get(5), vertexList.get(1));
+ n = new Vector3d();
+ n.cross(v2, v3);
+ n.normalize();
+ plane[2] = new Vector4d();
+ plane[2].set(n.x, n.y, n.z, -n.dot(v1));
+
+ // 4576
+ v1 = vertexList.get(6);
+ v2.sub(vertexList.get(4), vertexList.get(6));
+ v3.sub(vertexList.get(7), vertexList.get(6));
+ n = new Vector3d();
+ n.cross(v2, v3);
+ n.normalize();
+ plane[3] = new Vector4d();
+ plane[3].set(n.x, n.y, n.z, -n.dot(v1));
+
+ // 0462
+ v1 = vertexList.get(6);
+ v2.sub(vertexList.get(2), vertexList.get(6));
+ v3.sub(vertexList.get(4), vertexList.get(6));
+ n = new Vector3d();
+ n.cross(v2, v3);
+ n.normalize();
+ plane[4] = new Vector4d();
+ plane[4].set(n.x, n.y, n.z, -n.dot(v1));
+
+ // 2673
+ v1 = vertexList.get(6);
+ v2.sub(vertexList.get(7), vertexList.get(6));
+ v3.sub(vertexList.get(2), vertexList.get(6));
+ n = new Vector3d();
+ n.cross(v2, v3);
+ n.normalize();
+ plane[5] = new Vector4d();
+ plane[5].set(n.x, n.y, n.z, -n.dot(v1));
+
+ this.plane = plane;
+
+ bp = new BoundingPolytope();
+ bp.setPlanes(plane);
+ }
+
+ /**
+ * ���ʂƂ̏Փ˔���
+ * @param plane �Փ˔���̑ΏۂƂȂ镽��
+ * @return �Փ˔���̌��ʁi�Փ˂��Ă��Ȃ��ꍇ��null�j
+ */
+ public CollisionResult intersect(Vector4d plane) {
+ int i = 0;
+ boolean inside = false;
+ boolean outside = false;
+ int count = 0;
+ Vector3d center = new Vector3d(0, 0, 0);
+ double l = Math.sqrt(plane.x * plane.x + plane.y * plane.y + plane.z * plane.z);
+ double length;
+ double deepest = 0.0;
+ Vector3d v;
+ for (i = 0; i < vertexList.size(); i++) {
+ v = vertexList.get(i);
+ if (GeometryUtility.inside(v, plane)) {
+ inside = true;
+ length = -(v.x * plane.x + v.y * plane.y + v.z * plane.z + plane.w) / l;
+ if (length > deepest + GeometryUtility.TOLERANCE) {
+ center.set(v);
+ count = 1;
+ deepest = length;
+ } else if (length >= deepest - GeometryUtility.TOLERANCE) {
+ center.add(v);
+ count++;
+ }
+ } else {
+ outside = true;
+ }
+ }
+
+ if (!inside || !outside) {
+ // �S���_���O�����S���_�������̏ꍇ
+ return null;
+ }
+
+ center.scale(1.0 / count);
+
+ CollisionResult cr = new CollisionResult();
+ cr.length = deepest;
+ cr.collisionPoint.setX(center.x);
+ cr.collisionPoint.setY(center.y);
+ cr.collisionPoint.setZ(center.z);
+ cr.normal.setX(plane.x / l);
+ cr.normal.setY(plane.y / l);
+ cr.normal.setZ(plane.z / l);
+
+ return cr;
+ }
+
+ /**
+ * OBB�Ƃ̏Փ˔���
+ * @param o �Փ˔���̑ΏۂƂȂ�OBB
+ * @return �Փ˔���̌��ʁi�Փ˂��Ă��Ȃ��ꍇ��null�j
+ */
+ public CollisionResult intersect(OBB o) {
+ // o�̊e���_��this�̊e�ʂ̓����ɂ��邩�ׂ�
+ // i�F���_ j�F��
+ for (int i = 0; i < o.vertexList.size(); i++) {
+ for (int j = 0; j < plane.length; j++) {
+ inside[i][j] = GeometryUtility.inside(o.vertexList.get(i), plane[j]);
+ }
+ }
+
+ boolean collision = false;
+ int count = 0;
+ Vector3d center = new Vector3d(0, 0, 0);
+
+ // o�̊e���_��this�ɕ�܂���Ă��邩�H
+ for (int v = 0; v < 8; v++) {
+ boolean f1 = false;
+ for (int p = 0; p < 6; p++) {
+ f1 = inside[v][p];
+ if (!f1) {
+ break;
+ }
+ }
+ inside2[v] = f1;
+ if (f1) {
+ collision = true;
+ center.add(o.vertexList.get(v));
+ count++;
+ }
+ }
+
+ if (!collision) {
+ // �ӂ�����̖ʂƌ�����Ă��邩�H
+ for (int p = 0; p < 6; p++) {
+ Vector3d intersection = null;
+ for (int e = 0; e < 12; e++) {
+ if (inside[edges[e][0]][p] == !inside[edges[e][1]][p]) {
+ intersection = GeometryUtility.intersect(
+ plane[p],
+ o.vertexList.get(edges[e][0]),
+ o.vertexList.get(edges[e][1]));
+ boolean bInside = true;
+ for (int p2 = 0; p2 < 6; p2++) {
+ if (p != p2
+ && !GeometryUtility.inside(intersection, plane[p2])) {
+ bInside = false;
+ break;
+ }
+ }
+ if (bInside) {
+ collision = true;
+ center.add(intersection);
+ count++;
+ }
+ }
+ }
+ }
+ }
+
+ if (!collision)
+ return null;
+
+ center.scale(1.0 / count);
+
+ CollisionResult cr = new CollisionResult();
+
+ double lMin = 0;
+ int cm = -1;
+ Vector3d normal = null;
+ for (int m = 0; m < plane.length; m++) {
+ Vector3d n = new Vector3d(plane[m].x, plane[m].y, plane[m].z);
+ double l = -(center.x * plane[m].x + center.y * plane[m].y + center.z
+ * plane[m].z + plane[m].w) / n.length();
+ if (lMin > l || cm == -1) {
+ lMin = l;
+ cm = m;
+ normal = n;
+ }
+ }
+ cr.length = lMin;
+ cr.collisionPoint.setVector3d(center);
+ cr.normal.setX(plane[cm].x / normal.length());
+ cr.normal.setY(plane[cm].y / normal.length());
+ cr.normal.setZ(plane[cm].z / normal.length());
+
+ return cr;
+
+ }
+
+ public Object clone() {
+ OBB obb = new OBB();
+ obb.plane = new Vector4d[6];
+ for (int i = 0; i < plane.length; i++) {
+ obb.plane[i] = (Vector4d) plane[i].clone();
+ }
+ for (int i = 0; i < vertexList.size(); i++) {
+ obb.vertexList.add((Vector3d) vertexList.get(i).clone());
+ }
+ obb.bp = new BoundingPolytope(obb.plane);
+
+ // System.out.println("veretexListSIZE:"+vertexList.size());
+ return obb;
+ }
+
+ public void transform(Transform3D t) {
+ // TODO Auto-generated method stub
+ bp.transform(t);
+ bp.getPlanes(plane);
+ // for(int i = 0; i" + plane[i].x + "," + plane[i].y + "," +
+ // plane[i].z + "," + plane[i].w);
+ // }
+ for (int i = 0; i < vertexList.size(); i++) {
+ // System.out.println("vertex");
+ // System.out.print(vertexList.get(i).x + "," + vertexList.get(i).y
+ // + "," + vertexList.get(i).z);
+ Matrix4d mat4d = new Matrix4d();
+ t.get(mat4d);
+ double x = mat4d.m00 * vertexList.get(i).x + mat4d.m01
+ * vertexList.get(i).y + mat4d.m02 * vertexList.get(i).z
+ + mat4d.m03;
+ double y = mat4d.m10 * vertexList.get(i).x + mat4d.m11
+ * vertexList.get(i).y + mat4d.m12 * vertexList.get(i).z
+ + mat4d.m13;
+ double z = mat4d.m20 * vertexList.get(i).x + mat4d.m21
+ * vertexList.get(i).y + mat4d.m22 * vertexList.get(i).z
+ + mat4d.m23;
+ vertexList.get(i).x = x;
+ vertexList.get(i).y = y;
+ vertexList.get(i).z = z;
+ // t.transform(vertexList.get(i));
+ // System.out.println("-->" + vertexList.get(i).x + "," +
+ // vertexList.get(i).y + "," + vertexList.get(i).z);
+ }
+ }
+}
diff --git a/src/framework/model3D/Object3D.java b/src/framework/model3D/Object3D.java
new file mode 100644
index 0000000..d0ad0d5
--- /dev/null
+++ b/src/framework/model3D/Object3D.java
@@ -0,0 +1,519 @@
+package framework.model3D;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+
+import java3d.Appearance;
+import java3d.AxisAngle4d;
+import java3d.BoundingSphere;
+import java3d.Box;
+import java3d.Cone;
+import java3d.Cylinder;
+import java3d.Geometry;
+import java3d.GeometryStripArray;
+import java3d.IndexedGeometryArray;
+import java3d.Leaf;
+import java3d.Node;
+import java3d.Primitive;
+import java3d.Quat4d;
+import java3d.Shape3D;
+import java3d.Sphere;
+import java3d.Transform3D;
+import java3d.TransformGroup;
+import java3d.TriangleArray;
+import java3d.Vector3d;
+
+
+public class Object3D extends BaseObject3D {
+ public String name;
+ public TransformGroup pos;
+ public TransformGroup rot;
+ public TransformGroup scale;
+ public Object3D[] children;
+ private Position3D position;
+ protected Quaternion3D quaternion;
+
+ private OBB obb = new OBB();
+// private boolean bLOD = false;
+// private LOD lodNode = null;
+
+ public BoundingSphere bs = null;
+ private UndoBuffer undoBuffer = new UndoBuffer();
+
+ public Object3D(String name, Primitive prim) {
+ init(name);
+ center.addChild(prim);
+ }
+
+ public Object3D(String name, Leaf node) {
+ init(name);
+ center.addChild(node);
+ }
+
+ public Object3D(String name, Object3D[] children) {
+ init(name);
+ this.children = children;
+ for (int i = 0; i < children.length; i++) {
+ center.addChild(children[i].getTransformGroupToPlace());
+ }
+ }
+
+ // �R�s�[�R���X�g���N�^
+ public Object3D(Object3D obj) {
+ this.name = new String(obj.name);
+ if (obj.position != null) {
+ this.position = new Position3D(obj.position);
+ } else {
+ this.position = new Position3D();
+ }
+ if (obj.getQuaternion() != null) {
+ this.quaternion = new Quaternion3D(obj.getQuaternion());
+ } else {
+ this.quaternion = new Quaternion3D();
+ }
+ Transform3D transPos = new Transform3D();
+ obj.pos.getTransform(transPos);
+ this.pos = new TransformGroup(transPos);
+ Transform3D transRot = new Transform3D();
+ obj.rot.getTransform(transRot);
+ this.rot = new TransformGroup(transRot);
+ Transform3D transScale = new Transform3D();
+ obj.scale.getTransform(transScale);
+ this.scale = new TransformGroup(transScale);
+ Transform3D transCenter = new Transform3D();
+ obj.center.getTransform(transCenter);
+ this.center = new TransformGroup(transCenter);
+ this.pos.addChild(this.rot);
+ this.rot.addChild(this.scale);
+ this.scale.addChild(this.center);
+// this.pos.addChild(this.scale);
+//// this.rot.addChild(this.scale);
+// this.scale.addChild(this.center);
+ if (obj.hasChildren()) {
+ this.children = new Object3D[obj.children.length];
+ for (int i = 0; i < obj.children.length; i++) {
+ this.children[i] = new Object3D(obj.children[i]);
+ this.center.addChild(this.children[i].pos);
+ }
+ } else {
+ this.children = new Object3D[0];
+ Enumeration nodes = obj.getPrimitiveNodes();
+ while (nodes.hasMoreElements()) {
+ Node node = nodes.nextElement();
+ if (node != null && node instanceof Shape3D) {
+ Shape3D shape = (Shape3D)node;
+ Appearance a = (Appearance)shape.getAppearance().cloneNodeComponent();
+ this.center.addChild(new Shape3D((Geometry) shape.getGeometry(), a));
+ } else if (node != null && node instanceof Primitive) {
+ Primitive primitive = (Primitive)node;
+ primitive = (Primitive)primitive.cloneTree();
+ this.center.addChild(primitive);
+ }
+ }
+ }
+ if (obj.obb != null) {
+ this.obb = obj.obb;
+ }
+ if (obj.bs != null) {
+ this.bs = obj.bs;
+ }
+ this.undoBuffer = new UndoBuffer(obj.undoBuffer);
+ }
+
+ protected void init(String name) {
+ this.name = new String(name);
+ pos = new TransformGroup();
+ rot = new TransformGroup();
+ scale = new TransformGroup();
+ center = new TransformGroup();
+ pos.addChild(rot);
+ rot.addChild(scale);
+ scale.addChild(center);
+ }
+
+ public Node getPrimitiveNode() {
+ if (hasChildren()) return null;
+// if (!bLOD) {
+ return (Node)center.getChild(0);
+ // TODO ������
+// } else {
+// // LOD �̏ꍇ
+// return lodNode.getSwitch(0).getChild(0);
+// }
+ }
+
+ public Enumeration getPrimitiveNodes() {
+ if (hasChildren()) return null;
+// if (!bLOD) {
+ return (Enumeration)center.getAllChildren();
+ // TODO ������
+// } else {
+// // LOD �̏ꍇ
+// return lodNode.getSwitch(0).getAllChildren();
+// }
+ }
+
+ @Override
+ public TransformGroup getTransformGroupToPlace() {
+ return pos;
+ }
+
+ public void setPosition(Position3D p) {
+ position = (Position3D) p.clone();
+ Vector3d v = new Vector3d(p.getX(), p.getY(), p.getZ());
+ Transform3D trans = new Transform3D();
+ trans.set(v);
+ pos.setTransform(trans);
+ }
+
+ public Position3D getPosition3D() {
+ return (Position3D) position.clone();
+ }
+
+ public void scale(double s) {
+ Transform3D trans = new Transform3D();
+ trans.setScale(s);
+ scale.setTransform(trans);
+ }
+
+ public void scale(double x, double y, double z) {
+ Transform3D trans = new Transform3D();
+ trans.setScale(new Vector3d(x, y, z));
+ scale.setTransform(trans);
+ }
+
+ // �L�����N�^�[����]������
+ public void rotate(double vx, double vy, double vz, double a) {
+ AxisAngle4d t = new AxisAngle4d(vx, vy, vz, a);
+ Transform3D trans = new Transform3D();
+ trans.setRotation(t);
+ rot.setTransform(trans);
+ }
+
+ public void apply(Property3D p, boolean enableUndo) {
+ if (enableUndo) {
+ undoBuffer.push(p);
+ }
+ p.applyTo(this);
+ }
+
+// undo����|�C���g��ݒ肷��B
+ public void setUndoMark() {
+ undoBuffer.setUndoMark();
+ }
+
+// undo����B
+ public void undo() {
+ Iterator iterator = undoBuffer.undo().iterator();
+ while (iterator.hasNext()) {
+ Property3D p = iterator.next();
+ p.applyTo(this);
+ }
+ }
+
+ // object�Ɏq�������邩�ǂ����ׂ�
+ public boolean hasChildren() {
+ if (this.children != null && this.children.length > 0)
+ return true;
+ else
+ return false;
+ }
+
+ /**
+ * ���i�I�u�W�F�N�g��T��
+ * @param partName�@���i��
+ * @return�@partName �������i�I�u�W�F�N�g
+ */
+ public Object3D getPart(String partName) {
+ if (partName.equals(this.name)) return this;
+
+ for (int i = 0; i < children.length; i++) {
+ if (children[i] != null) {
+ Object3D obj = children[i].getPart(partName);
+ if (obj != null) return obj;
+ }
+ }
+ return null;
+ }
+
+ protected void rotate(Quat4d quat) {
+ Transform3D trans = new Transform3D();
+ trans.setRotation(quat);
+ rot.setTransform(trans);
+ }
+
+ public void accept(ObjectVisitor objectVisitor) {
+ int i;
+ objectVisitor.preVisit(this);
+ if (children != null) {
+ for (i = 0; i < children.length; i++)
+ children[i].accept(objectVisitor);
+ }
+ objectVisitor.postVisit(this);
+ }
+
+ // Quaternion3D �� applyTo() �ȊO����͌ĂȂ�����
+ void setQuaternion(Quaternion3D quaternion) {
+ this.quaternion = quaternion;
+ rotate(quaternion.getQuat());
+ }
+
+ public Quaternion3D getQuaternion() {
+ return quaternion;
+ }
+
+ public OBB getOBB(int pattern) {
+ if (obb == null || obb.bp == null) {
+ Node node = getPrimitiveNode();
+ if (node == null) return null;
+ if (node instanceof Box) {
+ // Box�̏ꍇ
+ Box box = ((Box)node);
+ double xDim = box.getXdimension();
+ double yDim = box.getYdimension();
+ double zDim = box.getZdimension();
+ obb = new OBB(new Vector3d(-xDim, -yDim, -zDim),
+ new Vector3d(-xDim, yDim, -zDim),
+ new Vector3d(-xDim, -yDim, zDim),
+ new Vector3d(-xDim, yDim, zDim),
+ new Vector3d(xDim, -yDim, -zDim),
+ new Vector3d(xDim, yDim, -zDim),
+ new Vector3d(xDim, -yDim, zDim),
+ new Vector3d(xDim, yDim, zDim));
+ } else if (node instanceof Cylinder) {
+ // Cylinder�̏ꍇ
+ Cylinder cylinder = ((Cylinder)node);
+ double xDim = cylinder.getRadius();
+ double yDim = cylinder.getHeight() / 2;
+ double zDim = cylinder.getRadius();
+ obb = new OBB(new Vector3d(-xDim, -yDim, -zDim),
+ new Vector3d(-xDim, yDim, -zDim),
+ new Vector3d(-xDim, -yDim, zDim),
+ new Vector3d(-xDim, yDim, zDim),
+ new Vector3d(xDim, -yDim, -zDim),
+ new Vector3d(xDim, yDim, -zDim),
+ new Vector3d(xDim, -yDim, zDim),
+ new Vector3d(xDim, yDim, zDim));
+ } else if (node instanceof Cone) {
+ // Cone�̏ꍇ
+ Cone cone = ((Cone)node);
+ double xDim = cone.getRadius();
+ double yDim = cone.getHeight() / 2;
+ double zDim = cone.getRadius();
+ obb = new OBB(new Vector3d(-xDim, -yDim, -zDim),
+ new Vector3d(-xDim, yDim, -zDim),
+ new Vector3d(-xDim, -yDim, zDim),
+ new Vector3d(-xDim, yDim, zDim),
+ new Vector3d(xDim, -yDim, -zDim),
+ new Vector3d(xDim, yDim, -zDim),
+ new Vector3d(xDim, -yDim, zDim),
+ new Vector3d(xDim, yDim, zDim));
+ } else if (node instanceof Sphere) {
+ // Sphere�̏ꍇ
+ Sphere sphere = ((Sphere)node);
+ double xDim = sphere.getRadius();
+ double yDim = sphere.getRadius();
+ double zDim = sphere.getRadius();
+ obb = new OBB(new Vector3d(-xDim, -yDim, -zDim),
+ new Vector3d(-xDim, yDim, -zDim),
+ new Vector3d(-xDim, -yDim, zDim),
+ new Vector3d(-xDim, yDim, zDim),
+ new Vector3d(xDim, -yDim, -zDim),
+ new Vector3d(xDim, yDim, -zDim),
+ new Vector3d(xDim, -yDim, zDim),
+ new Vector3d(xDim, yDim, zDim));
+ } else {
+ if (!(node instanceof Shape3D)) return null;
+ // Shape3D�̏ꍇ
+ Shape3D shape = (Shape3D)node;
+ double coordinate[] = new double[3];
+
+ // OBB�̍쐬�ɗp���钸�_��̎擾
+ ArrayList vertex3DList = new ArrayList();
+ if (shape.getGeometry() instanceof IndexedGeometryArray) {
+ // IndexedGeometryArray�̏ꍇ
+ IndexedGeometryArray iga = (IndexedGeometryArray) shape.getGeometry();
+ for (int i = 0; i < iga.getIndexCount() - 3; i++) {
+ iga.getCoordinates(iga.getCoordinateIndex(i), coordinate);
+ Vector3d p = new Vector3d(coordinate[0], coordinate[1], coordinate[2]);
+ vertex3DList.add(p);
+ }
+ } else if (shape.getGeometry() instanceof GeometryStripArray) {
+ // GeometryStripArray�̏ꍇ
+ GeometryStripArray gsa = (GeometryStripArray) shape.getGeometry();
+ for (int i = 0; i < gsa.getVertexCount(); i++) {
+ gsa.getCoordinates(i, coordinate);
+ Vector3d p = new Vector3d(coordinate[0], coordinate[1], coordinate[2]);
+ vertex3DList.add(p);
+ }
+ } else if (shape.getGeometry() instanceof TriangleArray) {
+ // TriangleArray�̏ꍇ
+ TriangleArray tra = (TriangleArray) shape.getGeometry();
+ for (int i = 0; i < tra.getVertexCount(); i++) {
+ tra.getCoordinates(i, coordinate);
+ Vector3d p = new Vector3d(coordinate[0], coordinate[1], coordinate[2]);
+ vertex3DList.add(p);
+ }
+ }
+
+ if (pattern == 0) {
+ // �ő�ʐϖ@
+ Vector3d cv1 = new Vector3d();
+ Vector3d cv2 = new Vector3d();
+
+ double cvMax = 0.0;
+ Vector3d axis1 = new Vector3d(); // 3D���_���狁�߂��@���x�N�g��
+ Vector3d axis2 = new Vector3d(); // 2D���_���狁�߂��@���x�N�g��
+ Vector3d axis3 = new Vector3d(); // axis1,axis2�̊O�ς��狁�߂��@���x�N�g��
+
+ // �ʐς�3D���_���X�g���狁�߁A�@�������߂鏈��
+ for (int i = 0; i < vertex3DList.size(); i += 3) {
+ cv1.sub(vertex3DList.get(i + 2), vertex3DList.get(i));
+ cv2.sub(vertex3DList.get(i + 1), vertex3DList.get(i));
+ Vector3d cv = new Vector3d();
+ cv.cross(cv1, cv2);
+ if (i == 0 || cv.length() >= cvMax) {
+ cvMax = cv.length();
+ axis1 = cv;
+ }
+ }
+
+ ProjectionResult pr1 = GeometryUtility.projection3D(vertex3DList, axis1);
+ // �ӂ̂�2D���_���X�g���狁�߁A�@�������߂鏈��
+ for (int i = 0; i < pr1.vertexList.size() - 1; i++) {
+ Vector3d cv = new Vector3d();
+ cv.sub(vertex3DList.get(i + 1), vertex3DList.get(i));
+ if (i == 0 || cv.length() >= cvMax) {
+ cvMax = cv.length();
+ axis2 = cv;
+ }
+ }
+
+
+ ProjectionResult pr2 = GeometryUtility.projection2D(pr1.vertexList, axis2);
+ // axis1,axis2�ŊO�ς�axis3�����߂�B
+ axis3.cross(axis1, axis2);
+
+ ProjectionResult pr3 = GeometryUtility.projection2D(pr1.vertexList, axis3);
+ AxisResult ar = new AxisResult(axis1, axis2, axis3);
+
+ // ��������ő�ʐϖ@�ŋ��߂��_���擾���Ă�������
+
+ // OBB�̐���
+ obb = new OBB();
+
+ // No.1
+ ar.axis1.scale(pr1.min);
+ ar.axis2.scale(pr2.min);
+ ar.axis3.scale(pr3.min);
+ ar.axis1.add(ar.axis2);
+ ar.axis3.add(ar.axis1);
+ obb.addVertex(ar.axis3);
+
+ // No.2
+ ar = new AxisResult(axis1, axis2, axis3);
+ ar.axis1.scale(pr1.min);
+ ar.axis2.scale(pr2.max);
+ ar.axis3.scale(pr3.min);
+ ar.axis1.add(ar.axis2);
+ ar.axis3.add(ar.axis1);
+ obb.addVertex(ar.axis3);
+
+ // No.3
+ ar = new AxisResult(axis1, axis2, axis3);
+ ar.axis1.scale(pr1.min);
+ ar.axis2.scale(pr2.min);
+ ar.axis3.scale(pr3.max);
+ ar.axis1.add(ar.axis2);
+ ar.axis3.add(ar.axis1);
+ obb.addVertex(ar.axis3);
+
+ // No.4
+ ar = new AxisResult(axis1, axis2, axis3);
+ ar.axis1.scale(pr1.min);
+ ar.axis2.scale(pr2.max);
+ ar.axis3.scale(pr3.max);
+ ar.axis1.add(ar.axis2);
+ ar.axis3.add(ar.axis1);
+ obb.addVertex(ar.axis3);
+
+ // No.5
+ ar = new AxisResult(axis1, axis2, axis3);
+ ar.axis1.scale(pr1.max);
+ ar.axis2.scale(pr2.min);
+ ar.axis3.scale(pr3.min);
+ ar.axis1.add(ar.axis2);
+ ar.axis3.add(ar.axis1);
+ obb.addVertex(ar.axis3);
+
+ // No.6
+ ar = new AxisResult(axis1, axis2, axis3);
+ ar.axis1.scale(pr1.max);
+ ar.axis2.scale(pr2.max);
+ ar.axis3.scale(pr3.min);
+ ar.axis1.add(ar.axis2);
+ ar.axis3.add(ar.axis1);
+ obb.addVertex(ar.axis3);
+
+ // No.7
+ ar = new AxisResult(axis1, axis2, axis3);
+ ar.axis1.scale(pr1.max);
+ ar.axis2.scale(pr2.min);
+ ar.axis3.scale(pr3.max);
+ ar.axis1.add(ar.axis2);
+ ar.axis3.add(ar.axis1);
+ obb.addVertex(ar.axis3);
+
+ // No.8
+ ar = new AxisResult(axis1, axis2, axis3);
+ ar.axis1.scale(pr1.max);
+ ar.axis2.scale(pr2.max);
+ ar.axis3.scale(pr3.max);
+ ar.axis1.add(ar.axis2);
+ ar.axis3.add(ar.axis1);
+ obb.addVertex(ar.axis3);
+
+ // �ʂ���ы��E���ʑ̂̐���
+ obb.createPlanes();
+ } else {
+ // AABB
+ double minX, maxX, minY, maxY, minZ, maxZ;
+ minX = maxX = vertex3DList.get(0).x;
+ minY = maxY = vertex3DList.get(0).y;
+ minZ = maxZ = vertex3DList.get(0).z;
+ for (int n = 1; n < vertex3DList.size(); n++) {
+ Vector3d v = vertex3DList.get(n);
+ if (minX > v.x) minX = v.x;
+ if (maxX < v.x) maxX = v.x;
+ if (minY > v.y) minY = v.y;
+ if (maxY < v.y) maxY = v.y;
+ if (minZ > v.z) minZ = v.z;
+ if (maxZ < v.z) maxZ = v.z;
+ }
+ obb = new OBB(new Vector3d(minX, minY, minZ),
+ new Vector3d(minX, maxY, minZ),
+ new Vector3d(minX, minY, maxZ),
+ new Vector3d(minX, maxY, maxZ),
+ new Vector3d(maxX, minY, minZ),
+ new Vector3d(maxX, maxY, minZ),
+ new Vector3d(maxX, minY, maxZ),
+ new Vector3d(maxX, maxY, maxZ));
+ }
+ }
+ }
+ return obb;
+ }
+
+ private class AxisResult {
+ Vector3d axis1;
+ Vector3d axis2;
+ Vector3d axis3;
+
+ AxisResult(Vector3d a1, Vector3d a2, Vector3d a3) {
+ axis1 = (Vector3d) a1.clone();
+ axis2 = (Vector3d) a2.clone();
+ axis3 = (Vector3d) a3.clone();
+ }
+ }
+}
diff --git a/src/framework/model3D/ObjectVisitor.java b/src/framework/model3D/ObjectVisitor.java
new file mode 100644
index 0000000..e1df8ad
--- /dev/null
+++ b/src/framework/model3D/ObjectVisitor.java
@@ -0,0 +1,57 @@
+package framework.model3D;
+
+import java.util.ArrayList;
+
+import java3d.Transform3D;
+
+/**
+ * �I�u�W�F�N�g�̊K�w�\�����g���o�[�X����r�W�^�[
+ * @author �V�c����
+ *
+ */
+public abstract class ObjectVisitor {
+ /**
+ * ������K��ߓ_�܂ł̃p�X��ɑ��݂���ϊ��s��
+ */
+ protected ArrayList stackList = new ArrayList();
+
+ /*
+ * �ߓ_�i�I�u�W�F�N�g�j��K�₷�钼�O�ɌĂ�郁�\�b�h
+ * @param obj �K��ߓ_
+ */
+ public abstract void preVisit(Object3D obj);
+ /**
+ * �ߓ_�i�I�u�W�F�N�g��K�₵������ɌĂ�郁�\�b�h�j
+ * @param obj �K��ߓ_
+ */
+ public abstract void postVisit(Object3D obj);
+
+ /**
+ * 1�K�w�������Ƃ��ɕϊ��s��𑝂₷
+ * @param obj�@�V�����K�₵���ߓ_
+ */
+ protected void pushTransform(Object3D obj) {
+ Transform3D transPos = new Transform3D();
+ obj.pos.getTransform(transPos);
+ stackList.add(transPos);
+ Transform3D transRot = new Transform3D();
+ obj.rot.getTransform(transRot);
+ stackList.add(transRot);
+ Transform3D transScale = new Transform3D();
+ obj.scale.getTransform(transScale);
+ stackList.add(transScale);
+ Transform3D transCenter = new Transform3D();
+ obj.center.getTransform(transCenter);
+ stackList.add(transCenter);
+ }
+
+ /**
+ *�@1�K�w���A�����Ƃ��ɕϊ��s��� ���炷
+ */
+ protected void popTransform() {
+ for (int i = 0; i < 4; i++) {
+ stackList.remove(stackList.size() - 1);
+ }
+ }
+
+}
diff --git a/src/framework/model3D/Placeable.java b/src/framework/model3D/Placeable.java
new file mode 100644
index 0000000..c17d485
--- /dev/null
+++ b/src/framework/model3D/Placeable.java
@@ -0,0 +1,13 @@
+package framework.model3D;
+
+import java3d.TransformGroup;
+
+/**
+ * �z�u�ł�����̑S��
+ * @author �V�c����
+ *
+ */
+public interface Placeable {
+ abstract TransformGroup getTransformGroupToPlace();
+ abstract BaseObject3D getBody();
+}
diff --git a/src/framework/model3D/Position3D.java b/src/framework/model3D/Position3D.java
new file mode 100644
index 0000000..16dd800
--- /dev/null
+++ b/src/framework/model3D/Position3D.java
@@ -0,0 +1,151 @@
+package framework.model3D;
+
+import java3d.Vector3d;
+
+/**
+ * ���W�l��\��
+ * @author �V�c����
+ *
+ */
+public class Position3D extends Property3D {
+ private double x;
+ private double y;
+ private double z;
+
+ // �R���X�g���N�^
+ public Position3D() {
+ x = 0.0;
+ y = 0.0;
+ z = 0.0;
+ }
+
+ // �R���X�g���N�^
+ public Position3D(double px, double py, double pz) {
+ x = px;
+ y = py;
+ z = pz;
+ }
+
+ public Position3D(Vector3d v) {
+ x = v.x;
+ y = v.y;
+ z = v.z;
+ }
+
+ // property3D�̒��ۃN���X�߂�
+ public void applyTo(Object3D o) {
+ o.setPosition(this);
+ }
+
+ // �R�s�[�R���X�g���N�^
+ public Position3D(Position3D p) {
+ this.x = p.x;
+ this.y = p.y;
+ this.z = p.z;
+ }
+
+ public Position3D set(double x, double y, double z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ return this;
+ }
+
+ // ���Z
+ public Position3D add(double x, double y, double z) {
+ this.x += x;
+ this.y += y;
+ this.z += z;
+ return this;
+ }
+
+ // ���Z
+ public Position3D add(Position3D p) {
+ this.x += p.x;
+ this.y += p.y;
+ this.z += p.z;
+ return this;
+ }
+
+ // ���Z
+ public Position3D add(Vector3d v) {
+ this.x += v.x;
+ this.y += v.y;
+ this.z += v.z;
+ return this;
+ }
+
+ // ���Z
+ public Position3D sub(double x, double y, double z) {
+ this.x -= x;
+ this.y -= y;
+ this.z -= z;
+ return this;
+ }
+
+ // ���Z
+ public Position3D sub(Position3D p) {
+ this.x -= p.x;
+ this.y -= p.y;
+ this.z -= p.z;
+ return this;
+ }
+
+ // ���Z
+ public Position3D sub(Vector3d v) {
+ this.x -= v.x;
+ this.y -= v.y;
+ this.z -= v.z;
+ return this;
+ }
+
+ // �X�J���[�{
+ public Position3D mul(double d) {
+ this.x *= d;
+ this.y *= d;
+ this.z *= d;
+ return this;
+ }
+
+ public Position3D setX(double x) {
+ this.x = x;
+ return this;
+ }
+
+ public double getX() {
+ return x;
+ }
+
+ public Position3D setY(double y) {
+ this.y = y;
+ return this;
+ }
+
+ public double getY() {
+ return y;
+ }
+
+ public Position3D setZ(double z) {
+ this.z = z;
+ return this;
+ }
+
+ public double getZ() {
+ return z;
+ }
+
+ public Vector3d getVector3d() {
+ return new Vector3d(x, y, z);
+ }
+
+ public Position3D setVector3d(Vector3d v) {
+ x = v.x;
+ y = v.y;
+ z = v.z;
+ return this;
+ }
+
+ public Position3D clone() {
+ return new Position3D(this);
+ }
+}
diff --git a/src/framework/model3D/ProjectionResult.java b/src/framework/model3D/ProjectionResult.java
new file mode 100644
index 0000000..012082d
--- /dev/null
+++ b/src/framework/model3D/ProjectionResult.java
@@ -0,0 +1,10 @@
+package framework.model3D;
+import java.util.ArrayList;
+
+import java3d.Vector3d;
+
+public class ProjectionResult {
+ double max = 0.0;
+ double min = 0.0;
+ ArrayList vertexList = new ArrayList();
+}
diff --git a/src/framework/model3D/Property3D.java b/src/framework/model3D/Property3D.java
new file mode 100644
index 0000000..3b462a0
--- /dev/null
+++ b/src/framework/model3D/Property3D.java
@@ -0,0 +1,7 @@
+package framework.model3D;
+
+public abstract class Property3D{
+ public abstract void applyTo(Object3D o);
+
+ public abstract Property3D clone();
+}
diff --git a/src/framework/model3D/Quaternion3D.java b/src/framework/model3D/Quaternion3D.java
new file mode 100644
index 0000000..a8c3508
--- /dev/null
+++ b/src/framework/model3D/Quaternion3D.java
@@ -0,0 +1,107 @@
+package framework.model3D;
+
+import java3d.AxisAngle4d;
+import java3d.Quat4d;
+
+
+public class Quaternion3D extends Property3D {
+ private Quat4d quaternion;
+
+ // �R���X�g���N�^=============================
+ public Quaternion3D() {
+ AxisAngle4d aa = new AxisAngle4d(0.0, 0.0, 1.0, 0.0);
+ quaternion = new Quat4d();
+ quaternion.set(aa);
+ }
+
+ public Quaternion3D(AxisAngle4d aa) {
+ quaternion = new Quat4d();
+ quaternion.set(aa);
+ }
+
+ public Quaternion3D(double x, double y, double z, double w) {
+ AxisAngle4d aa = new AxisAngle4d(x, y, z, w);
+ quaternion = new Quat4d();
+ quaternion.set(aa);
+ }
+
+ public Quaternion3D(Quaternion3D q) {
+ this.quaternion = (Quat4d) q.getQuat().clone();
+ }
+
+ public Quat4d getQuat() {
+ return quaternion;
+ }
+
+ // �Q�b�^=================================
+ public double getX() {
+ return quaternion.x;
+ }
+
+ public double getY() {
+ return quaternion.y;
+ }
+
+ public double getZ() {
+ return quaternion.z;
+ }
+
+ public double getW() {
+ return quaternion.w;
+ }
+
+ public Quaternion3D getInterpolate(Quaternion3D q, double alpha) {
+ quaternion.interpolate(q.getQuat(), alpha);
+ return this;
+ }
+
+ public AxisAngle4d getAxisAngle() {
+ AxisAngle4d axisAngle = new AxisAngle4d();
+ axisAngle.set(quaternion);
+ return axisAngle;
+ }
+
+ // �Z�b�^=================================
+ public Quaternion3D setQuaternion(double x, double y, double z, double w) {
+ quaternion = new Quat4d(x, y, z, w);
+ return this;
+ }
+
+ public Quaternion3D setAxisAngle(double x, double y, double z, double w) {
+ AxisAngle4d aa = new AxisAngle4d(x, y, z, w);
+ quaternion = new Quat4d();
+ quaternion.set(aa);
+ return this;
+ }
+
+ public Quaternion3D add(AxisAngle4d aa) {
+ Quat4d q = new Quat4d();
+ q.set(aa);
+ q.mul(quaternion);
+ quaternion = q;
+ return this;
+ }
+
+ public Quaternion3D mul(Quaternion3D q) {
+ quaternion.mul(q.getQuat());
+ return this;
+ }
+
+ public void applyTo(Object3D o) {
+ o.setQuaternion(this);
+ }
+
+ @Override
+ public Quaternion3D clone() {
+ return new Quaternion3D(this);
+ }
+
+ public double norm() {
+ return quaternion.w * quaternion.w + quaternion.x * quaternion.x + quaternion.y * quaternion.y + quaternion.z * quaternion.z;
+ }
+
+ public Quaternion3D normalize() {
+ quaternion.normalize();
+ return this;
+ }
+}
diff --git a/src/framework/model3D/Terrain3D.java b/src/framework/model3D/Terrain3D.java
new file mode 100644
index 0000000..02b8fc1
--- /dev/null
+++ b/src/framework/model3D/Terrain3D.java
@@ -0,0 +1,450 @@
+package framework.model3D;
+
+import java3d.Appearance;
+import java3d.BoundingBox;
+import java3d.Shape3D;
+import java3d.IndexedTriangleStripArray;
+import java3d.TriangleStripArray;
+import java3d.Point3d;
+import java3d.Vector3d;
+import java3d.Vector3f;
+
+public class Terrain3D extends BaseObject3D {
+ static final int MESH_SIZE = 4;
+ private Position3D origin;
+ private double sizeX = 0;
+ private double sizeZ = 0;
+ private double heightMap[][] = null;
+ private int meshX = 0;
+ private int meshZ = 0;
+ private TriangleStripArray triStripAttay = null;
+
+ public Terrain3D(Position3D origin, double sizeX, double sizeZ, double heightMap[][], Appearance a) {
+ super();
+ this.origin = origin;
+ this.sizeX = sizeX;
+ this.sizeZ = sizeZ;
+ this.heightMap = heightMap;
+ meshX = heightMap[0].length;
+ meshZ = heightMap.length;
+
+ int stripVertexCounts[] = new int[meshZ - 1];
+ for (int n = 0; n < meshZ - 1; n++) {
+ stripVertexCounts[n] = meshX * 2;
+ }
+ triStripAttay = new TriangleStripArray(meshX * 2 * (meshZ - 1),
+ TriangleStripArray.COORDINATES | TriangleStripArray.NORMALS,
+ stripVertexCounts);
+ int index = 0;
+ for (int z = 0; z < meshZ; z++) {
+ for (int x = 0; x < meshX; x++) {
+ // ���b�V�����ƂɎO�p�`��2�Â���
+ if (z < meshZ - 1) {
+ // ���_���W�̐ݒ�
+ // ���_�̖@���x�N�g���̐ݒ�
+ triStripAttay.setCoordinate(index,
+ new Point3d(origin.getX() + sizeX * (double)x,
+ origin.getY() + heightMap[z][x],
+ origin.getZ() + sizeZ * (double)z));
+ Vector3f normal = calcNormal(z, x);
+ normal.normalize();
+ triStripAttay.setNormal(index, normal);
+
+ triStripAttay.setCoordinate(index + 1,
+ new Point3d(origin.getX() + sizeX * (double)x,
+ origin.getY() + heightMap[z + 1][x],
+ origin.getZ() + sizeZ * (double)(z + 1)));
+ normal = calcNormal(z + 1, x);
+ normal.normalize();
+ triStripAttay.setNormal(index + 1, normal);
+
+ index += 2;
+ }
+ }
+ }
+ Appearance a2 = (Appearance)a.cloneNodeComponent();
+ Shape3D shape = new Shape3D(triStripAttay, a2);
+ center.addChild(shape);
+ }
+
+ private Vector3f calcNormal(int z, int x) {
+ Vector3f normal = new Vector3f();
+ if (x < meshX - 1) {
+ Vector3f xp = new Vector3f((float)sizeX, (float)(heightMap[z][x+1] - heightMap[z][x]), 0.0f);
+ if (z < meshZ - 1) {
+ Vector3f zp = new Vector3f(0.0f, (float)(heightMap[z+1][x] - heightMap[z][x]), (float)sizeZ);
+ Vector3f v1 = new Vector3f();
+ v1.cross(zp, xp);
+ v1.normalize();
+ normal.add(v1);
+ }
+ if (z > 0) {
+ Vector3f zm = new Vector3f(0.0f, (float)(heightMap[z-1][x] - heightMap[z][x]), -(float)sizeZ);
+ Vector3f v1 = new Vector3f();
+ v1.cross(xp, zm);
+ v1.normalize();
+ normal.add(v1);
+ }
+ }
+ if (x > 0) {
+ Vector3f xm = new Vector3f(-(float)sizeX, (float)(heightMap[z][x-1] - heightMap[z][x]), 0.0f);
+ if (z < meshZ - 1) {
+ Vector3f zp = new Vector3f(0.0f, (float)(heightMap[z+1][x] - heightMap[z][x]), (float)sizeZ);
+ Vector3f v1 = new Vector3f();
+ v1.cross(xm, zp);
+ v1.normalize();
+ normal.add(v1);
+ }
+ if (z > 0) {
+ Vector3f zm = new Vector3f(0.0f, (float)(heightMap[z-1][x] - heightMap[z][x]), -(float)sizeZ);
+ Vector3f v1 = new Vector3f();
+ v1.cross(zm, xm);
+ v1.normalize();
+ normal.add(v1);
+ }
+ }
+ return normal;
+ }
+
+ public BoundingSurface[] getBoundingSurfaces() {
+ if (boundingSurfaces == null) {
+ if (triStripAttay == null) return null;
+ double coordinate1[] = new double[3];
+ double coordinate2[] = new double[3];
+ double coordinate3[] = new double[3];
+ double coordinate4[] = new double[3];
+
+ // GeometryArray�̏K��
+ if (triStripAttay instanceof TriangleStripArray) {
+ // IndexedTriangleStripArray �̏ꍇ
+ // 8 x 8 ���b�V���P�ʂł܂Ƃ߂�
+ BoundingSurface surfaces[] = new BoundingSurface[((meshX + MESH_SIZE - 2) / MESH_SIZE) * ((meshZ + MESH_SIZE - 2) / MESH_SIZE)];
+ int n = 0;
+ for (int j = 0; j < meshZ - 1; j += MESH_SIZE) {
+ for (int i = 0; i < meshX - 1; i += MESH_SIZE) {
+ BoundingSurface parent = new BoundingSurface();
+ double lowY = 1.0;
+ double highY = -1.0;
+ for (int j2 = 0; j + j2 < meshZ - 1 && j2 < MESH_SIZE; j2++) {
+ for (int i2 = 0; i + i2 < meshX - 1 && i2 < MESH_SIZE; i2++) {
+ int index = (j + j2) * meshX * 2 + (i + i2) * 2;
+ triStripAttay.getCoordinates(index, coordinate1);
+ triStripAttay.getCoordinates(index + 1, coordinate2);
+ triStripAttay.getCoordinates(index + 2, coordinate3);
+ triStripAttay.getCoordinates(index + 3, coordinate4);
+ if (lowY > highY) {
+ lowY = highY = coordinate1[1];
+ } else {
+ if (lowY > coordinate1[1]) {
+ lowY = coordinate1[1];
+ } else if (highY < coordinate1[1]) {
+ highY = coordinate1[1];
+ }
+ if (lowY > coordinate2[1]) {
+ lowY = coordinate2[1];
+ } else if (highY < coordinate2[1]) {
+ highY = coordinate2[1];
+ }
+ if (lowY > coordinate3[1]) {
+ lowY = coordinate3[1];
+ } else if (highY < coordinate3[1]) {
+ highY = coordinate3[1];
+ }
+ if (lowY > coordinate4[1]) {
+ lowY = coordinate4[1];
+ } else if (highY < coordinate4[1]) {
+ highY = coordinate4[1];
+ }
+ }
+
+ // 1 x 1 ���b�V������BoundingSurface
+ Vector3d v1 = new Vector3d(coordinate1);
+ Vector3d v2 = new Vector3d(coordinate2);
+ Vector3d v3 = new Vector3d(coordinate3);
+ Vector3d v4 = new Vector3d(coordinate4);
+ BoundingSurface bSurface = new BoundingSurface();
+ bSurface.addVertex((Vector3d)v1.clone()); //1�߂̎O�p�`
+ bSurface.addVertex((Vector3d)v2.clone());
+ bSurface.addVertex((Vector3d)v3.clone());
+ bSurface.setBounds(createBoundingPolytope(v1, v2, v3));
+ parent.addChild(bSurface, false);
+
+ bSurface = new BoundingSurface();
+ bSurface.addVertex((Vector3d)v2.clone()); //2�߂̎O�p�`
+ bSurface.addVertex((Vector3d)v4.clone());
+ bSurface.addVertex((Vector3d)v3.clone());
+ bSurface.setBounds(createBoundingPolytope(v2, v4, v3));
+ parent.addChild(bSurface, true);
+ }
+ }
+ // 8 x 8 ���b�V���P�ʂ�BoundingSurface
+ triStripAttay.getCoordinates(j * meshX * 2 + i * 2, coordinate1);
+ parent.setBounds(new BoundingBox(new Point3d(coordinate1[0], lowY, coordinate1[2]),
+ new Point3d(coordinate4[0], highY, coordinate4[2])));
+ surfaces[n] = parent;
+ n++;
+ }
+ }
+ boundingSurfaces = surfaces;
+ } else {
+ return null;
+ }
+ }
+ return boundingSurfaces;
+ }
+
+ public double getHeight(double x, double z) {
+ int i = (int)((x - origin.getX()) / sizeX);
+ int j = (int)((z - origin.getZ()) / sizeZ);
+ if (i >= meshX || i < 0 || j >= meshZ || j < 0) return 0.0;
+
+ int index = j * meshX * 2 + i * 2;
+ double coordinate1[] = new double[3];
+ double coordinate2[] = new double[3];
+ double coordinate3[] = new double[3];
+ double coordinate4[] = new double[3];
+ triStripAttay.getCoordinates(index, coordinate1);
+ triStripAttay.getCoordinates(index + 1, coordinate2);
+ triStripAttay.getCoordinates(index + 2, coordinate3);
+ triStripAttay.getCoordinates(index + 3, coordinate4);
+ Vector3d v1 = new Vector3d(coordinate1);
+ Vector3d v2 = new Vector3d(coordinate2);
+ Vector3d v3 = new Vector3d(coordinate3);
+ Vector3d v4 = new Vector3d(coordinate4);
+ Vector3d p1 = new Vector3d(x, 0.0, z);
+ Vector3d p2 = new Vector3d(x, 1.0, z);
+
+ double x2 = x - (double)i * sizeX - origin.getX();
+ double z2 = z - (double)j * sizeZ - origin.getZ();
+ if (x2 < GeometryUtility.TOLERANCE || (meshZ - z2) / x2 > meshZ / meshX) {
+ // 1�߂̎O�p�`��ʂ�ꍇ
+ Vector3d crossPoint = GeometryUtility.intersect(GeometryUtility.createPlane(v1, v2, v3), p1, p2);
+ return crossPoint.getY();
+ } else {
+ // 2�߂̎O�p�`��ʂ�ꍇ
+ Vector3d crossPoint = GeometryUtility.intersect(GeometryUtility.createPlane(v2, v4, v3), p1, p2);
+ return crossPoint.getY();
+ }
+ }
+}
+
+//
+// ********** IndexedTriangleStripArray ���g���o�[�W���� **********
+// (IndexedTriangleStripArray��p����ƃ�������ߖ�ł��邪�A�V�F�[�f�B���O���ł��Ȃ��̂Œ���)
+//
+//public class Terrain3D extends BaseObject3D {
+// static final int MESH_SIZE = 8;
+// private Position3D origin;
+// private double sizeX = 0;
+// private double sizeZ = 0;
+// private double heightMap[][] = null;
+// private int meshX = 0;
+// private int meshZ = 0;
+// private IndexedTriangleStripArray triStripAttay = null;
+//
+// public Terrain3D(Position3D origin, double sizeX, double sizeZ, double heightMap[][], Appearance a) {
+// super();
+// this.origin = origin;
+// this.sizeX = sizeX;
+// this.sizeZ = sizeZ;
+// this.heightMap = heightMap;
+// meshX = heightMap[0].length;
+// meshZ = heightMap.length;
+//
+// int stripVertexCounts[] = new int[meshZ - 1];
+// for (int n = 0; n < meshZ - 1; n++) {
+// stripVertexCounts[n] = meshX * 2;
+// }
+// triStripAttay = new IndexedTriangleStripArray(meshX * meshZ,
+// IndexedTriangleStripArray.COORDINATES | IndexedTriangleStripArray.NORMALS,
+// meshX * 2 * (meshZ - 1),
+// stripVertexCounts);
+// int index = 0, index2 = 0, i1, i2;
+// for (int z = 0; z < meshZ; z++) {
+// for (int x = 0; x < meshX; x++) {
+// // ���_���W�̐ݒ�
+// triStripAttay.setCoordinate(index,
+// new Point3d(origin.getX() + sizeX * (double)x,
+// origin.getY() + heightMap[z][x],
+// origin.getZ() + sizeZ * (double)z));
+// // ���_�̖@���x�N�g���̐ݒ�
+// Vector3f normal = new Vector3f();
+// if (x < meshX - 1) {
+// Vector3f xp = new Vector3f((float)sizeX, (float)(heightMap[z][x+1] - heightMap[z][x]), 0.0f);
+// if (z < meshZ - 1) {
+// Vector3f zp = new Vector3f(0.0f, (float)(heightMap[z+1][x] - heightMap[z][x]), (float)sizeZ);
+// Vector3f v1 = new Vector3f();
+// v1.cross(zp, xp);
+// v1.normalize();
+// normal.add(v1);
+// }
+// if (z > 0) {
+// Vector3f zm = new Vector3f(0.0f, (float)(heightMap[z-1][x] - heightMap[z][x]), -(float)sizeZ);
+// Vector3f v1 = new Vector3f();
+// v1.cross(xp, zm);
+// v1.normalize();
+// normal.add(v1);
+// }
+// }
+// if (x > 0) {
+// Vector3f xm = new Vector3f(-(float)sizeX, (float)(heightMap[z][x-1] - heightMap[z][x]), 0.0f);
+// if (z < meshZ - 1) {
+// Vector3f zp = new Vector3f(0.0f, (float)(heightMap[z+1][x] - heightMap[z][x]), (float)sizeZ);
+// Vector3f v1 = new Vector3f();
+// v1.cross(xm, zp);
+// v1.normalize();
+// normal.add(v1);
+// }
+// if (z > 0) {
+// Vector3f zm = new Vector3f(0.0f, (float)(heightMap[z-1][x] - heightMap[z][x]), -(float)sizeZ);
+// Vector3f v1 = new Vector3f();
+// v1.cross(zm, xm);
+// v1.normalize();
+// normal.add(v1);
+// }
+// }
+// normal.normalize();
+// triStripAttay.setNormal(index, normal);
+// index++;
+// // ���b�V�����ƂɎO�p�`��2�Â���
+// if (z < meshZ - 1) {
+// i1 = z * meshX + x;
+// i2 = (z + 1) * meshX + x;
+// triStripAttay.setCoordinateIndices(index2, new int[]{i1, i2});
+// index2 += 2;
+// }
+// }
+// }
+// Appearance a2 = (Appearance)a.cloneNodeComponent(true);
+// a2.setCapability(Appearance.ALLOW_MATERIAL_READ);
+// a2.setCapability(Appearance.ALLOW_TEXTURE_READ);
+// a2.setCapability(Appearance.ALLOW_TEXTURE_WRITE);
+// a2.setCapability(Appearance.ALLOW_TEXTURE_ATTRIBUTES_READ);
+// a2.setCapability(Appearance.ALLOW_TEXTURE_ATTRIBUTES_WRITE);
+// Shape3D shape = new Shape3D(triStripAttay, a2);
+// shape.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
+// shape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
+// center.addChild(shape);
+// }
+//
+// public BoundingSurface[] getBoundingSurfaces() {
+// if (boundingSurfaces == null) {
+// if (triStripAttay == null) return null;
+// double coordinate1[] = new double[3];
+// double coordinate2[] = new double[3];
+// double coordinate3[] = new double[3];
+// double coordinate4[] = new double[3];
+//
+// // GeometryArray�̏K��
+// if (triStripAttay instanceof IndexedTriangleStripArray) {
+// // IndexedTriangleStripArray �̏ꍇ
+// // 8 x 8 ���b�V���P�ʂł܂Ƃ߂�
+// BoundingSurface surfaces[] = new BoundingSurface[((meshX + MESH_SIZE - 2) / MESH_SIZE) * ((meshZ + MESH_SIZE - 2) / MESH_SIZE)];
+// int n = 0;
+// for (int j = 0; j < meshZ - 1; j += MESH_SIZE) {
+// for (int i = 0; i < meshX - 1; i += MESH_SIZE) {
+// BoundingSurface parent = new BoundingSurface();
+// double lowY = 1.0;
+// double highY = -1.0;
+// for (int j2 = 0; j + j2 < meshZ - 1 && j2 < MESH_SIZE; j2++) {
+// for (int i2 = 0; i + i2 < meshX - 1 && i2 < MESH_SIZE; i2++) {
+// int index = (j + j2) * meshX * 2 + (i + i2) * 2;
+// triStripAttay.getCoordinates(triStripAttay.getCoordinateIndex(index), coordinate1);
+// triStripAttay.getCoordinates(triStripAttay.getCoordinateIndex(index+1), coordinate2);
+// triStripAttay.getCoordinates(triStripAttay.getCoordinateIndex(index+2), coordinate3);
+// triStripAttay.getCoordinates(triStripAttay.getCoordinateIndex(index+3), coordinate4);
+// if (lowY > highY) {
+// lowY = highY = coordinate1[1];
+// } else {
+// if (lowY > coordinate1[1]) {
+// lowY = coordinate1[1];
+// } else if (highY < coordinate1[1]) {
+// highY = coordinate1[1];
+// }
+// if (lowY > coordinate2[1]) {
+// lowY = coordinate2[1];
+// } else if (highY < coordinate2[1]) {
+// highY = coordinate2[1];
+// }
+// if (lowY > coordinate3[1]) {
+// lowY = coordinate3[1];
+// } else if (highY < coordinate3[1]) {
+// highY = coordinate3[1];
+// }
+// if (lowY > coordinate4[1]) {
+// lowY = coordinate4[1];
+// } else if (highY < coordinate4[1]) {
+// highY = coordinate4[1];
+// }
+// }
+//
+// // 1 x 1 ���b�V������BoundingSurface
+// Vector3d v1 = new Vector3d(coordinate1);
+// Vector3d v2 = new Vector3d(coordinate2);
+// Vector3d v3 = new Vector3d(coordinate3);
+// Vector3d v4 = new Vector3d(coordinate4);
+// BoundingSurface bSurface = new BoundingSurface();
+// bSurface.addVertex((Vector3d)v1.clone()); //1�߂̎O�p�`
+// bSurface.addVertex((Vector3d)v2.clone());
+// bSurface.addVertex((Vector3d)v3.clone());
+// bSurface.setBounds(createBoundingPolytope(v1, v2, v3));
+// parent.addChild(bSurface, false);
+//
+// bSurface = new BoundingSurface();
+// bSurface.addVertex((Vector3d)v2.clone()); //2�߂̎O�p�`
+// bSurface.addVertex((Vector3d)v4.clone());
+// bSurface.addVertex((Vector3d)v3.clone());
+// bSurface.setBounds(createBoundingPolytope(v2, v4, v3));
+// parent.addChild(bSurface, true);
+// }
+// }
+// // 8 x 8 ���b�V���P�ʂ�BoundingSurface
+// triStripAttay.getCoordinates(triStripAttay.getCoordinateIndex(j * meshX * 2 + i * 2), coordinate1);
+// parent.setBounds(new BoundingBox(new Point3d(coordinate1[0], lowY, coordinate1[2]),
+// new Point3d(coordinate4[0], highY, coordinate4[2])));
+// surfaces[n] = parent;
+// n++;
+// }
+// }
+// boundingSurfaces = surfaces;
+// } else {
+// return null;
+// }
+// }
+// return boundingSurfaces;
+// }
+//
+// public double getHeight(double x, double z) {
+// int i = (int)((x - origin.getX()) / sizeX);
+// int j = (int)((z - origin.getZ()) / sizeZ);
+// if (i >= meshX || i < 0 || j >= meshZ || j < 0) return 0.0;
+//
+// int index = j * meshX * 2 + i * 2;
+// double coordinate1[] = new double[3];
+// double coordinate2[] = new double[3];
+// double coordinate3[] = new double[3];
+// double coordinate4[] = new double[3];
+// triStripAttay.getCoordinates(triStripAttay.getCoordinateIndex(index), coordinate1);
+// triStripAttay.getCoordinates(triStripAttay.getCoordinateIndex(index+1), coordinate2);
+// triStripAttay.getCoordinates(triStripAttay.getCoordinateIndex(index+2), coordinate3);
+// triStripAttay.getCoordinates(triStripAttay.getCoordinateIndex(index+3), coordinate4);
+// Vector3d v1 = new Vector3d(coordinate1);
+// Vector3d v2 = new Vector3d(coordinate2);
+// Vector3d v3 = new Vector3d(coordinate3);
+// Vector3d v4 = new Vector3d(coordinate4);
+// Vector3d p1 = new Vector3d(x, 0.0, z);
+// Vector3d p2 = new Vector3d(x, 1.0, z);
+//
+// double x2 = x - (double)i * sizeX - origin.getX();
+// double z2 = z - (double)j * sizeZ - origin.getZ();
+// if (x2 < GeometryUtility.TOLERANCE || (meshZ - z2) / x2 > meshZ / meshX) {
+// // 1�߂̎O�p�`��ʂ�ꍇ
+// Vector3d crossPoint = GeometryUtility.intersect(GeometryUtility.createPlane(v1, v2, v3), p1, p2);
+// return crossPoint.getY();
+// } else {
+// // 2�߂̎O�p�`��ʂ�ꍇ
+// Vector3d crossPoint = GeometryUtility.intersect(GeometryUtility.createPlane(v2, v4, v3), p1, p2);
+// return crossPoint.getY();
+// }
+// }
+//}
diff --git a/src/framework/model3D/UndoBuffer.java b/src/framework/model3D/UndoBuffer.java
new file mode 100644
index 0000000..bc292d9
--- /dev/null
+++ b/src/framework/model3D/UndoBuffer.java
@@ -0,0 +1,48 @@
+package framework.model3D;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Hashtable;
+
+public class UndoBuffer {
+ @SuppressWarnings("unchecked")
+ private ArrayList> list = new ArrayList>();
+ @SuppressWarnings("unchecked")
+ private Hashtable nowCondition = new Hashtable();
+ private static final int max = 3;
+
+ UndoBuffer() {
+ }
+
+ UndoBuffer(UndoBuffer another) {
+ this.list = (ArrayList>)another.list.clone();
+ this.nowCondition = (Hashtable)another.nowCondition.clone();
+ }
+
+ public void push(Property3D p) {
+ nowCondition.put(p.getClass(), p.clone());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void setUndoMark() {
+ if(list.size() == max) {
+ list.remove(max - 1);
+ }
+ list.add(0, (Hashtable) nowCondition.clone());
+ }
+
+ @SuppressWarnings("unchecked")
+ public Collection undo() {
+ if(list.size() != 0) {
+ nowCondition = list.remove(0);
+ return nowCondition.values();
+ }
+ else {
+ return new Hashtable().values();
+ }
+ }
+
+ public void clear() {
+
+ }
+}
diff --git a/src/framework/model3D/Universe.java b/src/framework/model3D/Universe.java
new file mode 100644
index 0000000..479bcbb
--- /dev/null
+++ b/src/framework/model3D/Universe.java
@@ -0,0 +1,108 @@
+package framework.model3D;
+
+import java.util.ArrayList;
+
+import framework.gameMain.Actor;
+import framework.gameMain.Movable;
+import framework.physics.Ground;
+import java3d.BranchGroup;
+import java3d.Group;
+import java3d.Leaf;
+import java3d.Light;
+import java3d.Node;
+import java3d.Primitive;
+import java3d.Shape3D;
+import java3d.Transform3D;
+import java3d.TransformGroup;
+
+public class Universe {
+ private BranchGroup root = null;
+ private ArrayList lights = new ArrayList();
+ private BackgroundBox skyBox = null;
+ private Ground ground = null;
+ private ArrayList movableList = new ArrayList();
+
+ public Universe() {
+ root = new BranchGroup();
+ }
+
+
+ public void update(long interval){
+ for(int i = 0; i < movableList.size(); i++){
+ Movable movable = movableList.get(i);
+ movable.motion(interval,ground);
+ }
+ }
+
+ /**
+ * �I�u�W�F�N�g��z�u����
+ *
+ * @param obj
+ * �z�u����I�u�W�F�N�g
+ */
+ public void place(Placeable obj) {
+ if(obj instanceof Ground){
+ ground = (Ground)obj;
+ }
+ if(obj instanceof Movable){
+ movableList.add((Movable)obj);
+ }
+ place(obj.getTransformGroupToPlace());
+ }
+
+ private void place(Node node) {
+ root.addChild(node);
+ }
+
+ /**
+ * ��Ŏ�菜����悤�ɃI�u�W�F�N�g��z�u����
+ *
+ * @param obj
+ * �z�u����I�u�W�F�N�g
+ */
+ public void placeDisplacable(Placeable obj) {
+ placeDisplacable(obj.getTransformGroupToPlace());
+ }
+
+ private void placeDisplacable(Node node) {
+ root.addChild(node);
+ }
+
+ /**
+ * �����̒lj�
+ *
+ * @param light
+ * �lj��������
+ */
+ public void placeLight(Light light) {
+ getLights().add(light);
+ }
+
+ /**
+ * �X�J�C�{�b�N�X�̒lj�
+ * @param skyBox �lj�����X�J�C�{�b�N�X
+ */
+ public void placeSkyBox(BackgroundBox skyBox) {
+ root.addChild(skyBox);
+ this.skyBox = skyBox;
+ }
+
+ /**
+ * �I�u�W�F�N�g���\�Ȃ�Ύ�菜��
+ *
+ * @param obj
+ * ��菜���I�u�W�F�N�g
+ */
+ public void displace(Placeable obj) {
+ displace(obj.getTransformGroupToPlace());
+ }
+
+ private void displace(Node node) {
+ root.removeChild(node);
+ }
+
+ public ArrayList getLights() {
+ return lights;
+ }
+
+}
diff --git a/src/framework/physics/AngularVelocity3D.java b/src/framework/physics/AngularVelocity3D.java
new file mode 100644
index 0000000..8c84b56
--- /dev/null
+++ b/src/framework/physics/AngularVelocity3D.java
@@ -0,0 +1,85 @@
+package framework.physics;
+import java3d.AxisAngle4d;
+import java3d.Vector3d;
+
+import framework.model3D.Object3D;
+import framework.model3D.Property3D;
+
+
+public class AngularVelocity3D extends Property3D{
+ private double x;
+ private double y;
+ private double z;
+
+ public AngularVelocity3D(AngularVelocity3D w) {
+ x = w.x;
+ y = w.y;
+ z = w.z;
+ }
+
+ public AngularVelocity3D(double x,double y,double z){
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ public AngularVelocity3D(){
+ x = 0.0;
+ y = 0.0;
+ z = 0.0;
+ }
+
+ public void applyTo(Object3D o){
+ ((Solid3D)o).setAngularVelocity(this);
+ }
+
+ public double getX() {
+ // TODO Auto-generated method stub
+ return this.x;
+ }
+
+ public double getY() {
+ // TODO Auto-generated method stub
+ return this.y;
+ }
+
+ public double getZ() {
+ // TODO Auto-generated method stub
+ return this.z;
+ }
+
+ public AngularVelocity3D add(double x, double y, double z){
+ this.x += x;
+ this.y += y;
+ this.z += z;
+ return this;
+ }
+
+ public AngularVelocity3D add(Vector3d v) {
+ // TODO Auto-generated method stub
+ this.x += v.x;
+ this.y += v.y;
+ this.z += v.z;
+ return this;
+ }
+
+ public Vector3d getVector3d(){
+ return new Vector3d(x,y,z);
+ }
+
+ public AxisAngle4d getAxisAngle4d() {
+ double l = getVector3d().length();
+ if (l <= 0.00001) {
+ return new AxisAngle4d(0, 0, 1.0, 0.0);
+ }
+ return new AxisAngle4d(x / l, y / l, z / l, l);
+ }
+
+ @Override
+ public Property3D clone() {
+ // TODO Auto-generated method stub
+ return new AngularVelocity3D(this);
+ }
+}
+
+
diff --git a/src/framework/physics/BoundingBoxVisitor.java b/src/framework/physics/BoundingBoxVisitor.java
new file mode 100644
index 0000000..e4e664d
--- /dev/null
+++ b/src/framework/physics/BoundingBoxVisitor.java
@@ -0,0 +1,93 @@
+package framework.physics;
+import java.util.ArrayList;
+
+import java3d.BoundingSphere;
+
+import framework.model3D.OBB;
+import framework.model3D.Object3D;
+import framework.model3D.ObjectVisitor;
+
+
+public class BoundingBoxVisitor extends ObjectVisitor {
+ private ArrayList obbList = new ArrayList(); // �S�\���v�f��OBB�̃��X�g
+ private ArrayList bsStack = new ArrayList(); // �I�u�W�F�N�g�̊K�w����BoundingSphere�̃X�^�b�N
+ private String partName = null; // ���i���w�肷��ꍇ�Ɏg��
+ private boolean inPart = false;
+
+ public BoundingBoxVisitor() {
+ partName = null;
+ }
+
+ public BoundingBoxVisitor(String partName) {
+ this.partName = partName;
+ }
+
+ public void preVisit(Object3D obj) {
+ pushTransform(obj);
+ if (partName != null && obj.name.equals(partName)) {
+ inPart = true;
+ }
+ if (obj.hasChildren() && obj.bs == null) {
+ // �q��������ꍇ�A���̊K�w�p��null��push����
+ bsStack.add(null);
+ }
+ }
+
+ public void postVisit(Object3D obj) {
+ int pattern = 2;
+ if (!obj.hasChildren()) {
+ // �t�̏ꍇ
+ OBB obb = obj.getOBB(pattern);
+ if (obb != null) {
+ if (obj.bs == null) {
+ obj.bs = obb.getBoundingSphere();
+ }
+
+ obb = (OBB)obb.clone();
+ BoundingSphere bs = (BoundingSphere)obj.bs.clone();
+ for (int i = stackList.size() - 1; i >= 0; i--) {
+ obb.transform(stackList.get(i));
+ bs.transform(stackList.get(i));
+ }
+ if (partName == null || partName.length() == 0 || inPart) {
+ obbList.add(obb); // Transform3D��K��������Bounds��boundsList�ɒlj�
+ int stackTop = bsStack.size() - 1;
+ if (bs != null && stackTop >= 0) {
+ if (bsStack.get(stackTop) == null) {
+ // ���̊K�w�̍ŏ��̃I�u�W�F�N�g�̏ꍇ�Anull��u������
+ bsStack.set(stackTop, bs);
+ } else {
+ // ���̊K�w��2�Ԗڈȍ~�̃I�u�W�F�N�g�̏ꍇ�A����
+ bsStack.get(stackTop).combine(bs);
+ }
+ }
+ }
+ }
+ } else {
+ // �q��������ꍇ
+ int stackTop = bsStack.size() - 1;
+ if (obj.bs == null) {
+ // ���̊K�w�̌������ʂ�pop���ė��p����
+ obj.bs = bsStack.remove(stackTop);
+ stackTop--;
+ }
+ if (obj.bs != null && stackTop >= 0) {
+ if (bsStack.get(stackTop) == null) {
+ // ���̊K�w�̍ŏ��̃I�u�W�F�N�g�̏ꍇ�Anull��u������
+ bsStack.set(stackTop, obj.bs);
+ } else {
+ // ���̊K�w��2�Ԗڈȍ~�̃I�u�W�F�N�g�̏ꍇ�A����
+ bsStack.get(stackTop).combine(obj.bs);
+ }
+ }
+ }
+ popTransform();
+ if (partName != null && obj.name.equals(partName)) {
+ inPart = false;
+ }
+ }
+
+ public ArrayList getObbList() {
+ return obbList;
+ }
+}
diff --git a/src/framework/physics/BoundingSurfaceVisitor.java b/src/framework/physics/BoundingSurfaceVisitor.java
new file mode 100644
index 0000000..591c86f
--- /dev/null
+++ b/src/framework/physics/BoundingSurfaceVisitor.java
@@ -0,0 +1,59 @@
+package framework.physics;
+
+import java.util.ArrayList;
+
+import framework.model3D.BaseObject3D;
+import framework.model3D.BoundingSurface;
+import framework.model3D.Object3D;
+import framework.model3D.ObjectVisitor;
+
+/**
+ * �n�ʂ̏Փ˔���p�̃{�����[�������邽�߂̃r�W�^�[
+ * @author �V�c����
+ *
+ */
+public class BoundingSurfaceVisitor extends ObjectVisitor {
+ private ArrayList boundingSurfaceList = new ArrayList();
+ public BoundingSurfaceVisitor() {
+ boundingSurfaceList.add(new BoundingSurface());
+ }
+
+ public void preVisit(Object3D obj) {
+ pushTransform(obj);
+ if (obj.hasChildren()) {
+ boundingSurfaceList.add(new BoundingSurface());
+ }
+ }
+
+ public void postVisit(Object3D obj) {
+ if (!obj.hasChildren()) {
+ // �t�̏ꍇ
+ BoundingSurface[] s = (BoundingSurface[]) obj.getBoundingSurfaces().clone();
+ for (int i = 0; i < s.length; i++) {
+ s[i] = (BoundingSurface) s[i].clone();
+ for (int j = stackList.size() - 1; j >= 0; j--) {
+ s[i].transform(stackList.get(j));
+ }
+ boundingSurfaceList.get(boundingSurfaceList.size() - 1).addChild(s[i], true); // Transform3D��K��������Bounds��surfaceList�ɒlj�
+ }
+ } else {
+ BoundingSurface child = boundingSurfaceList.remove(boundingSurfaceList.size() - 1);
+ BoundingSurface parent = boundingSurfaceList.get(boundingSurfaceList.size() - 1);
+ parent.addChild(child, true);
+ }
+ popTransform();
+ }
+
+ public void baseVisit(BaseObject3D obj) {
+ BoundingSurface parent = boundingSurfaceList.get(boundingSurfaceList.size() - 1);
+ BoundingSurface[] s = (BoundingSurface[]) obj.getBoundingSurfaces().clone();
+ for (int i = 0; i < s.length; i++) {
+ s[i] = (BoundingSurface) s[i].clone();
+ parent.addChild(s[i], true);
+ }
+ }
+
+ public BoundingSurface getBoundingSurface() {
+ return boundingSurfaceList.get(0);
+ }
+}
diff --git a/src/framework/physics/CVS/Entries b/src/framework/physics/CVS/Entries
new file mode 100644
index 0000000..96d295d
--- /dev/null
+++ b/src/framework/physics/CVS/Entries
@@ -0,0 +1,11 @@
+/AngularVelocity3D.java/1.1/Thu Jul 7 08:22:45 2016//
+/BoundingBoxVisitor.java/1.2/Fri Dec 9 10:41:09 2016//
+/BoundingSurfaceVisitor.java/1.1/Thu Jul 7 08:22:45 2016//
+/Force3D.java/1.1/Thu Jul 7 08:22:45 2016//
+/Ground.java/1.2/Thu Oct 13 07:59:00 2016//
+/Inertia3D.java/1.1/Thu Jul 7 08:22:45 2016//
+/PhysicalSystem.java/1.1/Thu Jul 7 08:22:45 2016//
+/PhysicsUtility.java/1.1/Thu Jul 7 08:22:45 2016//
+/ProjectionResult.java/1.1/Thu Jul 7 08:22:45 2016//
+/Solid3D.java/1.2/Thu Oct 13 07:59:00 2016//
+/Velocity3D.java/1.1/Thu Jul 7 08:22:45 2016//
diff --git a/src/framework/physics/CVS/Repository b/src/framework/physics/CVS/Repository
new file mode 100644
index 0000000..1e820da
--- /dev/null
+++ b/src/framework/physics/CVS/Repository
@@ -0,0 +1 @@
+CarrotServer/src/framework/physics
diff --git a/src/framework/physics/CVS/Root b/src/framework/physics/CVS/Root
new file mode 100644
index 0000000..c36e9d0
--- /dev/null
+++ b/src/framework/physics/CVS/Root
@@ -0,0 +1 @@
+:pserver:guest@nitta-lab-www.is.konan-u.ac.jp:\CVSProject
diff --git a/src/framework/physics/Force3D.java b/src/framework/physics/Force3D.java
new file mode 100644
index 0000000..2f45e90
--- /dev/null
+++ b/src/framework/physics/Force3D.java
@@ -0,0 +1,35 @@
+package framework.physics;
+import java3d.Vector3d;
+
+
+public class Force3D {
+ double x;
+ double y;
+ double z;
+ public static final Force3D ZERO = new Force3D( 0.0, 0.0, 0.0);
+
+ public Force3D(double x,double y,double z){
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ public Force3D(Vector3d v) {
+ this.x = v.x;
+ this.y = v.y;
+ this.z = v.z;
+ }
+ public Vector3d getVector3d(){
+ return new Vector3d(x,y,z);
+ }
+
+ public void add(Force3D f) {
+ x += f.x;
+ y += f.y;
+ z += f.z;
+ }
+
+ public double getSeverity() {
+ return getVector3d().length();
+ }
+}
diff --git a/src/framework/physics/Ground.java b/src/framework/physics/Ground.java
new file mode 100644
index 0000000..08da50f
--- /dev/null
+++ b/src/framework/physics/Ground.java
@@ -0,0 +1,59 @@
+package framework.physics;
+import java3d.BranchGroup;
+import java3d.TransformGroup;
+
+import framework.model3D.BaseObject3D;
+import framework.model3D.BoundingSurface;
+import framework.model3D.Object3D;
+import framework.model3D.Placeable;
+
+
+/**
+ * �n�ʂȂǂ́i��{�I�ɓ����Ȃ��j�\������\���I�u�W�F�N�g
+ * @author �V�c����
+ *
+ */
+public class Ground implements Placeable {
+ protected BaseObject3D groundObj = null;
+ private BoundingSurface boundingSurface = null; // �Փ˔���p�{�����[���̃L���b�V��
+
+ public Ground(){}
+
+ public Ground(BaseObject3D obj) {
+ groundObj = obj;
+ }
+
+ public BaseObject3D getBody() {
+ return groundObj;
+ }
+
+ public void updateBody(BaseObject3D obj) {
+ groundObj = obj;
+ boundingSurface = null;
+ }
+
+ @Override
+ public TransformGroup getTransformGroupToPlace() {
+ return groundObj.getTransformGroupToPlace();
+ }
+
+ /**
+ * �Փ˔���p�̃{�����[�����擾����
+ * @return �Փ˔���p�{�����[���i�K�w������Ă���ꍇ������j
+ */
+ BoundingSurface getBoundingSurface() {
+ if (boundingSurface == null) {
+ // �L���b�V���ɉ����ς܂�Ă��Ȃ��ꍇ�̂v�Z����
+ BoundingSurfaceVisitor surfaceVisitor = new BoundingSurfaceVisitor();
+ if (groundObj instanceof Object3D) {
+ // Object3D�̏ꍇ�K�w�\�������ǂ�
+ ((Object3D)groundObj).accept(surfaceVisitor);
+ } else {
+ // BaseObject3d�̏ꍇ�K�w�\�����Ȃ�
+ surfaceVisitor.baseVisit(groundObj);
+ }
+ boundingSurface = surfaceVisitor.getBoundingSurface();
+ }
+ return boundingSurface;
+ }
+}
diff --git a/src/framework/physics/Inertia3D.java b/src/framework/physics/Inertia3D.java
new file mode 100644
index 0000000..a9f0d4f
--- /dev/null
+++ b/src/framework/physics/Inertia3D.java
@@ -0,0 +1,54 @@
+package framework.physics;
+import java3d.Vector3d;
+
+import framework.model3D.OBB;
+
+
+public class Inertia3D {
+ double ixx;
+ double iyy;
+ double izz;
+ static final Inertia3D ZERO = new Inertia3D( 0.0, 0.0, 0.0);
+
+ public Inertia3D(double x,double y,double z){
+ this.ixx = x;
+ this.iyy = y;
+ this.izz = z;
+ }
+
+ public Inertia3D(Vector3d v) {
+ this.ixx = v.x;
+ this.iyy = v.y;
+ this.izz = v.z;
+ }
+
+ public Inertia3D(Solid3D obj) {
+ BoundingBoxVisitor visitor = new BoundingBoxVisitor();
+ obj.accept(visitor);
+ if (visitor.getObbList().size() == 1) {
+ OBB obb = visitor.getObbList().get(0);
+ Vector3d vx = new Vector3d();
+ vx.sub(obb.vertexList.get(4), obb.vertexList.get(0));
+
+ Vector3d vy = new Vector3d();
+ vy.sub(obb.vertexList.get(1), obb.vertexList.get(0));
+
+ Vector3d vz = new Vector3d();
+ vz.sub(obb.vertexList.get(2), obb.vertexList.get(0));
+
+// System.out.println("vx:" + vx + ",vy:" + vy + ",vz:" + vz);
+ this.ixx = obj.mass * (1.0/12.0 * (Math.pow(vy.length(), 2.0) + Math.pow(vz.length(), 2.0)));
+ this.iyy = obj.mass * (1.0/12.0 * (Math.pow(vx.length(), 2.0) + Math.pow(vz.length(), 2.0)));
+ this.izz = obj.mass * (1.0/12.0 * (Math.pow(vx.length(), 2.0) + Math.pow(vy.length(), 2.0)));
+ } else {
+ this.ixx = obj.mass;
+ this.iyy = obj.mass;
+ this.izz = obj.mass;
+ }
+ }
+
+ public Vector3d getVector3d() {
+ return new Vector3d(ixx, iyy, izz);
+ }
+}
+
diff --git a/src/framework/physics/PhysicalSystem.java b/src/framework/physics/PhysicalSystem.java
new file mode 100644
index 0000000..9b4fef5
--- /dev/null
+++ b/src/framework/physics/PhysicalSystem.java
@@ -0,0 +1,152 @@
+package framework.physics;
+
+import java.util.ArrayList;
+import java3d.Vector3d;
+
+import framework.model3D.CollisionResult;
+import framework.model3D.Position3D;
+
+
+public class PhysicalSystem {
+
+ public ArrayList objects = new ArrayList();
+
+ // ���̂̑}��
+ public int add(Solid3D s) {
+ objects.add(s);
+ return objects.size() - 1;
+ }
+
+ // ���̂̉^��
+ public void motion(int id, long interval, Force3D f, Position3D appPoint, Ground ground) {
+ ArrayList forces[] = new ArrayList[objects.size()];
+ ArrayList appPoints[] = new ArrayList[objects.size()];
+ for (int i = 0; i < objects.size(); i++) {
+ forces[i] = new ArrayList();
+ appPoints[i] = new ArrayList();
+ }
+
+ // id�Ԗڂ̊O�͂̌v�Z
+ forces[id].add(f);
+ appPoints[id].add(appPoint);
+// objects.get(id).move(interval, f, appPoint);
+
+ double l; // �˂̐L��
+
+ Force3D penalty = new Force3D(0.0, 0.0, 0.0); // �y�i���e�B�@�ɂ��y�i���e�B�̍�p�̗�
+ Force3D inversepenalty; //
+ // //�y�i���e�B�@�ɂ��y�i���e�B�̔���p�̗�
+ CollisionResult cr;
+ Solid3D s;
+ for (int n = 0; n < objects.size(); n++) {
+ // �d�͂̌v�Z
+ s = objects.get(n);
+ forces[n].add(PhysicsUtility.getGravity(s));
+ appPoints[n].add(s.getGravityCenter());
+// objects.get(n).move(interval,
+// PhysicsFacade.getGravity(objects.get(n)),
+// objects.get(n).getGravityCenter()); // �d�͂̌v�Z
+ // �n�ʂƂ̓����蔻��
+ cr = PhysicsUtility.doesIntersect(s, ground);
+ // �n�ʂɕ��̂��߂荞��ł���ꍇ
+ if (cr != null) {
+ double gk = 5000.0; // �n�ʂł̂ˌW��
+ double e = 1.0; // �n�ʂł̒��˕Ԃ莞�̒�R�W��
+ double b = 300.0;
+ l = cr.length;
+ // <��p�̗͂̌v�Z>
+ // �y�i���e�B�̕ϐ�
+// Vector3d v = cr.normal;
+// v.scale(gk * l);
+ // ��p�_�x�N�g���̍쐬
+ Vector3d r = cr.collisionPoint.getVector3d();
+ // (��p�_-�d�S)�x�N�g��
+ r.sub(s.getGravityCenter().getVector3d());
+ // �p���x�x�N�g���̍쐬
+ Vector3d angVel = s.getAngularVelocity().getVector3d();
+ // �p���x�x�N�g����(��p�_-�d�S)�x�N�g���̊O�όv�Z
+ angVel.cross(angVel, r);
+ // ���x�x�N�g��+�p���x�x�N�g����(��p�_-�d�S)�x�N�g���̊O�όv�Z
+ Vector3d relV = s.getVelocity().getVector3d();
+ // ���Α��x�x�N�g���̍쐬
+ relV.add(angVel);
+ Vector3d v = cr.normal;
+//System.out.println(r + "," + (gk * l) + "," + (- relV.dot(v) * b));
+ // �y�i���e�B�̑傫������
+ v.scale(gk * l - relV.dot(v) * b);
+ penalty = new Force3D(v);
+
+ // ��p�̗͂ɂ��^��
+ forces[n].add(penalty);
+ appPoints[n].add(cr.collisionPoint);
+// objects.get(n).move(interval, penalty, cr.collisionPoint);
+ }
+ // �n�ʂɕ��̂��߂荞��ł��Ȃ��ꍇ
+ else {
+ }
+ for (int m = 0; m < n; m++) {
+ Solid3D s1 = objects.get(n);
+ Solid3D s2 = objects.get(m);
+ cr = PhysicsUtility.checkCollision(s1, null, s2, null);
+ // ���̂��߂荞��ł���ꍇ
+ if (cr != null) {
+ double sk = 5000; // ���̂ł̂ˌW��
+ double e = 0.2; // ���̂ł̒��˕Ԃ莞�̒�R�W��
+ double b = 300.0;
+ l = cr.length;
+ // <��p�̗͂̌v�Z>
+ // ��p�_�x�N�g���̍쐬
+ // s1�Ɋւ���v�Z
+ // s1�̊p���x�x�N�g���̍쐬
+ Vector3d r = cr.collisionPoint.getVector3d();
+ r.sub(s1.getGravityCenter().getVector3d());
+ Vector3d s1AngVel = s1.getAngularVelocity().getVector3d();
+ s1AngVel.cross(s1AngVel, r);
+ // s1�̑��x�x�N�g���̍쐬
+ Vector3d s1RelV = s1.getVelocity().getVector3d();
+ // s1�̑��x�x�N�g��+s1�̊p���x�x�N�g����(��p�_-s1�̏d�S)�x�N�g���̊O�όv�Z
+ s1RelV.add(s1AngVel);
+ // s2�Ɋւ���v�Z
+ // s2�̊p���x�x�N�g���̍쐬
+ r = cr.collisionPoint.getVector3d();
+ r.sub(s2.getGravityCenter().getVector3d());
+ Vector3d s2AngVel = s2.getAngularVelocity().getVector3d();
+ s2AngVel.cross(s2AngVel, r);
+ // s2�̑��x�x�N�g���̍쐬
+ Vector3d s2RelV = s2.getVelocity().getVector3d();
+ // s2�̑��x�x�N�g��+s2�̊p���x�x�N�g����(��p�_-s2�̏d�S)�x�N�g���̊O�όv�Z
+ s2RelV.add(s2AngVel);
+ // ���Α��x�x�N�g���̍쐬
+ s1RelV.sub(s2RelV);
+ // �y�i���e�B�̑傫������
+ Vector3d v = (Vector3d)cr.normal.clone();
+//System.out.println(r + "," + (sk * l) + "," + (- relV.dot(v) * b));
+ v.scale(sk * l - s1RelV.dot(v) * b);
+ penalty = new Force3D(v);
+
+ // ����p�̗͂̌v�Z
+ v.scale(-1);
+ inversepenalty = new Force3D(v);
+
+ // ��p�̗͂ɂ�镨�̂̈ړ�
+ forces[n].add(penalty);
+ appPoints[n].add(cr.collisionPoint);
+// s1.move(interval, penalty, cr.collisionPoint);
+
+ // ����p�̗͂ɂ�镨�̂̈ړ�
+ forces[m].add(inversepenalty);
+ appPoints[m].add(cr.collisionPoint);
+// s2.move(interval, inversepenalty, cr.collisionPoint);
+ }
+// // ���̂��߂荞��ł��Ȃ��ꍇ
+// else {
+// s2.move(interval, f, s2.getGravityCenter());
+// s1.move(interval, f, s1.getGravityCenter());
+// }
+ }
+ }
+ for (int n2 = 0; n2 < objects.size(); n2++) {
+ objects.get(n2).move(interval, forces[n2], appPoints[n2]);
+ }
+ }
+}
diff --git a/src/framework/physics/PhysicsUtility.java b/src/framework/physics/PhysicsUtility.java
new file mode 100644
index 0000000..3b038b0
--- /dev/null
+++ b/src/framework/physics/PhysicsUtility.java
@@ -0,0 +1,223 @@
+package framework.physics;
+
+import java.util.ArrayList;
+
+import java3d.BoundingSphere;
+import java3d.Transform3D;
+import java3d.Vector3d;
+
+import framework.model3D.BoundingSurface;
+import framework.model3D.CollisionResult;
+import framework.model3D.Object3D;
+import framework.model3D.Position3D;
+
+
+/**
+ * �������Z�̃R�A
+ * @author �V�c����
+ *
+ */
+public class PhysicsUtility {
+ public static final double GRAVITY = 9.8; // �d�͂̉����x
+ public static final Vector3d horizon = new Vector3d(1.0, 0.0, 0.0);
+ public static final Vector3d vertical = new Vector3d(0.0, 1.0, 0.0);
+
+ public static Vector3d gravityDirection = new Vector3d(0.0, 1.0, 0.0);
+
+ /**
+ * ���̂ɉ����d�͂����߂�
+ * @param body �Ώە���
+ * @return body�ɉ����d��
+ */
+ public static Force3D getGravity(Solid3D body) {
+ return new Force3D(gravityDirection.x * -body.mass * GRAVITY, gravityDirection.y * -body.mass * GRAVITY, gravityDirection.z * -body.mass * GRAVITY);
+ }
+
+ /**
+ * @param v
+ * �F�P�ʃx�N�g���A���邢�̓[���x�N�g���������œn������
+ */
+ public static void setGravityDirection(Vector3d v) {
+ gravityDirection = new Vector3d(v.x, v.y, v.z);
+ }
+
+ // ���[�����g�̌v�Z
+ static Vector3d calcMoment(Force3D f, Position3D gravityCenter,
+ Position3D applicationPoint) {
+ Vector3d v1 = applicationPoint.getVector3d();
+ Vector3d v2 = gravityCenter.getVector3d();
+ v1.sub(v2);
+
+ Vector3d cv = new Vector3d();
+ Vector3d fv = f.getVector3d();
+ cv.cross(v1, fv);
+ return cv;
+
+ }
+
+ /**
+ * ���̂̔����W������Փˎ��ɉ����͂����߂�
+ * @param interval �Փ˂��Ă��鎞��
+ * @param nor ���̂��Ԃ������ʂ̕��x�N�g��
+ * @param solid ����
+ * @return �Փˎ��ɉ�����
+ */
+ public static Force3D calcForce(long interval, Vector3d nor, Solid3D solid) {
+ double f1 = 0.0;
+ Vector3d vf = new Vector3d(solid.getVelocity().getX(), solid
+ .getVelocity().getY(), solid.getVelocity().getZ());
+ f1 = solid.mass * (vf.length() + solid.e * vf.length())
+ / ((double) interval / 1000.0);
+ nor.scale(f1);
+ Force3D f = new Force3D(nor.x, nor.y, nor.z);
+ return f;
+ }
+
+ /**
+ * ���̂ƒn�ʂƂ̏Փ˔���
+ * @param obj ����
+ * @param ground �n��
+ * @return �Փˏ��inull�̂Ƃ��Փ˂Ȃ��j
+ */
+ public static CollisionResult doesIntersect(Solid3D obj, Ground ground) {
+ if (ground == null) return null;
+ CollisionResult cr = null;
+ BoundingSurface boundingSurface = ground.getBoundingSurface();
+
+ // BoundingSphere���g���đ�G�c�ɏՓ˔�����s��
+ ArrayList boundingSurfaceList = null;
+ if (obj.bs != null) {
+ BoundingSphere bs = (BoundingSphere) (obj.bs.clone());
+ Transform3D t3d = new Transform3D();
+ obj.center.getTransform(t3d);
+ bs.transform(t3d);
+ obj.scale.getTransform(t3d);
+ bs.transform(t3d);
+ obj.rot.getTransform(t3d);
+ bs.transform(t3d);
+ obj.pos.getTransform(t3d);
+ bs.transform(t3d);
+ // �e���Փ˔�����s���i�ŏ�ʂ�BoundingSurface��BoundingSphere�̊ԂŁj
+ boundingSurfaceList = boundingSurface.intersect(bs);
+ bs = null;
+ t3d = null;
+ }
+
+ if (obj.bs == null) {
+ // BoundingSphere ���܂�����Ă��ȂȂ������ꍇ�A
+ // �ڍׂȏՓ˔���̂��߂ɁA�ŏ�ʂ̑S BoundingSurface ���擾����
+ if (boundingSurfaceList == null) boundingSurfaceList = new ArrayList();
+ boundingSurfaceList.add(boundingSurface);
+ }
+
+ if (boundingSurfaceList.size() > 0) {
+ // �e���Փ˔���ŏՓ˂��Ă����ꍇ�AOBB�̏W����p���Ă��ڂ����Փ˔�����s��
+ // �iBoundingSphere ���܂�����Ă��Ȃ��ꍇ�AOBB �̍쐬�Ɠ����� BoundingSphere ���쐬�����j
+ BoundingBoxVisitor obbVisitor = new BoundingBoxVisitor();
+ obj.accept(obbVisitor);
+ for (int i = 0; i < obbVisitor.getObbList().size(); i++) {
+ // OBB�ƏՓ˔��������ꍇ�́A�n�ʂ𑽊p�`�̂܂܈���
+ for (int j = 0; j < boundingSurfaceList.size(); j++) {
+ cr = boundingSurfaceList.get(j).intersect(obbVisitor.getObbList().get(i));
+ if (cr != null) {
+ return cr;
+ }
+ }
+ }
+ obbVisitor = null;
+ }
+ return null;
+ }
+
+ /**
+ * ���̓��m�̏Փ˔���
+ * @param obj1 ����1
+ * @param part1 ���肷�镨��1�̕����̖���
+ * @param obj2 ����2
+ * @param part2 ���肷�镨��2�̕����̖���
+ * @return�@�Փˏ��inull�̂Ƃ��Փ˂Ȃ��j
+ */
+ public static CollisionResult checkCollision(Object3D obj1, String part1,
+ Object3D obj2, String part2) {
+ CollisionResult cr = null;
+
+ // BoundingSphere���g���đ�G�c�ɏՓ˔�����s��
+ boolean f = false;
+ if (obj1.bs != null && obj2.bs != null) {
+ // sol1 �� BoundingSphere�@���v�Z
+ BoundingSphere bs1 = (BoundingSphere) (obj1.bs.clone());
+ Transform3D t3d = new Transform3D();
+ obj1.center.getTransform(t3d);
+ bs1.transform(t3d);
+ obj1.scale.getTransform(t3d);
+ bs1.transform(t3d);
+ obj1.rot.getTransform(t3d);
+ bs1.transform(t3d);
+ obj1.pos.getTransform(t3d);
+ bs1.transform(t3d);
+
+ // sol2 �� BoundingSphere�@���v�Z
+ BoundingSphere bs2 = (BoundingSphere) (obj2.bs.clone());
+ obj2.center.getTransform(t3d);
+ bs2.transform(t3d);
+ obj2.scale.getTransform(t3d);
+ bs2.transform(t3d);
+ obj2.rot.getTransform(t3d);
+ bs2.transform(t3d);
+ obj2.pos.getTransform(t3d);
+ bs2.transform(t3d);
+
+ // BoundingSphere ���m�̏Փ˔���
+ if (bs1.intersect(bs2)) {
+ f = true;
+ }
+ t3d = null;
+ bs1 = null;
+ bs2 = null;
+ }
+ if (f || obj1.bs == null || obj2.bs == null) {
+ BoundingBoxVisitor visitor1 = new BoundingBoxVisitor(part1);
+ BoundingBoxVisitor visitor2 = new BoundingBoxVisitor(part2);
+ obj1.accept(visitor1);
+ obj2.accept(visitor2);
+ // OBB o1 = obj1.getOBB(0);
+ // OBB o2 = obj2.getOBB(0);
+ // cr = o1.intersect(o2);
+ int i, j;
+ for (i = 0; i < visitor1.getObbList().size(); i++) {
+ for (j = 0; j < visitor2.getObbList().size(); j++) {
+ cr = visitor2.getObbList().get(j).intersect(visitor1.getObbList().get(i));
+ // System.out.println("flg:"+flg);
+ if (cr != null) {
+ // Vector3d v = new Vector3d(0,0,0);
+ // System.out.println("checkColision1
+ // Yes!!"+cr.collisionPoint.getX());
+ // System.out.println("checkColision1
+ // Yes!!"+cr.collisionPoint.getY());
+ // System.out.println("checkColision1
+ // Yes!!"+cr.collisionPoint.getZ());
+ // return v;
+ return cr;
+ } else {
+ cr = visitor1.getObbList().get(i).intersect(
+ visitor2.getObbList().get(j));
+ if (cr != null) {
+ cr.normal.scale(-1.0);
+ // Vector3d v = new Vector3d(0,0,0);
+ // System.out.println("checkColision2
+ // Yes!!"+cr.collisionPoint.getX());
+ // System.out.println("checkColision2
+ // Yes!!"+cr.collisionPoint.getY());
+ // System.out.println("checkColision2
+ // Yes!!"+cr.collisionPoint.getZ());
+ // return v;
+ return cr;
+ }
+ }
+ }
+ }
+ }
+ // System.out.println("Yes!!");
+ return null;
+ }
+}
diff --git a/src/framework/physics/ProjectionResult.java b/src/framework/physics/ProjectionResult.java
new file mode 100644
index 0000000..18a8b65
--- /dev/null
+++ b/src/framework/physics/ProjectionResult.java
@@ -0,0 +1,11 @@
+package framework.physics;
+
+import java.util.ArrayList;
+
+import java3d.Vector3d;
+
+public class ProjectionResult {
+ double max = 0.0;
+ double min = 0.0;
+ ArrayList vertexList = new ArrayList();
+}
diff --git a/src/framework/physics/Solid3D.java b/src/framework/physics/Solid3D.java
new file mode 100644
index 0000000..ac6db0d
--- /dev/null
+++ b/src/framework/physics/Solid3D.java
@@ -0,0 +1,177 @@
+package framework.physics;
+
+import java.util.ArrayList;
+
+import java3d.AxisAngle4d;
+import java3d.Vector3d;
+
+import framework.model3D.Object3D;
+import framework.model3D.Position3D;
+import framework.model3D.Quaternion3D;
+
+/**
+ * �����I�ȐU�镑�������镨�́i���́j��\��
+ * @author �V�c����
+ *
+ */
+public class Solid3D extends Object3D {
+ private Velocity3D velocity;
+ private AngularVelocity3D angularvelocity;
+ private Position3D gravityCenter = getPosition3D();
+ public double e = 1.0;
+ public double mass = 10;
+ private Inertia3D inertia = null;
+
+ // �R�s�[�R���X�g���N�^
+ public Solid3D(Object3D obj) {
+ super(obj);
+ velocity = new Velocity3D();
+ angularvelocity = new AngularVelocity3D();
+ inertia = new Inertia3D(this);
+ }
+
+ public Solid3D(Object3D obj, double mass) {
+ super(obj);
+ velocity = new Velocity3D();
+ angularvelocity = new AngularVelocity3D();
+ this.mass = mass;
+ inertia = new Inertia3D(this);
+ }
+
+ public Solid3D(Solid3D solid) {
+ super(solid);
+ if (solid.velocity != null) {
+ velocity = new Velocity3D(solid.velocity);
+ } else {
+ velocity = new Velocity3D();
+ }
+ if (solid.angularvelocity != null) {
+ angularvelocity = new AngularVelocity3D(solid.angularvelocity);
+ } else {
+ angularvelocity = new AngularVelocity3D();
+ }
+ mass = solid.mass;
+ inertia = new Inertia3D(this);
+ }
+
+ /**
+ * �͊w�^���̌v�Z�i�����͂�1�̏ꍇ�j
+ * @param interval �P�ʎ���
+ * @param f ��
+ * @param applicationPoint �͂̍�p�_
+ */
+ public void move(long interval, Force3D f, Position3D applicationPoint) {
+ // ���[�����g�̌v�Z
+ Vector3d moment = PhysicsUtility.calcMoment(f, getGravityCenter(),
+ applicationPoint);
+ moveSub(interval, f, moment);
+ }
+
+ /**
+ * �͊w�^���̌v�Z�i�����ɕ����̗͂������ꍇ�j
+ * @param interval �P�ʎ���
+ * @param forces �́i�����j
+ * @param appPoints ���ꂼ��̗͂̍�p�_
+ */
+ public void move(long interval, ArrayList forces,
+ ArrayList appPoints) {
+ // �d�S�ɉ����͂̍��v�����߂�
+ Force3D f = new Force3D(0.0, 0.0, 0.0);
+ for (int n = 0; n < forces.size(); n++) {
+ f.add(forces.get(n));
+ }
+
+ // ���[�����g�̍��v���v�Z����
+ Position3D gc = getGravityCenter();
+ Vector3d moment = new Vector3d(0.0, 0.0, 0.0);
+ for (int n2 = 0; n2 < forces.size(); n2++) {
+ moment.add(PhysicsUtility.calcMoment(forces.get(n2), gc, appPoints.get(n2)));
+ }
+ moveSub(interval, f, moment);
+ }
+
+ private void moveSub(long interval, Force3D f, Vector3d moment) {
+ // 1.�d�S�̉^���������i�j���[�g���������j
+ // �����x�A���x�v�Z
+ Vector3d deltaV = f.getVector3d(); // �̓x�N�g���̎擾
+ deltaV.scale(1.0 / mass * ((double) interval / 1000.0)); // �����x���瑬�x�̍������v�Z
+ Velocity3D v = getVelocity().add(deltaV); // ���x�ɍ��������Z
+ apply(v, false);
+
+ // �d�S�ʒu�v�Z
+ Vector3d deltaP = velocity.getVector3d(); // ���x�x�N�g���̎擾
+ deltaP.scale(((double) interval / 1000.0));
+ Position3D p = getPosition3D().add(deltaP); // �ʒu�ɍ��������Z
+ apply(p, false);
+
+ // 2.�I�C���[�̊p�^��������
+
+ // �p�����x�A�p���x�v�Z
+ AngularVelocity3D w = getAngularVelocity();
+ Vector3d deltaAngularV = new Vector3d(
+ (moment.x + (inertia.iyy - inertia.izz) * w.getY() * w.getZ()) / inertia.ixx,
+ (moment.y + (inertia.izz - inertia.ixx) * w.getZ() * w.getX()) / inertia.iyy,
+ (moment.z + (inertia.ixx - inertia.iyy) * w.getX() * w.getY()) / inertia.izz);
+ deltaAngularV.scale((double) interval / 1000.0);
+ w.add(deltaAngularV);
+ apply(w, false);
+
+ // �p���x�ɂ���]�v�Z
+ AxisAngle4d axisAngle = w.getAxisAngle4d();
+ axisAngle.angle *= ((double) interval / 1000.0);
+ Quaternion3D q = getQuaternion().add(axisAngle);
+ apply(q, false);
+ }
+
+ // ���������
+ public Object3D duplicate() {
+ Object3D copy = new Solid3D(this);
+ return copy;
+ }
+
+ public void scale(double s) {
+ super.scale(s);
+ inertia = new Inertia3D(this);
+ }
+
+ public void scale(double sx, double sy, double sz) {
+ super.scale(sx, sy, sz);
+ inertia = new Inertia3D(this);
+ }
+
+ public Velocity3D getVelocity() {
+ return (Velocity3D) velocity.clone();
+ }
+
+ public AngularVelocity3D getAngularVelocity() {
+ return (AngularVelocity3D) angularvelocity.clone();
+ }
+
+ // Velocity3D �� applyTo �ȊO����͌ĂȂ�����
+ void setVelocity(Velocity3D v) {
+ velocity = (Velocity3D) v.clone();
+ }
+
+ // AngularVelocity3D �� applyTo �ȊO����͌ĂȂ�����
+ void setAngularVelocity(AngularVelocity3D w) {
+ angularvelocity = (AngularVelocity3D) w.clone();
+ }
+
+ public void setGravityCenter(Position3D gravityCenter) {
+ this.gravityCenter = gravityCenter;
+ }
+
+ public Position3D getGravityCenter() {
+ return getPosition3D().add(gravityCenter);
+ }
+
+ public void setMass(double mass) {
+ this.mass = mass;
+ inertia = new Inertia3D(this);
+ }
+
+ public double getMass() {
+ return mass;
+ }
+
+}
diff --git a/src/framework/physics/Velocity3D.java b/src/framework/physics/Velocity3D.java
new file mode 100644
index 0000000..6b49c67
--- /dev/null
+++ b/src/framework/physics/Velocity3D.java
@@ -0,0 +1,140 @@
+package framework.physics;
+import java3d.Transform3D;
+import java3d.Vector3d;
+
+import framework.model3D.Object3D;
+import framework.model3D.Property3D;
+
+
+public class Velocity3D extends Property3D {
+ private double x;
+ private double y;
+ private double z;
+
+ public Velocity3D(Velocity3D v) {
+ x = v.x;
+ y = v.y;
+ z = v.z;
+ }
+
+ public Velocity3D(Vector3d v) {
+ this.x = v.x;
+ this.y = v.y;
+ this.z = v.z;
+ }
+
+ public Velocity3D(double x, double y, double z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ public Velocity3D() {
+ x = 0.0;
+ y = 0.0;
+ z = 0.0;
+ }
+
+ public void applyTo(Object3D o) {
+ ((Solid3D)o).setVelocity(this);
+ }
+
+ public double getX() {
+ return this.x;
+ }
+
+ public double getY() {
+ return this.y;
+ }
+
+ public double getZ() {
+ return this.z;
+ }
+
+ public Velocity3D setX(double x) {
+ this.x = x;
+ return this;
+ }
+
+ public Velocity3D setY(double y) {
+ this.y = y;
+ return this;
+ }
+
+ public Velocity3D setZ(double z) {
+ this.z = z;
+ return this;
+ }
+
+ public Velocity3D add(double x, double y, double z){
+ this.x += x;
+ this.y += y;
+ this.z += z;
+ return this;
+ }
+
+ public Velocity3D add(Vector3d v) {
+ this.x += v.x;
+ this.y += v.y;
+ this.z += v.z;
+ return this;
+ }
+
+ public Velocity3D setVector3d(Vector3d v) {
+ x = v.x;
+ y = v.y;
+ z = v.z;
+ return this;
+ }
+
+ public Vector3d getVector3d() {
+ return new Vector3d(x,y,z);
+ }
+
+ @Override
+ public Property3D clone() {
+ return new Velocity3D(this);
+ }
+
+ public Velocity3D rotX(double a) {
+ Vector3d v = getVector3d();
+ Transform3D rotX = new Transform3D();
+ rotX.rotX(a);
+ rotX.transform(v);
+ setVector3d(v);
+ return this;
+ }
+
+ public Velocity3D rotY(double a) {
+ Vector3d v = getVector3d();
+ Transform3D rotY = new Transform3D();
+ rotY.rotY(a);
+ rotY.transform(v);
+ setVector3d(v);
+ return this;
+ }
+
+ public Velocity3D rotZ(double a) {
+ Vector3d v = getVector3d();
+ Transform3D rotZ = new Transform3D();
+ rotZ.rotZ(a);
+ rotZ.transform(v);
+ setVector3d(v);
+ return this;
+ }
+
+ public Velocity3D setVelocity(double velocity) {
+ Vector3d v = getVector3d();
+ double oldV = v.length();
+ v.scale(velocity / oldV);
+ setVector3d(v);
+ return this;
+ }
+
+ public Velocity3D mul(double d) {
+ this.x *= d;
+ this.y *= d;
+ this.z *= d;
+ return this;
+ }
+}
diff --git a/src/game/Bomb.java b/src/game/Bomb.java
new file mode 100644
index 0000000..41ff5cb
--- /dev/null
+++ b/src/game/Bomb.java
@@ -0,0 +1,5 @@
+package game;
+
+public class Bomb implements Item {
+
+}
diff --git a/src/game/CVS/Entries b/src/game/CVS/Entries
new file mode 100644
index 0000000..b8ad02e
--- /dev/null
+++ b/src/game/CVS/Entries
@@ -0,0 +1,17 @@
+/Bomb.java/1.1/Tue Jul 12 06:48:48 2016//
+/Entity.java/1.1/Tue Oct 25 06:28:07 2016//
+/Game.java/1.34/Tue Dec 13 06:22:05 2016//
+/GameManager.java/1.18/Tue Dec 6 05:19:14 2016//
+/IGameElement.java/1.2/Tue Jun 21 03:11:17 2016//
+/IGameElementVisitor.java/1.2/Tue Jun 21 03:11:17 2016//
+/Item.java/1.1/Thu Jul 7 06:45:05 2016//
+/Laser.java/1.13/Thu Dec 1 08:18:09 2016//
+/LaserTurret.java/1.14/Thu Dec 1 08:48:38 2016//
+/Mirror.java/1.7/Thu Nov 17 08:48:30 2016//
+/Player.java/1.14/Thu Dec 1 10:06:06 2016//
+/PlayerSearchVisitor.java/1.4/Tue Jun 21 07:01:10 2016//
+/Stage.java/1.10/Tue Nov 29 08:40:28 2016//
+/StageStandard.java/1.1/Tue Nov 22 08:16:45 2016//
+/Team.java/1.14/Thu Dec 1 10:05:00 2016//
+/TestPlayerSearchVisitorjava.java/1.5/Tue Nov 8 06:09:32 2016//
+/TestPlayerSearchVisitorjava2.java/1.2/Tue Nov 8 06:09:32 2016//
diff --git a/src/game/CVS/Repository b/src/game/CVS/Repository
new file mode 100644
index 0000000..e1ba274
--- /dev/null
+++ b/src/game/CVS/Repository
@@ -0,0 +1 @@
+CarrotServer/src/game
diff --git a/src/game/CVS/Root b/src/game/CVS/Root
new file mode 100644
index 0000000..c36e9d0
--- /dev/null
+++ b/src/game/CVS/Root
@@ -0,0 +1 @@
+:pserver:guest@nitta-lab-www.is.konan-u.ac.jp:\CVSProject
diff --git a/src/game/Entity.java b/src/game/Entity.java
new file mode 100644
index 0000000..5172e7a
--- /dev/null
+++ b/src/game/Entity.java
@@ -0,0 +1,68 @@
+package game;
+
+import framework.model3D.BaseObject3D;
+import framework.model3D.GeometryUtility;
+import framework.model3D.Object3D;
+import framework.model3D.Placeable;
+import framework.model3D.Position3D;
+import framework.model3D.Quaternion3D;
+import framework.physics.Solid3D;
+import java3d.AxisAngle4d;
+import java3d.Transform3D;
+import java3d.TransformGroup;
+import java3d.Vector3d;
+
+public class Entity implements Placeable {
+protected Object3D body;
+protected Vector3d direction = new Vector3d(1.0, 0.0, 0.0);
+
+ @Override
+ public TransformGroup getTransformGroupToPlace() {
+ // TODO Auto-generated method stub
+ return body.getTransformGroupToPlace();
+ }
+
+ @Override
+ public BaseObject3D getBody() {
+ // TODO Auto-generated method stub
+ return body;
+ }
+
+ public Position3D getPosition() {
+ return body.getPosition3D();
+ }
+
+ public void setPosition(Position3D p) {
+ body.apply(p, false);
+ }
+
+ public Vector3d getDirection() {
+ Vector3d dir = new Vector3d(direction);
+ Transform3D trans = new Transform3D();
+ trans.set(((Solid3D)body).getQuaternion().getAxisAngle());
+ trans.transform(dir);
+ return dir;
+ }
+
+ public void setDirection(Vector3d vec) {
+ Vector3d v1 = new Vector3d();
+ Vector3d v2 = new Vector3d();
+ v1.cross(direction, GeometryUtility.Y_AXIS);
+ v2.cross(vec, GeometryUtility.Y_AXIS);
+ if (v2.length() < GeometryUtility.TOLERANCE) return;
+ v1.normalize();
+ v2.normalize();
+ double cos = v1.dot(v2);
+ v1.cross(v1, v2);
+ double sin = v1.dot(GeometryUtility.Y_AXIS);
+ double angle = Math.atan2(sin, cos);
+ AxisAngle4d axisAngle = new AxisAngle4d(GeometryUtility.Y_AXIS, angle);
+ Quaternion3D quat = new Quaternion3D(axisAngle);
+ ((Solid3D)body).apply(quat, false);
+ }
+
+ public void setInitialDirection(Vector3d dir) {
+ direction = dir;
+ }
+
+}
diff --git a/src/game/Game.java b/src/game/Game.java
new file mode 100644
index 0000000..0aa0c43
--- /dev/null
+++ b/src/game/Game.java
@@ -0,0 +1,346 @@
+package game;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import javax.servlet.http.HttpServlet;
+
+import account.Account;
+import framework.gameMain.OvergroundActor;
+import framework.model3D.CollisionResult;
+import framework.model3D.Object3D;
+import framework.model3D.Position3D;
+import framework.model3D.Universe;
+import framework.physics.Ground;
+import framework.physics.PhysicsUtility;
+import framework.physics.Velocity3D;
+import java3d.Vector3d;
+import room.Room;
+
+public class Game implements IGameElement {
+
+ public static final int TEAM_RED = 0;
+ public static final int TEAM_BLUE = 1;
+
+ private Room room = null;
+ private Team teamRed = new Team();
+ private Team teamBlue = new Team();
+
+ private Stage stage = new Stage();
+
+ public static final int GAME_TIME = 180000; //3m 180000ms
+ public static final int COOL_TIME = 10000; //10s 10000ms
+ public static final int LASER_ACTIVE_TIME = 20000; //20s 20000ms
+ public static final int MIRROR_ACTIVE_TIME = 20000; //20s 20000ms
+
+ int remainTime = 180000;//�c�莞��
+
+ int startTime = 0;
+
+ boolean removeFlag = false;
+
+ //pre:�������@play:�Q�[�����@red,blue:�����`�[���@end:�������ԏI��
+ String state = "pre";
+
+ private Universe universe = new Universe();
+
+ CollisionResult cr = null;
+
+ /*******************************
+ * update
+ *******************************/
+ public void update(int countTime) {
+
+ /*------------------------------
+ state = pre �ҋ@��
+ ------------------------------*/
+ if(state.equals("pre")) {
+ state = "play";
+ startTime = countTime;
+
+
+ /*------------------------------
+ state = play �Q�[����
+ ------------------------------*/
+ } else if(state.equals("play")) {
+
+ //�c�莞��
+ remainTime = GAME_TIME - calcElapsedTime(countTime, startTime);
+
+ //�Q�[���i�s����@�c�莞�Ԃ����邩�ǂ���
+ if(remainTime <= 0) {
+ state = "end";
+ return;
+ }
+
+ //Laser�̃N�[���^�C���̊m�F
+ if(teamRed.getCoolTimeFlag() == true) {
+ //�o�ߎ���
+ if(COOL_TIME <= calcElapsedTime(countTime, teamRed.getCoolTime())) {
+ teamRed.setCoolTimeFlag(false);
+ }
+ }
+
+ //teamRed��LaserTurert�EMirror�̏�������
+ LaserTurretActiveCheck(teamRed, countTime);
+ MirrorActiveCheck(teamRed, countTime);
+
+ //teamBlue��LaserTurert�EMirror�̏�������
+ LaserTurretActiveCheck(teamBlue, countTime);
+ MirrorActiveCheck(teamBlue, countTime);
+
+ //�A�C�e������
+ universe.update(GameManager.DELAY_TIME);
+
+ //Laser�ƕǂ�������������Laser���������@�e�`�[����
+ if(teamRed.getLaserTurret() != null && teamRed.getLaserTurret().getLaser() != null && teamRed.getLaserTurret().getLaser().getIsCollision()) {
+ universe.displace(teamRed.getLaserTurret().getLaser());
+ teamRed.removeLaserTurret(countTime);
+ }
+ if(teamBlue.getLaserTurret() != null && teamBlue.getLaserTurret().getLaser() != null &&teamBlue.getLaserTurret().getLaser().getIsCollision()) {
+ universe.displace(teamBlue.getLaserTurret().getLaser());
+ teamBlue.removeLaserTurret(countTime);
+ }
+
+ //���e�̏����E��,�X�e�[�W�Ƃ̂����蔻��܂�
+
+ //teamRed�̃��[�U�̂����蔻��
+ if(teamRed.getLaserTurret() != null) {
+ //�@���d�l��state��on�ł�comp�ł������蔻�肷��@�{����on�̂�
+ if((teamRed.getLaserTurret().getState().equals("comp")) || (teamRed.getLaserTurret().getState().equals("on"))) {
+
+ //Laser���擾
+ Laser laserR = teamRed.getLaserTurret().getLaser();
+
+ //laserR�@�Ɓ@teamRed�̑S���̂����蔻��@����
+ LaserMirrorCheckCollision(laserR, teamRed);
+
+ //laserR �� teamBlue�̑S���̂����蔻��@����
+ LaserMirrorCheckCollision(laserR, teamBlue);
+
+ //laserR �� �S�v���C���̂����蔻��
+ LaserPlayerCheckCollision(laserR);
+ }
+ }
+
+ //teamBlue�̃��[�U�̂����蔻��
+ if(teamBlue.getLaserTurret() != null) {
+ //�@���d�l��state��on�ł�comp�ł������蔻�肷��
+ if((teamBlue.getLaserTurret().getState().equals("comp")) || (teamBlue.getLaserTurret().getState().equals("on"))) {
+
+ //Laser���擾
+ Laser laserB = teamBlue.getLaserTurret().getLaser();
+
+ //laserB�@�Ɓ@teamRed�̑S�Ă̋��̂����蔻��@����
+ LaserMirrorCheckCollision(laserB, teamRed);
+
+ //laserB�@�Ɓ@teamBlue�̑S�Ă̋��̂����蔻��@����
+ LaserMirrorCheckCollision(laserB, teamBlue);
+
+ //���[�U�����ƃv���C���S���̂����蔻��
+ LaserPlayerCheckCollision(laserB);
+ }
+ }
+ /*------------------------------
+ state = end, red, blue�@�Q�[���I��
+ ------------------------------*/
+ } else if(state.equals("end") || state.equals("red") || state.equals("blue")) {
+System.out.println("end�@���@red ���@blue�@�� else if");
+ gameRemoveCheck(countTime);
+ }
+ }
+
+ //�ԁE�`�[���ɃA�J�E���g��lj����A�A�J�E���g�ɂ��o�^����
+ public void setTeamTo(Account ac, int team) {
+ if(team == TEAM_RED) {
+ teamRed.addMember(ac);
+ } else if(team == TEAM_BLUE) {
+ teamBlue.addMember(ac);
+ }
+
+ //�A�J�E���g�ɓo�^
+ ac.setTeam(team);
+ }
+
+ //�ԁE�`�[����n�Ԗڂ̃����o�[��Ԃ�
+ public Account getTeamMember(int n,int team) {
+ if(team == TEAM_RED){
+ return teamRed.getMember(n);
+ }else if(team == TEAM_BLUE){
+ return teamBlue.getMember(n);
+ }
+
+ return null;
+ }
+
+ //�����ȊO�̐ԁE�`�[����n�Ԗڂ̃����o�[��Ԃ�
+ public Account getTeamMemberExceptSelf(int n,int team,String sId) {
+ if(team == TEAM_RED){
+ Account ac = teamRed.getMember(n);
+ if(!ac.getsId().equals(sId)){
+ return ac;
+ }
+ }else if(team == TEAM_BLUE){
+ Account ac = teamBlue.getMember(n);
+ if(!ac.getsId().equals(sId)){
+ return ac;
+ }
+ }
+
+ return null;
+ }
+
+ //���[�U��z�u����
+ public void placeLaser(Laser laser) {
+ universe.place(laser);
+ }
+
+ //Mirror��z�u����
+ public void placeMirror(Mirror mirror) {
+ universe.place(mirror);
+ }
+
+ //�X�e�[�W��z�u����
+ public void placeStage() {
+ final Ground ground = new StageStandard();
+ universe.place(ground);
+ }
+
+ //�o�ߎ��Ԃ̌v�Z�@�@countTime = ���ݎ��ԁA time =�@�Q�[���̃X�^�[�g���Ԃ�A�C�e���̐ݒu���ԂȂ�
+ public int calcElapsedTime(int countTime, int startTime) {
+ return (countTime - startTime) * GameManager.DELAY_TIME;
+ }
+
+ //�c�莞��
+ public int remainTime() {
+ int rTime = remainTime / 1000;
+ return rTime;
+ }
+
+ //LaserTurret�̗L������
+ public void LaserTurretActiveCheck(Team team, int countTime) {
+ if(team.getLaserTurret() != null) {
+
+ //Laser�������Ă���̂ɁAstartTime���L�^����Ă��Ȃ���L�^����B
+ if(team.getLaserTurret().getLaser() != null && team.getLaserTurret().getStartTime() == 0) {
+ team.getLaserTurret().setStartTime(countTime);
+
+ //Laser�������Ă��āAstartTime���L�^����Ă���Ƃ��͌o�ߎ��Ԃ̔���
+ } else if(team.getLaserTurret().getLaser() != null && team.getLaserTurret().getStartTime() != 0) {
+
+ //�o�ߎ��Ԃ肵�A�K�莞�Ԉȏ�̏ꍇ�͏���
+ if(LASER_ACTIVE_TIME <= calcElapsedTime(countTime, team.getLaserTurret().getStartTime())) {
+ universe.displace(team.getLaserTurret().getLaser());
+ team.removeLaserTurret(countTime);
+ }
+ }
+ }
+ }
+
+ //Mirror�̗L������
+ public void MirrorActiveCheck(Team team, int countTime) {
+ for(int i=0; i gameList = new ArrayList();
+
+ //�^�C�}�[���������J�n
+ public void start() {
+ ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
+ scheduler.scheduleAtFixedRate(this, 0, DELAY_TIME, TimeUnit.MILLISECONDS);
+ }
+
+ //�����蔻��E���[�U�����┚�e�̏����@run()
+ @Override
+ public void run() {
+
+System.out.println("scheduler : " + countTime);
+ countTime++;
+
+ //game�����鎞��
+ if(gameList.size() > 0) {
+ Game game;
+ for(int j=0; j= 120){
+ return true;
+ }
+ }
+ //�S�[�����Ă��Ȃ�
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/src/game/StageStandard.java b/src/game/StageStandard.java
new file mode 100644
index 0000000..e3abd33
--- /dev/null
+++ b/src/game/StageStandard.java
@@ -0,0 +1,260 @@
+package game;
+
+import framework.model3D.BaseObject3D;
+import framework.model3D.Object3D;
+import framework.model3D.Position3D;
+import framework.model3D.Quaternion3D;
+import framework.physics.Ground;
+import framework.physics.Solid3D;
+import java3d.Appearance;
+import java3d.Box;
+import java3d.IndexedTriangleArray;
+import java3d.Material;
+import java3d.Point3d;
+import java3d.Shape3D;
+import java3d.Texture;
+import java3d.Vector3f;
+
+public class StageStandard extends Stage {
+
+ public StageStandard() {
+ super();
+
+
+ // TODO Auto-generated constructor stub
+
+ //���_�̐��A���_�̎g�p�̐錾
+ //�����̍쐬�̂��߂̃W�I���g��
+ IndexedTriangleArray cubeGeometry = new IndexedTriangleArray(24,
+ IndexedTriangleArray.COORDINATES | IndexedTriangleArray.NORMALS, 36);
+
+
+ //��ʐ����@���_���W������
+ //�O�ʁi�����̖̂ʂ̖��O�j
+ cubeGeometry.setCoordinate(0, new Point3d(0.0, 0.0, 0.0));
+ cubeGeometry.setCoordinate(1, new Point3d(1.0, 0.0, 0.0));
+ cubeGeometry.setCoordinate(2, new Point3d(1.0, 1.0, 0.0));
+ cubeGeometry.setCoordinate(3, new Point3d(0.0, 1.0, 0.0));
+ //�P��
+ cubeGeometry.setCoordinate(4, new Point3d(1.0, 0.0, 0.0));
+ cubeGeometry.setCoordinate(5, new Point3d(1.0, 0.0, 1.0));
+ cubeGeometry.setCoordinate(6, new Point3d(1.0, 1.0, 1.0));
+ cubeGeometry.setCoordinate(7, new Point3d(1.0, 1.0, 0.0));
+ //2��
+ cubeGeometry.setCoordinate(8, new Point3d(1.0, 0.0, 1.0));
+ cubeGeometry.setCoordinate(9, new Point3d(1.0, 1.0, 1.0));
+ cubeGeometry.setCoordinate(10, new Point3d(0.0, 1.0, 1.0));
+ cubeGeometry.setCoordinate(11, new Point3d(0.0, 0.0, 1.0));
+ //3��
+ cubeGeometry.setCoordinate(12, new Point3d(0.0, 0.0, 1.0));
+ cubeGeometry.setCoordinate(13, new Point3d(0.0, 1.0, 1.0));
+ cubeGeometry.setCoordinate(14, new Point3d(0.0, 1.0, 0.0));
+ cubeGeometry.setCoordinate(15, new Point3d(0.0, 0.0, 0.0));
+ //���
+ cubeGeometry.setCoordinate(16, new Point3d(0.0, 1.0, 0.0));
+ cubeGeometry.setCoordinate(17, new Point3d(1.0, 1.0, 0.0));
+ cubeGeometry.setCoordinate(18, new Point3d(1.0, 1.0, 1.0));
+ cubeGeometry.setCoordinate(19, new Point3d(0.0, 1.0, 1.0));
+ //���
+ cubeGeometry.setCoordinate(20, new Point3d(0.0, 0.0, 0.0));
+ cubeGeometry.setCoordinate(21, new Point3d(1.0, 0.0, 0.0));
+ cubeGeometry.setCoordinate(22, new Point3d(1.0, 0.0, 1.0));
+ cubeGeometry.setCoordinate(23, new Point3d(0.0, 0.0, 1.0));
+ //�@���x�N�g��������
+ //0��
+ cubeGeometry.setNormal(0, new Vector3f(0.0f, 0.0f, -1.0f));
+ cubeGeometry.setNormal(1, new Vector3f(0.0f, 0.0f, -1.0f));
+ cubeGeometry.setNormal(2, new Vector3f(0.0f, 0.0f, -1.0f));
+ cubeGeometry.setNormal(3, new Vector3f(0.0f, 0.0f, -1.0f));
+ //�P��
+ cubeGeometry.setNormal(4, new Vector3f(1.0f, 0.0f, 0.0f));
+ cubeGeometry.setNormal(5, new Vector3f(1.0f, 0.0f, 0.0f));
+ cubeGeometry.setNormal(6, new Vector3f(1.0f, 0.0f, 0.0f));
+ cubeGeometry.setNormal(7, new Vector3f(1.0f, 0.0f, 0.0f));
+ //2��
+ cubeGeometry.setNormal(8, new Vector3f(0.0f, 0.0f, 1.0f));
+ cubeGeometry.setNormal(9, new Vector3f(0.0f, 0.0f, 1.0f));
+ cubeGeometry.setNormal(10, new Vector3f(0.0f, 0.0f, 1.0f));
+ cubeGeometry.setNormal(11, new Vector3f(0.0f, 0.0f, 1.0f));
+ //3��
+ cubeGeometry.setNormal(12, new Vector3f(-1.0f, 0.0f, 0.0f));
+ cubeGeometry.setNormal(13, new Vector3f(-1.0f, 0.0f, 0.0f));
+ cubeGeometry.setNormal(14, new Vector3f(-1.0f, 0.0f, 0.0f));
+ cubeGeometry.setNormal(15, new Vector3f(-1.0f, 0.0f, 0.0f));
+ //���
+ cubeGeometry.setNormal(16, new Vector3f(0.0f, 1.0f, 0.0f));
+ cubeGeometry.setNormal(17, new Vector3f(0.0f, 1.0f, 0.0f));
+ cubeGeometry.setNormal(18, new Vector3f(0.0f, 1.0f, 0.0f));
+ cubeGeometry.setNormal(19, new Vector3f(0.0f, 1.0f, 0.0f));
+ //���
+ cubeGeometry.setNormal(20, new Vector3f(0.0f, -1.0f, 0.0f));
+ cubeGeometry.setNormal(21, new Vector3f(0.0f, -1.0f, 0.0f));
+ cubeGeometry.setNormal(22, new Vector3f(0.0f, -1.0f, 0.0f));
+ cubeGeometry.setNormal(23, new Vector3f(0.0f, -1.0f, 0.0f));
+ //���_���w�肵�ĎO�p�`�쐬
+ //�O�ʍ쐬
+ cubeGeometry.setCoordinateIndices(0, new int[]{1, 0, 3});
+ cubeGeometry.setCoordinateIndices(3, new int[]{1, 3, 2});
+ //1�ʍ쐬
+ cubeGeometry.setCoordinateIndices(6, new int[]{5, 4, 7});
+ cubeGeometry.setCoordinateIndices(9, new int[]{5, 7, 6});
+ //2�ʍ쐬
+ cubeGeometry.setCoordinateIndices(12, new int[]{11, 8, 9});
+ cubeGeometry.setCoordinateIndices(15, new int[]{11, 9, 10});
+ //3�ʍ쐬
+ cubeGeometry.setCoordinateIndices(18, new int[]{12, 13, 14});
+ cubeGeometry.setCoordinateIndices(21, new int[]{12, 14, 15});
+ //��ʍ쐬
+ cubeGeometry.setCoordinateIndices(24, new int[]{16, 18, 17});
+ cubeGeometry.setCoordinateIndices(27, new int[]{16, 19, 18});
+ //��ʍ쐬
+ cubeGeometry.setCoordinateIndices(30, new int[]{20, 22, 21});
+ cubeGeometry.setCoordinateIndices(33, new int[]{20, 23, 22});
+ //
+
+
+ //�p�[�c�̐F�̐ݒ�
+ //��
+ Appearance groundApp = new Appearance();
+ Material groundMa =new Material();
+ groundMa.setDiffuseColor(0.8f,0.2f,0.0f);
+ groundApp.setMaterial(groundMa);
+
+ //��
+ Appearance wallApp = new Appearance();
+ Material wallMa =new Material();
+ wallMa.setDiffuseColor(0.0f, 1.0f, 1.0f);
+ wallApp.setMaterial(wallMa);
+
+ //��Q��(Obstacle)
+ Appearance ObstacleApp = new Appearance();
+ Material ObstacleMa =new Material();
+ ObstacleMa.setDiffuseColor(0.0f, 10.0f, 0.0f);
+ ObstacleApp.setMaterial(ObstacleMa);
+
+ //�̖߰����A�F�̐ݒ�
+ Shape3D groundShape = new Shape3D(cubeGeometry, groundApp);
+ Shape3D wallShape = new Shape3D(cubeGeometry,wallApp);
+ Shape3D ObstacleShape =new Shape3D(cubeGeometry,ObstacleApp);
+
+ //�����̂𗘗p���X�e�[�W�̃p�[�c�i�n�ʁB�ǁB��Q���Ȃǁj��Object3D�Ƃ��Ĉ�����悤�ɐݒ�
+ //��
+ Object3D ground = new Object3D("ground", groundShape);
+ //��(���� �����}�C�i�X��)
+ Object3D wallM = new Object3D("wallM",wallShape);
+ //��(���������v���X��)
+ Object3D wallP = new Object3D("wallP",wallShape);
+ //��(x���}�C�i�X��)
+ Object3D wall_lM = new Object3D("wall_lM",wallShape);
+ //��(x���v���X��)
+ Object3D wall_lP = new Object3D("wall_lP",wallShape);
+ //��Q���iobstacle�j
+ Object3D Obstacle0=new Object3D("Obstacle0",ObstacleShape);
+ //��Q���iobstacle�j
+ Object3D Obstacle1=new Object3D("Obstacle1",ObstacleShape);
+ //��Q���iobstacle�j
+ Object3D Obstacle2=new Object3D("Obstacle2",ObstacleShape);
+
+ //��Q���iobstacle�j
+ Object3D Obstacle3=new Object3D("Obstacle3",ObstacleShape);
+ //��Q���iobstacle�j
+ Object3D Obstacle4=new Object3D("Obstacle4",ObstacleShape);
+
+ //��Q���iobstacle�j
+ Object3D Obstacle5=new Object3D("Obstacle5",ObstacleShape);
+ //��Q���iobstacle�j
+ Object3D Obstacle6=new Object3D("Obstacle6",ObstacleShape);
+
+
+ //�e�X�e�[�W�̃p�[�c�̃T�C�Y�̐ݒ�
+ //��
+ ground.scale(320.0, 1.0, 160.0);
+ //�ǁi�����}�C�i�X���jM��-�̈Ӗ�
+ wallM.scale(320.0,100.0,10.0);
+ //�ǁi�����v���X���j
+ wallP.scale(320.0,100.0,10.0);
+ //�ǁi�}�C�i�X���j
+ wall_lM.scale(10.0,100.0,160.0);
+ //�ǁi�v���X���j
+ wall_lP.scale(10.0,100.0,160.0);
+ //��Q��0
+ Obstacle0.scale(50.0, 50.0, 20.0);
+
+ //��Q��1
+ Obstacle1.scale(50.0, 50.0, 20.0);
+ //��Q��2
+ Obstacle2.scale(50.0, 50.0, 20.0);
+
+ //��Q��3
+ Obstacle3.scale(20.0, 20.0, 20.0);
+ //��Q��4
+ Obstacle4.scale(20.0, 20.0, 20.0);
+
+ //��Q��5
+ Obstacle5.scale(30.0, 20.0, 30.0);
+ //��Q��6
+ Obstacle6.scale(30.0, 20.0, 30.0);
+
+
+
+ //�e�X�e�[�W�̃p�[�c�̈ړ�&��]
+ //��
+ Position3D groundpoint = new Position3D(-160.0,0.0,-80.0);
+ ground.setPosition( groundpoint);
+ //��(���� z���}�C�i�X��)
+ Position3D wallpointM = new Position3D(-160.0,0.0,-80.0);
+ wallM.setPosition(wallpointM);
+ //�ǁi���� �����v���X���j
+ Position3D wallpointP = new Position3D(-160.0,0.0,80.0);
+ wallP.setPosition(wallpointP);
+ //�ǁix���v���X���j
+ Position3D wallpoint_lM = new Position3D(-160.0,0.0,-80.0);
+ wall_lM.setPosition(wallpoint_lM);
+ //�ǁix���v���X���j
+ Position3D wallpoint_lP = new Position3D(160.0,0.0,-80.0);
+ wall_lP.setPosition(wallpoint_lP);
+
+ //��Q��0�E���̉����̕�
+ Position3D Obstacle_0 = new Position3D(60.0,0.0,30.0);
+ Obstacle0.setPosition(Obstacle_0);
+ //��Q��1����̉����̕�
+ Position3D Obstacle_1 = new Position3D(-100.0,0.0,-50.0);
+ Obstacle1.setPosition(Obstacle_1);
+ //��Q���Q�^�̕�
+ Position3D Obstacle_2 = new Position3D(10.0,0.0,30.0);
+ Obstacle2.setPosition(Obstacle_2);
+ //��Q���Q��]
+ Obstacle2.apply(new Quaternion3D(0.0,1.0,0.0,3*Math.PI/4), false);
+
+ //��Q��3
+ Position3D Obstacle_3 = new Position3D(90.0,0.0,-40.0);
+ Obstacle3.setPosition(Obstacle_3);
+ //��Q��4
+ Position3D Obstacle_4 = new Position3D(-90.0,0.0,40.0);
+ Obstacle4.setPosition(Obstacle_4);
+
+ //��Q��5
+ Position3D Obstacle_5 = new Position3D(50.0,0.0,-70.0);
+ Obstacle5.setPosition(Obstacle_5);
+ //��Q��6
+ Position3D Obstacle_6 = new Position3D(-50.0,0.0,60.0);
+ Obstacle6.setPosition(Obstacle_6);
+
+
+
+ groundObj = new Object3D("stage", new Object3D[]{ground,wallM,wallP,wall_lM,wall_lP,Obstacle0,Obstacle1,Obstacle2,Obstacle3,Obstacle4,Obstacle5,Obstacle6});
+
+
+
+
+
+
+
+
+
+
+
+ }
+
+
+}
diff --git a/src/game/Team.java b/src/game/Team.java
new file mode 100644
index 0000000..087d42d
--- /dev/null
+++ b/src/game/Team.java
@@ -0,0 +1,124 @@
+package game;
+
+import java.util.ArrayList;
+import account.Account;
+
+public class Team implements IGameElement {
+ //private boolean laser;
+ //����//
+
+ //Account��3�l��������
+ private ArrayList playersAccount = new ArrayList();
+
+ //Bomb��0�`6������
+ //private ArrayList bombList = new ArrayList();
+
+ //LaserTurret��0�`1��������
+ private LaserTurret laserTurret = null;
+
+ //Mirror��0�`3��������
+ private ArrayList mirrorList = new ArrayList();
+
+ //laser�̃N�[���^�C���@false�ŃN�[���^�C�����Ȃ����
+ private int coolTime = 0;
+ private boolean coolTimeFlag = false;
+
+ //�`�[���ɃA�J�E���g��lj�
+ public void addMember(Account ac) {
+ playersAccount.add(ac);
+ }
+
+ //�`�[���̃A�J�E���g���폜
+ public void removeMember(Account ac) {
+ playersAccount.remove(ac);
+ }
+
+ // �`�[����n�Ԗڂ̃A�J�E���g�����擾
+ public Account getMember(int n) {
+ return playersAccount.get(n);
+ }
+
+ //�`�[���̃A�J�E���g���J�E���g
+ public int getTeamMemberCount(){
+ return playersAccount.size();
+ }
+
+ //LaserTurret���擾
+ public LaserTurret getLaserTurret() {
+ return laserTurret;
+ }
+
+ //LaserTurret��V�K�쐬
+ public void createLaserTurret(double x, double y, double z, double a, String state, String sId) {
+ laserTurret = new LaserTurret(x,y,z,a,state,sId);
+ }
+ //LaserTurert���X�V
+ public void updateLaserTurret(double angle, String state) {
+ this.laserTurret.setAngle(angle);
+ this.laserTurret.setState(state);
+ }
+ //LaserTurret���폜
+ public void removeLaserTurret(int countTime) {
+ this.laserTurret = null;
+ coolTime = countTime;
+ coolTimeFlag = true;
+ }
+
+ //Mirror��V�K�쐬
+ public void createMirror(double mPointX, double mPointY, double mPointZ, double mAngle, String mState, String sId) {
+ mirrorList.add(new Mirror(mPointX,mPointY,mPointZ,mAngle,mState,sId));
+ }
+ //Mirror���X�V
+ public void updateMirror(double angle, String state, Mirror myMirror) {
+ myMirror.setAngle(angle);
+ myMirror.setState(state);
+ }
+ //Mirror���폜
+ public void removeMirror(Mirror mirror) {
+ mirrorList.remove(mirror);
+ }
+ //Mirror�̐�
+ public int countMirror() {
+ return mirrorList.size();
+ }
+ //i�Ԗڂ�Mirror���擾
+ public Mirror getMirror(int i) {
+ return mirrorList.get(i);
+ }
+
+ //�������g�̐ݒu����Mirror��sId�ŒT��
+ public Mirror getMyMirror(String sId) {
+
+ Mirror mirror;
+
+ for (int i=0; i EPS ) {
+ mag = Math.sqrt(mag);
+ double invMag = 1.0/mag;
+
+ x = q1.x*invMag;
+ y = q1.y*invMag;
+ z = q1.z*invMag;
+ angle = 2.0*Math.atan2(mag, q1.w);
+ } else {
+ x = 0.0d;
+ y = 1.0d;
+ z = 0.0d;
+ angle = 0.0d;
+ }
+ }
+
+ public AxisAngle4d clone() {
+ return new AxisAngle4d(x, y, z, angle);
+ }
+
+}
diff --git a/src/java3d/Background.java b/src/java3d/Background.java
new file mode 100644
index 0000000..482db7e
--- /dev/null
+++ b/src/java3d/Background.java
@@ -0,0 +1,10 @@
+package java3d;
+
+public class Background extends Leaf {
+
+ @Override
+ public Node cloneTree() {
+ return new Background();
+ }
+
+}
diff --git a/src/java3d/BoundingBox.java b/src/java3d/BoundingBox.java
new file mode 100644
index 0000000..cf1e92c
--- /dev/null
+++ b/src/java3d/BoundingBox.java
@@ -0,0 +1,37 @@
+package java3d;
+
+public class BoundingBox extends Bounds {
+ Point3d lower;
+ Point3d upper;
+
+ public BoundingBox(Point3d lower, Point3d upper) {
+ boundId = BOUNDING_BOX;
+ this.lower = lower;
+ this.upper = upper;
+ }
+
+ @Override
+ public Object clone() {
+ // TODO Auto-generated method stub
+ return new BoundingBox(new Point3d(lower), new Point3d(upper));
+ }
+
+ @Override
+ public void combine(Bounds boundsObject) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void transform(Transform3D trans) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean intersect(Bounds boundsObject) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
diff --git a/src/java3d/BoundingPolytope.java b/src/java3d/BoundingPolytope.java
new file mode 100644
index 0000000..fb93071
--- /dev/null
+++ b/src/java3d/BoundingPolytope.java
@@ -0,0 +1,543 @@
+package java3d;
+
+
+public class BoundingPolytope extends Bounds {
+ Vector4d[] planes;
+ double[] mag; // magnitude of plane vector
+ double[] pDotN; // point on plane dotted with normal
+ Point3d[] verts; // vertices of polytope
+ int nVerts; // number of verts in polytope
+ Point3d centroid = new Point3d(); // centroid of polytope
+ Point3d boxVerts[];
+ boolean allocBoxVerts = false;
+
+ /**
+ * Constructs a BoundingPolytope using the specified planes.
+ *
+ * @param planes
+ * a set of planes defining the polytope.
+ * @exception IllegalArgumentException
+ * if the length of the specified array of planes is less
+ * than 4.
+ */
+ public BoundingPolytope(Vector4d[] planes) {
+ boundId = BOUNDING_POLYTOPE;
+ int i;
+ double invMag;
+ this.planes = new Vector4d[planes.length];
+ mag = new double[planes.length];
+ pDotN = new double[planes.length];
+ for (i = 0; i < planes.length; i++) {
+ // normalize the plane normals
+ mag[i] = Math.sqrt(planes[i].x * planes[i].x + planes[i].y
+ * planes[i].y + planes[i].z * planes[i].z);
+ invMag = 1.0 / mag[i];
+ this.planes[i] = new Vector4d(planes[i].x * invMag, planes[i].y
+ * invMag, planes[i].z * invMag, planes[i].w * invMag);
+ }
+ computeAllVerts(); // XXXX: lazy evaluate
+ }
+
+ /**
+ * Constructs a BoundingPolytope and initializes it to a set of 6 planes
+ * that defines a cube such that -1 <= x,y,z <= 1. The values of the planes
+ * are as follows:
+ *
+ * planes[0] : x <= 1 (1,0,0,-1)
+ * planes[1] : -x <= 1 (-1,0,0,-1)
+ * planes[2] : y <= 1 (0,1,0,-1)
+ * planes[3] : -y <= 1 (0,-1,0,-1)
+ * planes[4] : z <= 1 (0,0,1,-1)
+ * planes[5] : -z <= 1 (0,0,-1,-1)
+ *
+ */
+ public BoundingPolytope() {
+ boundId = BOUNDING_POLYTOPE;
+ planes = new Vector4d[6];
+ mag = new double[planes.length];
+ pDotN = new double[planes.length];
+ planes[0] = new Vector4d(1.0, 0.0, 0.0, -1.0);
+ planes[1] = new Vector4d(-1.0, 0.0, 0.0, -1.0);
+ planes[2] = new Vector4d(0.0, 1.0, 0.0, -1.0);
+ planes[3] = new Vector4d(0.0, -1.0, 0.0, -1.0);
+ planes[4] = new Vector4d(0.0, 0.0, 1.0, -1.0);
+ planes[5] = new Vector4d(0.0, 0.0, -1.0, -1.0);
+ mag[0] = 1.0;
+ mag[1] = 1.0;
+ mag[2] = 1.0;
+ mag[3] = 1.0;
+ mag[4] = 1.0;
+ mag[5] = 1.0;
+ computeAllVerts(); // XXXX: lazy evaluate
+ }
+
+ public void setPlanes(Vector4d[] planes) {
+ int i;
+ double invMag;
+ this.planes = new Vector4d[planes.length];
+ pDotN = new double[planes.length];
+ mag = new double[planes.length];
+ if (planes.length <= 0) {
+ computeAllVerts(); // XXXX: lazy evaluate
+ return;
+ }
+ for (i = 0; i < planes.length; i++) {
+ // normalize the plane normals
+ mag[i] = Math.sqrt(planes[i].x * planes[i].x + planes[i].y
+ * planes[i].y + planes[i].z * planes[i].z);
+ invMag = 1.0 / mag[i];
+ this.planes[i] = new Vector4d(planes[i].x * invMag, planes[i].y
+ * invMag, planes[i].z * invMag, planes[i].w * invMag);
+ }
+ computeAllVerts(); // XXXX: lazy evaluate
+ }
+
+ /**
+ * Returns the equations of the bounding planes for this bounding polytope.
+ * The equations are copied into the specified array. The array must be
+ * large enough to hold all of the vectors. The individual array elements
+ * must be allocated by the caller.
+ *
+ * @param planes
+ * an array Vector4d to receive the bounding planes
+ */
+ public void getPlanes(Vector4d[] planes) {
+ int i;
+ for (i = 0; i < planes.length; i++) {
+ planes[i].x = this.planes[i].x * mag[i];
+ planes[i].y = this.planes[i].y * mag[i];
+ planes[i].z = this.planes[i].z * mag[i];
+ planes[i].w = this.planes[i].w * mag[i];
+ }
+ }
+
+ public int getNumPlanes() {
+ return planes.length;
+ }
+
+ /**
+ * Sets the planes for this BoundingPolytope by keeping its current
+ * number and position of planes and computing new planes positions
+ * to enclose the given bounds object.
+ * @param boundsObject another bounds object
+ */
+ public void set(Bounds boundsObject) {
+ int i,k;
+ double dis;
+
+ // no polytope exists yet so initialize one using the boundsObject
+ if( boundsObject == null ) {
+ boundsIsEmpty = true;
+ boundsIsInfinite = false;
+ computeAllVerts(); // XXXX: lazy evaluate
+ }else if( boundsObject.boundId == BOUNDING_SPHERE ) {
+ BoundingSphere sphere = (BoundingSphere)boundsObject;
+ if( boundsIsEmpty) {
+ initEmptyPolytope(); // no ptope exist so must initialize to default
+ computeAllVerts();
+ }
+ for(i=0;i 0.0) planes[i].w = -newD;
+ if( (newD = ux + ly + uz ) + planes[i].w > 0.0) planes[i].w = -newD;
+ if( (newD = ux + ly + lz ) + planes[i].w > 0.0) planes[i].w = -newD;
+ if( (newD = lx + uy + uz ) + planes[i].w > 0.0) planes[i].w = -newD;
+ if( (newD = lx + uy + lz ) + planes[i].w > 0.0) planes[i].w = -newD;
+ if( (newD = lx + ly + uz ) + planes[i].w > 0.0) planes[i].w = -newD;
+ if( (newD = lx + ly + lz ) + planes[i].w > 0.0) planes[i].w = -newD;
+ }
+ boundsIsEmpty = boundsObject.boundsIsEmpty;
+ boundsIsInfinite = boundsObject.boundsIsInfinite;
+ computeAllVerts(); // XXXX: lazy evaluate
+ } else if(boundsObject.boundId == BOUNDING_POLYTOPE) {
+ BoundingPolytope polytope = (BoundingPolytope)boundsObject;
+ if( planes.length != polytope.planes.length) {
+ planes = new Vector4d[polytope.planes.length];
+ for(k=0;k 0.0 ) {
+ planes[i].w += -dis;
+ }
+ }
+ } else if( boundsObject instanceof BoundingBox){
+ BoundingBox b = (BoundingBox)boundsObject;
+ if( !allocBoxVerts){
+ boxVerts = new Point3d[8];
+ for(int j=0;j<8;j++)boxVerts[j] = new Point3d();
+ allocBoxVerts = true;
+ }
+ boxVerts[0].set(b.lower.x, b.lower.y, b.lower.z );
+ boxVerts[1].set(b.lower.x, b.upper.y, b.lower.z );
+ boxVerts[2].set(b.upper.x, b.lower.y, b.lower.z );
+ boxVerts[3].set(b.upper.x, b.upper.y, b.lower.z );
+ boxVerts[4].set(b.lower.x, b.lower.y, b.upper.z );
+ boxVerts[5].set(b.lower.x, b.upper.y, b.upper.z );
+ boxVerts[6].set(b.upper.x, b.lower.y, b.upper.z );
+ boxVerts[7].set(b.upper.x, b.upper.y, b.upper.z );
+ this.combine(boxVerts);
+
+ } else if(boundsObject.boundId == BOUNDING_POLYTOPE) {
+ BoundingPolytope polytope = (BoundingPolytope)boundsObject;
+ this.combine(polytope.verts);
+ } else {
+ }
+
+ computeAllVerts();
+ }
+
+ /**
+ * Combines this bounding polytope with a point.
+ * @param point a 3d point in space
+ */
+ public void combine(Point3d point) {
+ int i;
+ double dis;
+
+ if(boundsIsInfinite) {
+ return;
+ }
+
+ if( boundsIsEmpty ){
+ planes = new Vector4d[6];
+ mag = new double[planes.length];
+ pDotN = new double[planes.length];
+ nVerts = 1;
+ verts = new Point3d[nVerts];
+ verts[0] = new Point3d( point.x, point.y, point.z);
+
+ for(i=0;i 0.0 ) {
+ planes[i].w += -dis;
+ }
+ }
+ computeAllVerts();
+ }
+ }
+
+ /**
+ * Combines this bounding polytope with an array of points.
+ * @param points an array of 3d points in space
+ */
+ public void combine(Point3d[] points) {
+ int i,j;
+ double dis;
+
+ if( boundsIsInfinite) {
+ return;
+ }
+
+ if( boundsIsEmpty ){
+ planes = new Vector4d[6];
+ mag = new double[planes.length];
+ pDotN = new double[planes.length];
+ nVerts = points.length;
+ verts = new Point3d[nVerts];
+ verts[0] = new Point3d( points[0].x, points[0].y, points[0].z);
+
+ for(i=0;i 0.0 ) {
+ planes[i].w += -dis;
+ }
+ }
+ }
+
+ computeAllVerts();
+ }
+
+ /**
+ * Transforms this bounding polytope by the given transformation matrix.
+ *
+ * @param matrix
+ * a transformation matrix
+ */
+ @Override
+ public void transform(Transform3D matrix) {
+ int i;
+ double invMag;
+ Transform3D invTrans = new Transform3D(matrix);
+ invTrans.invert();
+ invTrans.transpose();
+ for (i = 0; i < planes.length; i++) {
+ planes[i].x = planes[i].x * mag[i];
+ planes[i].y = planes[i].y * mag[i];
+ planes[i].z = planes[i].z * mag[i];
+ planes[i].w = planes[i].w * mag[i];
+ invTrans.transform(planes[i]);
+ }
+ for (i = 0; i < planes.length; i++) {
+ // normalize the plane normals
+ mag[i] = Math.sqrt(planes[i].x * planes[i].x + planes[i].y
+ * planes[i].y + planes[i].z * planes[i].z);
+ invMag = 1.0 / mag[i];
+ this.planes[i] = new Vector4d(planes[i].x * invMag, planes[i].y
+ * invMag, planes[i].z * invMag, planes[i].w * invMag);
+ }
+ for (i = 0; i < verts.length; i++) {
+ matrix.transform(verts[i]);
+ }
+ }
+
+ /**
+ * Test for intersection with another bounds object.
+ * @param boundsObject another bounds object
+ * @return true or false indicating if an intersection occured
+ */
+ public boolean intersect(Bounds boundsObject) {
+
+ if( boundsObject == null ) {
+ return false;
+ }
+
+ if( boundsIsEmpty || boundsObject.boundsIsEmpty ) {
+ return false;
+ }
+
+ if( boundsIsInfinite || boundsObject.boundsIsInfinite ) {
+ return true;
+ }
+
+ if( boundsObject.boundId == BOUNDING_SPHERE ) {
+ return intersect_ptope_sphere( this, (BoundingSphere)boundsObject);
+ } else if( boundsObject.boundId == BOUNDING_BOX){
+ return intersect_ptope_abox( this, (BoundingBox)boundsObject);
+ } else if(boundsObject.boundId == BOUNDING_POLYTOPE) {
+ return intersect_ptope_ptope( this, (BoundingPolytope)boundsObject);
+ } else {
+ return false;
+ }
+ }
+
+ private void computeVertex(int a, int b, int c) {
+ double det, x, y, z;
+ det = planes[a].x * planes[b].y * planes[c].z + planes[a].y
+ * planes[b].z * planes[c].x + planes[a].z * planes[b].x
+ * planes[c].y - planes[a].z * planes[b].y * planes[c].x
+ - planes[a].y * planes[b].x * planes[c].z - planes[a].x
+ * planes[b].z * planes[c].y;
+ // System.err.println("\n det="+det);
+ if (det * det < EPSILON) {
+ // System.err.println("parallel planes="+a+" "+b+" "+c);
+ return; // two planes are parallel
+ }
+ det = 1.0 / det;
+ x = (planes[b].y * planes[c].z - planes[b].z * planes[c].y) * pDotN[a];
+ y = (planes[b].z * planes[c].x - planes[b].x * planes[c].z) * pDotN[a];
+ z = (planes[b].x * planes[c].y - planes[b].y * planes[c].x) * pDotN[a];
+ x += (planes[c].y * planes[a].z - planes[c].z * planes[a].y) * pDotN[b];
+ y += (planes[c].z * planes[a].x - planes[c].x * planes[a].z) * pDotN[b];
+ z += (planes[c].x * planes[a].y - planes[c].y * planes[a].x) * pDotN[b];
+ x += (planes[a].y * planes[b].z - planes[a].z * planes[b].y) * pDotN[c];
+ y += (planes[a].z * planes[b].x - planes[a].x * planes[b].z) * pDotN[c];
+ z += (planes[a].x * planes[b].y - planes[a].y * planes[b].x) * pDotN[c];
+ x = x * det;
+ y = y * det;
+ z = z * det;
+ if (pointInPolytope(x, y, z)) {
+ if (nVerts >= verts.length) {
+ Point3d newVerts[] = new Point3d[nVerts << 1];
+ for (int i = 0; i < nVerts; i++) {
+ newVerts[i] = verts[i];
+ }
+ verts = newVerts;
+ }
+ verts[nVerts++] = new Point3d(x, y, z);
+ }
+ }
+
+ private void computeAllVerts() {
+ int i, a, b, c;
+ double x, y, z;
+ nVerts = 0;
+ verts = new Point3d[planes.length * planes.length];
+ for (i = 0; i < planes.length; i++) {
+ pDotN[i] = -planes[i].x * planes[i].w * planes[i].x - planes[i].y
+ * planes[i].w * planes[i].y - planes[i].z * planes[i].w
+ * planes[i].z;
+ }
+ for (a = 0; a < planes.length - 2; a++) {
+ for (b = a + 1; b < planes.length - 1; b++) {
+ for (c = b + 1; c < planes.length; c++) {
+ computeVertex(a, b, c);
+ }
+ }
+ }
+ // XXXX: correctly compute centroid
+ x = y = z = 0.0;
+ Point3d newVerts[] = new Point3d[nVerts];
+ for (i = 0; i < nVerts; i++) {
+ x += verts[i].x;
+ y += verts[i].y;
+ z += verts[i].z;
+ // copy the verts into an array of the correct size
+ newVerts[i] = verts[i];
+ }
+ this.verts = newVerts; // copy the verts into an array of the correct
+ // size
+ centroid.x = x / nVerts;
+ centroid.y = y / nVerts;
+ centroid.z = z / nVerts;
+ }
+
+ private boolean pointInPolytope(double x, double y, double z) {
+ for (int i = 0; i < planes.length; i++) {
+ if ((x * planes[i].x + y * planes[i].y + z * planes[i].z + planes[i].w) > EPSILON) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private void checkBoundsIsEmpty() {
+ boundsIsEmpty = (planes.length < 4);
+ }
+
+ private void initEmptyPolytope() {
+ planes = new Vector4d[6];
+ pDotN = new double[6];
+ mag = new double[6];
+ verts = new Point3d[planes.length*planes.length];
+ nVerts = 0;
+
+ planes[0] = new Vector4d( 1.0, 0.0, 0.0, -1.0 );
+ planes[1] = new Vector4d(-1.0, 0.0, 0.0, -1.0 );
+ planes[2] = new Vector4d( 0.0, 1.0, 0.0, -1.0 );
+ planes[3] = new Vector4d( 0.0,-1.0, 0.0, -1.0 );
+ planes[4] = new Vector4d( 0.0, 0.0, 1.0, -1.0 );
+ planes[5] = new Vector4d( 0.0, 0.0,-1.0, -1.0 );
+ mag[0] = 1.0;
+ mag[1] = 1.0;
+ mag[2] = 1.0;
+ mag[3] = 1.0;
+ mag[4] = 1.0;
+ mag[5] = 1.0;
+ checkBoundsIsEmpty();
+ }
+}
diff --git a/src/java3d/BoundingSphere.java b/src/java3d/BoundingSphere.java
new file mode 100644
index 0000000..20660a3
--- /dev/null
+++ b/src/java3d/BoundingSphere.java
@@ -0,0 +1,93 @@
+package java3d;
+
+public class BoundingSphere extends Bounds {
+ public Point3d center = new Point3d();
+ public double radius;
+
+ public BoundingSphere(Point3d center, double r) {
+ boundId = BOUNDING_SPHERE;
+ this.center = center;
+ this.radius = r;
+ }
+
+ public BoundingSphere() {
+ boundId = BOUNDING_SPHERE;
+ center.x = 0;
+ center.y = 0;
+ center.z = 0;
+ radius = 1;
+ }
+
+ public void combine(BoundingSphere bs) {
+ double r1 = this.radius;
+ double r2 = bs.radius;
+
+ Point3d c1 = new Point3d(center);
+ Point3d c2 = new Point3d(bs.center);
+
+ double d = center.distance(bs.center);
+
+ if (d + r2 <= r1) {
+ // this �� bs ���܂���ꍇ�A�������Ȃ�
+ } else if (d + r1 < r2) {
+ // bs �� this ���܂���ꍇ�Abs���R�s�[
+ this.radius = bs.radius;
+ this.center.set(bs.center);
+ } else {
+ // this �� �@bs �̂�������������܂��Ȃ��ꍇ
+ this.radius = (r1 + r2 + d) / 2.0;
+
+ double a1 = this.radius - r1;
+ double a2 = this.radius - r2;
+
+ c1.scale(a2);
+ c2.scale(a1);
+ c1.add(c2);
+ c1.scale(1 / d);
+ center.set(c1);
+ }
+ }
+
+ public void transform(Transform3D trans) {
+ Vector4d v = new Vector4d(center.x, center.y, center.z, 1.0);
+ trans.transform(v);
+ center.set(v.x, v.y, v.z);
+
+ double max = 0.0;
+ for(int i = 0; i < trans.scales.length; i++) {
+ if (max < trans.scales[i]) {
+ max = trans.scales[i];
+ }
+ }
+ radius *= max;
+ }
+
+ @Override
+ public Object clone() {
+ return new BoundingSphere(new Point3d(this.center), this.radius);
+ }
+
+ @Override
+ public void combine(Bounds boundsObject) {
+ if( boundsObject instanceof BoundingSphere) {
+ combine((BoundingSphere) boundsObject);
+ }
+ }
+
+ @Override
+ public boolean intersect(Bounds boundsObject) {
+ if (boundsObject instanceof BoundingSphere) {
+ BoundingSphere bs = (BoundingSphere) boundsObject;
+ double r = this.radius + bs.radius;
+ double x = center.x - bs.center.x;
+ double y = center.y - bs.center.y;
+ double z = center.z - bs.center.z;
+ double d = x * x + y * y + z * z;
+ if (d <= r * r) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/src/java3d/Bounds.java b/src/java3d/Bounds.java
new file mode 100644
index 0000000..3d70094
--- /dev/null
+++ b/src/java3d/Bounds.java
@@ -0,0 +1,459 @@
+package java3d;
+
+public abstract class Bounds extends Object implements Cloneable {
+ static final double EPSILON = .000001;
+ static final boolean debug = false;
+ static final int BOUNDING_BOX = 0x1;
+ static final int BOUNDING_SPHERE = 0x2;
+ static final int BOUNDING_POLYTOPE = 0x4;
+ boolean boundsIsEmpty = false;
+ boolean boundsIsInfinite = false;
+ int boundId = 0;
+
+ public Bounds(){
+
+ }
+
+ // public Bounds clone() {
+ // return new Bounds();
+ // }
+
+ @Override
+ public abstract Object clone();
+
+ public abstract void combine(Bounds boundsObject);
+
+ public abstract void transform(Transform3D trans);
+
+ public abstract boolean intersect(Bounds boundsObject);
+
+
+
+ // //�Z�H�m�F���\�b�h�Bradius(���a)�𗘗p�����~�̐ڐG�ł���Ɖ��肵�Ă݂�Ƃ�������
+ // public boolean intersect(BoundingSphere bs) {
+ // // TODO Auto-generated method stub
+ // return false;
+ // }
+
+ private void test_point(Vector4d[] planes, Point3d new_point) {
+ for (int i = 0; i < planes.length; i++){
+ double dist = (new_point.x*planes[i].x + new_point.y*planes[i].y +
+ new_point.z*planes[i].z + planes[i].w ) ;
+ if (dist > EPSILON ){
+ System.err.println("new point is outside of" +
+ " plane["+i+"] dist = " + dist);
+ }
+ }
+ }
+
+ /**
+ * computes the closest point from the given point to a set of planes
+ * (polytope)
+ * @param g the point
+ * @param planes array of bounding planes
+ * @param new_point point on planes closest g
+ */
+ boolean closest_point(Point3d g, Vector4d[] planes, Point3d new_point) {
+
+ double t, s, dist, w;
+ boolean converged, inside, firstPoint, firstInside;
+ int i, count;
+ double ab, ac, bc, ad, bd, cd, aa, bb, cc;
+ double b1, b2, b3, d1, d2, d3, y1, y2, y3;
+ double h11, h12, h13, h22, h23, h33;
+ double l12, l13, l23;
+ Point3d n = new Point3d();
+ Point3d p = new Point3d();
+ Vector3d delta = null;
+
+ // These are temporary until the solve code is working
+
+ /*
+ * The algorithm: We want to find the point "n", closest to "g", while
+ * still within the the polytope defined by "planes". We find the
+ * solution by minimizing the value for a "penalty function";
+ *
+ * f = distance(n,g)^2 + sum for each i: w(distance(n, planes[i]))
+ *
+ * Where "w" is a weighting which indicates how much more important it
+ * is to be close to the planes than it is to be close to "g".
+ *
+ * We minimize this function by taking it's derivitive, and then solving
+ * for the value of n when the derivitive equals 0.
+ *
+ * For the 1D case with a single plane (a,b,c,d), x = n.x and g = g.x,
+ * this looks like:
+ *
+ * f(x) = (x - g) ^ 2 + w(ax + d)^2 f'(x) = 2x -2g + 2waax + 2wad
+ *
+ * (note aa = a^2) setting f'(x) = 0 gives:
+ *
+ * (1 + waa)x = g - wad
+ *
+ * Note that the solution is just outside the plane [a, d]. With the
+ * correct choice of w, this should be inside of the EPSILON tolerance
+ * outside the planes.
+ *
+ * Extending to 3D gives the matrix solution:
+ *
+ * | (1 + waa) wab wac | H = | wab (1 + wbb) wbc | | wac wbc (1 + wcc) |
+ *
+ * b = [g.x - wad, g.y - wbd, g.z - wcd]
+ *
+ * H * n = b
+ *
+ * n = b * H.inverse()
+ *
+ * The implementation speeds this process up by recognizing that H is
+ * symmetric, so that it can be decomposed into three matrices:
+ *
+ * H = L * D * L.transpose()
+ *
+ * 1.0 0.0 0.0 d1 0.0 0.0 L = l12 1.0 0.0 D = 0.0 d2 0.0 l13 l23 1.0 0.0
+ * 0.0 d3
+ *
+ * n can then be derived by back-substitution, where the original
+ * problem is decomposed as:
+ *
+ * H * n = b L * D * L.transpose() * n = b L * D * y = b; L.transpose()
+ * * n = y
+ *
+ * We can then multiply out the terms of L * D and solve for y, and then
+ * use y to solve for n.
+ */
+
+ w = 100.0 / EPSILON; // must be large enough to ensure that solution
+ // is within EPSILON of planes
+
+ count = 0;
+ p.set(g);
+
+ if (debug) {
+ System.err.println("closest_point():\nincoming g=" + " " + g.x
+ + " " + g.y + " " + g.z);
+ }
+
+ converged = false;
+ firstPoint = true;
+ firstInside = false;
+
+ Vector4d pln;
+
+ while (!converged) {
+ if (debug) {
+ System.err.println("start: p=" + " " + p.x + " " + p.y + " "
+ + p.z);
+ }
+
+ // test the current point against the planes, for each
+ // plane that is violated, add it's contribution to the
+ // penalty function
+ inside = true;
+ aa = 0.0;
+ bb = 0.0;
+ cc = 0.0;
+ ab = 0.0;
+ ac = 0.0;
+ bc = 0.0;
+ ad = 0.0;
+ bd = 0.0;
+ cd = 0.0;
+ for (i = 0; i < planes.length; i++) {
+ pln = planes[i];
+ dist = (p.x * pln.x + p.y * pln.y + p.z * pln.z + pln.w);
+ // if point is outside or within EPSILON of the boundary, add
+ // the plane to the penalty matrix. We do this even if the
+ // point is already inside the polytope to prevent numerical
+ // instablity in cases where the point is just outside the
+ // boundary of several planes of the polytope
+ if (dist > -EPSILON) {
+ aa = aa + pln.x * pln.x;
+ bb = bb + pln.y * pln.y;
+ cc = cc + pln.z * pln.z;
+ ab = ab + pln.x * pln.y;
+ ac = ac + pln.x * pln.z;
+ bc = bc + pln.y * pln.z;
+ ad = ad + pln.x * pln.w;
+ bd = bd + pln.y * pln.w;
+ cd = cd + pln.z * pln.w;
+ }
+ // If the point is inside if dist is <= EPSILON
+ if (dist > EPSILON) {
+ inside = false;
+ if (debug) {
+ System.err.println("point outside plane[" + i + "]=("
+ + pln.x + "," + pln.y + ",\n\t" + pln.z + ","
+ + pln.w + ")\ndist = " + dist);
+ }
+ }
+ }
+ // see if we are done
+ if (inside) {
+ if (debug) {
+ System.err.println("p is inside");
+ }
+ if (firstPoint) {
+ firstInside = true;
+ }
+ new_point.set(p);
+ converged = true;
+ } else { // solve for a closer point
+ firstPoint = false;
+
+ // this is the upper right corner of H, which is all we
+ // need to do the decomposition since the matrix is symetric
+ h11 = 1.0 + aa * w;
+ h12 = ab * w;
+ h13 = ac * w;
+ h22 = 1.0 + bb * w;
+ h23 = bc * w;
+ h33 = 1.0 + cc * w;
+
+ if (debug) {
+ System.err.println(" hessin= ");
+ System.err.println(h11 + " " + h12 + " " + h13);
+ System.err.println(" " + h22 + " " + h23);
+ System.err.println(" " + h33);
+ }
+
+ // these are the constant terms
+ b1 = g.x - w * ad;
+ b2 = g.y - w * bd;
+ b3 = g.z - w * cd;
+
+ if (debug) {
+ System.err.println(" b1,b2,b3 = " + b1 + " " + b2 + " "
+ + b3);
+ }
+
+ // solve, d1, d2, d3 actually 1/dx, which is more useful
+ d1 = 1 / h11;
+ l12 = d1 * h12;
+ l13 = d1 * h13;
+ s = h22 - l12 * h12;
+ d2 = 1 / s;
+ t = h23 - h12 * l13;
+ l23 = d2 * t;
+ d3 = 1 / (h33 - h13 * l13 - t * l23);
+
+ if (debug) {
+ System.err.println(" l12,l13,l23 " + l12 + " " + l13 + " "
+ + l23);
+ System.err.println(" d1,d2,d3 " + d1 + " " + d2 + " " + d3);
+ }
+
+ // we have L and D, now solve for y
+ y1 = d1 * b1;
+ y2 = d2 * (b2 - h12 * y1);
+ y3 = d3 * (b3 - h13 * y1 - t * y2);
+
+ if (debug) {
+ System.err.println(" y1,y2,y3 = " + y1 + " " + y2 + " "
+ + y3);
+ }
+
+ // we have y, solve for n
+ n.z = y3;
+ n.y = (y2 - l23 * n.z);
+ n.x = (y1 - l13 * n.z - l12 * n.y);
+
+ if (debug) {
+ System.err.println("new point = " + n.x + " " + n.y + " "
+ + n.z);
+ test_point(planes, n);
+
+ if (delta == null)
+ delta = new Vector3d();
+ delta.sub(n, p);
+ delta.normalize();
+ System.err.println("p->n direction: " + delta);
+ Matrix3d hMatrix = new Matrix3d();
+ // check using the the javax.vecmath routine
+ hMatrix.m00 = h11;
+ hMatrix.m01 = h12;
+ hMatrix.m02 = h13;
+ hMatrix.m10 = h12; // h21 = h12
+ hMatrix.m11 = h22;
+ hMatrix.m12 = h23;
+ hMatrix.m20 = h13; // h31 = h13
+ hMatrix.m21 = h23; // h32 = h22
+ hMatrix.m22 = h33;
+ hMatrix.invert();
+ Point3d check = new Point3d(b1, b2, b3);
+ hMatrix.transform(check);
+
+ System.err.println("check point = " + check.x + " "
+ + check.y + " " + check.z);
+ }
+
+ // see if we have converged yet
+ dist = (p.x - n.x) * (p.x - n.x) + (p.y - n.y) * (p.y - n.y)
+ + (p.z - n.z) * (p.z - n.z);
+
+ if (debug) {
+ System.err.println("p->n distance =" + dist);
+ }
+
+ if (dist < EPSILON) { // close enough
+ converged = true;
+ new_point.set(n);
+ } else {
+ p.set(n);
+ count++;
+ if (count > 4) { // watch for cycling between two minimums
+ new_point.set(n);
+ converged = true;
+ }
+ }
+ }
+ }
+ if (debug) {
+ System.err.println("returning pnt (" + new_point.x + " "
+ + new_point.y + " " + new_point.z + ")");
+
+ if (firstInside)
+ System.err.println("input point inside polytope ");
+ }
+ return firstInside;
+ }
+
+ boolean intersect_ptope_sphere( BoundingPolytope polyTope,
+ BoundingSphere sphere) {
+ Point3d p = new Point3d();
+ boolean inside;
+
+
+ if (debug) {
+ System.err.println("ptope_sphere intersect sphere ="+sphere);
+ }
+ inside = closest_point( sphere.center, polyTope.planes, p );
+ if (debug) {
+ System.err.println("ptope sphere intersect point ="+p);
+ }
+ if (!inside){
+ // if distance between polytope and sphere center is greater than
+ // radius then no intersection
+ if (p.distanceSquared( sphere.center) >
+ sphere.radius*sphere.radius){
+ if (debug) {
+ System.err.println("ptope_sphere returns false");
+ }
+ return false;
+ } else {
+ if (debug) {
+ System.err.println("ptope_sphere returns true");
+ }
+ return true;
+ }
+ } else {
+ if (debug) {
+ System.err.println("ptope_sphere returns true");
+ }
+ return true;
+ }
+ }
+
+ boolean intersect_ptope_abox( BoundingPolytope polyTope, BoundingBox box) {
+ Vector4d planes[] = new Vector4d[6];
+
+ if (debug) {
+ System.err.println("ptope_abox, box = " + box);
+ }
+ planes[0] = new Vector4d( -1.0, 0.0, 0.0, box.lower.x);
+ planes[1] = new Vector4d( 1.0, 0.0, 0.0,-box.upper.x);
+ planes[2] = new Vector4d( 0.0,-1.0, 0.0, box.lower.y);
+ planes[3] = new Vector4d( 0.0, 1.0, 0.0,-box.upper.y);
+ planes[4] = new Vector4d( 0.0, 0.0,-1.0, box.lower.z);
+ planes[5] = new Vector4d( 0.0, 0.0, 1.0,-box.upper.z);
+
+
+ BoundingPolytope pbox = new BoundingPolytope( planes);
+
+ boolean result = intersect_ptope_ptope( polyTope, pbox );
+ if (debug) {
+ System.err.println("ptope_abox returns " + result);
+ }
+ return(result);
+ }
+
+
+ boolean intersect_ptope_ptope( BoundingPolytope poly1,
+ BoundingPolytope poly2) {
+ boolean intersect;
+ Point3d p = new Point3d();
+ Point3d g = new Point3d();
+ Point3d gnew = new Point3d();
+ Point3d pnew = new Point3d();
+
+ intersect = false;
+
+ p.x = 0.0;
+ p.y = 0.0;
+ p.z = 0.0;
+
+ // start from an arbitrary point on poly1
+ closest_point( p, poly1.planes, g);
+
+ // get the closest points on each polytope
+ if (debug) {
+ System.err.println("ptope_ptope: first g = "+g);
+ }
+ intersect = closest_point( g, poly2.planes, p);
+
+ if (intersect) {
+ return true;
+ }
+
+ if (debug) {
+ System.err.println("first p = "+p+"\n");
+ }
+ intersect = closest_point( p, poly1.planes, gnew);
+ if (debug) {
+ System.err.println("gnew = "+gnew+" intersect="+intersect);
+ }
+
+ // loop until the closest points on the two polytopes are not changing
+
+ double prevDist = p.distanceSquared(g);
+ double dist;
+
+ while( !intersect ) {
+
+ dist = p.distanceSquared(gnew);
+
+ if (dist < prevDist) {
+ g.set(gnew);
+ intersect = closest_point( g, poly2.planes, pnew );
+ if (debug) {
+ System.err.println("pnew = "+pnew+" intersect="+intersect);
+ }
+ } else {
+ g.set(gnew);
+ break;
+ }
+ prevDist = dist;
+ dist = pnew.distanceSquared(g);
+
+ if (dist < prevDist) {
+ p.set(pnew);
+ if( !intersect ) {
+ intersect = closest_point( p, poly1.planes, gnew );
+ if (debug) {
+ System.err.println("gnew = "+gnew+" intersect="+
+ intersect);
+ }
+ }
+ } else {
+ p.set(pnew);
+ break;
+ }
+ prevDist = dist;
+ }
+
+ if (debug) {
+ System.err.println("gnew="+" "+gnew.x+" "+gnew.y+" "+gnew.z);
+ System.err.println("pnew="+" "+pnew.x+" "+pnew.y+" "+pnew.z);
+ }
+ return intersect;
+ }
+}
diff --git a/src/java3d/Box.java b/src/java3d/Box.java
new file mode 100644
index 0000000..183cb6f
--- /dev/null
+++ b/src/java3d/Box.java
@@ -0,0 +1,205 @@
+package java3d;
+
+public class Box extends Primitive {
+ public static final int FRONT = 0;
+ public static final int BACK = 1;
+ public static final int RIGHT = 2;
+ public static final int LEFT = 3;
+ public static final int TOP = 4;
+ public static final int BOTTOM = 5;
+
+ float xDim = 1.0f;
+ float yDim = 1.0f;
+ float zDim = 1.0f;
+
+ private Shape3D frontShape = null;
+ private Shape3D backShape = null;
+ private Shape3D rightShape = null;
+ private Shape3D leftShape = null;
+ private Shape3D topShape = null;
+ private Shape3D bottomShape = null;
+
+ public Box() {
+ this(1.0f, 1.0f, 1.0f, null);
+ }
+
+ public Box(float x, float y, float z, Appearance ap) {
+ float coordinates[][] = {
+ {-x, -y, z},
+ { x, -y, z},
+ { x, y, z},
+ {-x, y, z},
+ {-x, -y, -z},
+ { x, -y, -z},
+ { x, y, -z},
+ {-x, y, -z}
+ };
+
+ float uv[] = {
+ 0, 0, 1, 0, 1, 1 , 0, 1,
+ };
+
+ // �e�ʂ̃W�I���g�����쐬
+ TriangleFanArray frontGeom = new TriangleFanArray(4,
+ TriangleFanArray.COORDINATES | TriangleFanArray.NORMALS | TriangleFanArray.TEXTURE_COORDINATE_2,
+ new int[]{4});
+ TriangleFanArray backGeom = new TriangleFanArray(4,
+ TriangleFanArray.COORDINATES | TriangleFanArray.NORMALS | TriangleFanArray.TEXTURE_COORDINATE_2,
+ new int[]{4});
+ TriangleFanArray rightGeom = new TriangleFanArray(4,
+ TriangleFanArray.COORDINATES | TriangleFanArray.NORMALS | TriangleFanArray.TEXTURE_COORDINATE_2,
+ new int[]{4});
+ TriangleFanArray leftGeom = new TriangleFanArray(4,
+ TriangleFanArray.COORDINATES | TriangleFanArray.NORMALS | TriangleFanArray.TEXTURE_COORDINATE_2,
+ new int[]{4});
+ TriangleFanArray topGeom = new TriangleFanArray(4,
+ TriangleFanArray.COORDINATES | TriangleFanArray.NORMALS | TriangleFanArray.TEXTURE_COORDINATE_2,
+ new int[]{4});
+ TriangleFanArray bottomGeom = new TriangleFanArray(4,
+ TriangleFanArray.COORDINATES | TriangleFanArray.NORMALS | TriangleFanArray.TEXTURE_COORDINATE_2,
+ new int[]{4});
+
+ // ���_���W�̐ݒ�
+ frontGeom.setCoordinate(0, coordinates[0]);
+ frontGeom.setCoordinate(1, coordinates[1]);
+ frontGeom.setCoordinate(2, coordinates[2]);
+ frontGeom.setCoordinate(3, coordinates[3]);
+
+ backGeom.setCoordinate(0, coordinates[5]);
+ backGeom.setCoordinate(1, coordinates[4]);
+ backGeom.setCoordinate(2, coordinates[7]);
+ backGeom.setCoordinate(3, coordinates[6]);
+
+ rightGeom.setCoordinate(0, coordinates[1]);
+ rightGeom.setCoordinate(1, coordinates[5]);
+ rightGeom.setCoordinate(2, coordinates[6]);
+ rightGeom.setCoordinate(3, coordinates[2]);
+
+ leftGeom.setCoordinate(0, coordinates[4]);
+ leftGeom.setCoordinate(1, coordinates[0]);
+ leftGeom.setCoordinate(2, coordinates[3]);
+ leftGeom.setCoordinate(3, coordinates[7]);
+
+ topGeom.setCoordinate(0, coordinates[3]);
+ topGeom.setCoordinate(1, coordinates[2]);
+ topGeom.setCoordinate(2, coordinates[6]);
+ topGeom.setCoordinate(3, coordinates[7]);
+
+ bottomGeom.setCoordinate(0, coordinates[4]);
+ bottomGeom.setCoordinate(1, coordinates[5]);
+ bottomGeom.setCoordinate(2, coordinates[1]);
+ bottomGeom.setCoordinate(3, coordinates[0]);
+
+ // �e�N�X�`�����W�̐ݒ�
+ frontGeom.setTextureCoordinates(0, uv);
+ backGeom.setTextureCoordinates(0, uv);
+ rightGeom.setTextureCoordinates(0, uv);
+ leftGeom.setTextureCoordinates(0, uv);
+ topGeom.setTextureCoordinates(0, uv);
+ bottomGeom.setTextureCoordinates(0, uv);
+
+ // �@���̐ݒ�
+ float[] frontNorm = new float[]{0.0f, 0.0f, 1.0f};
+ frontGeom.setNormal(0, frontNorm);
+ frontGeom.setNormal(1, frontNorm);
+ frontGeom.setNormal(2, frontNorm);
+ frontGeom.setNormal(3, frontNorm);
+
+ float[] backNorm = new float[]{0.0f, 0.0f, -1.0f};
+ backGeom.setNormal(0, backNorm);
+ backGeom.setNormal(1, backNorm);
+ backGeom.setNormal(2, backNorm);
+ backGeom.setNormal(3, backNorm);
+
+ float[] rightNorm = new float[]{1.0f, 0.0f, 0.0f};
+ rightGeom.setNormal(0, rightNorm);
+ rightGeom.setNormal(1, rightNorm);
+ rightGeom.setNormal(2, rightNorm);
+ rightGeom.setNormal(3, rightNorm);
+
+ float[] leftNorm = new float[]{-1.0f, 0.0f, 0.0f};
+ leftGeom.setNormal(0, leftNorm);
+ leftGeom.setNormal(1, leftNorm);
+ leftGeom.setNormal(2, leftNorm);
+ leftGeom.setNormal(3, leftNorm);
+
+ float[] topNorm = new float[]{0.0f, 1.0f, 0.0f};
+ topGeom.setNormal(0, topNorm);
+ topGeom.setNormal(1, topNorm);
+ topGeom.setNormal(2, topNorm);
+ topGeom.setNormal(3, topNorm);
+
+ float[] bottomNorm = new float[]{0.0f, -1.0f, 0.0f};
+ bottomGeom.setNormal(0, bottomNorm);
+ bottomGeom.setNormal(1, bottomNorm);
+ bottomGeom.setNormal(2, bottomNorm);
+ bottomGeom.setNormal(3, bottomNorm);
+
+ // �\�ʑ����̍쐬
+ if (ap == null) {
+ ap = new Appearance();
+ }
+ setAppearance(ap);
+ Appearance ap1;
+ Appearance ap2;
+ Appearance ap3;
+ Appearance ap4;
+ Appearance ap5;
+ Appearance ap6;
+ Texture tex = ap.getTexture();
+
+ ap1 = ap2 = ap3 = ap4 = ap5 = ap6 = ap;
+
+ // �e�ʂ̍쐬
+ frontShape = new Shape3D(frontGeom, ap1);
+ backShape = new Shape3D(backGeom, ap2);
+ rightShape = new Shape3D(rightGeom, ap3);
+ leftShape = new Shape3D(leftGeom, ap4);
+ topShape = new Shape3D(topGeom, ap5);
+ bottomShape = new Shape3D(bottomGeom, ap6);
+
+ xDim = x;
+ yDim = y;
+ zDim = z;
+ }
+
+ public double getXdimension() {
+ return xDim;
+ }
+
+ public double getYdimension() {
+ return yDim;
+ }
+
+ public double getZdimension() {
+ return zDim;
+ }
+
+ @Override
+ public Shape3D getShape(int partid) {
+ switch (partid) {
+ case FRONT:
+ return frontShape;
+ case BACK:
+ return backShape;
+ case RIGHT:
+ return rightShape;
+ case LEFT:
+ return leftShape;
+ case TOP:
+ return topShape;
+ case BOTTOM:
+ return bottomShape;
+ }
+ return null;
+ }
+
+ public Node cloneTree() {
+ Appearance ap = getAppearance();
+ if (ap != null) {
+ ap = (Appearance)ap.cloneNodeComponent();
+ }
+ Box b = new Box(xDim, yDim, zDim, ap);
+ return b;
+ }
+}
diff --git a/src/java3d/BranchGroup.java b/src/java3d/BranchGroup.java
new file mode 100644
index 0000000..48026d9
--- /dev/null
+++ b/src/java3d/BranchGroup.java
@@ -0,0 +1,6 @@
+package java3d;
+
+
+public class BranchGroup extends Group {
+
+}
diff --git a/src/java3d/CVS/Entries b/src/java3d/CVS/Entries
new file mode 100644
index 0000000..a8b8478
--- /dev/null
+++ b/src/java3d/CVS/Entries
@@ -0,0 +1,51 @@
+/Appearance.java/1.1/Thu Jul 7 08:22:45 2016//
+/AxisAngle4d.java/1.2/Tue Nov 8 08:32:08 2016//
+/Background.java/1.1/Thu Jul 7 08:22:45 2016//
+/BoundingBox.java/1.2/Thu Nov 10 13:29:33 2016//
+/BoundingPolytope.java/1.1/Thu Jul 7 08:22:45 2016//
+/BoundingSphere.java/1.5/Fri Dec 9 14:33:11 2016//
+/Bounds.java/1.1/Thu Jul 7 08:22:45 2016//
+/Box.java/1.4/Thu Dec 8 08:31:21 2016//
+/BranchGroup.java/1.1/Thu Jul 7 08:22:45 2016//
+/Color3f.java/1.1/Tue Oct 18 08:39:36 2016//
+/Color4f.java/1.2/Tue Oct 18 08:39:36 2016//
+/Cone.java/1.4/Thu Dec 8 08:31:21 2016//
+/Cylinder.java/1.3/Thu Dec 8 08:31:21 2016//
+/DirectionalLight.java/1.1/Tue Oct 18 08:39:36 2016//
+/Geometry.java/1.1/Thu Jul 7 08:22:45 2016//
+/GeometryArray.java/1.1/Thu Jul 7 08:22:45 2016//
+/GeometryStripArray.java/1.1/Thu Jul 7 08:22:45 2016//
+/Group.java/1.1/Thu Jul 7 08:22:45 2016//
+/ImageComponent.java/1.1/Thu Jul 7 08:22:45 2016//
+/IndexedGeometryArray.java/1.1/Thu Jul 7 08:22:45 2016//
+/IndexedGeometryStripArray.java/1.1/Thu Jul 7 08:22:45 2016//
+/IndexedTriangleArray.java/1.1/Thu Jul 7 08:22:45 2016//
+/IndexedTriangleFanArray.java/1.1/Thu Jul 7 08:22:45 2016//
+/IndexedTriangleStripArray.java/1.1/Thu Jul 7 08:22:45 2016//
+/Leaf.java/1.1/Thu Jul 7 08:22:45 2016//
+/Light.java/1.2/Tue Oct 18 08:39:36 2016//
+/Material.java/1.1/Thu Jul 7 08:22:45 2016//
+/Matrix3d.java/1.2/Thu Oct 13 07:59:00 2016//
+/Matrix4d.java/1.1/Thu Jul 7 08:22:45 2016//
+/Node.java/1.1/Thu Jul 7 08:22:45 2016//
+/NodeComponent.java/1.1/Thu Jul 7 08:22:45 2016//
+/Point3d.java/1.2/Thu Oct 13 07:59:00 2016//
+/Primitive.java/1.1/Thu Jul 7 08:22:45 2016//
+/Quat4d.java/1.1/Thu Jul 7 08:22:45 2016//
+/Shape3D.java/1.1/Thu Jul 7 08:22:45 2016//
+/Sphere.java/1.2/Thu Dec 8 08:31:21 2016//
+/TexCoordGeneration.java/1.1/Thu Jul 7 08:22:45 2016//
+/Texture.java/1.1/Thu Jul 7 08:22:45 2016//
+/Texture2D.java/1.1/Thu Jul 7 08:22:45 2016//
+/TextureAttributes.java/1.1/Thu Jul 7 08:22:45 2016//
+/TextureUnitState.java/1.1/Thu Jul 7 08:22:45 2016//
+/Transform3D.java/1.2/Thu Nov 10 13:29:33 2016//
+/TransformGroup.java/1.1/Thu Jul 7 08:22:45 2016//
+/TriangleArray.java/1.1/Thu Jul 7 08:22:45 2016//
+/TriangleFanArray.java/1.1/Thu Jul 7 08:22:45 2016//
+/TriangleStripArray.java/1.1/Thu Jul 7 08:22:45 2016//
+/Tuple3d.java/1.1/Thu Oct 13 07:59:00 2016//
+/Vector3d.java/1.4/Thu Dec 8 08:31:21 2016//
+/Vector3f.java/1.2/Tue Nov 8 06:31:06 2016//
+/Vector4d.java/1.1/Thu Jul 7 08:22:45 2016//
+/View.java/1.1/Thu Jul 7 08:22:45 2016//
diff --git a/src/java3d/CVS/Repository b/src/java3d/CVS/Repository
new file mode 100644
index 0000000..8fef618
--- /dev/null
+++ b/src/java3d/CVS/Repository
@@ -0,0 +1 @@
+CarrotServer/src/java3d
diff --git a/src/java3d/CVS/Root b/src/java3d/CVS/Root
new file mode 100644
index 0000000..c36e9d0
--- /dev/null
+++ b/src/java3d/CVS/Root
@@ -0,0 +1 @@
+:pserver:guest@nitta-lab-www.is.konan-u.ac.jp:\CVSProject
diff --git a/src/java3d/Color3f.java b/src/java3d/Color3f.java
new file mode 100644
index 0000000..592ca4c
--- /dev/null
+++ b/src/java3d/Color3f.java
@@ -0,0 +1,26 @@
+package java3d;
+
+public class Color3f {
+ public float r;
+ public float g;
+ public float b;
+
+ // �R���X�g���N�^
+ public Color3f() {
+ r = 0.0f;
+ g = 0.0f;
+ b = 0.0f;
+ }
+
+ // �R���X�g���N�^
+ public Color3f(float px, float py, float pz) {
+ r = px;
+ g = py;
+ b = pz;
+ }
+
+ public Color3f clone() {
+ return new Color3f(r, g, b);
+ }
+
+}
diff --git a/src/java3d/Color4f.java b/src/java3d/Color4f.java
new file mode 100644
index 0000000..53a4a40
--- /dev/null
+++ b/src/java3d/Color4f.java
@@ -0,0 +1,29 @@
+package java3d;
+
+public class Color4f {
+ public float r;
+ public float g;
+ public float b;
+ public float a;
+
+ // �R���X�g���N�^
+ public Color4f() {
+ r = 0.0f;
+ g = 0.0f;
+ b = 0.0f;
+ a = 0.0f;
+ }
+
+ // �R���X�g���N�^
+ public Color4f(float px, float py, float pz, float pw) {
+ r = px;
+ g = py;
+ b = pz;
+ a = pw;
+ }
+
+ public Color4f clone() {
+ return new Color4f(r, g, b, a);
+ }
+
+}
diff --git a/src/java3d/Cone.java b/src/java3d/Cone.java
new file mode 100644
index 0000000..397e936
--- /dev/null
+++ b/src/java3d/Cone.java
@@ -0,0 +1,129 @@
+package java3d;
+
+public class Cone extends Primitive {
+ public static final int BODY = 0;
+ public static final int CAP = 1;
+
+ static final int MID_REZ_DIV_X = 16;
+ static final int MID_REZ_DIV_Y = 1;
+
+ float radius;
+ float height;
+ int xdivisions;
+ int ydivisions;
+
+
+ private Shape3D bodyShape = null;
+ private Shape3D capShape = null;
+
+ public Cone() {
+ this(0.5f, 1.0f, null);
+ }
+
+ public Cone(float r, float h, Appearance ap) {
+ xdivisions = MID_REZ_DIV_X;
+ ydivisions = MID_REZ_DIV_Y;
+
+ float coordinates[][] = new float[xdivisions][3];
+
+ for (int i = 0; i < xdivisions; i++) { // BOTTOM(���)�̓_��(x,y,z)���W
+ coordinates[i][0] = r * (float) Math.cos(2 * Math.PI * ((double)i / xdivisions));
+ coordinates[i][1] = -h / 2;
+ coordinates[i][2] = r * (float) Math.sin(2 * Math.PI * ((double)i / xdivisions));
+ }
+
+ float coordinates_center[][] = new float[2][3];//���_��,��ʂ̒��S,�̍��W
+ coordinates_center[0][0] = 0;
+ coordinates_center[0][1] = h / 2;
+ coordinates_center[0][2] = 0;
+ coordinates_center[1][0] = 0;
+ coordinates_center[1][1] = -h / 2;
+ coordinates_center[1][2] = 0;
+
+ float uv[] = { 0, 0, 1, 0, 1, 1, 0, 1, };
+
+ // �e�ʂ̃W�I���g�����쐬
+ TriangleFanArray bodyGeom = new TriangleFanArray(xdivisions + 2,
+ TriangleFanArray.COORDINATES | TriangleFanArray.NORMALS | TriangleFanArray.TEXTURE_COORDINATE_2,
+ new int[] { xdivisions + 2 });
+ TriangleFanArray capGeom = new TriangleFanArray(xdivisions + 2,
+ TriangleFanArray.COORDINATES | TriangleFanArray.NORMALS | TriangleFanArray.TEXTURE_COORDINATE_2,
+ new int[] { xdivisions + 2 });
+
+ // ���_���W�̐ݒ�
+ //����
+ bodyGeom.setCoordinate(0,coordinates_center[0]);
+ for (int i = 0; i < xdivisions; i++){
+ bodyGeom.setCoordinate(i + 1, coordinates[i]); //�ォ�猩�Ĕ����v���̏�
+ }
+ bodyGeom.setCoordinate(xdivisions + 1, coordinates[0]);
+ //���
+ capGeom.setCoordinate(0,coordinates_center[1]);
+ capGeom.setCoordinate(1, coordinates[0]);
+ for (int i = 0; i < xdivisions; i++){
+ capGeom.setCoordinate(i + 2, coordinates[xdivisions - i - 1]); //�ォ�猩�Ď��v���̏�
+ }
+
+ // �e�N�X�`�����W�̐ݒ�
+ bodyGeom.setTextureCoordinates(0, uv); //
+ capGeom.setTextureCoordinates(0, uv);
+
+ // �@���̐ݒ�
+ double theta;
+ theta = Math.atan(h / r);
+ for (int i = 0; i < xdivisions; i++) {
+ float[] bodyNorm = new float[]{
+ (float)(r * Math.sin(theta) * Math.cos(90 - theta) * Math.cos(2 * Math.PI * ((double)i / xdivisions))),
+ (float)(r * Math.sin(theta) * Math.sin(90 - theta)),
+ (float) Math.sin(2 * Math.PI * ((double)i / xdivisions))
+ };
+ bodyGeom.setNormal(i, bodyNorm);
+ }
+
+ float[] bottomNorm = new float[]{0.0f, -1.0f, 0.0f};
+ for (int i = 0; i < xdivisions + 2; i++) {
+ capGeom.setNormal(i, bottomNorm);
+ }
+
+ // �\�ʑ����̍쐬
+ if (ap == null) {
+ ap = new Appearance();
+ }
+ setAppearance(ap);
+
+ // �e�ʂ̍쐬 //�S�ē����e�N�X�`���[(ap)��\��t����
+ bodyShape = new Shape3D(bodyGeom, ap);
+ capShape = new Shape3D(capGeom, ap);
+
+ radius = r;
+ height = h;
+ }
+
+ public double getRadius() {
+ return radius;
+ }
+ public double getHeight() {
+ return height;
+ }
+
+ @Override
+ public Shape3D getShape(int partid) {
+ switch (partid) {
+ case BODY:
+ return bodyShape;
+ case CAP:
+ return capShape;
+ }
+ return null;
+ }
+
+ public Node cloneTree() {
+ Appearance ap = getAppearance();
+ if (ap != null) {
+ ap = (Appearance)ap.cloneNodeComponent();
+ }
+ Cone c = new Cone(radius, height, ap);
+ return c;
+ }
+}
+
diff --git a/src/java3d/Cylinder.java b/src/java3d/Cylinder.java
new file mode 100644
index 0000000..f1aec20
--- /dev/null
+++ b/src/java3d/Cylinder.java
@@ -0,0 +1,203 @@
+package java3d;
+
+public class Cylinder extends Primitive {
+ public static final int BODY = 0;
+ public static final int TOP = 1;
+ public static final int BOTTOM = 2;
+
+ static final int MID_REZ_DIV_X = 16;
+ static final int MID_REZ_DIV_Y = 1;
+
+ float radius;
+ float height;
+ int xdivisions;
+ int ydivisions;
+
+ private Shape3D bodyShape = null;
+ private Shape3D topShape = null;
+ private Shape3D bottomShape = null;
+
+ public Cylinder() {
+ this(0.5f, 1.0f, null);
+ }
+
+ public Cylinder(float r, float h) {
+ this(r, h, null);
+ }
+
+ public Cylinder(float r, float h, Appearance ap) {
+ xdivisions = MID_REZ_DIV_X;
+ ydivisions = MID_REZ_DIV_Y;
+
+ float coordinates[][] = new float[xdivisions * 2][3];
+
+ float coordinates_center[][] = new float[2][3];//��ʂƒ�ʂ̒��S�̍��W
+ coordinates_center[0][0] = 0;
+ coordinates_center[0][1] = h / 2;
+ coordinates_center[0][2] = 0;
+ coordinates_center[1][0] = 0;
+ coordinates_center[1][1] = -h / 2;
+ coordinates_center[1][2] = 0;
+
+ for (int i = 0; i < xdivisions; i++) { // TOP(���)���̓_��(x,y,z)���W
+ coordinates[i][0] = r * (float) Math.cos(2 * Math.PI * ((double)i / xdivisions));
+ coordinates[i][1] = h / 2;
+ coordinates[i][2] = r * (float) Math.sin(2 * Math.PI * ((double)i / xdivisions));
+ }
+ for (int i = 0; i < xdivisions; i++) { // BOTTOM(���)�̓_��(x,y,z)���W
+ coordinates[i + xdivisions][0] = r * (float) Math.cos(2 * Math.PI * ((double)i / xdivisions));
+ coordinates[i + xdivisions][1] = -h / 2;
+ coordinates[i + xdivisions][2] = r * (float) Math.sin(2 * Math.PI * ((double)i / xdivisions));
+ }
+
+ float uv[] = { 0, 0, 1, 0, 1, 1, 0, 1, };
+
+ // �e�ʂ̃W�I���g�����쐬
+ IndexedTriangleStripArray bodyGeom = new IndexedTriangleStripArray(xdivisions * 2,
+ IndexedTriangleStripArray.COORDINATES | IndexedTriangleStripArray.NORMALS | IndexedTriangleStripArray.TEXTURE_COORDINATE_2,
+ xdivisions * 2 + 2,
+ new int[] { xdivisions * 2 + 2 });
+ TriangleFanArray topGeom = new TriangleFanArray(xdivisions + 2,
+ TriangleFanArray.COORDINATES | TriangleFanArray.NORMALS | TriangleFanArray.TEXTURE_COORDINATE_2,
+ new int[] { xdivisions + 2 });
+ TriangleFanArray bottomGeom = new TriangleFanArray(xdivisions + 2,
+ TriangleFanArray.COORDINATES | TriangleFanArray.NORMALS | TriangleFanArray.TEXTURE_COORDINATE_2,
+ new int[] { xdivisions + 2 });
+
+ // ���_���W�̐ݒ�
+ //����
+ for (int i = 0; i < xdivisions; i++) { //��ʂ����ʂ����ɍ~��āA��ʂ����ʂ֎߂ɏ�鏇�ɍ��W��ݒ�
+ bodyGeom.setCoordinate(2 * i , coordinates[i]);
+ bodyGeom.setCoordinate(2 * i + 1, coordinates[i + xdivisions]);
+ }
+
+ int coordinateIndices[] = new int[xdivisions * 2 + 2];
+ for (int i = 0; i < xdivisions * 2; i++) {
+ coordinateIndices[i] = i;
+ }
+ coordinateIndices[xdivisions * 2] = 0;
+ coordinateIndices[xdivisions * 2 + 1] = 1;
+
+ bodyGeom.setCoordinateIndices(0, coordinateIndices);
+
+ //���
+ topGeom.setCoordinate(0,coordinates_center[0]);
+ for(int i = 0; i < xdivisions; i++){
+ topGeom.setCoordinate(i + 1, coordinates[i]); //�ォ�猩�Ĕ����v���̏�
+ }
+ topGeom.setCoordinate(xdivisions + 1, coordinates[0]);
+
+ //���
+ bottomGeom.setCoordinate(0,coordinates_center[1]);
+ bottomGeom.setCoordinate(1, coordinates[xdivisions]);
+ for(int i = 0; i < xdivisions; i++){
+ bottomGeom.setCoordinate(i + 2, coordinates[2 * xdivisions - i - 1]); //�ォ�猩�Ď��v���̏�
+ }
+
+ // �e�N�X�`�����W�̐ݒ�
+ bodyGeom.setTextureCoordinates(0, uv); //
+ topGeom.setTextureCoordinates(0, uv);
+ bottomGeom.setTextureCoordinates(0, uv);
+
+ // �@���̐ݒ�
+
+ for (int i = 0; i < xdivisions * 2; i++) {
+ float[] bodyNorm = new float[]{(float) Math.cos(Math.PI * ((double)i / xdivisions)),0.0f,(float) Math.sin(Math.PI * ((double)i / xdivisions))};
+ bodyGeom.setNormal(i, bodyNorm);
+ }
+
+ float[] topNorm = new float[]{0.0f, 1.0f, 0.0f};
+ for (int i = 0; i < xdivisions + 2; i++) {
+ topGeom.setNormal(i, topNorm);
+ }
+
+ float[] bottomNorm = new float[]{0.0f, -1.0f, 0.0f};
+ for (int i = 0; i < xdivisions + 2; i++) {
+ bottomGeom.setNormal(i, bottomNorm);
+ }
+
+ // �\�ʑ����̍쐬
+ if (ap == null) {
+ ap = new Appearance();
+ }
+ setAppearance(ap);
+// Appearance ap1 = new Appearance();
+// Appearance ap2 = new Appearance();
+// Appearance ap3 = new Appearance();
+ // Appearance ap4 = new Appearance();
+ // Appearance ap5 = new Appearance();
+ // Appearance ap6 = new Appearance();
+// Texture tex = ap.getTexture();
+// if (tex != null && tex instanceof TextureCubeMap) {
+ // GL10 �ł� GL_TEXTURE_CUBE_MAP ���g���Ȃ��̂ŁATextureCubeMap �̏ꍇ�� Texture2D
+ // �ɕ�������
+// ImageComponent ic1 = tex.getImage(TextureCubeMap.POSITIVE_Z);
+// Texture2D tex1 = new Texture2D(Texture2D.BASE_LEVEL, Texture2D.RGB,
+// ic1.width, ic1.height);
+// tex1.setImage(0, ic1);
+// ap1.setTexture(tex1);
+// ImageComponent ic2 = tex.getImage(TextureCubeMap.NEGATIVE_Z);
+// Texture2D tex2 = new Texture2D(Texture2D.BASE_LEVEL, Texture2D.RGB,
+// ic2.width, ic2.height);
+// tex2.setImage(0, ic2);
+// ap2.setTexture(tex2);
+// ImageComponent ic3 = tex.getImage(TextureCubeMap.POSITIVE_X);
+// Texture2D tex3 = new Texture2D(Texture2D.BASE_LEVEL, Texture2D.RGB,
+// ic3.width, ic3.height);
+// tex3.setImage(0, ic3);
+ // ap3.setTexture(tex3);
+ // ImageComponent ic4 = tex.getImage(TextureCubeMap.NEGATIVE_X);
+ // Texture2D tex4 = new Texture2D(Texture2D.BASE_LEVEL, Texture2D.RGB,
+ // ic4.width, ic4.height);
+ // tex4.setImage(0, ic4);
+ // ap4.setTexture(tex4);
+ // ImageComponent ic5 = tex.getImage(TextureCubeMap.POSITIVE_Y);
+ // Texture2D tex5 = new Texture2D(Texture2D.BASE_LEVEL, Texture2D.RGB,
+ // ic5.width, ic5.height);
+ // tex5.setImage(0, ic5);
+ // ap5.setTexture(tex5);
+ // ImageComponent ic6 = tex.getImage(TextureCubeMap.NEGATIVE_Y);
+ // Texture2D tex6 = new Texture2D(Texture2D.BASE_LEVEL, Texture2D.RGB,
+ // ic6.width, ic6.height);
+ // tex6.setImage(0, ic6);
+ // ap6.setTexture(tex6);
+// }
+ // �e�ʂ̍쐬 //�S�ē����e�N�X�`���[(ap)��\��t����
+ bodyShape = new Shape3D(bodyGeom, ap);
+ topShape = new Shape3D(topGeom, ap);
+ bottomShape = new Shape3D(bottomGeom, ap);
+ //
+ radius = r;
+ height = h;
+ }
+
+ public double getRadius() {
+ return radius;
+ }
+ public double getHeight() {
+ return height;
+ }
+
+
+ @Override
+ public Shape3D getShape(int partid) {
+ switch (partid) {
+ case BODY:
+ return bodyShape;
+ case TOP:
+ return topShape;
+ case BOTTOM:
+ return bottomShape;
+ }
+ return null;
+ }
+
+ public Node cloneTree() {
+ Appearance ap = getAppearance();
+ if (ap != null) {
+ ap = (Appearance)ap.cloneNodeComponent();
+ }
+ Cylinder c = new Cylinder(radius, height, ap);
+ return c;
+ }
+}
\ No newline at end of file
diff --git a/src/java3d/DirectionalLight.java b/src/java3d/DirectionalLight.java
new file mode 100644
index 0000000..0cc6fef
--- /dev/null
+++ b/src/java3d/DirectionalLight.java
@@ -0,0 +1,23 @@
+package java3d;
+
+public class DirectionalLight extends Light {
+ private Vector3f direction;
+
+ @Override
+ public Node cloneTree() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public DirectionalLight(Color3f c,Vector3f d){
+ super(c);
+ this.direction = d;
+ }
+ public void setDirection(Vector3f d){
+ this.direction = d;
+ }
+ public Vector3f getDirection(){
+ return direction;
+ }
+
+}
diff --git a/src/java3d/Geometry.java b/src/java3d/Geometry.java
new file mode 100644
index 0000000..a45d1b1
--- /dev/null
+++ b/src/java3d/Geometry.java
@@ -0,0 +1,10 @@
+package java3d;
+
+public abstract class Geometry extends NodeComponent {
+ public static final int ALLOW_INTERSECT = 18;
+
+ // �R���X�g���N�^
+ public Geometry() {
+ }
+
+}
diff --git a/src/java3d/GeometryArray.java b/src/java3d/GeometryArray.java
new file mode 100644
index 0000000..2312919
--- /dev/null
+++ b/src/java3d/GeometryArray.java
@@ -0,0 +1,236 @@
+package java3d;
+
+import java.nio.Buffer;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.FloatBuffer;
+import java.util.ArrayList;
+
+public abstract class GeometryArray extends Geometry {
+// public static final int ALLOW_COLOR_READ = 2;
+// public static final int ALLOW_COLOR_WRITE = 3;
+// public static final int ALLOW_COORDINATE_READ = 0;
+// public static final int ALLOW_COORDINATE_WRITE = 1;
+// public static final int ALLOW_COUNT_READ = 8;
+// public static final int ALLOW_COUNT_WRITE = 20;
+// public static final int ALLOW_FORMAT_READ = 17;
+// public static final int ALLOW_NORMAL_READ = 4;
+// public static final int ALLOW_NORMAL_WRITE = 5;
+// public static final int ALLOW_REF_DATA_READ = 21;
+// public static final int ALLOW_REF_DATA_WRITE = 19;
+// public static final int ALLOW_TEXCOORD_READ = 6;
+// public static final int ALLOW_TEXCOORD_WRITE = 7;
+
+ public static final int BY_REFERENCE = 128;
+ public static final int COLOR_3 = 4;
+ public static final int COLOR_4 = 12;
+ public static final int COORDINATES = 1;
+ public static final int INTERLEAVED = 256;
+ public static final int NORMALS = 2;
+ public static final int TEXTURE_COORDINATE_2 = 32;
+ public static final int TEXTURE_COORDINATE_3 = 64;
+ public static final int TEXTURE_COORDINATE_4 = 1024;
+ public static final int USE_COORD_INDEX_ONLY = 512;
+ public static final int USE_NIO_BUFFER = 2048;
+
+ protected int vertexCount;
+ protected int vertexFormat;
+ protected FloatBuffer vertexBuffer = null;
+ protected FloatBuffer normalBuffer = null;
+ protected FloatBuffer uvBuffer = null;
+
+ // �R���X�g���N�^
+ public GeometryArray(int vertexCount, int vertexFormat) {
+ this.vertexCount = vertexCount;
+ this.vertexFormat = vertexFormat;
+ ByteBuffer vbb = ByteBuffer.allocateDirect(vertexCount * 4 * 3);
+ vbb.order(ByteOrder.nativeOrder());
+ vertexBuffer = vbb.asFloatBuffer();
+ if ((vertexFormat & NORMALS) != 0) {
+ ByteBuffer vbb2 = ByteBuffer.allocateDirect(vertexCount * 4 * 3);
+ vbb2.order(ByteOrder.nativeOrder());
+ normalBuffer = vbb2.asFloatBuffer();
+ }
+ if ((vertexFormat & TEXTURE_COORDINATE_2) != 0) {
+ ByteBuffer vbb3 = ByteBuffer.allocateDirect(vertexCount * 4 * 2);
+ vbb3.order(ByteOrder.nativeOrder());
+ uvBuffer = vbb3.asFloatBuffer();
+ } else if ((vertexFormat & TEXTURE_COORDINATE_3) != 0) {
+ ByteBuffer vbb3 = ByteBuffer.allocateDirect(vertexCount * 4 * 3);
+ vbb3.order(ByteOrder.nativeOrder());
+ uvBuffer = vbb3.asFloatBuffer();
+ } else if ((vertexFormat & TEXTURE_COORDINATE_4) != 0) {
+ ByteBuffer vbb3 = ByteBuffer.allocateDirect(vertexCount * 4 * 4);
+ vbb3.order(ByteOrder.nativeOrder());
+ uvBuffer = vbb3.asFloatBuffer();
+ }
+// mVertexBuffer.put(vertices);
+// mVertexBuffer.position(0);
+ }
+
+// public GeometryArray(int vertexCount, int vertexFormat, int texCoordSetCount, int[] texCoordSetMap) {
+// this.vertexCount = vertexCount;
+// this.vertexFormat = vertexFormat;
+// this.texCoordSetCount = texCoordSetCount;
+// this.texCoordSetMap = texCoordSetMap;
+// }
+
+ /** �I�u�W�F�N�g�̒��_�� */
+ public int getVertexCount() {
+ return vertexCount;
+ }
+
+ public int getVertexFormat() {
+ return vertexFormat;
+ }
+
+ /** index�̒��_�̍��W��p�ɐV�����i�[���� */
+ public void getCoordinate(int index, float[] p) {
+ vertexBuffer.position(index * 3);
+ vertexBuffer.get(p);
+ vertexBuffer.position(0);
+ }
+
+ /** index�̒��_�̍��W��p�ɐV�����i�[���� */
+ public void getCoordinate(int index, double[] p) {
+ p[0] = vertexBuffer.get(index * 3);
+ p[1] = vertexBuffer.get(index * 3 + 1);
+ p[2] = vertexBuffer.get(index * 3 + 2);
+ }
+
+ /** index�̒��_�̍��W��p�ɐV�����i�[���� */
+ public void getCoordinate(int index, Point3d p) {
+ p.x = vertexBuffer.get(index * 3);
+ p.y = vertexBuffer.get(index * 3 + 1);
+ p.z = vertexBuffer.get(index * 3 + 2);
+ }
+
+ public void getCoordinates(int index, double[] coordinates) {
+ for (int n = 0; n < coordinates.length / 3 && n + index < vertexBuffer.capacity() / 3; n++) {
+ coordinates[n * 3] = vertexBuffer.get((index + n) * 3);
+ coordinates[n * 3 + 1] = vertexBuffer.get((index + n) * 3 + 1);
+ coordinates[n * 3 + 2] = vertexBuffer.get((index + n) * 3 + 2);
+ }
+ }
+
+ /** index�̒��_�̖@����p�ɐV�����i�[���� */
+ public void getNormal(int index, float[] p) {
+ if (normalBuffer == null) return;
+ normalBuffer .position(index * 3);
+ normalBuffer.get(p);
+ normalBuffer .position(0);
+ }
+
+ /** index�̒��_�̖@����p�ɐV�����i�[���� */
+ public void getNormal(int index, Vector3f p) {
+ if (normalBuffer == null) return;
+ p.x = normalBuffer.get(index * 3);
+ p.y = normalBuffer.get(index * 3 + 1);
+ p.z = normalBuffer.get(index * 3 + 2);
+ }
+
+ public void setCoordinate(int index, float[] p) {
+ vertexBuffer.position(index * 3);
+ vertexBuffer.put(p);
+ vertexBuffer.position(0);
+ }
+
+ public void setCoordinate(int index, double[] p) {
+ vertexBuffer.position(index * 3);
+ vertexBuffer.put((float)p[0]);
+ vertexBuffer.put((float)p[1]);
+ vertexBuffer.put((float)p[2]);
+ vertexBuffer.position(0);
+ }
+
+ public void setCoordinate(int index, Point3d p) {
+ vertexBuffer.position(index * 3);
+ vertexBuffer.put((float)p.x);
+ vertexBuffer.put((float)p.y);
+ vertexBuffer.put((float)p.z);
+ vertexBuffer.position(0);
+ }
+
+ public void setCoordinates(int index, float[] p) {
+ vertexBuffer.position(index * 3);
+ vertexBuffer.put(p);
+ vertexBuffer.position(0);
+ }
+
+ public void setCoordinates(int index, double[] p) {
+ vertexBuffer.position(index * 3);
+ for (int i = 0; i < p.length; i++) {
+ vertexBuffer.put((float)p[i]);
+ }
+ vertexBuffer.position(0);
+ }
+
+ public void setNormal(int index, float[] n) {
+ if (normalBuffer == null) return;
+ normalBuffer .position(index * 3);
+ normalBuffer.put(n);
+ normalBuffer.position(0);
+ }
+
+ public void setNormal(int index, Vector3f n) {
+ if (normalBuffer == null) return;
+ normalBuffer.position(index * 3);
+ normalBuffer.put(n.x);
+ normalBuffer.put(n.y);
+ normalBuffer.put(n.z);
+ normalBuffer.position(0);
+ }
+
+ public void setTextureCoordinate(int index, float[] texCoord) {
+ if ((vertexFormat & TEXTURE_COORDINATE_2) != 0) {
+ uvBuffer.position(index * 2);
+ uvBuffer.put(texCoord[0]);
+ uvBuffer.put(texCoord[1]);
+ } else if ((vertexFormat & TEXTURE_COORDINATE_3) != 0) {
+ uvBuffer.position(index * 3);
+ uvBuffer.put(texCoord[0]);
+ uvBuffer.put(texCoord[1]);
+ uvBuffer.put(texCoord[2]);
+ } else if ((vertexFormat & TEXTURE_COORDINATE_4) != 0) {
+ uvBuffer.position(index * 4);
+ uvBuffer.put(texCoord[0]);
+ uvBuffer.put(texCoord[1]);
+ uvBuffer.put(texCoord[2]);
+ uvBuffer.put(texCoord[3]);
+ }
+ uvBuffer.position(0);
+ }
+
+ public void setTextureCoordinates(int index, float[] texCoords) {
+ if ((vertexFormat & TEXTURE_COORDINATE_2) != 0) {
+ ByteBuffer vbb3 = ByteBuffer.allocateDirect((texCoords.length + index) * 4 * 2);
+ vbb3.order(ByteOrder.nativeOrder());
+ uvBuffer = vbb3.asFloatBuffer();
+ uvBuffer.position(index * 2);
+ } else if ((vertexFormat & TEXTURE_COORDINATE_3) != 0) {
+ ByteBuffer vbb3 = ByteBuffer.allocateDirect((texCoords.length + index) * 4 * 3);
+ vbb3.order(ByteOrder.nativeOrder());
+ uvBuffer = vbb3.asFloatBuffer();
+ uvBuffer.position(index * 3);
+ } else if ((vertexFormat & TEXTURE_COORDINATE_4) != 0) {
+ ByteBuffer vbb3 = ByteBuffer.allocateDirect((texCoords.length + index) * 4 * 4);
+ vbb3.order(ByteOrder.nativeOrder());
+ uvBuffer = vbb3.asFloatBuffer();
+ uvBuffer.position(index * 4);
+ }
+ uvBuffer.put(texCoords);
+ uvBuffer.position(0);
+ }
+
+ public FloatBuffer getVertexBuffer() {
+ return vertexBuffer;
+ }
+
+ public FloatBuffer getNormalBuffer() {
+ return normalBuffer;
+ }
+
+ public FloatBuffer getUVBuffer() {
+ return uvBuffer;
+ }
+}
diff --git a/src/java3d/GeometryStripArray.java b/src/java3d/GeometryStripArray.java
new file mode 100644
index 0000000..82de5d5
--- /dev/null
+++ b/src/java3d/GeometryStripArray.java
@@ -0,0 +1,22 @@
+package java3d;
+
+public abstract class GeometryStripArray extends GeometryArray {
+ protected int[] stripIndexCounts;
+
+ public GeometryStripArray(int vertexCount, int vertexFormat, int[] stripIndexCounts) {
+ super(vertexCount, vertexFormat);
+ this.stripIndexCounts = stripIndexCounts;
+ }
+
+ public int getNumStrips() {
+ return stripIndexCounts.length;
+ }
+
+ public void setStripIndexCounts(int[] stripIndexCounts) {
+ this.stripIndexCounts = stripIndexCounts;
+ }
+
+ public void getStripVertexCounts(int[] stripIndexCounts) {
+ System.arraycopy(this.stripIndexCounts, 0, stripIndexCounts, 0, stripIndexCounts.length);
+ }
+}
diff --git a/src/java3d/Group.java b/src/java3d/Group.java
new file mode 100644
index 0000000..46ad536
--- /dev/null
+++ b/src/java3d/Group.java
@@ -0,0 +1,40 @@
+package java3d;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+
+public class Group extends Node {
+
+ private List children = new ArrayList();
+
+ public Node getChild(int num) {
+ return children.get(num);
+ }
+
+ public int numChildren() {
+ return children.size();
+ }
+
+ public void addChild(Node node) {
+ children.add(node);
+ }
+
+ public void removeChild(Node node) {
+ children.remove(node);
+ }
+
+ public Enumeration getAllChildren() {
+ return Collections.enumeration(children);
+ }
+
+ public Node cloneTree() {
+ Group newInstance = new Group();
+ newInstance.children = new ArrayList();
+ for (int n = 0; n < children.size(); n++) {
+ newInstance.children.add(children.get(n).cloneTree());
+ }
+ return newInstance;
+ }
+}
diff --git a/src/java3d/ImageComponent.java b/src/java3d/ImageComponent.java
new file mode 100644
index 0000000..da95790
--- /dev/null
+++ b/src/java3d/ImageComponent.java
@@ -0,0 +1,16 @@
+package java3d;
+
+public abstract class ImageComponent extends NodeComponent {
+ public static final int FORMAT_RGB = 1;
+ public static final int FORMAT_RGBA = 2;
+
+ protected int format = 0;
+ protected int width = 0;
+ protected int height = 0;
+
+ public ImageComponent(int format, int width, int height) {
+ this.format = format;
+ this.width = width;
+ this.height = height;
+ }
+}
diff --git a/src/java3d/IndexedGeometryArray.java b/src/java3d/IndexedGeometryArray.java
new file mode 100644
index 0000000..e991718
--- /dev/null
+++ b/src/java3d/IndexedGeometryArray.java
@@ -0,0 +1,45 @@
+package java3d;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.ShortBuffer;
+
+public abstract class IndexedGeometryArray extends GeometryArray {
+
+ protected int indexCount;
+ protected ShortBuffer indexBuffer = null;
+
+ // �R���X�g���N�^
+ public IndexedGeometryArray(int vertexCount, int vertexFormat, int indexCount) {
+ super(vertexCount, vertexFormat);
+ this.indexCount = indexCount;
+ ByteBuffer vbb = ByteBuffer.allocateDirect(indexCount * 2);
+ vbb.order(ByteOrder.nativeOrder());
+ indexBuffer = vbb.asShortBuffer();
+ }
+
+ /** �I�u�W�F�N�g�̃C���f�b�N�X�����擾���� */
+ public int getIndexCount() {
+ return indexCount;
+ }
+
+ public int getCoordinateIndex(int index) {
+ return indexBuffer.get(index);
+ }
+
+ public void setCoordinateIndex(int index, int coordinateIndex) {
+ indexBuffer.put(index, (short)coordinateIndex);
+ }
+
+ public void setCoordinateIndices(int index, int[] coordinateIndicies) {
+ indexBuffer.position(index);
+ for (int i = 0; i < coordinateIndicies.length; i++) {
+ indexBuffer.put((short)coordinateIndicies[i]);
+ }
+ indexBuffer.position(0);
+ }
+
+ public ShortBuffer getIndexBuffer() {
+ return indexBuffer;
+ }
+}
diff --git a/src/java3d/IndexedGeometryStripArray.java b/src/java3d/IndexedGeometryStripArray.java
new file mode 100644
index 0000000..c597ab1
--- /dev/null
+++ b/src/java3d/IndexedGeometryStripArray.java
@@ -0,0 +1,22 @@
+package java3d;
+
+public abstract class IndexedGeometryStripArray extends IndexedGeometryArray {
+ protected int[] stripIndexCounts;
+
+ public IndexedGeometryStripArray(int vertexCount, int vertexFormat, int indexCount, int[] stripIndexCounts) {
+ super(vertexCount, vertexFormat, indexCount);
+ this.stripIndexCounts = stripIndexCounts;
+ }
+
+ public int getNumStrips() {
+ return stripIndexCounts.length;
+ }
+
+ public void setStripIndexCounts(int[] stripIndexCounts) {
+ this.stripIndexCounts = stripIndexCounts;
+ }
+
+ public void getStripIndexCounts(int[] stripIndexCounts) {
+ System.arraycopy(this.stripIndexCounts, 0, stripIndexCounts, 0, stripIndexCounts.length);
+ }
+}
diff --git a/src/java3d/IndexedTriangleArray.java b/src/java3d/IndexedTriangleArray.java
new file mode 100644
index 0000000..2bdb198
--- /dev/null
+++ b/src/java3d/IndexedTriangleArray.java
@@ -0,0 +1,19 @@
+package java3d;
+
+public class IndexedTriangleArray extends IndexedGeometryArray {
+ public IndexedTriangleArray(int vertexCount, int vertexFormat, int indexCount) {
+ super(vertexCount, vertexFormat, indexCount);
+ }
+
+ @Override
+ public NodeComponent cloneNodeComponent() {
+ IndexedTriangleArray newOne = new IndexedTriangleArray(vertexCount, vertexFormat, indexCount);
+ newOne.vertexBuffer = vertexBuffer.duplicate();
+ if (normalBuffer != null) newOne.normalBuffer = normalBuffer.duplicate();
+ if (uvBuffer != null) newOne.uvBuffer = uvBuffer.duplicate();
+ newOne.indexCount = indexCount;
+ newOne.indexBuffer = indexBuffer.duplicate();
+ return newOne;
+ }
+
+}
diff --git a/src/java3d/IndexedTriangleFanArray.java b/src/java3d/IndexedTriangleFanArray.java
new file mode 100644
index 0000000..f3b0506
--- /dev/null
+++ b/src/java3d/IndexedTriangleFanArray.java
@@ -0,0 +1,19 @@
+package java3d;
+
+public class IndexedTriangleFanArray extends IndexedGeometryStripArray {
+ public IndexedTriangleFanArray(int vertexCount, int vertexFormat, int indexCount, int[] fanIndexCounts) {
+ super(vertexCount, vertexFormat, indexCount, fanIndexCounts);
+ }
+
+ @Override
+ public NodeComponent cloneNodeComponent() {
+ IndexedTriangleFanArray newOne = new IndexedTriangleFanArray(vertexCount, vertexFormat, indexCount, (int [])stripIndexCounts.clone());
+ newOne.vertexBuffer = vertexBuffer.duplicate();
+ if (normalBuffer != null) newOne.normalBuffer = normalBuffer.duplicate();
+ if (uvBuffer != null) newOne.uvBuffer = uvBuffer.duplicate();
+ newOne.indexCount = indexCount;
+ newOne.indexBuffer = indexBuffer.duplicate();
+ return newOne;
+ }
+
+}
diff --git a/src/java3d/IndexedTriangleStripArray.java b/src/java3d/IndexedTriangleStripArray.java
new file mode 100644
index 0000000..5d79c9f
--- /dev/null
+++ b/src/java3d/IndexedTriangleStripArray.java
@@ -0,0 +1,18 @@
+package java3d;
+
+public class IndexedTriangleStripArray extends IndexedGeometryStripArray {
+ public IndexedTriangleStripArray(int vertexCount, int vertexFormat, int indexCount, int[] stripIndexCounts) {
+ super(vertexCount, vertexFormat, indexCount, stripIndexCounts);
+ }
+
+ @Override
+ public NodeComponent cloneNodeComponent() {
+ IndexedTriangleStripArray newOne = new IndexedTriangleStripArray(vertexCount, vertexFormat, indexCount, (int [])stripIndexCounts.clone());
+ newOne.vertexBuffer = vertexBuffer.duplicate();
+ if (normalBuffer != null) newOne.normalBuffer = normalBuffer.duplicate();
+ if (uvBuffer != null) newOne.uvBuffer = uvBuffer.duplicate();
+ newOne.indexCount = indexCount;
+ newOne.indexBuffer = indexBuffer.duplicate();
+ return newOne;
+ }
+}
diff --git a/src/java3d/Leaf.java b/src/java3d/Leaf.java
new file mode 100644
index 0000000..8e12078
--- /dev/null
+++ b/src/java3d/Leaf.java
@@ -0,0 +1,5 @@
+package java3d;
+
+public abstract class Leaf extends Node {
+
+}
diff --git a/src/java3d/Light.java b/src/java3d/Light.java
new file mode 100644
index 0000000..6e2bfa5
--- /dev/null
+++ b/src/java3d/Light.java
@@ -0,0 +1,15 @@
+package java3d;
+
+public abstract class Light extends Leaf {
+ private Color3f Color;
+
+ public Light(Color3f c){
+ this.Color = c;
+ }
+ public void setColor(Color3f c){
+ Color = c;
+ }
+ public Color3f getColor(){
+ return Color;
+ }
+}
diff --git a/src/java3d/Material.java b/src/java3d/Material.java
new file mode 100644
index 0000000..c33458d
--- /dev/null
+++ b/src/java3d/Material.java
@@ -0,0 +1,77 @@
+package java3d;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.FloatBuffer;
+
+public class Material extends NodeComponent {
+ float diffuseR = 1.0f;
+ float diffuseG = 1.0f;
+ float diffuseB = 1.0f;
+ float ambientR = 0.2f;
+ float ambientG = 0.2f;
+ float ambientB = 0.2f;
+ float specularR = 1.0f;
+ float specularG = 1.0f;
+ float specularB = 1.0f;
+ float emissiveR = 0.0f;
+ float emissiveG = 0.0f;
+ float emissiveB = 0.0f;
+ float shininess = 64.0f;
+ float[] diffuse = null;
+ float[] ambient = null;
+ float[] specular = null;
+ float[] emissive = null;
+
+ public Material() {
+ setDiffuseColor(1.0f, 1.0f, 1.0f);
+ setAmbientColor(0.2f, 0.2f, 0.2f);
+ setSpecularColor(1.0f, 1.0f, 1.0f);
+ setEmissiveColor(0.0f, 0.0f, 0.0f);
+ setShininess(64.0f);
+ }
+
+ public void setDiffuseColor(float r, float g, float b) {
+ this.diffuseR = r;
+ this.diffuseG = g;
+ this.diffuseB = b;
+ diffuse = new float[]{r, g ,b, 1.0f};
+ }
+
+ public void setAmbientColor(float r, float g, float b) {
+ this.ambientR = r;
+ this.ambientG = g;
+ this.ambientB = b;
+ ambient = new float[]{r, g ,b, 1.0f};
+ }
+
+ public void setSpecularColor(float r, float g, float b) {
+ this.specularR = r;
+ this.specularG = g;
+ this.specularB = b;
+ specular = new float[]{r, g ,b, 1.0f};
+ }
+
+ public void setEmissiveColor(float r, float g, float b) {
+ this.emissiveR = r;
+ this.emissiveG = g;
+ this.emissiveB = b;
+ emissive = new float[]{r, g ,b, 1.0f};
+ }
+
+ public void setShininess(float shininess) {
+ this.shininess = shininess;
+ }
+
+ @Override
+ public NodeComponent cloneNodeComponent() {
+ Material m = new Material();
+ m.setDiffuseColor(diffuseR, diffuseG, diffuseB);
+ m.setAmbientColor(ambientR, ambientG, ambientB);
+ m.setSpecularColor(specularR, specularG, specularB);
+ m.setEmissiveColor(emissiveR, emissiveG, emissiveB);
+ m.setShininess(shininess);
+ return m;
+ }
+
+}
diff --git a/src/java3d/Matrix3d.java b/src/java3d/Matrix3d.java
new file mode 100644
index 0000000..2fc6695
--- /dev/null
+++ b/src/java3d/Matrix3d.java
@@ -0,0 +1,479 @@
+package java3d;
+
+public class Matrix3d {
+ public double m00;
+ public double m01;
+ public double m02;
+ public double m10;
+ public double m11;
+ public double m12;
+ public double m20;
+ public double m21;
+ public double m22;
+
+ // �R���X�g���N�^
+ public Matrix3d() {
+ m00 = 0.0;
+ m01 = 0.0;
+ m02 = 0.0;
+ m10 = 0.0;
+ m11 = 0.0;
+ m12 = 0.0;
+ m20 = 0.0;
+ m21 = 0.0;
+ m22 = 0.0;
+ }
+
+ public Matrix3d(double[] v) {
+ m00 = v[0];
+ m01 = v[1];
+ m02 = v[2];
+ m10 = v[3];
+ m11 = v[4];
+ m12 = v[5];
+ m20 = v[6];
+ m21 = v[7];
+ m22 = v[8];
+ }
+
+ public Matrix3d(double m00, double m01, double m02, double m10, double m11,
+ double m12, double m20, double m21, double m22) {
+ this.m00 = m00;
+ this.m01 = m01;
+ this.m02 = m02;
+ this.m10 = m10;
+ this.m11 = m11;
+ this.m12 = m12;
+ this.m20 = m20;
+ this.m21 = m21;
+ this.m22 = m22;
+ }
+
+ public Matrix3d(Matrix3d m1) {
+ this.m00 = m1.m00;
+ this.m01 = m1.m01;
+ this.m02 = m1.m02;
+ this.m10 = m1.m10;
+ this.m11 = m1.m11;
+ this.m12 = m1.m12;
+ this.m20 = m1.m20;
+ this.m21 = m1.m21;
+ this.m22 = m1.m22;
+ }
+
+ public Matrix3d clone() {
+ return new Matrix3d(m00, m01, m02, m10, m11, m12, m20, m21, m22);
+ }
+
+ /** �e�v�f�ɑ��� */
+ public void add(Matrix3d m1) {
+ this.m00 += m1.m00;
+ this.m01 += m1.m01;
+ this.m02 += m1.m02;
+ this.m10 += m1.m10;
+ this.m11 += m1.m11;
+ this.m12 += m1.m12;
+ this.m20 += m1.m20;
+ this.m21 += m1.m21;
+ this.m22 += m1.m22;
+ }
+
+ /** ��̍s��̘a���i�[���� */
+ public void add(Matrix3d m1, Matrix3d m2) {
+ this.m00 = m1.m00 + m2.m00;
+ this.m01 = m1.m01 + m2.m01;
+ this.m02 = m1.m02 + m2.m02;
+ this.m10 = m1.m10 + m2.m10;
+ this.m11 = m1.m11 + m2.m11;
+ this.m12 = m1.m12 + m2.m12;
+ this.m20 = m1.m20 + m2.m20;
+ this.m21 = m1.m21 + m2.m21;
+ this.m22 = m1.m22 + m2.m22;
+ }
+
+ /** x�������angle��] */
+ public void rotX(double angle) {
+ double d1 = Math.sin(angle);
+ double d2 = Math.cos(angle);
+ m00 = 1.0D;
+ m01 = 0.0D;
+ m02 = 0.0D;
+ m10 = 0.0D;
+ m11 = d2;
+ m12 = -d1;
+ m20 = 0.0D;
+ m21 = d1;
+ m22 = d2;
+ }
+
+ /** y�������angle��] */
+ public void rotY(double angle) {
+ double d1 = Math.sin(angle);
+ double d2 = Math.cos(angle);
+ m00 = d2;
+ m01 = 0.0D;
+ m02 = d1;
+ m10 = 0.0D;
+ m11 = 1.0D;
+ m12 = 0.0D;
+ m20 = -d1;
+ m21 = 0.0D;
+ m22 = d2;
+ }
+
+ /** z�������angle1��] */
+ public void rotZ(double angle) {
+ double d1 = Math.sin(angle);
+ double d2 = Math.cos(angle);
+ m00 = d2;
+ m01 = -d1;
+ m02 = 0.0D;
+ m10 = d1;
+ m11 = d2;
+ m12 = 0.0D;
+ m20 = 0.0D;
+ m21 = 0.0D;
+ m22 = 1.0D;
+ }
+
+ /** �����Ɉ����̍s����|�������̂��i�[���� */
+ public void mul(Matrix3d mat) {
+ double t00 = m00 * mat.m00 + m01 * mat.m10 + m02 * mat.m20;
+ double t01 = m00 * mat.m01 + m01 * mat.m11 + m02 * mat.m21;
+ double t02 = m00 * mat.m02 + m01 * mat.m12 + m02 * mat.m22;
+ double t10 = m10 * mat.m10 + m11 * mat.m10 + m12 * mat.m20;
+ double t11 = m10 * mat.m11 + m11 * mat.m11 + m12 * mat.m21;
+ double t12 = m10 * mat.m12 + m11 * mat.m12 + m12 * mat.m22;
+ double t20 = m20 * mat.m20 + m21 * mat.m10 + m22 * mat.m20;
+ double t21 = m20 * mat.m21 + m21 * mat.m11 + m22 * mat.m21;
+ double t22 = m20 * mat.m22 + m21 * mat.m12 + m22 * mat.m22;
+
+ set(t00, t01, t02, t10, t11, t12, t20, t21, t22);
+ }
+
+ public void set(double t00, double t01, double t02, double t10, double t11,
+ double t12, double t20, double t21, double t22) {
+ m00 = t00;
+ m01 = t01;
+ m02 = t02;
+ m10 = t10;
+ m11 = t11;
+ m12 = t12;
+ m20 = t20;
+ m21 = t21;
+ m22 = t22;
+ }
+
+ /**
+ * Sets the value of this matrix to the matrix inverse of the passed matrix
+ * m1.
+ *
+ * @param m1
+ * the matrix to be inverted
+ */
+ public final void invert(Matrix3d m1) {
+ invertGeneral(m1);
+ }
+
+ /**
+ * Inverts this matrix in place.
+ */
+ public final void invert() {
+ invertGeneral(this);
+ }
+
+ /**
+ * General invert routine. Inverts m1 and places the result in "this". Note
+ * that this routine handles both the "this" version and the non-"this"
+ * version.
+ *
+ * Also note that since this routine is slow anyway, we won't worry about
+ * allocating a little bit of garbage.
+ */
+ private final void invertGeneral(Matrix3d m1) {
+ double result[] = new double[9];
+ int row_perm[] = new int[3];
+ int i, r, c;
+ double[] tmp = new double[9]; // scratch matrix
+
+ // Use LU decomposition and backsubstitution code specifically
+ // for floating-point 3x3 matrices.
+
+ // Copy source matrix to t1tmp
+ tmp[0] = m1.m00;
+ tmp[1] = m1.m01;
+ tmp[2] = m1.m02;
+
+ tmp[3] = m1.m10;
+ tmp[4] = m1.m11;
+ tmp[5] = m1.m12;
+
+ tmp[6] = m1.m20;
+ tmp[7] = m1.m21;
+ tmp[8] = m1.m22;
+
+ // Calculate LU decomposition: Is the matrix singular?
+ if (!luDecomposition(tmp, row_perm)) {
+ // Matrix has no inverse
+ // throw new
+ // SingularMatrixException(VecMathI18N.getString("Matrix3d12"));
+ }
+
+ // Perform back substitution on the identity matrix
+ for (i = 0; i < 9; i++)
+ result[i] = 0.0;
+ result[0] = 1.0;
+ result[4] = 1.0;
+ result[8] = 1.0;
+ luBacksubstitution(tmp, row_perm, result);
+
+ this.m00 = result[0];
+ this.m01 = result[1];
+ this.m02 = result[2];
+
+ this.m10 = result[3];
+ this.m11 = result[4];
+ this.m12 = result[5];
+
+ this.m20 = result[6];
+ this.m21 = result[7];
+ this.m22 = result[8];
+
+ }
+
+ /**
+ * Given a 3x3 array "matrix0", this function replaces it with the LU
+ * decomposition of a row-wise permutation of itself. The input parameters
+ * are "matrix0" and "dimen". The array "matrix0" is also an output
+ * parameter. The vector "row_perm[3]" is an output parameter that contains
+ * the row permutations resulting from partial pivoting. The output
+ * parameter "even_row_xchg" is 1 when the number of row exchanges is even,
+ * or -1 otherwise. Assumes data type is always double.
+ *
+ * This function is similar to luDecomposition, except that it is tuned
+ * specifically for 3x3 matrices.
+ *
+ * @return true if the matrix is nonsingular, or false otherwise.
+ */
+ //
+ // Reference: Press, Flannery, Teukolsky, Vetterling,
+ // _Numerical_Recipes_in_C_, Cambridge University Press,
+ // 1988, pp 40-45.
+ //
+ static boolean luDecomposition(double[] matrix0, int[] row_perm) {
+
+ double row_scale[] = new double[3];
+
+ // Determine implicit scaling information by looping over rows
+ {
+ int i, j;
+ int ptr, rs;
+ double big, temp;
+
+ ptr = 0;
+ rs = 0;
+
+ // For each row ...
+ i = 3;
+ while (i-- != 0) {
+ big = 0.0;
+
+ // For each column, find the largest element in the row
+ j = 3;
+ while (j-- != 0) {
+ temp = matrix0[ptr++];
+ temp = Math.abs(temp);
+ if (temp > big) {
+ big = temp;
+ }
+ }
+
+ // Is the matrix singular?
+ if (big == 0.0) {
+ return false;
+ }
+ row_scale[rs++] = 1.0 / big;
+ }
+ }
+
+ {
+ int j;
+ int mtx;
+
+ mtx = 0;
+
+ // For all columns, execute Crout's method
+ for (j = 0; j < 3; j++) {
+ int i, imax, k;
+ int target, p1, p2;
+ double sum, big, temp;
+
+ // Determine elements of upper diagonal matrix U
+ for (i = 0; i < j; i++) {
+ target = mtx + (3 * i) + j;
+ sum = matrix0[target];
+ k = i;
+ p1 = mtx + (3 * i);
+ p2 = mtx + j;
+ while (k-- != 0) {
+ sum -= matrix0[p1] * matrix0[p2];
+ p1++;
+ p2 += 3;
+ }
+ matrix0[target] = sum;
+ }
+
+ // Search for largest pivot element and calculate
+ // intermediate elements of lower diagonal matrix L.
+ big = 0.0;
+ imax = -1;
+ for (i = j; i < 3; i++) {
+ target = mtx + (3 * i) + j;
+ sum = matrix0[target];
+ k = j;
+ p1 = mtx + (3 * i);
+ p2 = mtx + j;
+ while (k-- != 0) {
+ sum -= matrix0[p1] * matrix0[p2];
+ p1++;
+ p2 += 3;
+ }
+ matrix0[target] = sum;
+
+ // Is this the best pivot so far?
+ if ((temp = row_scale[i] * Math.abs(sum)) >= big) {
+ big = temp;
+ imax = i;
+ }
+ }
+
+ if (imax < 0) {
+ // throw new
+ // RuntimeException(VecMathI18N.getString("Matrix3d13"));
+ }
+
+ // Is a row exchange necessary?
+ if (j != imax) {
+ // Yes: exchange rows
+ k = 3;
+ p1 = mtx + (3 * imax);
+ p2 = mtx + (3 * j);
+ while (k-- != 0) {
+ temp = matrix0[p1];
+ matrix0[p1++] = matrix0[p2];
+ matrix0[p2++] = temp;
+ }
+
+ // Record change in scale factor
+ row_scale[imax] = row_scale[j];
+ }
+
+ // Record row permutation
+ row_perm[j] = imax;
+
+ // Is the matrix singular
+ if (matrix0[(mtx + (3 * j) + j)] == 0.0) {
+ return false;
+ }
+
+ // Divide elements of lower diagonal matrix L by pivot
+ if (j != (3 - 1)) {
+ temp = 1.0 / (matrix0[(mtx + (3 * j) + j)]);
+ target = mtx + (3 * (j + 1)) + j;
+ i = 2 - j;
+ while (i-- != 0) {
+ matrix0[target] *= temp;
+ target += 3;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Solves a set of linear equations. The input parameters "matrix1", and
+ * "row_perm" come from luDecompostionD3x3 and do not change here. The
+ * parameter "matrix2" is a set of column vectors assembled into a 3x3
+ * matrix of floating-point values. The procedure takes each column of
+ * "matrix2" in turn and treats it as the right-hand side of the matrix
+ * equation Ax = LUx = b. The solution vector replaces the original column
+ * of the matrix.
+ *
+ * If "matrix2" is the identity matrix, the procedure replaces its contents
+ * with the inverse of the matrix from which "matrix1" was originally
+ * derived.
+ */
+ //
+ // Reference: Press, Flannery, Teukolsky, Vetterling,
+ // _Numerical_Recipes_in_C_, Cambridge University Press,
+ // 1988, pp 44-45.
+ //
+ static void luBacksubstitution(double[] matrix1, int[] row_perm,
+ double[] matrix2) {
+
+ int i, ii, ip, j, k;
+ int rp;
+ int cv, rv;
+
+ // rp = row_perm;
+ rp = 0;
+
+ // For each column vector of matrix2 ...
+ for (k = 0; k < 3; k++) {
+ // cv = &(matrix2[0][k]);
+ cv = k;
+ ii = -1;
+
+ // Forward substitution
+ for (i = 0; i < 3; i++) {
+ double sum;
+
+ ip = row_perm[rp + i];
+ sum = matrix2[cv + 3 * ip];
+ matrix2[cv + 3 * ip] = matrix2[cv + 3 * i];
+ if (ii >= 0) {
+ // rv = &(matrix1[i][0]);
+ rv = i * 3;
+ for (j = ii; j <= i - 1; j++) {
+ sum -= matrix1[rv + j] * matrix2[cv + 3 * j];
+ }
+ } else if (sum != 0.0) {
+ ii = i;
+ }
+ matrix2[cv + 3 * i] = sum;
+ }
+
+ // Backsubstitution
+ // rv = &(matrix1[3][0]);
+ rv = 2 * 3;
+ matrix2[cv + 3 * 2] /= matrix1[rv + 2];
+
+ rv -= 3;
+ matrix2[cv + 3 * 1] = (matrix2[cv + 3 * 1] - matrix1[rv + 2]
+ * matrix2[cv + 3 * 2])
+ / matrix1[rv + 1];
+
+ rv -= 3;
+ matrix2[cv + 4 * 0] = (matrix2[cv + 3 * 0] - matrix1[rv + 1]
+ * matrix2[cv + 3 * 1] - matrix1[rv + 2]
+ * matrix2[cv + 3 * 2])
+ / matrix1[rv + 0];
+
+ }
+ }
+
+ /**
+ * Multiply this matrix by the tuple t and place the result
+ * back into the tuple (t = this*t).
+ * @param t the tuple to be multiplied by this matrix and then replaced
+ */
+ public final void transform(Tuple3d t) {
+ double x,y,z;
+ x = m00* t.x + m01*t.y + m02*t.z;
+ y = m10* t.x + m11*t.y + m12*t.z;
+ z = m20* t.x + m21*t.y + m22*t.z;
+ t.set(x,y,z);
+ }
+}
diff --git a/src/java3d/Matrix4d.java b/src/java3d/Matrix4d.java
new file mode 100644
index 0000000..0c817d2
--- /dev/null
+++ b/src/java3d/Matrix4d.java
@@ -0,0 +1,216 @@
+package java3d;
+
+public class Matrix4d {
+ public double m00;
+ public double m01;
+ public double m02;
+ public double m03;
+ public double m10;
+ public double m11;
+ public double m12;
+ public double m13;
+ public double m20;
+ public double m21;
+ public double m22;
+ public double m23;
+ public double m30;
+ public double m31;
+ public double m32;
+ public double m33;
+
+ // �R���X�g���N�^
+ public Matrix4d() {
+ m00 = 1.0;
+ m01 = 0.0;
+ m02 = 0.0;
+ m03 = 0.0;
+ m10 = 0.0;
+ m11 = 1.0;
+ m12 = 0.0;
+ m13 = 0.0;
+ m20 = 0.0;
+ m21 = 0.0;
+ m22 = 1.0;
+ m23 = 0.0;
+ m30 = 0.0;
+ m31 = 0.0;
+ m32 = 0.0;
+ m33 = 1.0;
+ }
+
+ public Matrix4d(double[] v) {
+ m00 = v[0];
+ m01 = v[1];
+ m02 = v[2];
+ m03 = v[3];
+ m10 = v[4];
+ m11 = v[5];
+ m12 = v[6];
+ m13 = v[7];
+ m20 = v[8];
+ m21 = v[9];
+ m22 = v[10];
+ m23 = v[11];
+ m30 = v[12];
+ m31 = v[13];
+ m32 = v[14];
+ m33 = v[15];
+ }
+
+ public Matrix4d(double m00, double m01, double m02, double m03, double m10,
+ double m11, double m12, double m13, double m20, double m21,
+ double m22, double m23, double m30, double m31, double m32,
+ double m33) {
+ this.m00 = m00;
+ this.m01 = m01;
+ this.m02 = m02;
+ this.m03 = m03;
+ this.m10 = m10;
+ this.m11 = m11;
+ this.m12 = m12;
+ this.m13 = m13;
+ this.m20 = m20;
+ this.m21 = m21;
+ this.m22 = m22;
+ this.m23 = m23;
+ this.m30 = m30;
+ this.m31 = m31;
+ this.m32 = m32;
+ this.m33 = m33;
+ }
+
+ public Matrix4d clone() {
+ return new Matrix4d(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33);
+ }
+
+ public Matrix4d(Matrix4d m1) {
+ this.m00 = m1.m00;
+ this.m01 = m1.m01;
+ this.m02 = m1.m02;
+ this.m03 = m1.m03;
+ this.m10 = m1.m10;
+ this.m11 = m1.m11;
+ this.m12 = m1.m12;
+ this.m13 = m1.m13;
+ this.m20 = m1.m20;
+ this.m21 = m1.m21;
+ this.m22 = m1.m22;
+ this.m23 = m1.m23;
+ this.m30 = m1.m30;
+ this.m31 = m1.m31;
+ this.m32 = m1.m32;
+ this.m33 = m1.m33;
+ }
+
+ /** �e�v�f�ɑ��� */
+ public void add(Matrix4d m1) {
+ this.m00 += m1.m00;
+ this.m01 += m1.m01;
+ this.m02 += m1.m02;
+ this.m03 += m1.m03;
+ this.m10 += m1.m10;
+ this.m11 += m1.m11;
+ this.m12 += m1.m12;
+ this.m13 += m1.m13;
+ this.m20 += m1.m20;
+ this.m21 += m1.m21;
+ this.m22 += m1.m22;
+ this.m23 += m1.m23;
+ this.m30 += m1.m30;
+ this.m31 += m1.m31;
+ this.m32 += m1.m32;
+ this.m33 += m1.m33;
+ }
+
+ /** ��̍s��̘a���i�[���� */
+ public void add(Matrix4d m1, Matrix4d m2) {
+ this.m00 = m1.m00 + m2.m00;
+ this.m01 = m1.m01 + m2.m01;
+ this.m02 = m1.m02 + m2.m02;
+ this.m03 = m1.m03 + m2.m03;
+ this.m10 = m1.m10 + m2.m10;
+ this.m11 = m1.m11 + m2.m11;
+ this.m12 = m1.m12 + m2.m12;
+ this.m13 = m1.m13 + m2.m13;
+ this.m20 = m1.m20 + m2.m20;
+ this.m21 = m1.m21 + m2.m21;
+ this.m22 = m1.m22 + m2.m22;
+ this.m23 = m1.m23 + m2.m23;
+ this.m30 = m1.m30 + m2.m30;
+ this.m31 = m1.m31 + m2.m31;
+ this.m32 = m1.m32 + m2.m32;
+ this.m33 = m1.m33 + m2.m33;
+ }
+
+ /** �����Ɉ����̍s����E����|�������̂��i�[���� */
+ public void mul(Matrix4d right) {
+ double _m00 = m00 * right.m00 + m01 * right.m10 + m02 * right.m20 + m03 * right.m30;
+ double _m01 = m00 * right.m01 + m01 * right.m11 + m02 * right.m21 + m03 * right.m31;
+ double _m02 = m00 * right.m02 + m01 * right.m12 + m02 * right.m22 + m03 * right.m32;
+ double _m03 = m00 * right.m03 + m01 * right.m13 + m02 * right.m23 + m03 * right.m33;
+
+ double _m10 = m10 * right.m00 + m11 * right.m10 + m12 * right.m20 + m13 * right.m30;
+ double _m11 = m10 * right.m01 + m11 * right.m11 + m12 * right.m21 + m13 * right.m31;
+ double _m12 = m10 * right.m02 + m11 * right.m12 + m12 * right.m22 + m13 * right.m32;
+ double _m13 = m10 * right.m03 + m11 * right.m13 + m12 * right.m23 + m13 * right.m33;
+
+ double _m20 = m20 * right.m00 + m21 * right.m10 + m22 * right.m20 + m23 * right.m30;
+ double _m21 = m20 * right.m01 + m21 * right.m11 + m22 * right.m21 + m23 * right.m31;
+ double _m22 = m20 * right.m02 + m21 * right.m12 + m22 * right.m22 + m23 * right.m32;
+ double _m23 = m20 * right.m03 + m21 * right.m13 + m22 * right.m23 + m23 * right.m33;
+
+ double _m30 = m30 * right.m00 + m31 * right.m10 + m32 * right.m20 + m33 * right.m30;
+ double _m31 = m30 * right.m01 + m31 * right.m11 + m32 * right.m21 + m33 * right.m31;
+ double _m32 = m30 * right.m02 + m31 * right.m12 + m32 * right.m22 + m33 * right.m32;
+ double _m33 = m30 * right.m03 + m31 * right.m13 + m32 * right.m23 + m33 * right.m33;
+
+ m00 = _m00; m01 = _m01; m02 = _m02; m03 = _m03;
+ m10 = _m10; m11 = _m11; m12 = _m12; m13 = _m13;
+ m20 = _m20; m21 = _m21; m22 = _m22; m23 = _m23;
+ m30 = _m30; m31 = _m31; m32 = _m32; m33 = _m33;
+ }
+
+ public void invert() {
+ double det = determinant();
+ if (det == 0) {
+ return;
+ }
+ double b00 = determinant3x3(m11,m12,m13,m21,m22,m23,m31,m32,m33) / det;
+ double b01 = -determinant3x3(m01,m02,m03,m21,m22,m23,m31,m32,m33) / det;
+ double b02 = determinant3x3(m01,m02,m03,m11,m12,m13,m31,m32,m33) / det;
+ double b03 = -determinant3x3(m01,m02,m03,m11,m12,m13,m21,m22,m23) / det;
+
+ double b10 = -determinant3x3(m10,m12,m13,m20,m22,m23,m30,m32,m33) / det;
+ double b11 = determinant3x3(m00,m02,m03,m20,m22,m23,m30,m32,m33) / det;
+ double b12 = -determinant3x3(m00,m02,m03,m10,m12,m13,m30,m32,m33) / det;
+ double b13 = determinant3x3(m00,m02,m03,m10,m12,m13,m20,m22,m23) / det;
+
+ double b20 = determinant3x3(m10,m11,m13,m20,m21,m23,m30,m31,m33) / det;
+ double b21 = -determinant3x3(m00,m01,m03,m20,m21,m23,m30,m31,m33) / det;
+ double b22 = determinant3x3(m00,m01,m03,m10,m11,m13,m30,m31,m33) / det;
+ double b23 = -determinant3x3(m00,m01,m03,m10,m11,m13,m20,m21,m23) / det;
+
+ double b30 = -determinant3x3(m10,m11,m12,m20,m21,m22,m30,m31,m32) / det;
+ double b31 = determinant3x3(m00,m01,m02,m20,m21,m22,m30,m31,m32) / det;
+ double b32 = -determinant3x3(m00,m01,m02,m10,m11,m12,m30,m31,m32) / det;
+ double b33 = determinant3x3(m00,m01,m02,m10,m11,m12,m20,m21,m22) / det;
+
+ m00 = b00; m01 = b01; m02 = b02; m03 = b03;
+ m10 = b10; m11 = b11; m12 = b12; m13 = b13;
+ m20 = b20; m21 = b21; m22 = b22; m23 = b23;
+ m30 = b30; m31 = b31; m32 = b32; m33 = b33;
+ }
+
+ private static double determinant3x3(double m11, double m12, double m13,double m21,double m22, double m23,double m31,double m32,double m33) {
+ return m11*m22*m33+m12*m23*m31+m13*m21*m32-m11*m23*m32-m12*m21*m33-m13*m22*m31;
+ }
+
+ /** �s�����߂� */
+ public double determinant() {
+ return m00 * determinant3x3(m11,m12,m13,m21,m22,m23,m31,m32,m33)-
+ m01 * determinant3x3(m10,m12,m13,m20,m22,m23,m30,m32,m33)+
+ m02 * determinant3x3(m10,m11,m13,m20,m21,m23,m30,m31,m33)-
+ m03 * determinant3x3(m10,m11,m12,m20,m21,m22,m30,m31,m32);
+ }
+
+}
diff --git a/src/java3d/Node.java b/src/java3d/Node.java
new file mode 100644
index 0000000..9d1bfbf
--- /dev/null
+++ b/src/java3d/Node.java
@@ -0,0 +1,11 @@
+package java3d;
+
+public abstract class Node {
+
+ public Node() {
+ super();
+ }
+
+ public abstract Node cloneTree();
+
+}
\ No newline at end of file
diff --git a/src/java3d/NodeComponent.java b/src/java3d/NodeComponent.java
new file mode 100644
index 0000000..2527ecf
--- /dev/null
+++ b/src/java3d/NodeComponent.java
@@ -0,0 +1,6 @@
+package java3d;
+
+public abstract class NodeComponent {
+ public abstract NodeComponent cloneNodeComponent();
+
+}
diff --git a/src/java3d/Point3d.java b/src/java3d/Point3d.java
new file mode 100644
index 0000000..bec0854
--- /dev/null
+++ b/src/java3d/Point3d.java
@@ -0,0 +1,62 @@
+package java3d;
+
+public class Point3d extends Tuple3d {
+
+ // �R���X�g���N�^
+ public Point3d() {
+ this.x = 0;
+ this.y = 0;
+ this.z = 0;
+ }
+
+ public Point3d(double[] p) {
+ this.x = p[0];
+ this.y = p[1];
+ this.z = p[2];
+ }
+
+ public Point3d(double x, double y, double z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ public Point3d(Point3d p1) {
+ this.x = p1.x;
+ this.y = p1.y;
+ this.z = p1.z;
+ }
+
+ public Point3d(Tuple3d v) {
+ this.x = v.x;
+ this.y = v.y;
+ this.z = v.z;
+ }
+
+ public void scale(double s) {
+ this.x = x * s;
+ this.y = y * s;
+ this.z = z * s;
+ }
+
+ public void add(Tuple3d p) {
+ this.x += p.x;
+ this.y += p.y;
+ this.z += p.z;
+ }
+
+ public void set(Tuple3d v) {
+ this.x = v.x;
+ this.y = v.y;
+ this.z = v.z;
+ }
+
+ /** �����̓_�Ƃ̋�����Ԃ� */
+ public double distance(Point3d p) {
+ return Math.sqrt(distanceSquared(p));
+ }
+
+ public double distanceSquared(Point3d p) {
+ return (this.x - p.x) * (this.x - p.x) + (this.y - p.y) * (this.y - p.y) + (this.z - p.z) * (this.z - p.z);
+ }
+}
diff --git a/src/java3d/Primitive.java b/src/java3d/Primitive.java
new file mode 100644
index 0000000..810065c
--- /dev/null
+++ b/src/java3d/Primitive.java
@@ -0,0 +1,15 @@
+package java3d;
+
+public abstract class Primitive extends Group {
+ private Appearance ap = null;
+
+ public Appearance getAppearance() {
+ return ap;
+ }
+
+ public void setAppearance(Appearance ap) {
+ this.ap = ap;
+ }
+
+ public abstract Shape3D getShape(int partid);
+}
diff --git a/src/java3d/Quat4d.java b/src/java3d/Quat4d.java
new file mode 100644
index 0000000..fd592a1
--- /dev/null
+++ b/src/java3d/Quat4d.java
@@ -0,0 +1,130 @@
+package java3d;
+
+public class Quat4d implements Cloneable {
+ private static final double EPS = 1.0e-12;
+ public double x;
+ public double y;
+ public double z;
+ public double w;
+
+ public Quat4d clone() {
+ Quat4d q;
+ try {
+ q = (Quat4d) super.clone();
+ } catch (CloneNotSupportedException ce) {
+ throw new RuntimeException();
+ }
+ q.set(x, y, z, w);
+ return q;
+ }
+
+ // �R���X�g���N�^
+ public Quat4d() {
+ x = 0.0;
+ y = 0.0;
+ z = 0.0;
+ w = 0.0;
+ }
+
+ // �R���X�g���N�^
+ public Quat4d(double px, double py, double pz, double pw) {
+ double mag = 1.0/Math.sqrt(px*px+py*py+pz*pz+pw*pw);
+ x = px*mag;
+ y = py*mag;
+ z = pz*mag;
+ w = pw*mag;
+ }
+
+ public Quat4d(Quat4d q) {
+ x = q.x;
+ y = q.y;
+ z = q.z;
+ w = q.w;
+ }
+
+ public void set(AxisAngle4d a) {
+ double mag,amag;
+ amag = Math.sqrt( a.x*a.x + a.y*a.y + a.z*a.z);
+ if( amag < EPS ) {
+ w = 0.0;
+ x = 0.0;
+ y = 0.0;
+ z = 0.0;
+ } else {
+ amag = 1.0/amag;
+ mag = Math.sin(a.angle/2.0);
+ w = Math.cos(a.angle/2.0);
+ x = a.x*amag*mag;
+ y = a.y*amag*mag;
+ z = a.z*amag*mag;
+ }
+ }
+
+ private void set(double x2, double y2, double z2, double w2) {
+ x = x2;
+ y = y2;
+ z = z2;
+ w = w2;
+ }
+
+ public void mul(Quat4d q1) {
+ double x, y, w;
+ w = this.w * q1.w - this.x * q1.x - this.y * q1.y - this.z * q1.z;
+ x = this.w * q1.x + q1.w * this.x + this.y * q1.z - this.z * q1.y;
+ y = this.w * q1.y + q1.w * this.y - this.x * q1.z + this.z * q1.x;
+ this.z = this.w * q1.z + q1.w * this.z + this.x * q1.y - this.y * q1.x;
+ this.w = w;
+ this.x = x;
+ this.y = y;
+ }
+
+ public void interpolate(Quat4d q1, double alpha) {
+ double dot, s1, s2, om, sinom;
+
+ dot = x * q1.x + y * q1.y + z * q1.z + w * q1.w;
+
+ if (dot < 0) {
+ // negate quaternion
+ q1.x = -q1.x;
+ q1.y = -q1.y;
+ q1.z = -q1.z;
+ q1.w = -q1.w;
+ dot = -dot;
+ }
+
+ if ((1.0 - dot) > EPS) {
+ om = Math.acos(dot);
+ sinom = Math.sin(om);
+ s1 = Math.sin((1.0 - alpha) * om) / sinom;
+ s2 = Math.sin(alpha * om) / sinom;
+ } else {
+ s1 = 1.0 - alpha;
+ s2 = alpha;
+ }
+
+ w = s1 * w + s2 * q1.w;
+ x = s1 * x + s2 * q1.x;
+ y = s1 * y + s2 * q1.y;
+ z = s1 * z + s2 * q1.z;
+ }
+
+ public void normalize() {
+ double norm;
+
+ norm = (this.x * this.x + this.y * this.y + this.z * this.z + this.w
+ * this.w);
+
+ if (norm > 0.0) {
+ norm = 1.0 / Math.sqrt(norm);
+ this.x *= norm;
+ this.y *= norm;
+ this.z *= norm;
+ this.w *= norm;
+ } else {
+ this.x = 0.0;
+ this.y = 0.0;
+ this.z = 0.0;
+ this.w = 0.0;
+ }
+ }
+}
diff --git a/src/java3d/Shape3D.java b/src/java3d/Shape3D.java
new file mode 100644
index 0000000..b80d4e5
--- /dev/null
+++ b/src/java3d/Shape3D.java
@@ -0,0 +1,33 @@
+package java3d;
+
+public class Shape3D extends Leaf {
+ private Geometry geometry;
+ private Appearance ap;
+
+ public Shape3D(Geometry g, Appearance a) {
+ this.geometry = g;
+ this.ap = a;
+ }
+
+ public Appearance getAppearance() {
+ return ap;
+ }
+
+ public void setAppearance(Appearance ap) {
+ this.ap = ap;
+ }
+
+ public Geometry getGeometry() {
+ return geometry;
+ }
+
+ public void setGeometry(Geometry geometry) {
+ this.geometry = geometry;
+ }
+
+ @Override
+ public Node cloneTree() {
+ Shape3D shape = new Shape3D(geometry, (Appearance)ap.cloneNodeComponent());
+ return shape;
+ }
+}
diff --git a/src/java3d/Sphere.java b/src/java3d/Sphere.java
new file mode 100644
index 0000000..e45b402
--- /dev/null
+++ b/src/java3d/Sphere.java
@@ -0,0 +1,22 @@
+package java3d;
+
+public class Sphere extends Primitive {
+ public static final int BODY = 0;
+ static final int MID_REZ_DIV = 16;
+
+ private float radius;
+ private int divisions;
+
+ public float getRadius() {
+ return radius;
+ }
+
+ public void setRadius(float radius) {
+ this.radius = radius;
+ }
+
+ @Override
+ public Shape3D getShape(int partid) {
+ return null;
+ }
+}
diff --git a/src/java3d/TexCoordGeneration.java b/src/java3d/TexCoordGeneration.java
new file mode 100644
index 0000000..6148421
--- /dev/null
+++ b/src/java3d/TexCoordGeneration.java
@@ -0,0 +1,42 @@
+package java3d;
+
+public class TexCoordGeneration extends NodeComponent {
+ public static final int OBJECT_LINEAR = 0;
+ public static final int EYE_LINEAR = 1;
+ public static final int SPHERE_MAP = 2;
+ public static final int NORMAL_MAP = 3;
+ public static final int REFLECTION_MAP = 4;
+ public static final int TEXTURE_COORDINATE_2 = 0;
+ public static final int TEXTURE_COORDINATE_3 = 1;
+ public static final int TEXTURE_COORDINATE_4 = 2;
+
+ private int genMode;
+ private int format;
+
+ public TexCoordGeneration(int genMode, int format) {
+ this.genMode = genMode;
+ this.format = format;
+ }
+
+ public int getGenMode() {
+ return genMode;
+ }
+
+ public void setGenMode(int genMode) {
+ this.genMode = genMode;
+ }
+
+ public int getFormat() {
+ return format;
+ }
+
+ public void setFormat(int format) {
+ this.format = format;
+ }
+
+ @Override
+ public NodeComponent cloneNodeComponent() {
+ return new TexCoordGeneration(genMode, format);
+ }
+
+}
diff --git a/src/java3d/Texture.java b/src/java3d/Texture.java
new file mode 100644
index 0000000..d937a81
--- /dev/null
+++ b/src/java3d/Texture.java
@@ -0,0 +1,36 @@
+package java3d;
+
+public abstract class Texture extends NodeComponent {
+ public static final int BASE_LEVEL = 1;
+ public static final int RGB = 5;
+ public static final int RGBA = 6;
+
+ protected ImageComponent[] imageComponents = null;
+ protected int mipmapMode;
+ protected int format;
+ protected int width;
+ protected int hight;
+
+ public Texture(int mipmapMode, int format, int width, int hight) {
+ this.mipmapMode = mipmapMode;
+ this.format = format;
+ this.width = width;
+ this.hight = hight;
+ }
+
+ public void setImage(int n, ImageComponent image) {
+ imageComponents[n] = image;
+ }
+
+ public ImageComponent getImage(int n) {
+ return imageComponents[n];
+ }
+
+ public void setImages(ImageComponent[] images) {
+ imageComponents = images;
+ }
+
+ public ImageComponent[] getImages() {
+ return imageComponents;
+ }
+}
diff --git a/src/java3d/Texture2D.java b/src/java3d/Texture2D.java
new file mode 100644
index 0000000..234b6de
--- /dev/null
+++ b/src/java3d/Texture2D.java
@@ -0,0 +1,16 @@
+package java3d;
+
+public class Texture2D extends Texture {
+
+ public Texture2D(int mipmapMode, int format, int width, int hight) {
+ super(mipmapMode, format, width, hight);
+ imageComponents = new ImageComponent[1];
+ }
+
+ @Override
+ public NodeComponent cloneNodeComponent() {
+ Texture2D tex2D = new Texture2D(mipmapMode, format, width, hight);
+ tex2D.imageComponents = imageComponents.clone();
+ return tex2D;
+ }
+}
diff --git a/src/java3d/TextureAttributes.java b/src/java3d/TextureAttributes.java
new file mode 100644
index 0000000..157a1a6
--- /dev/null
+++ b/src/java3d/TextureAttributes.java
@@ -0,0 +1,70 @@
+package java3d;
+
+public class TextureAttributes extends NodeComponent {
+ public static final int FASTEST = 0;
+ public static final int NICEST = 1;
+ public static final int MODULATE = 2;
+ public static final int DECAL = 3;
+ public static final int BLEND = 4;
+ public static final int REPLACE = 5;
+// public static final int COMBINE = 6;
+// public static final int COMBINE_REPLACE = 0;
+// public static final int COMBINE_MODULATE = 1;
+// public static final int COMBINE_ADD = 2;
+// public static final int COMBINE_ADD_SIGNED = 3;
+// public static final int COMBINE_SUBTRACT = 4;
+// public static final int COMBINE_INTERPOLATE = 5;
+// public static final int COMBINE_DOT3 = 6;
+// public static final int COMBINE_OBJECT_COLOR = 0;
+// public static final int COMBINE_TEXTURE_COLOR = 1;
+// public static final int COMBINE_CONSTANT_COLOR = 2;
+// public static final int COMBINE_PREVIOUS_TEXTURE_UNIT_STATE = 3;
+// public static final int COMBINE_SRC_COLOR = 0;
+// public static final int COMBINE_ONE_MINUS_SRC_COLOR = 1;
+// public static final int COMBINE_SRC_ALPHA = 2;
+// public static final int COMBINE_ONE_MINUS_SRC_ALPHA = 3;
+
+ private int textureMode;
+ private Transform3D transform;
+ private Color4f textureBlendColor;
+ private int perspCorrectionMode;
+
+ public TextureAttributes() {
+ textureMode = TextureAttributes.REPLACE;
+ textureBlendColor = new Color4f();
+ perspCorrectionMode = TextureAttributes.NICEST;
+ }
+
+ public TextureAttributes(int textureMode, Transform3D transform, Color4f textureBlendColor, int perspCorrectionMode) {
+ this.textureMode = textureMode;
+ this.transform = transform;
+ this.textureBlendColor = textureBlendColor;
+ this.perspCorrectionMode = perspCorrectionMode;
+ }
+
+ public int getTextureMode() {
+ return textureMode;
+ }
+
+ public void setTextureMode(int textureMode) {
+ this.textureMode = textureMode;
+ }
+
+ public void setTextureTransform(Transform3D transform) {
+ this.transform = transform;
+ }
+
+ public int getPerspectiveCorrectionMode() {
+ return perspCorrectionMode;
+ }
+
+ public void setPerspectiveCorrectionMode(int perspCorrectionMode) {
+ this.perspCorrectionMode = perspCorrectionMode;
+ }
+
+ @Override
+ public NodeComponent cloneNodeComponent() {
+ return new TextureAttributes(textureMode, new Transform3D(transform), textureBlendColor.clone(), perspCorrectionMode);
+ }
+
+}
diff --git a/src/java3d/TextureUnitState.java b/src/java3d/TextureUnitState.java
new file mode 100644
index 0000000..6177403
--- /dev/null
+++ b/src/java3d/TextureUnitState.java
@@ -0,0 +1,48 @@
+package java3d;
+
+public class TextureUnitState extends NodeComponent {
+ private Texture texture;
+ private TextureAttributes textureAttribute;
+ private TexCoordGeneration texCoordGeneration;
+
+ public TextureUnitState() {
+ this(null, null ,null);
+ }
+
+ public TextureUnitState(Texture texture, TextureAttributes textureAttribute, TexCoordGeneration texCoordGeneration) {
+ this.texture = texture;
+ this.textureAttribute = textureAttribute;
+ this.texCoordGeneration= texCoordGeneration;
+ }
+
+ public Texture getTexture() {
+ return texture;
+ }
+
+ public void setTexture(Texture texture) {
+ this.texture = texture;
+ }
+
+ public TextureAttributes getTextureAttributes() {
+ return textureAttribute;
+ }
+
+ public void setTextureAttributes(TextureAttributes textureAttribute) {
+ this.textureAttribute = textureAttribute;
+ }
+
+ public TexCoordGeneration getTexCoordGeneration() {
+ return texCoordGeneration;
+ }
+
+ public void setTexCoordGeneration(TexCoordGeneration texCoordGeneration) {
+ this.texCoordGeneration = texCoordGeneration;
+ }
+
+ @Override
+ public NodeComponent cloneNodeComponent() {
+ return new TextureUnitState((Texture)texture.cloneNodeComponent(),
+ (TextureAttributes)textureAttribute.cloneNodeComponent(),
+ (TexCoordGeneration)texCoordGeneration.cloneNodeComponent());
+ }
+}
diff --git a/src/java3d/Transform3D.java b/src/java3d/Transform3D.java
new file mode 100644
index 0000000..e30dc8e
--- /dev/null
+++ b/src/java3d/Transform3D.java
@@ -0,0 +1,425 @@
+package java3d;
+
+
+public class Transform3D {
+ double[][] mat;
+ double[] rot;
+ double[] scales = new double[] {1.0,1.0,1.0};
+
+ static final double EPSILON_ABSOLUTE = 1.0e-5;
+
+ public Transform3D() {
+ mat = new double[][]{{1.0,0.0,0.0,0.0},{0.0,1.0,0.0,0.0},{0.0,0.0,1.0,0.0},{0.0,0.0,0.0,1.0}};
+ }
+
+ public Transform3D(Matrix4d m1) {
+ mat = new double[][]{{m1.m00,m1.m01,m1.m02,m1.m03},{m1.m10,m1.m11,m1.m12,m1.m13},{m1.m20,m1.m21,m1.m22,m1.m23},{m1.m30,m1.m31,m1.m32,m1.m33}};
+ }
+
+ public Transform3D(Transform3D transform) {
+ mat = new double[4][4];
+ set(transform);
+ }
+
+ public void set(Transform3D transform) {
+ for (int i = 0;i < 4; i++) {
+ for (int j = 0;j < 4; j++) {
+ mat[i][j] = transform.mat[i][j];
+ }
+ }
+ scales[0] = transform.scales[0];
+ scales[1] = transform.scales[1];
+ scales[2] = transform.scales[2];
+ }
+
+ /**
+ * this = t1 * t2
+ *
+ * @param t1
+ * @param t2
+ */
+ public void mul(Transform3D t1, Transform3D t2) {
+ for (int i = 0; i < 4; i++) {
+ double[] row = row(i, t1.mat);
+ for (int j = 0; j < 4; j++) {
+ mat[i][j] = 0.0;
+ double[] col = col(j, t2.mat);
+ for (int k = 0; k < 4; k++) {
+ mat[i][j] += row[k] * col[k];
+ }
+ }
+ }
+ }
+
+ /**
+ * this = this * t1
+ *
+ * @param t1
+ */
+ public void mul(Transform3D t1) {
+ this.mul(new Transform3D(this), t1);
+ }
+
+ /** 4*4�s��̍s��Ԃ� */
+ private double[] row(int row, double[][] mat) {
+ return new double[] {mat[row][0], mat[row][1], mat[row][2], mat[row][3]};
+ }
+
+ /** 4*4�s��̗��Ԃ� */
+ private double[] col(int col, double[][] mat) {
+ return new double[] {mat[0][col], mat[1][col], mat[2][col], mat[3][col]};
+ }
+
+ public void set(Vector3d v) {
+ mat[0][3] = v.x;
+ mat[1][3] = v.y;
+ mat[2][3] = v.z;
+ }
+
+ /** 4*4�̍s���16��1�����z��ŕԂ� */
+ public float[] getMatrix() {
+ float[] result = new float[16];
+ for (int i = 0; i < 4; i++) {
+ for (int j = 0; j < 4; j++) {
+ result[j + 4 * i] = (float)(mat[j][i]);
+ }
+ }
+ return result;
+ }
+
+ /** �Ίp�s����X�J���{���� */
+ public void setScale(double s) {
+ for (int i = 0; i < 3; i++) {
+ mat[i][i] = s;
+ scales[i] = s;
+ }
+ }
+
+ /** �Ίp�s���vector�̐����{���� */
+ public void setScale(Vector3d vector3d) {
+ scales[0] = mat[0][0] = vector3d.x;
+ scales[1] = mat[1][1] = vector3d.y;
+ scales[2] = mat[2][2] = vector3d.z;
+ }
+
+ /** �C�ӂ̒P�ʃx�N�g���܂��ɉ�]���� */
+ public void setRotation(AxisAngle4d t) {
+ double vx = t.x;
+ double vy = t.y;
+ double vz = t.z;
+ double sin = Math.sin(t.angle);
+ double cos = Math.cos(t.angle);
+
+ mat[0][0] = (Math.pow(vx, 2.0)) * (1 - cos) + cos;
+ mat[0][1] = ((vx * vy) * (1 - cos)) - (vz * sin);
+ mat[0][2] = ((vz * vx) * (1 - cos)) + (vy * sin);
+ mat[1][0] = ((vx * vy) * (1 - cos)) + (vz * sin);
+ mat[1][1] = (Math.pow(vy, 2.0)) * (1 - cos) + cos;
+ mat[1][2] = ((vy * vz) * (1 - cos)) - (vx * sin);
+ mat[2][0] = ((vz * vx) * (1 - cos)) - (vy * sin);
+ mat[2][1] = ((vy * vz) * (1 - cos)) + (vx * sin);
+ mat[2][2] = (Math.pow(vz, 2.0)) * (1 - cos) + cos;
+ }
+
+ /** �C�ӂ̒P�ʃx�N�g���܂��ɉ�]���� */
+ public void setRotation(Quat4d q) {
+// double vx = q.x;
+// double vy = q.y;
+// double vz = q.z;
+// double sin = Math.sin(q.w);
+// double cos = Math.cos(q.w);
+// double cosm = 1 - cos;
+//
+// mat[0][0] = (vx * vx) * cosm + cos;
+// mat[0][1] = ((vx * vy) * cosm) - (vz * sin);
+// mat[0][2] = ((vz * vx) * cosm) + (vy * sin);
+// mat[1][0] = ((vx * vy) * cosm) + (vz * sin);
+// mat[1][1] = (vy * vy) * cosm + cos;
+// mat[1][2] = ((vy * vz) * cosm) - (vx * sin);
+// mat[2][0] = ((vz * vx) * cosm) - (vy * sin);
+// mat[2][1] = ((vy * vz) * cosm) + (vx * sin);
+// mat[2][2] = (vz * vz) * cosm + cos;
+
+ mat[0][0] = (1.0 - 2.0 * q.y * q.y - 2.0 * q.z * q.z) * scales[0];
+ mat[1][0] = (2.0 * (q.x * q.y + q.w * q.z)) * scales[0];
+ mat[2][0] = (2.0 * (q.x * q.z - q.w * q.y)) * scales[0];
+ mat[0][1] = (2.0 * (q.x * q.y - q.w * q.z)) * scales[1];
+ mat[1][1] = (1.0 - 2.0 * q.x * q.x - 2.0 * q.z * q.z) * scales[1];
+ mat[2][1] = (2.0 * (q.y * q.z + q.w * q.x)) * scales[1];
+ mat[0][2] = (2.0 * (q.x * q.z + q.w * q.y)) * scales[2];
+ mat[1][2] = (2.0 * (q.y * q.z - q.w * q.x)) * scales[2];
+ mat[2][2] = (1.0 - 2.0 * q.x * q.x - 2.0 * q.y * q.y) * scales[2];
+ }
+
+ public void rotX(double angle) {
+ double sinAngle = Math.sin(angle);
+ double cosAngle = Math.cos(angle);
+
+ mat[0][0] = 1.0;
+ mat[0][1] = 0.0;
+ mat[0][2] = 0.0;
+ mat[0][3] = 0.0;
+
+ mat[1][0] = 0.0;
+ mat[1][1] = cosAngle;
+ mat[1][2] = -sinAngle;
+ mat[1][3] = 0.0;
+
+ mat[2][0] = 0.0;
+ mat[2][1] = sinAngle;
+ mat[2][2] = cosAngle;
+ mat[2][3] = 0.0;
+
+ mat[3][0] = 0.0;
+ mat[3][1] = 0.0;
+ mat[3][2] = 0.0;
+ mat[3][3] = 1.0;
+ }
+
+ public void rotY(double angle) {
+ double sinAngle = Math.sin(angle);
+ double cosAngle = Math.cos(angle);
+
+ mat[0][0] = cosAngle;
+ mat[0][1] = 0.0;
+ mat[0][2] = sinAngle;
+ mat[0][3] = 0.0;
+
+ mat[1][0] = 0.0;
+ mat[1][1] = 1.0;
+ mat[1][2] = 0.0;
+ mat[1][3] = 0.0;
+
+ mat[2][0] = -sinAngle;
+ mat[2][1] = 0.0;
+ mat[2][2] = cosAngle;
+ mat[2][3] = 0.0;
+
+ mat[3][0] = 0.0;
+ mat[3][1] = 0.0;
+ mat[3][2] = 0.0;
+ mat[3][3] = 1.0;
+ }
+
+ public void rotZ(double angle) {
+ double sinAngle = Math.sin(angle);
+ double cosAngle = Math.cos(angle);
+
+ mat[0][0] = cosAngle;
+ mat[0][1] = -sinAngle;
+ mat[0][2] = 0.0;
+ mat[0][3] = 0.0;
+
+ mat[1][0] = sinAngle;
+ mat[1][1] = cosAngle;
+ mat[1][2] = 0.0;
+ mat[1][3] = 0.0;
+
+ mat[2][0] = 0.0;
+ mat[2][1] = 0.0;
+ mat[2][2] = 1.0;
+ mat[2][3] = 0.0;
+
+ mat[3][0] = 0.0;
+ mat[3][1] = 0.0;
+ mat[3][2] = 0.0;
+ mat[3][3] = 1.0;
+ }
+
+ /** �����̐������i�[���� */
+ public void get(Matrix4d mat4d) {
+ mat4d.m00 = mat[0][0];
+ mat4d.m01 = mat[0][1];
+ mat4d.m02 = mat[0][2];
+ mat4d.m03 = mat[0][3];
+ mat4d.m10 = mat[1][0];
+ mat4d.m11 = mat[1][1];
+ mat4d.m12 = mat[1][2];
+ mat4d.m13 = mat[1][3];
+ mat4d.m20 = mat[2][0];
+ mat4d.m21 = mat[2][1];
+ mat4d.m22 = mat[2][2];
+ mat4d.m23 = mat[2][3];
+ mat4d.m30 = mat[3][0];
+ mat4d.m31 = mat[3][1];
+ mat4d.m32 = mat[3][2];
+ mat4d.m33 = mat[3][3];
+ }
+
+
+ public void set(double[] matrix) {
+ mat[0][0] = matrix[0];
+ mat[0][1] = matrix[1];
+ mat[0][2] = matrix[2];
+ mat[0][3] = matrix[3];
+ mat[1][0] = matrix[4];
+ mat[1][1] = matrix[5];
+ mat[1][2] = matrix[6];
+ mat[1][3] = matrix[7];
+ mat[2][0] = matrix[8];
+ mat[2][1] = matrix[9];
+ mat[2][2] = matrix[10];
+ mat[2][3] = matrix[11];
+ mat[3][0] = matrix[12];
+ mat[3][1] = matrix[13];
+ mat[3][2] = matrix[14];
+ mat[3][3] = matrix[15];
+ scales[0] = 1.0;
+ scales[1] = 1.0;
+ scales[2] = 1.0;
+ }
+
+ public void set(AxisAngle4d a1) {
+ double mag = Math.sqrt( a1.x*a1.x + a1.y*a1.y + a1.z*a1.z);
+ if (almostZero(mag)) {
+ setIdentity();
+ } else {
+ mag = 1.0/mag;
+ double ax = a1.x*mag;
+ double ay = a1.y*mag;
+ double az = a1.z*mag;
+ double sinTheta = Math.sin((double)a1.angle);
+ double cosTheta = Math.cos((double)a1.angle);
+ double t = 1.0 - cosTheta;
+ double xz = ax * az;
+ double xy = ax * ay;
+ double yz = ay * az;
+ mat[0][0] = t * ax * ax + cosTheta;
+ mat[0][1] = t * xy - sinTheta * az;
+ mat[0][2] = t * xz + sinTheta * ay;
+ mat[0][3] = 0.0;
+ mat[1][0] = t * xy + sinTheta * az;
+ mat[1][1] = t * ay * ay + cosTheta;
+ mat[1][2] = t * yz - sinTheta * ax;
+ mat[1][3] = 0.0;
+ mat[2][0] = t * xz - sinTheta * ay;
+ mat[2][1] = t * yz + sinTheta * ax;
+ mat[2][2] = t * az * az + cosTheta;
+ mat[2][3] = 0.0;
+ mat[3][0] = 0.0;
+ mat[3][1] = 0.0;
+ mat[3][2] = 0.0;
+ mat[3][3] = 1.0;
+ }
+ }
+
+ public void set(Quat4d q1) {
+ mat[0][0] = (1.0f - 2.0f*q1.y*q1.y - 2.0f*q1.z*q1.z);
+ mat[1][0] = (2.0f*(q1.x*q1.y + q1.w*q1.z));
+ mat[2][0] = (2.0f*(q1.x*q1.z - q1.w*q1.y));
+
+ mat[0][1] = (2.0f*(q1.x*q1.y - q1.w*q1.z));
+ mat[1][1] = (1.0f - 2.0f*q1.x*q1.x - 2.0f*q1.z*q1.z);
+ mat[2][1] = (2.0f*(q1.y*q1.z + q1.w*q1.x));
+
+ mat[0][2] = (2.0f*(q1.x*q1.z + q1.w*q1.y));
+ mat[1][2] = (2.0f*(q1.y*q1.z - q1.w*q1.x));
+ mat[2][2] = (1.0f - 2.0f*q1.x*q1.x - 2.0f*q1.y*q1.y);
+
+ mat[0][3] = 0.0;
+ mat[1][3] = 0.0;
+ mat[2][3] = 0.0;
+
+ mat[3][0] = 0.0;
+ mat[3][1] = 0.0;
+ mat[3][2] = 0.0;
+ mat[3][3] = 1.0;
+
+ // Issue 253: set all dirty bits if input is infinity or NaN
+// if (isInfOrNaN(q1)) {
+// dirtyBits = ALL_DIRTY;
+// return;
+// }
+
+// dirtyBits = CLASSIFY_BIT | SCALE_BIT | ROTATION_BIT;
+// type = RIGID | CONGRUENT | AFFINE | ORTHO;
+ }
+
+ /** Vector3d��Transform3d�ŕϊ����� */
+ public void transform(Vector3d v) {
+ double vx = mat[0][0]*v.x + mat[0][1]*v.y + mat[0][2]*v.z;// + mat[0][3] * 1.0;
+ double vy = mat[1][0]*v.x + mat[1][1]*v.y + mat[1][2]*v.z;// + mat[1][3] * 1.0;
+ v.z = mat[2][0]*v.x + mat[2][1]*v.y + mat[2][2]*v.z;// + mat[2][3] * 1.0;
+ v.x = vx;
+ v.y = vy;
+ }
+
+ private static final boolean almostZero(double a) {
+ return ((a < EPSILON_ABSOLUTE) && (a > -EPSILON_ABSOLUTE));
+ }
+
+ public final void setIdentity() {
+ mat[0][0] = 1.0; mat[0][1] = 0.0; mat[0][2] = 0.0; mat[0][3] = 0.0;
+ mat[1][0] = 0.0; mat[1][1] = 1.0; mat[1][2] = 0.0; mat[1][3] = 0.0;
+ mat[2][0] = 0.0; mat[2][1] = 0.0; mat[2][2] = 1.0; mat[2][3] = 0.0;
+ mat[3][0] = 0.0; mat[3][1] = 0.0; mat[3][2] = 0.0; mat[3][3] = 1.0;
+ }
+
+ public void invert() {
+ Matrix4d m = new Matrix4d();
+ m.m00 = mat[0][0]; m.m01 = mat[0][1]; m.m02 = mat[0][2]; m.m03 = mat[0][3];
+ m.m10 = mat[1][0]; m.m11 = mat[1][1]; m.m12 = mat[1][2]; m.m13 = mat[1][3];
+ m.m20 = mat[2][0]; m.m21 = mat[2][1]; m.m22 = mat[2][2]; m.m23 = mat[2][3];
+ m.m30 = mat[3][0]; m.m31 = mat[3][1]; m.m32 = mat[3][2]; m.m33 = mat[3][3];
+ m.invert();
+ mat = new double[][]{{m.m00,m.m01,m.m02,m.m03},{m.m10,m.m11,m.m12,m.m13},{m.m20,m.m21,m.m22,m.m23},{m.m30,m.m31,m.m32,m.m33}};
+ }
+
+ public void transpose() {
+ for (int i = 0; i < 3; i++) {
+ for (int j = 1 + i; j < 4; j++) {
+ double m = mat[j][i];
+ mat[j][i] = mat[i][j];
+ mat[i][j] = m;
+ }
+ }
+ }
+
+ public void transform(Point3d point) {
+ Point3d p = new Point3d();
+ p.x = mat[0][0] * point.x + mat[0][1] * point.y + mat[0][2] * point.z;
+ p.y = mat[1][0] * point.x + mat[1][1] * point.y + mat[1][2] * point.z;
+ p.z = mat[2][0] * point.x + mat[2][1] * point.y + mat[2][2] * point.z;
+ point.x = p.x;
+ point.y = p.y;
+ point.z = p.z;
+ }
+
+ /**
+ * ���ʂɑ��Ă����g���Ă͂����Ȃ�
+ * @param plane
+ */
+ public void transform(Vector4d plane) {
+// double x = mat[0][0] * plane.x + mat[0][1] * plane.y + mat[0][2] * plane.z;
+// double y = mat[1][0] * plane.x + mat[1][1] * plane.y + mat[1][2] * plane.z;
+// double z = mat[2][0] * plane.x + mat[2][1] * plane.y + mat[2][2] * plane.z;
+//
+// double vx = x * plane.w - mat[0][3];
+// double vy = y * plane.w - mat[1][3];
+// double vz = z * plane.w - mat[2][3];
+//
+// plane.x = x;
+// plane.y = y;
+// plane.z = z;
+// plane.w = x * vx + y * vy + z * vz;
+//
+ double x = (mat[0][0]*plane.x + mat[0][1]*plane.y
+ + mat[0][2]*plane.z + mat[0][3]*plane.w);
+ double y = (mat[1][0]*plane.x + mat[1][1]*plane.y
+ + mat[1][2]*plane.z + mat[1][3]*plane.w);
+ double z = (mat[2][0]*plane.x + mat[2][1]*plane.y
+ + mat[2][2]*plane.z + mat[2][3]*plane.w);
+ plane.w = (mat[3][0]*plane.x + mat[3][1]*plane.y
+ + mat[3][2]*plane.z + mat[3][3]*plane.w);
+ plane.x = x;
+ plane.y = y;
+ plane.z = z;
+ }
+
+ public void setTranslation(Vector3d v) {
+ mat[3][0] = v.x;
+ mat[3][1] = v.y;
+ mat[3][2] = v.z;
+ }
+
+}
\ No newline at end of file
diff --git a/src/java3d/TransformGroup.java b/src/java3d/TransformGroup.java
new file mode 100644
index 0000000..f011178
--- /dev/null
+++ b/src/java3d/TransformGroup.java
@@ -0,0 +1,29 @@
+package java3d;
+
+import java.util.Enumeration;
+
+public class TransformGroup extends Group {
+
+ private Transform3D transform;
+
+ public TransformGroup() {
+ this(new Transform3D());
+ }
+
+ public TransformGroup(Transform3D transform) {
+ this.transform = transform;
+ }
+
+ public void setTransform(Transform3D transform) {
+ this.transform = transform;
+ }
+
+ public void getTransform(Transform3D transform) {
+ transform.set(this.transform);
+ }
+
+ public Node cloneTree() {
+ TransformGroup newInstance = new TransformGroup(new Transform3D(transform));
+ return newInstance;
+ }
+}
diff --git a/src/java3d/TriangleArray.java b/src/java3d/TriangleArray.java
new file mode 100644
index 0000000..a252e1f
--- /dev/null
+++ b/src/java3d/TriangleArray.java
@@ -0,0 +1,18 @@
+package java3d;
+
+public class TriangleArray extends GeometryArray {
+
+ public TriangleArray(int vertexCount, int vertexFormat) {
+ super(vertexCount, vertexFormat);
+ }
+
+ @Override
+ public NodeComponent cloneNodeComponent() {
+ TriangleArray newOne = new TriangleArray(vertexCount, vertexFormat);
+ newOne.vertexBuffer = vertexBuffer.duplicate();
+ if (normalBuffer != null) newOne.normalBuffer = normalBuffer.duplicate();
+ if (uvBuffer != null) newOne.uvBuffer = uvBuffer.duplicate();
+ return newOne;
+ }
+
+}
diff --git a/src/java3d/TriangleFanArray.java b/src/java3d/TriangleFanArray.java
new file mode 100644
index 0000000..b67f461
--- /dev/null
+++ b/src/java3d/TriangleFanArray.java
@@ -0,0 +1,18 @@
+package java3d;
+
+public class TriangleFanArray extends GeometryStripArray {
+
+ public TriangleFanArray(int vertexCount, int vertexFormat, int[] stripIndexCounts) {
+ super(vertexCount, vertexFormat, stripIndexCounts);
+ }
+
+ @Override
+ public NodeComponent cloneNodeComponent() {
+ TriangleFanArray newOne = new TriangleFanArray(vertexCount, vertexFormat, (int [])stripIndexCounts.clone());
+ newOne.vertexBuffer = vertexBuffer.duplicate();
+ if (normalBuffer != null) newOne.normalBuffer = normalBuffer.duplicate();
+ if (uvBuffer != null) newOne.uvBuffer = uvBuffer.duplicate();
+ return newOne;
+ }
+
+}
diff --git a/src/java3d/TriangleStripArray.java b/src/java3d/TriangleStripArray.java
new file mode 100644
index 0000000..22fadc7
--- /dev/null
+++ b/src/java3d/TriangleStripArray.java
@@ -0,0 +1,18 @@
+package java3d;
+
+public class TriangleStripArray extends GeometryStripArray {
+
+ public TriangleStripArray(int vertexCount, int vertexFormat, int[] stripIndexCounts) {
+ super(vertexCount, vertexFormat, stripIndexCounts);
+ }
+
+ @Override
+ public NodeComponent cloneNodeComponent() {
+ TriangleStripArray newOne = new TriangleStripArray(vertexCount, vertexFormat, (int [])stripIndexCounts.clone());
+ newOne.vertexBuffer = vertexBuffer.duplicate();
+ if (normalBuffer != null) newOne.normalBuffer = normalBuffer.duplicate();
+ if (uvBuffer != null) newOne.uvBuffer = uvBuffer.duplicate();
+ return newOne;
+ }
+
+}
diff --git a/src/java3d/Tuple3d.java b/src/java3d/Tuple3d.java
new file mode 100644
index 0000000..4d23e95
--- /dev/null
+++ b/src/java3d/Tuple3d.java
@@ -0,0 +1,38 @@
+package java3d;
+
+public class Tuple3d {
+
+ public double x;
+ public double y;
+ public double z;
+
+ public void set(double x, double y, double z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ public void setX(double x) {
+ this.x = x;
+ }
+
+ public void setY(double y) {
+ this.y = y;
+ }
+
+ public void setZ(double z) {
+ this.z = z;
+ }
+
+ public double getX() {
+ return x;
+ }
+
+ public double getY() {
+ return y;
+ }
+
+ public double getZ() {
+ return z;
+ }
+}
diff --git a/src/java3d/Vector3d.java b/src/java3d/Vector3d.java
new file mode 100644
index 0000000..aa7fd43
--- /dev/null
+++ b/src/java3d/Vector3d.java
@@ -0,0 +1,134 @@
+package java3d;
+
+public class Vector3d extends Tuple3d {
+
+ // �R���X�g���N�^
+ public Vector3d() {
+ x = 0.0;
+ y = 0.0;
+ z = 0.0;
+ }
+
+ // �R���X�g���N�^
+ public Vector3d(double px, double py, double pz) {
+ x = px;
+ y = py;
+ z = pz;
+ }
+
+ public Vector3d(Vector3d v) {
+ x = v.x;
+ y = v.y;
+ z = v.z;
+ }
+
+ public Vector3d(Tuple3d p) {
+ x = p.x;
+ y = p.y;
+ z = p.z;
+ }
+
+ public Vector3d(double[] coordinate) {
+ x = coordinate[0];
+ y = coordinate[1];
+ z = coordinate[2];
+ }
+
+ public Vector3d clone() {
+ return new Vector3d(this.x, this.y, this.z);
+ }
+
+ public double dot(Vector3d a) {
+ return x*a.x + y*a.y + z*a.z;
+ }
+
+ public void cross(Vector3d a, Vector3d b) {
+ double x = a.y*b.z - a.z*b.y;
+ double y = a.z*b.x - a.x*b.z;
+ double z = a.x*b.y - a.y*b.x;
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ public double length() {
+ return Math.sqrt(x*x+y*y+z*z);
+ }
+
+ public void scale(double s) {
+ x = x*s;
+ y = y*s;
+ z = z*s;
+ }
+
+ public void normalize() {
+ double l = length();
+ x = x / l;
+ y = y / l;
+ z = z / l;
+ }
+
+ /** v1��v2�̘a���i�[���� */
+ public void add(Tuple3d v1, Tuple3d v2) {
+ this.x = v1.x + v2.x;
+ this.y = v1.y + v2.y;
+ this.z = v1.z + v2.z;
+ }
+
+ /** v1�Ƃ̘a���i�[���� */
+ public void add(Tuple3d v1) {
+ this.x += v1.x;
+ this.y += v1.y;
+ this.z += v1.z;
+ }
+
+ /** v1��v2�̍����i�[���� */
+ public void sub(Tuple3d v1, Tuple3d v2) {
+ this.x = v1.x - v2.x;
+ this.y = v1.y - v2.y;
+ this.z = v1.z - v2.z;
+ }
+
+ /** v1�Ƃ̍����i�[���� */
+ public void sub(Tuple3d v1) {
+ this.x -= v1.x;
+ this.y -= v1.y;
+ this.z -= v1.z;
+ }
+
+ /** Vector3d���Z�b�g���� */
+ public void set(Tuple3d v) {
+ this.x = v.x;
+ this.y = v.y;
+ this.z = v.z;
+ }
+
+ /** �����]���� */
+ public void negate() {
+ this.x = -x;
+ this.y = -y;
+ this.z = -z;
+ }
+
+ /** this = d * axis + p */
+ public void scaleAdd(double d, Vector3d axis, Vector3d p) {
+ this.x = d * axis.x + p.x;
+ this.y = d * axis.y + p.y;
+ this.z = d * axis.z + p.z;
+ }
+
+ public void negate(Vector3d v) {
+ this.x = -v.x;
+ this.y = -v.y;
+ this.z = -v.z;
+ }
+
+ public double angle(Vector3d v) {
+ double d = dot(v) / (length() * v.length());
+ if (d < -1D)
+ d = -1D;
+ if (d > 1.0D)
+ d = 1.0D;
+ return Math.acos(d);
+ }
+}
diff --git a/src/java3d/Vector3f.java b/src/java3d/Vector3f.java
new file mode 100644
index 0000000..110b138
--- /dev/null
+++ b/src/java3d/Vector3f.java
@@ -0,0 +1,134 @@
+package java3d;
+
+public class Vector3f {
+ public float x;
+ public float y;
+ public float z;
+
+ // �R���X�g���N�^
+ public Vector3f() {
+ x = 0.0f;
+ y = 0.0f;
+ z = 0.0f;
+ }
+
+ // �R���X�g���N�^
+ public Vector3f(float px, float py, float pz) {
+ x = px;
+ y = py;
+ z = pz;
+ }
+
+ public Vector3f(Vector3f v) {
+ x = v.x;
+ y = v.y;
+ z = v.z;
+ }
+
+ public Vector3f clone() {
+ return new Vector3f(this.x, this.y, this.z);
+ }
+
+ public double dot(Vector3f a){
+ return x*a.x + y*a.y + z*a.z;
+ }
+
+ public void cross(Vector3f a, Vector3f b) {
+ float x = a.y*b.z - a.z*b.y;
+ float y = a.z*b.x - a.x*b.z;
+ float z = a.x*b.y - a.y*b.x;
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ public float length(){
+ return (float)Math.sqrt(x*x + y*y + z*z);
+ }
+
+ public void scale(float s){;
+ x = x*s;
+ y = y*s;
+ z = z*s;
+ }
+
+ public void normalize(){
+ float l = length();
+ x = x / l;
+ y = y / l;
+ z = z / l;
+ }
+
+ /** v1��v2�̘a���i�[���� */
+ public void add(Vector3f v1, Vector3f v2) {
+ this.x = v1.x + v2.x;
+ this.y = v1.y + v2.y;
+ this.z = v1.z + v2.z;
+ }
+
+ /** v1�Ƃ̘a���i�[���� */
+ public void add(Vector3f v1) {
+ this.x += v1.x;
+ this.y += v1.y;
+ this.z += v1.z;
+ }
+
+ /** v1��v2�̍����i�[���� */
+ public void sub(Vector3f v1, Vector3f v2) {
+ this.x = v1.x - v2.x;
+ this.y = v1.y - v2.y;
+ this.z = v1.z - v2.z;
+ }
+
+ /** v1�Ƃ̍����i�[���� */
+ public void sub(Vector3f v1) {
+ this.x -= v1.x;
+ this.y -= v1.y;
+ this.z -= v1.z;
+ }
+
+ /** Vector3d���Z�b�g���� */
+ public void set(Vector3f v) {
+ this.x = v.x;
+ this.y = v.y;
+ this.z = v.z;
+ }
+
+ /** �����]���� */
+ public void negate() {
+ this.x = -x;
+ this.y = -y;
+ this.z = -z;
+ }
+
+ /** this = d * axis + p */
+ public void scaleAdd(float d, Vector3f axis, Vector3f p) {
+ this.x = d * axis.x + p.x;
+ this.y = d * axis.y + p.y;
+ this.z = d * axis.z + p.z;
+ }
+
+ public void setX(float x) {
+ this.x = x;
+ }
+
+ public void setY(float y) {
+ this.y = y;
+ }
+
+ public void setZ(float z) {
+ this.z = z;
+ }
+
+ public float getX() {
+ return x;
+ }
+
+ public float getY() {
+ return y;
+ }
+
+ public float getZ() {
+ return z;
+ }
+}
diff --git a/src/java3d/Vector4d.java b/src/java3d/Vector4d.java
new file mode 100644
index 0000000..1bd0098
--- /dev/null
+++ b/src/java3d/Vector4d.java
@@ -0,0 +1,168 @@
+package java3d;
+
+public class Vector4d {
+ public double x;
+ public double y;
+ public double z;
+ public double w;
+
+ // �R���X�g���N�^
+ public Vector4d() {
+ x = 0.0;
+ y = 0.0;
+ z = 0.0;
+ w = 0.0;
+ }
+
+ // �R���X�g���N�^
+ public Vector4d(double px, double py, double pz, double pw) {
+ x = px;
+ y = py;
+ z = pz;
+ w = pw;
+ }
+
+ public Vector4d(Vector4d v) {
+ x = v.x;
+ y = v.y;
+ z = v.z;
+ w = v.w;
+ }
+
+ public void set(double x2, double y2, double z2, double w2) {
+ x = x2;
+ y = y2;
+ z = z2;
+ w = w2;
+ }
+
+ private void set(double[] t) {
+ x = t[0];
+ y = t[1];
+ z = t[2];
+ w = t[3];
+ }
+
+ public Vector4d clone() {
+ return new Vector4d(x, y, z, w);
+ }
+
+ /** ��Βl��Ԃ� */
+ final void absolute() {
+ x = Math.abs(x);
+ y = Math.abs(y);
+ z = Math.abs(z);
+ w = Math.abs(w);
+ }
+
+ final double angle(Vector4d v1) {
+ double vDot = this.dot(v1) / (this.length() * v1.length());
+ if (vDot < -1.0)
+ vDot = -1.0;
+ if (vDot > 1.0)
+ vDot = 1.0;
+ return ((double) (Math.acos(vDot)));
+ }
+
+ public final double dot(Vector4d v1) {
+ return (this.x * v1.x + this.y * v1.y + this.z * v1.z + this.w * v1.w);
+ }
+
+ public final double length() {
+ return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z
+ + this.w * this.w);
+ }
+
+ final void clamp(double min, double max) {
+ if (x > max) {
+ x = max;
+ } else if (x < min) {
+ x = min;
+ }
+
+ if (y > max) {
+ y = max;
+ } else if (y < min) {
+ y = min;
+ }
+
+ if (z > max) {
+ z = max;
+ } else if (z < min) {
+ z = min;
+ }
+
+ if (w > max) {
+ w = max;
+ } else if (w < min) {
+ w = min;
+ }
+ }
+
+ final void clampMax(double max) {
+ if (x > max)
+ x = max;
+ if (y > max)
+ y = max;
+ if (z > max)
+ z = max;
+ if (w > max)
+ w = max;
+ }
+
+ final void clampMin(double min) {
+ if (x < min)
+ x = min;
+ if (y < min)
+ y = min;
+ if (z < min)
+ z = min;
+ if (w < min)
+ w = min;
+ }
+
+ final void normalize() {
+ double norm;
+
+ norm = 1.0 / Math.sqrt(this.x * this.x + this.y * this.y + this.z
+ * this.z + this.w * this.w);
+ this.x *= norm;
+ this.y *= norm;
+ this.z *= norm;
+ this.w *= norm;
+ }
+
+ final void normalize(Vector4d v1) {
+ double norm;
+
+ norm = 1.0 / Math.sqrt(v1.x * v1.x + v1.y * v1.y + v1.z * v1.z + v1.w
+ * v1.w);
+ this.x = v1.x * norm;
+ this.y = v1.y * norm;
+ this.z = v1.z * norm;
+ this.w = v1.w * norm;
+ }
+
+ final void get(double[] t) {
+ t[0] = this.x;
+ t[1] = this.y;
+ t[2] = this.z;
+ t[3] = this.w;
+ }
+
+ public double getX() {
+ return x;
+ }
+
+ public double getY() {
+ return y;
+ }
+
+ public double getZ() {
+ return z;
+ }
+
+ public double getW() {
+ return w;
+ }
+}
diff --git a/src/java3d/View.java b/src/java3d/View.java
new file mode 100644
index 0000000..2eaa13f
--- /dev/null
+++ b/src/java3d/View.java
@@ -0,0 +1,8 @@
+package java3d;
+
+public class View {
+
+ public View() {
+
+ }
+}
diff --git a/src/room/CVS/Entries b/src/room/CVS/Entries
new file mode 100644
index 0000000..883e00f
--- /dev/null
+++ b/src/room/CVS/Entries
@@ -0,0 +1,2 @@
+/Room.java/1.32/Tue Dec 13 06:46:26 2016//
+/RoomManager.java/1.12/Thu Nov 24 06:14:46 2016//
diff --git a/src/room/CVS/Repository b/src/room/CVS/Repository
new file mode 100644
index 0000000..59c61f4
--- /dev/null
+++ b/src/room/CVS/Repository
@@ -0,0 +1 @@
+CarrotServer/src/room
diff --git a/src/room/CVS/Root b/src/room/CVS/Root
new file mode 100644
index 0000000..c36e9d0
--- /dev/null
+++ b/src/room/CVS/Root
@@ -0,0 +1 @@
+:pserver:guest@nitta-lab-www.is.konan-u.ac.jp:\CVSProject
diff --git a/src/room/Room.java b/src/room/Room.java
new file mode 100644
index 0000000..73746db
--- /dev/null
+++ b/src/room/Room.java
@@ -0,0 +1,172 @@
+package room;
+
+import java.util.ArrayList;
+import java.util.Date;
+
+import account.Account;
+import account.AccountManager;
+import game.Game;
+import game.GameManager;
+import game.Team;
+
+public class Room {
+ private int id; //��������ӂɔF������id
+ private String name;
+ private String pass;
+ private String mode;
+
+ // 0 = divide�O /�@1 = divide�� / 2 = divide��
+ private int divideFlag = 0;
+
+ private Game game = null;
+ private Team team = null;
+
+ public static final int TEAM_RED = 0;
+ public static final int TEAM_BLUE = 1;
+ public static final int MAX_MEMBERS = 2;
+
+ public static final int REMOVE_TIME = 30000; //30000ms = 30s
+
+ private ArrayList members = new ArrayList();
+
+ // AccountManager���g�����߂ɐ錾���Ă��� �@���V���O���g���p�^�[���𗘗p���Ă��邽��
+ GameManager gamemgr = GameManager.getInstance();
+
+ // �ꕔ���̐l���𑝂₷
+ public void addMember(Account ac) {
+ members.add(ac);
+ ac.setRoom(this);
+ }
+
+ // �ꕔ���̒��ɂ���l���ޏo�@ac��room��wat�̏�������
+ public void removeMember(Account ac) {
+ members.remove(ac);
+ ac.setRoom(null);
+ ac.setWait("no");
+ }
+
+ // �ꕔ�����̐l�����J�E���g
+ public int getMemberCount() {
+ return members.size();
+ }
+
+ // �����̒���n�Ԗڂ̃A�J�E���g�����擾
+ public Account getMember(int n) {
+ return members.get(n);
+ }
+
+ //MAX_MEMBERS(6)�l�W�܂�����`�[���������s��
+ public void divideTeam() {
+
+ game = new Game();
+ game.setRoom(this);
+ gamemgr.addGame(game);
+
+ //���łɓ����Ă�game�����݂���ꍇ�ɂ��̃Q�[������Y���A�J�E���g���폜����
+// gamemgr.searchGameSid(this);
+
+ //ramdom��[0�`5�܂ł̘A��][0�`99�܂ł̗���]������
+ int ramdom[][] = new int[MAX_MEMBERS][2];
+
+ //0�`5�܂ł̔ԍ������蓖�Ă�
+ for(int i=0; i ramdom[j+1][1]) {
+ //�ϐ�����ւ�
+ int temp1 = ramdom[j][1];
+ ramdom[j][1] = ramdom[j+1][1];
+ ramdom[j+1][1] = temp1;
+ //���Ԗڂ��̓���ւ�
+ int temp2 = ramdom[j][0];
+ ramdom[j][0] = ramdom[j+1][0];
+ ramdom[j+1][0] = temp2;
+ }
+ }
+ }
+
+ //�����������珇��3�l��ԃ`�[���@getMember(0�`2)�̐l���ԃ`�[��
+ for(int i=0; i roomList = new ArrayList();
+ private static RoomManager theInstance = null;
+
+ //�ʂ���roomId
+ int id = 0;
+
+ private RoomManager(){
+ }
+
+ public static RoomManager getInstance(){
+ if(theInstance == null){
+ theInstance = new RoomManager(); //�ŏ������쐬
+ }
+ return theInstance;
+ }
+
+ //�����𑝂₷
+ public void addRoom(Room room){
+ roomList.add(room);
+ }
+
+ //���������炷
+ public void removeRoom(Room room){
+ roomList.remove(room);
+ }
+
+ //�����̌����J�E���g
+ public int getRoomCount(){
+ return roomList.size();
+ }
+
+ //n�Ԗڂ̕��������擾
+ public Room getRoom(int n){
+ return roomList.get(n);
+ }
+
+ //���������A�쐬�҂��ɒlj�����
+ public boolean createRoom(String name, String mode, String pass, String sId) {
+
+ // AccountManager���g�����߂ɐ錾���Ă��� �@���V���O���g���p�^�[���𗘗p���Ă��邽��
+ AccountManager accountmgr = AccountManager.getInstance();
+
+ Room room = new Room();
+
+// //������id�����߂� �@//�������폜����Ȃ��ꍇ
+// int n = getRoomCount();
+// System.out.println("room count : " + n);
+// int roomid = n+1;
+
+ //������id�����߂�@//�������폜�����ꍇ
+ int roomid = id;
+ id++;
+
+System.out.println("createrRoom sId" + sId);
+
+ //�쐬�҂��ɒlj����Aroomid��ac�ɋL�^����
+ Account ac = new Account();
+ ac = accountmgr.getAccount(sId);
+ if(ac == null){ //�A�J�E���g��������Ȃ������ꍇ��false��Ԃ�
+ return false;
+ }
+
+ room.addMember(ac);
+
+ //���������
+ room.setName(name);
+ room.setPass(pass);
+ room.setId(roomid);
+ roomList.add(room);
+
+ return true;
+ }
+
+ //������id�����T��
+ public Room searchIdRoom(int id){
+ Room room = new Room();
+ for(int i=0; i");
+ printwriter.println("");
+System.out.println("manager time=" + (int)game.remainTime() + " game=" + game.getState());
+
+ printwriter.println("");
+
+ //�����̏���]��
+ printwriter.println("");
+ printwriter.println("");
+ myPlayer.setHit("no");
+
+ //�ԃ`�[���̏���]��
+ printwriter.println("");
+ for(int i=0; i");
+System.out.println("name : " + ac.getName() + " mode = " + player.getMode());
+ printwriter.println("");
+ }
+ }
+
+ printwriter.println("");
+
+ //�`�[���̏���]��
+ printwriter.println("");
+ for(int i=0;i");
+System.out.println("name : " + ac.getName() + " mode = " + player.getMode());
+ printwriter.println("");
+ }
+ }
+ printwriter.println("");
+
+ printwriter.println("");
+
+ printwriter.println("- ");
+//System.out.println("GameUpdateServlet :
- ");
+
+ printwriter.println("");
+
+ //laser�@red�`�[��
+ LaserTurret redLaserTurret = redTeam.getLaserTurret();
+ //laser�̃N�[���^�C����ݒ�
+ String redCool = "off";
+ if(redTeam.getCoolTimeFlag() == true) {
+ redCool = "on";
+ }
+ //�N�[���^�C���𑗐M
+ printwriter.println("");
+ if(redLaserTurret != null) {
+ Laser redLaser = redLaserTurret.getLaser();
+ if (redLaser != null) {
+ //laser�̏��𑗐M
+ printwriter.println("");
+ } else {
+ //laserTurret�̏��𑗐M
+ printwriter.println("");
+ }
+ printwriter.println("");
+ }
+
+
+ //mirror
+ Mirror redMirror = redTeam.getMyMirror(sId);
+ if(redMirror != null) {
+ //mirror�̏��𑗐M
+ printwriter.println("");
+ printwriter.println("");
+ }
+
+ //bomb
+ //printwriter.println("");
+ //printwriter.println("");
+
+ printwriter.println("");
+
+ printwriter.println("");
+
+ //laser blue�`�[��
+ LaserTurret blueLaserTurret = blueTeam.getLaserTurret();
+ //laser�̃N�[���^�C����ݒ�
+ String blueCool = "off";
+ if(blueTeam.getCoolTimeFlag() == true) {
+ blueCool = "on";
+ }
+ //�N�[���^�C���𑗐M
+ printwriter.println("");
+ if(blueLaserTurret != null) {
+ Laser blueLaser = blueLaserTurret.getLaser();
+ if(blueLaser != null) {
+ //laser�̏��𑗐M
+ printwriter.println("");
+ } else {
+ //laserTurret�̏��𑗐M
+ printwriter.println("");
+ }
+ printwriter.println("");
+ }
+
+ //mirror
+ Mirror blueMirror = blueTeam.getMyMirror(sId);
+ if(blueMirror != null) {
+ //mirror�̏��𑗐M
+ printwriter.println("");
+ printwriter.println("");
+ }
+
+ //bomb
+ //printwriter.println("");
+ //printwriter.println("");
+
+ printwriter.println("");
+
+ printwriter.println("
");
+// System.out.println("GameUpdateServlet : ");
+
+ printwriter.println("");
+ System.out.println("GameUpdateServlet : ");
+
+ }
+
+ // �Ԃ�����(�e�X�g�p)
+ public void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+
+ // ���L�����邱�Ƃɂ���Ă����炾���Ŏ����ł���
+ doPost(req, resp);
+
+ }
+
+
+}
diff --git a/src/servlet/LoginServlet.java b/src/servlet/LoginServlet.java
new file mode 100644
index 0000000..24ea7e5
--- /dev/null
+++ b/src/servlet/LoginServlet.java
@@ -0,0 +1,62 @@
+package servlet;
+
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import account.AccountManager;
+
+public class LoginServlet extends HttpServlet {
+
+ // ��镔�� ��req�Ŏ��@�@�@�@�@�@�@�@�@�@�@��resp�ŕԂ�
+ public void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+
+ // AccountManager���g�����߂ɐ錾���Ă��� �@���V���O���g���p�^�[���𗘗p���Ă��邽��
+ AccountManager accountmgr = AccountManager.getInstance();
+
+ //�Ԃ������̐錾 resp
+ PrintWriter printwriter = resp.getWriter();
+
+ /*******************************
+ * �p�����[�^����� req
+ *******************************/
+ String name = req.getParameter("name");
+ String pass = req.getParameter("pass");
+ String sId = req.getSession().getId();
+
+
+
+ /*******************************
+ * ���O�C������
+ *******************************/
+ if (accountmgr.login(name, pass, sId) == 0) {
+ printwriter.println("");
+ System.out.println("Login OK");
+ } else if (accountmgr.login(name, pass, sId) == 1) {
+ printwriter.println("");
+ System.out.println("Login PASS NG");
+ } else if (accountmgr.login(name, pass, sId) == 2){
+ printwriter.println("");
+ System.out.println("Login NAME NG");
+ }
+
+System.out.println("Login sId : " + sId);
+
+ printwriter.println("");
+
+ }
+
+ // �Ԃ�����(�e�X�g�p)
+ public void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+
+ // ���L�����邱�Ƃɂ���Ă����炾���Ŏ����ł���
+ doPost(req, resp);
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/servlet/RegistServlet.java b/src/servlet/RegistServlet.java
new file mode 100644
index 0000000..9260ef8
--- /dev/null
+++ b/src/servlet/RegistServlet.java
@@ -0,0 +1,63 @@
+package servlet;
+
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import account.AccountManager;
+
+public class RegistServlet extends HttpServlet {
+
+ // ��镔�� ��req�Ŏ��@�@�@�@�@�@�@�@�@�@�@��resp�ŕԂ�
+ public void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+
+long start = System.currentTimeMillis();
+
+ // AccountManager���g�����߂ɐ錾���Ă��� �@���V���O���g���p�^�[���𗘗p���Ă��邽��
+ AccountManager accountmgr = AccountManager.getInstance();
+
+ //�Ԃ������̐錾 resp
+ PrintWriter printwriter = resp.getWriter();
+
+ /*******************************
+ * �p�����[�^����� req
+ *******************************/
+ String name = req.getParameter("name");
+ String pass = req.getParameter("pass");
+ String sId = req.getSession().getId();
+
+ /*******************************
+ * �A�J�E���g�o�^����
+ *******************************/
+ if (accountmgr.registration(name, pass, sId)) {
+ printwriter.println("");
+ System.out.println("Registration OK");
+ } else {
+ printwriter.println("");
+ System.out.println("Registration NG");
+ }
+
+ printwriter.println("");
+
+System.out.println("Registration sId : " + sId);
+
+
+long end = System.currentTimeMillis();
+System.out.println("RegistrationServlet : " + (end - start) + "ms");
+
+ }
+
+ // �Ԃ�����(�e�X�g�p)
+ public void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+
+ // ���L�����邱�Ƃɂ���Ă����炾���Ŏ��s�ł���
+ doPost(req, resp);
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/servlet/RoomCreateServlet.java b/src/servlet/RoomCreateServlet.java
new file mode 100644
index 0000000..41a7a90
--- /dev/null
+++ b/src/servlet/RoomCreateServlet.java
@@ -0,0 +1,57 @@
+package servlet;
+
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServlet;
+
+import room.RoomManager;
+
+public class RoomCreateServlet extends HttpServlet {
+
+ // ��镔�� ��req�Ŏ��@�@�@�@�@�@�@�@�@�@�@��resp�ŕԂ�
+ public void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+
+ // RoomManager���g�����߂ɐ錾���Ă��� �@���V���O���g���p�^�[���𗘗p���Ă��邽��
+ RoomManager roommgr = RoomManager.getInstance();
+
+ // �Ԃ������̐錾 ���Ԃ�����resp
+ PrintWriter printwriter = resp.getWriter();
+
+ /*******************************
+ * �p�����[�^����� req
+ *******************************/
+ String name = req.getParameter("name");
+ String mode = req.getParameter("mode");
+ String pass = req.getParameter("pass");
+ String sId = req.getSession().getId();
+
+ /*******************************
+ * �����̍쐬�ƁA�쐬�҂��ɒlj�
+ *******************************/
+ if(roommgr.createRoom(name, mode, pass, sId)) {
+ printwriter.println("");
+ System.out.println("-----RoomCreate OK-----");
+ System.out.println("name: " + name);
+ System.out.println("mode: " + mode);
+ System.out.println("pass: " + pass);
+ } else {
+ printwriter.println("");
+ System.out.println("RoomCreate NG");
+ }
+ printwriter.println("");
+
+ }
+
+ // �Ԃ�����(�e�X�g�p)
+ public void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+
+ // ���L�����邱�Ƃɂ���Ă����炾���Ŏ����ł���
+ doPost(req, resp);
+
+ }
+}
\ No newline at end of file
diff --git a/src/servlet/RoomListServlet.java b/src/servlet/RoomListServlet.java
new file mode 100644
index 0000000..0d25267
--- /dev/null
+++ b/src/servlet/RoomListServlet.java
@@ -0,0 +1,102 @@
+package servlet;
+
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import account.Account;
+import account.AccountManager;
+import room.Room;
+import room.RoomManager;
+
+public class RoomListServlet extends HttpServlet{
+
+ // ��镔�� ��req�Ŏ��@�@�@�@�@�@�@�@�@�@�@��resp�ŕԂ�
+ public void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+
+ //RoomManager���g�����߁A�錾���Ă���
+ RoomManager roommgr = RoomManager.getInstance();
+
+ // AccountManager���g�����߁A�錾���Ă��� �@���V���O���g���p�^�[���𗘗p���Ă��邽��
+ AccountManager accountmgr = AccountManager.getInstance();
+
+ // �Ԃ������̐錾 ���Ԃ�����resp
+ PrintWriter printwriter = resp.getWriter();
+
+ /*******************************
+ * �p�����[�^����� req
+ *******************************/
+ String state = req.getParameter("state");
+ String sId = req.getSession().getId();
+
+//System.out.println(" ******************** RoomListServlet ******************** ");
+
+ /*******************************
+ * init||update �S���[�����X�g��Ԃ�
+ *******************************/
+ if(state.equals("init") || state.equals("update")) {
+
+//System.out.println("RoomList sId : " + sId);
+
+ printwriter.println("");
+ for(int i=0; i");
+ printwriter.println("");
+ }
+ printwriter.println("");
+ System.out.println("RoomList state = init");
+
+ /*******************************
+ * enter �������肨��у��[�U�̒lj�
+ *******************************/
+
+ } else if(state.equals("enter")) {
+
+ //roomid�����
+ String roomid = req.getParameter("id");
+
+ //id�̈�v����room��T��
+ Room room = roommgr.searchIdRoom(Integer.parseInt(roomid));
+
+ //�Y������room���������ꍇ
+ if(room != null) {
+ //�����̐l�����AMAX_MENBER�����̂Ƃ��A�����ɓ����ł���
+ if(room.getMemberCount() < Room.MAX_MEMBERS){
+ //��������
+ Account ac = accountmgr.getAccount(sId);
+ room.addMember(ac);
+ printwriter.println("");
+
+ //�����̐l����MAX_MEMBERS�̎��A�����ł��Ȃ�
+ } else {
+ printwriter.println("");
+ }
+ //id�̈�v���镔�����Ȃ������ꍇ
+ } else {
+ printwriter.println("");
+ }
+
+ printwriter.println("");
+ }
+ }
+
+ // �Ԃ�����(�e�X�g�p)
+ public void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+
+ // ���L�����邱�Ƃɂ���Ă����炾���Ŏ��s�ł���
+ doPost(req, resp);
+ }
+}
\ No newline at end of file
diff --git a/src/servlet/RoomServlet.java b/src/servlet/RoomServlet.java
new file mode 100644
index 0000000..73fe84d
--- /dev/null
+++ b/src/servlet/RoomServlet.java
@@ -0,0 +1,201 @@
+package servlet;
+
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import account.Account;
+import account.AccountManager;
+import framework.model3D.Position3D;
+import game.Game;
+import game.Stage;
+import room.Room;
+import room.RoomManager;
+
+public class RoomServlet extends HttpServlet {
+
+ public static final int TEAM_RED = 0;
+ public static final int TEAM_BLUE = 1;
+
+ // ��镔�� ��req�Ŏ��@�@�@�@�@�@�@�@�@�@�@��resp�ŕԂ�
+ public void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+
+ // RoomManager���g�����߂ɐ錾���Ă��� �@���V���O���g���p�^�[���𗘗p���Ă��邽��
+ RoomManager roommgr = RoomManager.getInstance();
+ AccountManager accountmgr = AccountManager.getInstance();
+
+ // �Ԃ������̐錾 ���Ԃ�����resp
+ PrintWriter printwriter = resp.getWriter();
+
+ /*******************************
+ * �p�����[�^����� req
+ *******************************/
+ String state = req.getParameter("state");
+ String sId = req.getSession().getId();
+ String clSelfWait = req.getParameter("wait");
+
+ /*******************************
+ * sId����A�J�E���g���擾
+ *******************************/
+ Account svSelf = accountmgr.getAccount(sId);
+
+ //�������擾
+ Room myRoom = svSelf.getRoom();
+
+ //�ŏI�ʐM���Ԃ��X�V
+ svSelf.setFinalConnectTime();
+
+ /*******************************
+ * enter / update�@�̏���
+ *******************************/
+ if((state.equals("enter")) || (state.equals("update"))) {
+
+if(state.equals("enter")) {
+ System.out.println(" : " + state);
+}
+ printwriter.println("");
+
+ //wait���قȂ鎞�A�X�V����
+ if(!clSelfWait.equals(svSelf.getWait())) {
+ svSelf.setWait(clSelfWait);
+ }
+
+ //Room���̐l�̍ŏI�ڑ����Ԋm�F
+ myRoom.removeNotConnectMember();
+
+ //Room���̃A�J�E���g�����擾
+ Account account = new Account();
+ for(int i=0; i");
+ printwriter.println("");
+
+if(state.equals("enter")) {
+ System.out.println("player" + i + " sId : " + account.getsId());
+ System.out.println(" wait : " + account.getWait());
+}
+ }
+
+ printwriter.println("");
+ }
+
+ /*******************************
+ * exit�@�̏���
+ *******************************/
+ else if(state.equals("exit")) {
+
+ //�������玩�����폜
+ myRoom.removeMember(svSelf);
+
+ //�����̐l����0�ɂȂ����ꍇ�������폜
+ if(myRoom.getMemberCount() == 0) {
+ roommgr.removeRoom(myRoom);
+ }
+ printwriter.println("");
+ printwriter.println("");
+
+ }
+
+ /*******************************
+ * divide�@�̏���
+ *******************************/
+ else if(state.equals("divide")){
+
+System.out.println("state : divide");
+
+ if(myRoom.getDivideFlag() == 0) {
+ myRoom.setDivideFlag(1);
+ myRoom.divideTeam();
+ myRoom.setDivideFlag(2);
+ }
+
+ //���̃N���C�A���g���`�[�������������̏ꍇ�Ang�𑗐M����
+ if(myRoom.getDivideFlag() != 2) {
+ printwriter.println("");
+ printwriter.println("");
+ }
+
+ //�`�[�������������Ă����ꍇ�@�`�[���������]��
+ if(myRoom.getDivideFlag() == 2) {
+ Game game = new Game();
+ game = myRoom.getGame();
+
+ int myTeam = 0;
+ int myNum = 0;
+
+ printwriter.println("");
+
+ //�ԃ`�[���̏���]��
+ printwriter.println("");
+
+System.out.println("+++++++ teamRed +++++++");
+ for(int i=0; i");
+
+ printwriter.println("");
+
+ //���������݂���Ƃ��@myTeam=0,myNum=0~2
+ if(getsId.equals(sId)){
+ myTeam = 0;
+ myNum = i;
+ }
+
+ }
+
+ printwriter.println("");
+
+ //�`�[���̏���]��
+ printwriter.println("");
+
+System.out.println("+++++++ teamBlue +++++++");
+ for(int i=0; i");
+
+ printwriter.println("");
+
+ //���������݂���Ƃ��@myTeam=1,myNum=0~2
+ if(getsId.equals(sId)){
+ myTeam = 1;
+ myNum = i;
+ }
+
+ }
+ printwriter.println("");
+
+ //�����̍��W��ݒ�
+ Stage stage = new Stage();
+ Position3D p = stage.getSpawnPoint(myTeam, myNum);
+System.out.println("point x=" + p.getX() + " y=" + p.getY() + " z=" + p.getZ());
+ printwriter.println("");
+ printwriter.println("");
+
+ }
+ }
+ }
+
+ // �Ԃ�����(�e�X�g�p)
+ public void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, java.io.IOException {
+
+ // ���L�����邱�Ƃɂ���Ă����炾���Ŏ����ł���
+ doPost(req, resp);
+
+ }
+}
\ No newline at end of file
diff --git a/src/vecmath/CVS/Entries b/src/vecmath/CVS/Entries
new file mode 100644
index 0000000..dd31cfe
--- /dev/null
+++ b/src/vecmath/CVS/Entries
@@ -0,0 +1,7 @@
+/Matrix3d.java/1.1/Thu Jul 7 08:22:45 2016//
+/SingularMatrixException.java/1.1/Thu Jul 7 08:22:45 2016//
+/Tuple3d.java/1.1/Thu Jul 7 08:22:45 2016//
+/Tuple4d.java/1.1/Thu Jul 7 08:22:45 2016//
+/VecMathI18N.java/1.1/Thu Jul 7 08:22:45 2016//
+/Vector3d.java/1.1/Thu Jul 7 08:22:45 2016//
+/Vector4d.java/1.1/Thu Jul 7 08:22:45 2016//
diff --git a/src/vecmath/CVS/Repository b/src/vecmath/CVS/Repository
new file mode 100644
index 0000000..789fc2c
--- /dev/null
+++ b/src/vecmath/CVS/Repository
@@ -0,0 +1 @@
+CarrotServer/src/vecmath
diff --git a/src/vecmath/CVS/Root b/src/vecmath/CVS/Root
new file mode 100644
index 0000000..c36e9d0
--- /dev/null
+++ b/src/vecmath/CVS/Root
@@ -0,0 +1 @@
+:pserver:guest@nitta-lab-www.is.konan-u.ac.jp:\CVSProject
diff --git a/src/vecmath/Matrix3d.java b/src/vecmath/Matrix3d.java
new file mode 100644
index 0000000..e0cd723
--- /dev/null
+++ b/src/vecmath/Matrix3d.java
@@ -0,0 +1,2404 @@
+// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
+// Jad home page: http://www.kpdus.com/jad.html
+// Decompiler options: packimports(3)
+// Source File Name: Matrix3d.java
+
+package vecmath;
+import java.io.PrintStream;
+import java.io.Serializable;
+
+// Referenced classes of package javax.vecmath:
+// SingularMatrixException, Matrix3f, VecMathI18N, Vector3d,
+// Quat4d, AxisAngle4d, Quat4f, AxisAngle4f,
+// Tuple3d
+
+public class Matrix3d
+ implements Serializable, Cloneable
+{
+
+ public Matrix3d(double d, double d1, double d2, double d3, double d4, double d5, double d6,
+ double d7, double d8)
+ {
+ m00 = d;
+ m01 = d1;
+ m02 = d2;
+ m10 = d3;
+ m11 = d4;
+ m12 = d5;
+ m20 = d6;
+ m21 = d7;
+ m22 = d8;
+ }
+
+ public Matrix3d(double ad[])
+ {
+ m00 = ad[0];
+ m01 = ad[1];
+ m02 = ad[2];
+ m10 = ad[3];
+ m11 = ad[4];
+ m12 = ad[5];
+ m20 = ad[6];
+ m21 = ad[7];
+ m22 = ad[8];
+ }
+
+ public Matrix3d(Matrix3d matrix3d)
+ {
+ m00 = matrix3d.m00;
+ m01 = matrix3d.m01;
+ m02 = matrix3d.m02;
+ m10 = matrix3d.m10;
+ m11 = matrix3d.m11;
+ m12 = matrix3d.m12;
+ m20 = matrix3d.m20;
+ m21 = matrix3d.m21;
+ m22 = matrix3d.m22;
+ }
+/*
+ public Matrix3d(Matrix3f matrix3f)
+ {
+ m00 = matrix3f.m00;
+ m01 = matrix3f.m01;
+ m02 = matrix3f.m02;
+ m10 = matrix3f.m10;
+ m11 = matrix3f.m11;
+ m12 = matrix3f.m12;
+ m20 = matrix3f.m20;
+ m21 = matrix3f.m21;
+ m22 = matrix3f.m22;
+ }
+*/
+ public Matrix3d()
+ {
+ m00 = 0.0D;
+ m01 = 0.0D;
+ m02 = 0.0D;
+ m10 = 0.0D;
+ m11 = 0.0D;
+ m12 = 0.0D;
+ m20 = 0.0D;
+ m21 = 0.0D;
+ m22 = 0.0D;
+ }
+
+ public String toString()
+ {
+ return m00 + ", " + m01 + ", " + m02 + "\n" + m10 + ", " + m11 + ", " + m12 + "\n" + m20 + ", " + m21 + ", " + m22 + "\n";
+ }
+
+ public final void setIdentity()
+ {
+ m00 = 1.0D;
+ m01 = 0.0D;
+ m02 = 0.0D;
+ m10 = 0.0D;
+ m11 = 1.0D;
+ m12 = 0.0D;
+ m20 = 0.0D;
+ m21 = 0.0D;
+ m22 = 1.0D;
+ }
+
+ public final void setScale(double d)
+ {
+ double ad[] = new double[9];
+ double ad1[] = new double[3];
+ getScaleRotate(ad1, ad);
+ m00 = ad[0] * d;
+ m01 = ad[1] * d;
+ m02 = ad[2] * d;
+ m10 = ad[3] * d;
+ m11 = ad[4] * d;
+ m12 = ad[5] * d;
+ m20 = ad[6] * d;
+ m21 = ad[7] * d;
+ m22 = ad[8] * d;
+ }
+
+ public final void setElement(int i, int j, double d)
+ {
+ switch(i)
+ {
+ case 0: // '\0'
+ switch(j)
+ {
+ case 0: // '\0'
+ m00 = d;
+ break;
+
+ case 1: // '\001'
+ m01 = d;
+ break;
+
+ case 2: // '\002'
+ m02 = d;
+ break;
+
+ default:
+ throw new ArrayIndexOutOfBoundsException(VecMathI18N.getString("Matrix3d0"));
+ }
+ break;
+
+ case 1: // '\001'
+ switch(j)
+ {
+ case 0: // '\0'
+ m10 = d;
+ break;
+
+ case 1: // '\001'
+ m11 = d;
+ break;
+
+ case 2: // '\002'
+ m12 = d;
+ break;
+
+ default:
+ throw new ArrayIndexOutOfBoundsException(VecMathI18N.getString("Matrix3d0"));
+ }
+ break;
+
+ case 2: // '\002'
+ switch(j)
+ {
+ case 0: // '\0'
+ m20 = d;
+ break;
+
+ case 1: // '\001'
+ m21 = d;
+ break;
+
+ case 2: // '\002'
+ m22 = d;
+ break;
+
+ default:
+ throw new ArrayIndexOutOfBoundsException(VecMathI18N.getString("Matrix3d0"));
+ }
+ break;
+
+ default:
+ throw new ArrayIndexOutOfBoundsException(VecMathI18N.getString("Matrix3d0"));
+ }
+ }
+
+ public final double getElement(int i, int j)
+ {
+ switch(i)
+ {
+ default:
+ break;
+
+ case 0: // '\0'
+ switch(j)
+ {
+ case 0: // '\0'
+ return m00;
+
+ case 1: // '\001'
+ return m01;
+
+ case 2: // '\002'
+ return m02;
+ }
+ break;
+
+ case 1: // '\001'
+ switch(j)
+ {
+ case 0: // '\0'
+ return m10;
+
+ case 1: // '\001'
+ return m11;
+
+ case 2: // '\002'
+ return m12;
+ }
+ break;
+
+ case 2: // '\002'
+ switch(j)
+ {
+ case 0: // '\0'
+ return m20;
+
+ case 1: // '\001'
+ return m21;
+
+ case 2: // '\002'
+ return m22;
+ }
+ break;
+ }
+ throw new ArrayIndexOutOfBoundsException(VecMathI18N.getString("Matrix3d1"));
+ }
+
+ public final void getRow(int i, Vector3d vector3d)
+ {
+ if(i == 0)
+ {
+ vector3d.x = m00;
+ vector3d.y = m01;
+ vector3d.z = m02;
+ } else
+ if(i == 1)
+ {
+ vector3d.x = m10;
+ vector3d.y = m11;
+ vector3d.z = m12;
+ } else
+ if(i == 2)
+ {
+ vector3d.x = m20;
+ vector3d.y = m21;
+ vector3d.z = m22;
+ } else
+ {
+ throw new ArrayIndexOutOfBoundsException(VecMathI18N.getString("Matrix3d2"));
+ }
+ }
+
+ public final void getRow(int i, double ad[])
+ {
+ if(i == 0)
+ {
+ ad[0] = m00;
+ ad[1] = m01;
+ ad[2] = m02;
+ } else
+ if(i == 1)
+ {
+ ad[0] = m10;
+ ad[1] = m11;
+ ad[2] = m12;
+ } else
+ if(i == 2)
+ {
+ ad[0] = m20;
+ ad[1] = m21;
+ ad[2] = m22;
+ } else
+ {
+ throw new ArrayIndexOutOfBoundsException(VecMathI18N.getString("Matrix3d2"));
+ }
+ }
+
+ public final void getColumn(int i, Vector3d vector3d)
+ {
+ if(i == 0)
+ {
+ vector3d.x = m00;
+ vector3d.y = m10;
+ vector3d.z = m20;
+ } else
+ if(i == 1)
+ {
+ vector3d.x = m01;
+ vector3d.y = m11;
+ vector3d.z = m21;
+ } else
+ if(i == 2)
+ {
+ vector3d.x = m02;
+ vector3d.y = m12;
+ vector3d.z = m22;
+ } else
+ {
+ throw new ArrayIndexOutOfBoundsException(VecMathI18N.getString("Matrix3d4"));
+ }
+ }
+
+ public final void getColumn(int i, double ad[])
+ {
+ if(i == 0)
+ {
+ ad[0] = m00;
+ ad[1] = m10;
+ ad[2] = m20;
+ } else
+ if(i == 1)
+ {
+ ad[0] = m01;
+ ad[1] = m11;
+ ad[2] = m21;
+ } else
+ if(i == 2)
+ {
+ ad[0] = m02;
+ ad[1] = m12;
+ ad[2] = m22;
+ } else
+ {
+ throw new ArrayIndexOutOfBoundsException(VecMathI18N.getString("Matrix3d4"));
+ }
+ }
+
+ public final void setRow(int i, double d, double d1, double d2)
+ {
+ switch(i)
+ {
+ case 0: // '\0'
+ m00 = d;
+ m01 = d1;
+ m02 = d2;
+ break;
+
+ case 1: // '\001'
+ m10 = d;
+ m11 = d1;
+ m12 = d2;
+ break;
+
+ case 2: // '\002'
+ m20 = d;
+ m21 = d1;
+ m22 = d2;
+ break;
+
+ default:
+ throw new ArrayIndexOutOfBoundsException(VecMathI18N.getString("Matrix3d6"));
+ }
+ }
+
+ public final void setRow(int i, Vector3d vector3d)
+ {
+ switch(i)
+ {
+ case 0: // '\0'
+ m00 = vector3d.x;
+ m01 = vector3d.y;
+ m02 = vector3d.z;
+ break;
+
+ case 1: // '\001'
+ m10 = vector3d.x;
+ m11 = vector3d.y;
+ m12 = vector3d.z;
+ break;
+
+ case 2: // '\002'
+ m20 = vector3d.x;
+ m21 = vector3d.y;
+ m22 = vector3d.z;
+ break;
+
+ default:
+ throw new ArrayIndexOutOfBoundsException(VecMathI18N.getString("Matrix3d6"));
+ }
+ }
+
+ public final void setRow(int i, double ad[])
+ {
+ switch(i)
+ {
+ case 0: // '\0'
+ m00 = ad[0];
+ m01 = ad[1];
+ m02 = ad[2];
+ break;
+
+ case 1: // '\001'
+ m10 = ad[0];
+ m11 = ad[1];
+ m12 = ad[2];
+ break;
+
+ case 2: // '\002'
+ m20 = ad[0];
+ m21 = ad[1];
+ m22 = ad[2];
+ break;
+
+ default:
+ throw new ArrayIndexOutOfBoundsException(VecMathI18N.getString("Matrix3d6"));
+ }
+ }
+
+ public final void setColumn(int i, double d, double d1, double d2)
+ {
+ switch(i)
+ {
+ case 0: // '\0'
+ m00 = d;
+ m10 = d1;
+ m20 = d2;
+ break;
+
+ case 1: // '\001'
+ m01 = d;
+ m11 = d1;
+ m21 = d2;
+ break;
+
+ case 2: // '\002'
+ m02 = d;
+ m12 = d1;
+ m22 = d2;
+ break;
+
+ default:
+ throw new ArrayIndexOutOfBoundsException(VecMathI18N.getString("Matrix3d9"));
+ }
+ }
+
+ public final void setColumn(int i, Vector3d vector3d)
+ {
+ switch(i)
+ {
+ case 0: // '\0'
+ m00 = vector3d.x;
+ m10 = vector3d.y;
+ m20 = vector3d.z;
+ break;
+
+ case 1: // '\001'
+ m01 = vector3d.x;
+ m11 = vector3d.y;
+ m21 = vector3d.z;
+ break;
+
+ case 2: // '\002'
+ m02 = vector3d.x;
+ m12 = vector3d.y;
+ m22 = vector3d.z;
+ break;
+
+ default:
+ throw new ArrayIndexOutOfBoundsException(VecMathI18N.getString("Matrix3d9"));
+ }
+ }
+
+ public final void setColumn(int i, double ad[])
+ {
+ switch(i)
+ {
+ case 0: // '\0'
+ m00 = ad[0];
+ m10 = ad[1];
+ m20 = ad[2];
+ break;
+
+ case 1: // '\001'
+ m01 = ad[0];
+ m11 = ad[1];
+ m21 = ad[2];
+ break;
+
+ case 2: // '\002'
+ m02 = ad[0];
+ m12 = ad[1];
+ m22 = ad[2];
+ break;
+
+ default:
+ throw new ArrayIndexOutOfBoundsException(VecMathI18N.getString("Matrix3d9"));
+ }
+ }
+
+ public final double getScale()
+ {
+ double ad[] = new double[3];
+ double ad1[] = new double[9];
+ getScaleRotate(ad, ad1);
+ return max3(ad);
+ }
+
+ public final void add(double d)
+ {
+ m00 += d;
+ m01 += d;
+ m02 += d;
+ m10 += d;
+ m11 += d;
+ m12 += d;
+ m20 += d;
+ m21 += d;
+ m22 += d;
+ }
+
+ public final void add(double d, Matrix3d matrix3d)
+ {
+ m00 = matrix3d.m00 + d;
+ m01 = matrix3d.m01 + d;
+ m02 = matrix3d.m02 + d;
+ m10 = matrix3d.m10 + d;
+ m11 = matrix3d.m11 + d;
+ m12 = matrix3d.m12 + d;
+ m20 = matrix3d.m20 + d;
+ m21 = matrix3d.m21 + d;
+ m22 = matrix3d.m22 + d;
+ }
+
+ public final void add(Matrix3d matrix3d, Matrix3d matrix3d1)
+ {
+ m00 = matrix3d.m00 + matrix3d1.m00;
+ m01 = matrix3d.m01 + matrix3d1.m01;
+ m02 = matrix3d.m02 + matrix3d1.m02;
+ m10 = matrix3d.m10 + matrix3d1.m10;
+ m11 = matrix3d.m11 + matrix3d1.m11;
+ m12 = matrix3d.m12 + matrix3d1.m12;
+ m20 = matrix3d.m20 + matrix3d1.m20;
+ m21 = matrix3d.m21 + matrix3d1.m21;
+ m22 = matrix3d.m22 + matrix3d1.m22;
+ }
+
+ public final void add(Matrix3d matrix3d)
+ {
+ m00 += matrix3d.m00;
+ m01 += matrix3d.m01;
+ m02 += matrix3d.m02;
+ m10 += matrix3d.m10;
+ m11 += matrix3d.m11;
+ m12 += matrix3d.m12;
+ m20 += matrix3d.m20;
+ m21 += matrix3d.m21;
+ m22 += matrix3d.m22;
+ }
+
+ public final void sub(Matrix3d matrix3d, Matrix3d matrix3d1)
+ {
+ m00 = matrix3d.m00 - matrix3d1.m00;
+ m01 = matrix3d.m01 - matrix3d1.m01;
+ m02 = matrix3d.m02 - matrix3d1.m02;
+ m10 = matrix3d.m10 - matrix3d1.m10;
+ m11 = matrix3d.m11 - matrix3d1.m11;
+ m12 = matrix3d.m12 - matrix3d1.m12;
+ m20 = matrix3d.m20 - matrix3d1.m20;
+ m21 = matrix3d.m21 - matrix3d1.m21;
+ m22 = matrix3d.m22 - matrix3d1.m22;
+ }
+
+ public final void sub(Matrix3d matrix3d)
+ {
+ m00 -= matrix3d.m00;
+ m01 -= matrix3d.m01;
+ m02 -= matrix3d.m02;
+ m10 -= matrix3d.m10;
+ m11 -= matrix3d.m11;
+ m12 -= matrix3d.m12;
+ m20 -= matrix3d.m20;
+ m21 -= matrix3d.m21;
+ m22 -= matrix3d.m22;
+ }
+
+ public final void transpose()
+ {
+ double d = m10;
+ m10 = m01;
+ m01 = d;
+ d = m20;
+ m20 = m02;
+ m02 = d;
+ d = m21;
+ m21 = m12;
+ m12 = d;
+ }
+
+ public final void transpose(Matrix3d matrix3d)
+ {
+ if(this != matrix3d)
+ {
+ m00 = matrix3d.m00;
+ m01 = matrix3d.m10;
+ m02 = matrix3d.m20;
+ m10 = matrix3d.m01;
+ m11 = matrix3d.m11;
+ m12 = matrix3d.m21;
+ m20 = matrix3d.m02;
+ m21 = matrix3d.m12;
+ m22 = matrix3d.m22;
+ } else
+ {
+ transpose();
+ }
+ }
+/*
+ public final void set(Quat4d quat4d)
+ {
+ m00 = 1.0D - 2D * quat4d.y * quat4d.y - 2D * quat4d.z * quat4d.z;
+ m10 = 2D * (quat4d.x * quat4d.y + quat4d.w * quat4d.z);
+ m20 = 2D * (quat4d.x * quat4d.z - quat4d.w * quat4d.y);
+ m01 = 2D * (quat4d.x * quat4d.y - quat4d.w * quat4d.z);
+ m11 = 1.0D - 2D * quat4d.x * quat4d.x - 2D * quat4d.z * quat4d.z;
+ m21 = 2D * (quat4d.y * quat4d.z + quat4d.w * quat4d.x);
+ m02 = 2D * (quat4d.x * quat4d.z + quat4d.w * quat4d.y);
+ m12 = 2D * (quat4d.y * quat4d.z - quat4d.w * quat4d.x);
+ m22 = 1.0D - 2D * quat4d.x * quat4d.x - 2D * quat4d.y * quat4d.y;
+ }
+*/
+// public final void set(AxisAngle4d axisangle4d)
+// {
+// double d = Math.sqrt(axisangle4d.x * axisangle4d.x + axisangle4d.y * axisangle4d.y + axisangle4d.z * axisangle4d.z);
+// if(d < 1.1102230240000001E-016D)
+// {
+// m00 = 1.0D;
+// m01 = 0.0D;
+// m02 = 0.0D;
+// m10 = 0.0D;
+// m11 = 1.0D;
+// m12 = 0.0D;
+// m20 = 0.0D;
+// m21 = 0.0D;
+// m22 = 1.0D;
+// } else
+// {
+// d = 1.0D / d;
+// double d1 = axisangle4d.x * d;
+// double d2 = axisangle4d.y * d;
+// double d3 = axisangle4d.z * d;
+// double d4 = Math.sin(axisangle4d.angle);
+// double d5 = Math.cos(axisangle4d.angle);
+// double d6 = 1.0D - d5;
+// double d7 = axisangle4d.x * axisangle4d.z;
+// double d8 = axisangle4d.x * axisangle4d.y;
+// double d9 = axisangle4d.y * axisangle4d.z;
+// m00 = d6 * d1 * d1 + d5;
+// m01 = d6 * d8 - d4 * d3;
+// m02 = d6 * d7 + d4 * d2;
+// m10 = d6 * d8 + d4 * d3;
+// m11 = d6 * d2 * d2 + d5;
+// m12 = d6 * d9 - d4 * d1;
+// m20 = d6 * d7 - d4 * d2;
+// m21 = d6 * d9 + d4 * d1;
+// m22 = d6 * d3 * d3 + d5;
+// }
+// }
+
+// public final void set(Quat4f quat4f)
+// {
+// m00 = 1.0D - 2D * (double)quat4f.y * (double)quat4f.y - 2D * (double)quat4f.z * (double)quat4f.z;
+// m10 = 2D * (double)(quat4f.x * quat4f.y + quat4f.w * quat4f.z);
+// m20 = 2D * (double)(quat4f.x * quat4f.z - quat4f.w * quat4f.y);
+// m01 = 2D * (double)(quat4f.x * quat4f.y - quat4f.w * quat4f.z);
+// m11 = 1.0D - 2D * (double)quat4f.x * (double)quat4f.x - 2D * (double)quat4f.z * (double)quat4f.z;
+// m21 = 2D * (double)(quat4f.y * quat4f.z + quat4f.w * quat4f.x);
+// m02 = 2D * (double)(quat4f.x * quat4f.z + quat4f.w * quat4f.y);
+// m12 = 2D * (double)(quat4f.y * quat4f.z - quat4f.w * quat4f.x);
+// m22 = 1.0D - 2D * (double)quat4f.x * (double)quat4f.x - 2D * (double)quat4f.y * (double)quat4f.y;
+// }
+
+// public final void set(AxisAngle4f axisangle4f)
+// {
+// double d = Math.sqrt(axisangle4f.x * axisangle4f.x + axisangle4f.y * axisangle4f.y + axisangle4f.z * axisangle4f.z);
+// if(d < 1.1102230240000001E-016D)
+// {
+// m00 = 1.0D;
+// m01 = 0.0D;
+// m02 = 0.0D;
+// m10 = 0.0D;
+// m11 = 1.0D;
+// m12 = 0.0D;
+// m20 = 0.0D;
+// m21 = 0.0D;
+// m22 = 1.0D;
+// } else
+// {
+// d = 1.0D / d;
+// double d1 = (double)axisangle4f.x * d;
+// double d2 = (double)axisangle4f.y * d;
+// double d3 = (double)axisangle4f.z * d;
+// double d4 = Math.sin(axisangle4f.angle);
+// double d5 = Math.cos(axisangle4f.angle);
+// double d6 = 1.0D - d5;
+// double d7 = d1 * d3;
+// double d8 = d1 * d2;
+// double d9 = d2 * d3;
+// m00 = d6 * d1 * d1 + d5;
+// m01 = d6 * d8 - d4 * d3;
+// m02 = d6 * d7 + d4 * d2;
+// m10 = d6 * d8 + d4 * d3;
+// m11 = d6 * d2 * d2 + d5;
+// m12 = d6 * d9 - d4 * d1;
+// m20 = d6 * d7 - d4 * d2;
+// m21 = d6 * d9 + d4 * d1;
+// m22 = d6 * d3 * d3 + d5;
+// }
+// }
+
+// public final void set(Matrix3f matrix3f)
+// {
+// m00 = matrix3f.m00;
+// m01 = matrix3f.m01;
+// m02 = matrix3f.m02;
+// m10 = matrix3f.m10;
+// m11 = matrix3f.m11;
+// m12 = matrix3f.m12;
+// m20 = matrix3f.m20;
+// m21 = matrix3f.m21;
+// m22 = matrix3f.m22;
+// }
+
+ public final void set(Matrix3d matrix3d)
+ {
+ m00 = matrix3d.m00;
+ m01 = matrix3d.m01;
+ m02 = matrix3d.m02;
+ m10 = matrix3d.m10;
+ m11 = matrix3d.m11;
+ m12 = matrix3d.m12;
+ m20 = matrix3d.m20;
+ m21 = matrix3d.m21;
+ m22 = matrix3d.m22;
+ }
+
+ public final void set(double ad[])
+ {
+ m00 = ad[0];
+ m01 = ad[1];
+ m02 = ad[2];
+ m10 = ad[3];
+ m11 = ad[4];
+ m12 = ad[5];
+ m20 = ad[6];
+ m21 = ad[7];
+ m22 = ad[8];
+ }
+
+// public final void invert(Matrix3d matrix3d)
+// {
+// invertGeneral(matrix3d);
+// }
+//
+ public final void invert()
+ {
+ invertGeneral(this);
+ }
+
+ private final void invertGeneral(Matrix3d matrix3d)
+ {
+ double ad[] = new double[9];
+ int ai[] = new int[3];
+ double ad1[] = new double[9];
+ ad1[0] = matrix3d.m00;
+ ad1[1] = matrix3d.m01;
+ ad1[2] = matrix3d.m02;
+ ad1[3] = matrix3d.m10;
+ ad1[4] = matrix3d.m11;
+ ad1[5] = matrix3d.m12;
+ ad1[6] = matrix3d.m20;
+ ad1[7] = matrix3d.m21;
+ ad1[8] = matrix3d.m22;
+ if(!luDecomposition(ad1, ai))
+ try {
+ throw new SingularMatrixException(VecMathI18N.getString("Matrix3d12"));
+ } catch (SingularMatrixException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ for(int i = 0; i < 9; i++)
+ ad[i] = 0.0D;
+
+ ad[0] = 1.0D;
+ ad[4] = 1.0D;
+ ad[8] = 1.0D;
+ luBacksubstitution(ad1, ai, ad);
+ m00 = ad[0];
+ m01 = ad[1];
+ m02 = ad[2];
+ m10 = ad[3];
+ m11 = ad[4];
+ m12 = ad[5];
+ m20 = ad[6];
+ m21 = ad[7];
+ m22 = ad[8];
+ }
+
+ static boolean luDecomposition(double ad[], int ai[])
+ {
+ double ad1[] = new double[3];
+ int i1 = 0;
+ int i2 = 0;
+ for(int i = 3; i-- != 0;)
+ {
+ double d = 0.0D;
+ for(int k = 3; k-- != 0;)
+ {
+ double d1 = ad[i1++];
+ d1 = Math.abs(d1);
+ if(d1 > d)
+ d = d1;
+ }
+
+ if(d == 0.0D)
+ return false;
+ ad1[i2++] = 1.0D / d;
+ }
+
+ int l = 0;
+ for(int j = 0; j < 3; j++)
+ {
+ for(int j1 = 0; j1 < j; j1++)
+ {
+ int j3 = l + 3 * j1 + j;
+ double d2 = ad[j3];
+ int k2 = j1;
+ int i4 = l + 3 * j1;
+ for(int l4 = l + j; k2-- != 0; l4 += 3)
+ {
+ d2 -= ad[i4] * ad[l4];
+ i4++;
+ }
+
+ ad[j3] = d2;
+ }
+
+ double d4 = 0.0D;
+ int j2 = -1;
+ for(int k1 = j; k1 < 3; k1++)
+ {
+ int k3 = l + 3 * k1 + j;
+ double d3 = ad[k3];
+ int l2 = j;
+ int j4 = l + 3 * k1;
+ for(int i5 = l + j; l2-- != 0; i5 += 3)
+ {
+ d3 -= ad[j4] * ad[i5];
+ j4++;
+ }
+
+ ad[k3] = d3;
+ double d5;
+ if((d5 = ad1[k1] * Math.abs(d3)) >= d4)
+ {
+ d4 = d5;
+ j2 = k1;
+ }
+ }
+
+ if(j2 < 0)
+ throw new RuntimeException(VecMathI18N.getString("Matrix3d13"));
+ if(j != j2)
+ {
+ int i3 = 3;
+ int k4 = l + 3 * j2;
+ int j5 = l + 3 * j;
+ while(i3-- != 0)
+ {
+ double d6 = ad[k4];
+ ad[k4++] = ad[j5];
+ ad[j5++] = d6;
+ }
+ ad1[j2] = ad1[j];
+ }
+ ai[j] = j2;
+ if(ad[l + 3 * j + j] == 0.0D)
+ return false;
+ if(j != 2)
+ {
+ double d7 = 1.0D / ad[l + 3 * j + j];
+ int l3 = l + 3 * (j + 1) + j;
+ for(int l1 = 2 - j; l1-- != 0;)
+ {
+ ad[l3] *= d7;
+ l3 += 3;
+ }
+
+ }
+ }
+
+ return true;
+ }
+
+ static void luBacksubstitution(double ad[], int ai[], double ad1[])
+ {
+ int j1 = 0;
+ for(int i1 = 0; i1 < 3; i1++)
+ {
+ int k1 = i1;
+ int j = -1;
+ for(int i = 0; i < 3; i++)
+ {
+ int k = ai[j1 + i];
+ double d = ad1[k1 + 3 * k];
+ ad1[k1 + 3 * k] = ad1[k1 + 3 * i];
+ if(j >= 0)
+ {
+ int l1 = i * 3;
+ for(int l = j; l <= i - 1; l++)
+ d -= ad[l1 + l] * ad1[k1 + 3 * l];
+
+ } else
+ if(d != 0.0D)
+ j = i;
+ ad1[k1 + 3 * i] = d;
+ }
+
+ int i2 = 6;
+ ad1[k1 + 6] /= ad[i2 + 2];
+ i2 -= 3;
+ ad1[k1 + 3] = (ad1[k1 + 3] - ad[i2 + 2] * ad1[k1 + 6]) / ad[i2 + 1];
+ i2 -= 3;
+ ad1[k1 + 0] = (ad1[k1 + 0] - ad[i2 + 1] * ad1[k1 + 3] - ad[i2 + 2] * ad1[k1 + 6]) / ad[i2 + 0];
+ }
+
+ }
+
+ public final double determinant()
+ {
+ double d = m00 * (m11 * m22 - m12 * m21) + m01 * (m12 * m20 - m10 * m22) + m02 * (m10 * m21 - m11 * m20);
+ return d;
+ }
+
+ public final void set(double d)
+ {
+ m00 = d;
+ m01 = 0.0D;
+ m02 = 0.0D;
+ m10 = 0.0D;
+ m11 = d;
+ m12 = 0.0D;
+ m20 = 0.0D;
+ m21 = 0.0D;
+ m22 = d;
+ }
+
+ public final void rotX(double d)
+ {
+ double d1 = Math.sin(d);
+ double d2 = Math.cos(d);
+ m00 = 1.0D;
+ m01 = 0.0D;
+ m02 = 0.0D;
+ m10 = 0.0D;
+ m11 = d2;
+ m12 = -d1;
+ m20 = 0.0D;
+ m21 = d1;
+ m22 = d2;
+ }
+
+ public final void rotY(double d)
+ {
+ double d1 = Math.sin(d);
+ double d2 = Math.cos(d);
+ m00 = d2;
+ m01 = 0.0D;
+ m02 = d1;
+ m10 = 0.0D;
+ m11 = 1.0D;
+ m12 = 0.0D;
+ m20 = -d1;
+ m21 = 0.0D;
+ m22 = d2;
+ }
+
+ public final void rotZ(double d)
+ {
+ double d1 = Math.sin(d);
+ double d2 = Math.cos(d);
+ m00 = d2;
+ m01 = -d1;
+ m02 = 0.0D;
+ m10 = d1;
+ m11 = d2;
+ m12 = 0.0D;
+ m20 = 0.0D;
+ m21 = 0.0D;
+ m22 = 1.0D;
+ }
+
+ public final void mul(double d)
+ {
+ m00 *= d;
+ m01 *= d;
+ m02 *= d;
+ m10 *= d;
+ m11 *= d;
+ m12 *= d;
+ m20 *= d;
+ m21 *= d;
+ m22 *= d;
+ }
+
+ public final void mul(double d, Matrix3d matrix3d)
+ {
+ m00 = d * matrix3d.m00;
+ m01 = d * matrix3d.m01;
+ m02 = d * matrix3d.m02;
+ m10 = d * matrix3d.m10;
+ m11 = d * matrix3d.m11;
+ m12 = d * matrix3d.m12;
+ m20 = d * matrix3d.m20;
+ m21 = d * matrix3d.m21;
+ m22 = d * matrix3d.m22;
+ }
+
+ public final void mul(Matrix3d matrix3d)
+ {
+ double d = m00 * matrix3d.m00 + m01 * matrix3d.m10 + m02 * matrix3d.m20;
+ double d1 = m00 * matrix3d.m01 + m01 * matrix3d.m11 + m02 * matrix3d.m21;
+ double d2 = m00 * matrix3d.m02 + m01 * matrix3d.m12 + m02 * matrix3d.m22;
+ double d3 = m10 * matrix3d.m00 + m11 * matrix3d.m10 + m12 * matrix3d.m20;
+ double d4 = m10 * matrix3d.m01 + m11 * matrix3d.m11 + m12 * matrix3d.m21;
+ double d5 = m10 * matrix3d.m02 + m11 * matrix3d.m12 + m12 * matrix3d.m22;
+ double d6 = m20 * matrix3d.m00 + m21 * matrix3d.m10 + m22 * matrix3d.m20;
+ double d7 = m20 * matrix3d.m01 + m21 * matrix3d.m11 + m22 * matrix3d.m21;
+ double d8 = m20 * matrix3d.m02 + m21 * matrix3d.m12 + m22 * matrix3d.m22;
+ m00 = d;
+ m01 = d1;
+ m02 = d2;
+ m10 = d3;
+ m11 = d4;
+ m12 = d5;
+ m20 = d6;
+ m21 = d7;
+ m22 = d8;
+ }
+
+ public final void mul(Matrix3d matrix3d, Matrix3d matrix3d1)
+ {
+ if(this != matrix3d && this != matrix3d1)
+ {
+ m00 = matrix3d.m00 * matrix3d1.m00 + matrix3d.m01 * matrix3d1.m10 + matrix3d.m02 * matrix3d1.m20;
+ m01 = matrix3d.m00 * matrix3d1.m01 + matrix3d.m01 * matrix3d1.m11 + matrix3d.m02 * matrix3d1.m21;
+ m02 = matrix3d.m00 * matrix3d1.m02 + matrix3d.m01 * matrix3d1.m12 + matrix3d.m02 * matrix3d1.m22;
+ m10 = matrix3d.m10 * matrix3d1.m00 + matrix3d.m11 * matrix3d1.m10 + matrix3d.m12 * matrix3d1.m20;
+ m11 = matrix3d.m10 * matrix3d1.m01 + matrix3d.m11 * matrix3d1.m11 + matrix3d.m12 * matrix3d1.m21;
+ m12 = matrix3d.m10 * matrix3d1.m02 + matrix3d.m11 * matrix3d1.m12 + matrix3d.m12 * matrix3d1.m22;
+ m20 = matrix3d.m20 * matrix3d1.m00 + matrix3d.m21 * matrix3d1.m10 + matrix3d.m22 * matrix3d1.m20;
+ m21 = matrix3d.m20 * matrix3d1.m01 + matrix3d.m21 * matrix3d1.m11 + matrix3d.m22 * matrix3d1.m21;
+ m22 = matrix3d.m20 * matrix3d1.m02 + matrix3d.m21 * matrix3d1.m12 + matrix3d.m22 * matrix3d1.m22;
+ } else
+ {
+ double d = matrix3d.m00 * matrix3d1.m00 + matrix3d.m01 * matrix3d1.m10 + matrix3d.m02 * matrix3d1.m20;
+ double d1 = matrix3d.m00 * matrix3d1.m01 + matrix3d.m01 * matrix3d1.m11 + matrix3d.m02 * matrix3d1.m21;
+ double d2 = matrix3d.m00 * matrix3d1.m02 + matrix3d.m01 * matrix3d1.m12 + matrix3d.m02 * matrix3d1.m22;
+ double d3 = matrix3d.m10 * matrix3d1.m00 + matrix3d.m11 * matrix3d1.m10 + matrix3d.m12 * matrix3d1.m20;
+ double d4 = matrix3d.m10 * matrix3d1.m01 + matrix3d.m11 * matrix3d1.m11 + matrix3d.m12 * matrix3d1.m21;
+ double d5 = matrix3d.m10 * matrix3d1.m02 + matrix3d.m11 * matrix3d1.m12 + matrix3d.m12 * matrix3d1.m22;
+ double d6 = matrix3d.m20 * matrix3d1.m00 + matrix3d.m21 * matrix3d1.m10 + matrix3d.m22 * matrix3d1.m20;
+ double d7 = matrix3d.m20 * matrix3d1.m01 + matrix3d.m21 * matrix3d1.m11 + matrix3d.m22 * matrix3d1.m21;
+ double d8 = matrix3d.m20 * matrix3d1.m02 + matrix3d.m21 * matrix3d1.m12 + matrix3d.m22 * matrix3d1.m22;
+ m00 = d;
+ m01 = d1;
+ m02 = d2;
+ m10 = d3;
+ m11 = d4;
+ m12 = d5;
+ m20 = d6;
+ m21 = d7;
+ m22 = d8;
+ }
+ }
+
+ public final void mulNormalize(Matrix3d matrix3d)
+ {
+ double ad[] = new double[9];
+ double ad1[] = new double[9];
+ double ad2[] = new double[3];
+ ad[0] = m00 * matrix3d.m00 + m01 * matrix3d.m10 + m02 * matrix3d.m20;
+ ad[1] = m00 * matrix3d.m01 + m01 * matrix3d.m11 + m02 * matrix3d.m21;
+ ad[2] = m00 * matrix3d.m02 + m01 * matrix3d.m12 + m02 * matrix3d.m22;
+ ad[3] = m10 * matrix3d.m00 + m11 * matrix3d.m10 + m12 * matrix3d.m20;
+ ad[4] = m10 * matrix3d.m01 + m11 * matrix3d.m11 + m12 * matrix3d.m21;
+ ad[5] = m10 * matrix3d.m02 + m11 * matrix3d.m12 + m12 * matrix3d.m22;
+ ad[6] = m20 * matrix3d.m00 + m21 * matrix3d.m10 + m22 * matrix3d.m20;
+ ad[7] = m20 * matrix3d.m01 + m21 * matrix3d.m11 + m22 * matrix3d.m21;
+ ad[8] = m20 * matrix3d.m02 + m21 * matrix3d.m12 + m22 * matrix3d.m22;
+ compute_svd(ad, ad2, ad1);
+ m00 = ad1[0];
+ m01 = ad1[1];
+ m02 = ad1[2];
+ m10 = ad1[3];
+ m11 = ad1[4];
+ m12 = ad1[5];
+ m20 = ad1[6];
+ m21 = ad1[7];
+ m22 = ad1[8];
+ }
+
+ public final void mulNormalize(Matrix3d matrix3d, Matrix3d matrix3d1)
+ {
+ double ad[] = new double[9];
+ double ad1[] = new double[9];
+ double ad2[] = new double[3];
+ ad[0] = matrix3d.m00 * matrix3d1.m00 + matrix3d.m01 * matrix3d1.m10 + matrix3d.m02 * matrix3d1.m20;
+ ad[1] = matrix3d.m00 * matrix3d1.m01 + matrix3d.m01 * matrix3d1.m11 + matrix3d.m02 * matrix3d1.m21;
+ ad[2] = matrix3d.m00 * matrix3d1.m02 + matrix3d.m01 * matrix3d1.m12 + matrix3d.m02 * matrix3d1.m22;
+ ad[3] = matrix3d.m10 * matrix3d1.m00 + matrix3d.m11 * matrix3d1.m10 + matrix3d.m12 * matrix3d1.m20;
+ ad[4] = matrix3d.m10 * matrix3d1.m01 + matrix3d.m11 * matrix3d1.m11 + matrix3d.m12 * matrix3d1.m21;
+ ad[5] = matrix3d.m10 * matrix3d1.m02 + matrix3d.m11 * matrix3d1.m12 + matrix3d.m12 * matrix3d1.m22;
+ ad[6] = matrix3d.m20 * matrix3d1.m00 + matrix3d.m21 * matrix3d1.m10 + matrix3d.m22 * matrix3d1.m20;
+ ad[7] = matrix3d.m20 * matrix3d1.m01 + matrix3d.m21 * matrix3d1.m11 + matrix3d.m22 * matrix3d1.m21;
+ ad[8] = matrix3d.m20 * matrix3d1.m02 + matrix3d.m21 * matrix3d1.m12 + matrix3d.m22 * matrix3d1.m22;
+ compute_svd(ad, ad2, ad1);
+ m00 = ad1[0];
+ m01 = ad1[1];
+ m02 = ad1[2];
+ m10 = ad1[3];
+ m11 = ad1[4];
+ m12 = ad1[5];
+ m20 = ad1[6];
+ m21 = ad1[7];
+ m22 = ad1[8];
+ }
+
+ public final void mulTransposeBoth(Matrix3d matrix3d, Matrix3d matrix3d1)
+ {
+ if(this != matrix3d && this != matrix3d1)
+ {
+ m00 = matrix3d.m00 * matrix3d1.m00 + matrix3d.m10 * matrix3d1.m01 + matrix3d.m20 * matrix3d1.m02;
+ m01 = matrix3d.m00 * matrix3d1.m10 + matrix3d.m10 * matrix3d1.m11 + matrix3d.m20 * matrix3d1.m12;
+ m02 = matrix3d.m00 * matrix3d1.m20 + matrix3d.m10 * matrix3d1.m21 + matrix3d.m20 * matrix3d1.m22;
+ m10 = matrix3d.m01 * matrix3d1.m00 + matrix3d.m11 * matrix3d1.m01 + matrix3d.m21 * matrix3d1.m02;
+ m11 = matrix3d.m01 * matrix3d1.m10 + matrix3d.m11 * matrix3d1.m11 + matrix3d.m21 * matrix3d1.m12;
+ m12 = matrix3d.m01 * matrix3d1.m20 + matrix3d.m11 * matrix3d1.m21 + matrix3d.m21 * matrix3d1.m22;
+ m20 = matrix3d.m02 * matrix3d1.m00 + matrix3d.m12 * matrix3d1.m01 + matrix3d.m22 * matrix3d1.m02;
+ m21 = matrix3d.m02 * matrix3d1.m10 + matrix3d.m12 * matrix3d1.m11 + matrix3d.m22 * matrix3d1.m12;
+ m22 = matrix3d.m02 * matrix3d1.m20 + matrix3d.m12 * matrix3d1.m21 + matrix3d.m22 * matrix3d1.m22;
+ } else
+ {
+ double d = matrix3d.m00 * matrix3d1.m00 + matrix3d.m10 * matrix3d1.m01 + matrix3d.m20 * matrix3d1.m02;
+ double d1 = matrix3d.m00 * matrix3d1.m10 + matrix3d.m10 * matrix3d1.m11 + matrix3d.m20 * matrix3d1.m12;
+ double d2 = matrix3d.m00 * matrix3d1.m20 + matrix3d.m10 * matrix3d1.m21 + matrix3d.m20 * matrix3d1.m22;
+ double d3 = matrix3d.m01 * matrix3d1.m00 + matrix3d.m11 * matrix3d1.m01 + matrix3d.m21 * matrix3d1.m02;
+ double d4 = matrix3d.m01 * matrix3d1.m10 + matrix3d.m11 * matrix3d1.m11 + matrix3d.m21 * matrix3d1.m12;
+ double d5 = matrix3d.m01 * matrix3d1.m20 + matrix3d.m11 * matrix3d1.m21 + matrix3d.m21 * matrix3d1.m22;
+ double d6 = matrix3d.m02 * matrix3d1.m00 + matrix3d.m12 * matrix3d1.m01 + matrix3d.m22 * matrix3d1.m02;
+ double d7 = matrix3d.m02 * matrix3d1.m10 + matrix3d.m12 * matrix3d1.m11 + matrix3d.m22 * matrix3d1.m12;
+ double d8 = matrix3d.m02 * matrix3d1.m20 + matrix3d.m12 * matrix3d1.m21 + matrix3d.m22 * matrix3d1.m22;
+ m00 = d;
+ m01 = d1;
+ m02 = d2;
+ m10 = d3;
+ m11 = d4;
+ m12 = d5;
+ m20 = d6;
+ m21 = d7;
+ m22 = d8;
+ }
+ }
+
+ public final void mulTransposeRight(Matrix3d matrix3d, Matrix3d matrix3d1)
+ {
+ if(this != matrix3d && this != matrix3d1)
+ {
+ m00 = matrix3d.m00 * matrix3d1.m00 + matrix3d.m01 * matrix3d1.m01 + matrix3d.m02 * matrix3d1.m02;
+ m01 = matrix3d.m00 * matrix3d1.m10 + matrix3d.m01 * matrix3d1.m11 + matrix3d.m02 * matrix3d1.m12;
+ m02 = matrix3d.m00 * matrix3d1.m20 + matrix3d.m01 * matrix3d1.m21 + matrix3d.m02 * matrix3d1.m22;
+ m10 = matrix3d.m10 * matrix3d1.m00 + matrix3d.m11 * matrix3d1.m01 + matrix3d.m12 * matrix3d1.m02;
+ m11 = matrix3d.m10 * matrix3d1.m10 + matrix3d.m11 * matrix3d1.m11 + matrix3d.m12 * matrix3d1.m12;
+ m12 = matrix3d.m10 * matrix3d1.m20 + matrix3d.m11 * matrix3d1.m21 + matrix3d.m12 * matrix3d1.m22;
+ m20 = matrix3d.m20 * matrix3d1.m00 + matrix3d.m21 * matrix3d1.m01 + matrix3d.m22 * matrix3d1.m02;
+ m21 = matrix3d.m20 * matrix3d1.m10 + matrix3d.m21 * matrix3d1.m11 + matrix3d.m22 * matrix3d1.m12;
+ m22 = matrix3d.m20 * matrix3d1.m20 + matrix3d.m21 * matrix3d1.m21 + matrix3d.m22 * matrix3d1.m22;
+ } else
+ {
+ double d = matrix3d.m00 * matrix3d1.m00 + matrix3d.m01 * matrix3d1.m01 + matrix3d.m02 * matrix3d1.m02;
+ double d1 = matrix3d.m00 * matrix3d1.m10 + matrix3d.m01 * matrix3d1.m11 + matrix3d.m02 * matrix3d1.m12;
+ double d2 = matrix3d.m00 * matrix3d1.m20 + matrix3d.m01 * matrix3d1.m21 + matrix3d.m02 * matrix3d1.m22;
+ double d3 = matrix3d.m10 * matrix3d1.m00 + matrix3d.m11 * matrix3d1.m01 + matrix3d.m12 * matrix3d1.m02;
+ double d4 = matrix3d.m10 * matrix3d1.m10 + matrix3d.m11 * matrix3d1.m11 + matrix3d.m12 * matrix3d1.m12;
+ double d5 = matrix3d.m10 * matrix3d1.m20 + matrix3d.m11 * matrix3d1.m21 + matrix3d.m12 * matrix3d1.m22;
+ double d6 = matrix3d.m20 * matrix3d1.m00 + matrix3d.m21 * matrix3d1.m01 + matrix3d.m22 * matrix3d1.m02;
+ double d7 = matrix3d.m20 * matrix3d1.m10 + matrix3d.m21 * matrix3d1.m11 + matrix3d.m22 * matrix3d1.m12;
+ double d8 = matrix3d.m20 * matrix3d1.m20 + matrix3d.m21 * matrix3d1.m21 + matrix3d.m22 * matrix3d1.m22;
+ m00 = d;
+ m01 = d1;
+ m02 = d2;
+ m10 = d3;
+ m11 = d4;
+ m12 = d5;
+ m20 = d6;
+ m21 = d7;
+ m22 = d8;
+ }
+ }
+
+ public final void mulTransposeLeft(Matrix3d matrix3d, Matrix3d matrix3d1)
+ {
+ if(this != matrix3d && this != matrix3d1)
+ {
+ m00 = matrix3d.m00 * matrix3d1.m00 + matrix3d.m10 * matrix3d1.m10 + matrix3d.m20 * matrix3d1.m20;
+ m01 = matrix3d.m00 * matrix3d1.m01 + matrix3d.m10 * matrix3d1.m11 + matrix3d.m20 * matrix3d1.m21;
+ m02 = matrix3d.m00 * matrix3d1.m02 + matrix3d.m10 * matrix3d1.m12 + matrix3d.m20 * matrix3d1.m22;
+ m10 = matrix3d.m01 * matrix3d1.m00 + matrix3d.m11 * matrix3d1.m10 + matrix3d.m21 * matrix3d1.m20;
+ m11 = matrix3d.m01 * matrix3d1.m01 + matrix3d.m11 * matrix3d1.m11 + matrix3d.m21 * matrix3d1.m21;
+ m12 = matrix3d.m01 * matrix3d1.m02 + matrix3d.m11 * matrix3d1.m12 + matrix3d.m21 * matrix3d1.m22;
+ m20 = matrix3d.m02 * matrix3d1.m00 + matrix3d.m12 * matrix3d1.m10 + matrix3d.m22 * matrix3d1.m20;
+ m21 = matrix3d.m02 * matrix3d1.m01 + matrix3d.m12 * matrix3d1.m11 + matrix3d.m22 * matrix3d1.m21;
+ m22 = matrix3d.m02 * matrix3d1.m02 + matrix3d.m12 * matrix3d1.m12 + matrix3d.m22 * matrix3d1.m22;
+ } else
+ {
+ double d = matrix3d.m00 * matrix3d1.m00 + matrix3d.m10 * matrix3d1.m10 + matrix3d.m20 * matrix3d1.m20;
+ double d1 = matrix3d.m00 * matrix3d1.m01 + matrix3d.m10 * matrix3d1.m11 + matrix3d.m20 * matrix3d1.m21;
+ double d2 = matrix3d.m00 * matrix3d1.m02 + matrix3d.m10 * matrix3d1.m12 + matrix3d.m20 * matrix3d1.m22;
+ double d3 = matrix3d.m01 * matrix3d1.m00 + matrix3d.m11 * matrix3d1.m10 + matrix3d.m21 * matrix3d1.m20;
+ double d4 = matrix3d.m01 * matrix3d1.m01 + matrix3d.m11 * matrix3d1.m11 + matrix3d.m21 * matrix3d1.m21;
+ double d5 = matrix3d.m01 * matrix3d1.m02 + matrix3d.m11 * matrix3d1.m12 + matrix3d.m21 * matrix3d1.m22;
+ double d6 = matrix3d.m02 * matrix3d1.m00 + matrix3d.m12 * matrix3d1.m10 + matrix3d.m22 * matrix3d1.m20;
+ double d7 = matrix3d.m02 * matrix3d1.m01 + matrix3d.m12 * matrix3d1.m11 + matrix3d.m22 * matrix3d1.m21;
+ double d8 = matrix3d.m02 * matrix3d1.m02 + matrix3d.m12 * matrix3d1.m12 + matrix3d.m22 * matrix3d1.m22;
+ m00 = d;
+ m01 = d1;
+ m02 = d2;
+ m10 = d3;
+ m11 = d4;
+ m12 = d5;
+ m20 = d6;
+ m21 = d7;
+ m22 = d8;
+ }
+ }
+
+ public final void normalize()
+ {
+ double ad[] = new double[9];
+ double ad1[] = new double[3];
+ getScaleRotate(ad1, ad);
+ m00 = ad[0];
+ m01 = ad[1];
+ m02 = ad[2];
+ m10 = ad[3];
+ m11 = ad[4];
+ m12 = ad[5];
+ m20 = ad[6];
+ m21 = ad[7];
+ m22 = ad[8];
+ }
+
+ public final void normalize(Matrix3d matrix3d)
+ {
+ double ad[] = new double[9];
+ double ad1[] = new double[9];
+ double ad2[] = new double[3];
+ ad[0] = matrix3d.m00;
+ ad[1] = matrix3d.m01;
+ ad[2] = matrix3d.m02;
+ ad[3] = matrix3d.m10;
+ ad[4] = matrix3d.m11;
+ ad[5] = matrix3d.m12;
+ ad[6] = matrix3d.m20;
+ ad[7] = matrix3d.m21;
+ ad[8] = matrix3d.m22;
+ compute_svd(ad, ad2, ad1);
+ m00 = ad1[0];
+ m01 = ad1[1];
+ m02 = ad1[2];
+ m10 = ad1[3];
+ m11 = ad1[4];
+ m12 = ad1[5];
+ m20 = ad1[6];
+ m21 = ad1[7];
+ m22 = ad1[8];
+ }
+
+ public final void normalizeCP()
+ {
+ double d = 1.0D / Math.sqrt(m00 * m00 + m10 * m10 + m20 * m20);
+ m00 = m00 * d;
+ m10 = m10 * d;
+ m20 = m20 * d;
+ d = 1.0D / Math.sqrt(m01 * m01 + m11 * m11 + m21 * m21);
+ m01 = m01 * d;
+ m11 = m11 * d;
+ m21 = m21 * d;
+ m02 = m10 * m21 - m11 * m20;
+ m12 = m01 * m20 - m00 * m21;
+ m22 = m00 * m11 - m01 * m10;
+ }
+
+ public final void normalizeCP(Matrix3d matrix3d)
+ {
+ double d = 1.0D / Math.sqrt(matrix3d.m00 * matrix3d.m00 + matrix3d.m10 * matrix3d.m10 + matrix3d.m20 * matrix3d.m20);
+ m00 = matrix3d.m00 * d;
+ m10 = matrix3d.m10 * d;
+ m20 = matrix3d.m20 * d;
+ d = 1.0D / Math.sqrt(matrix3d.m01 * matrix3d.m01 + matrix3d.m11 * matrix3d.m11 + matrix3d.m21 * matrix3d.m21);
+ m01 = matrix3d.m01 * d;
+ m11 = matrix3d.m11 * d;
+ m21 = matrix3d.m21 * d;
+ m02 = m10 * m21 - m11 * m20;
+ m12 = m01 * m20 - m00 * m21;
+ m22 = m00 * m11 - m01 * m10;
+ }
+
+ public boolean equals(Matrix3d matrix3d)
+ {
+ try
+ {
+ return m00 == matrix3d.m00 && m01 == matrix3d.m01 && m02 == matrix3d.m02 && m10 == matrix3d.m10 && m11 == matrix3d.m11 && m12 == matrix3d.m12 && m20 == matrix3d.m20 && m21 == matrix3d.m21 && m22 == matrix3d.m22;
+ }
+ catch(NullPointerException nullpointerexception)
+ {
+ return false;
+ }
+ }
+
+ public boolean equals(Object obj)
+ {
+ try
+ {
+ Matrix3d matrix3d = (Matrix3d)obj;
+ return m00 == matrix3d.m00 && m01 == matrix3d.m01 && m02 == matrix3d.m02 && m10 == matrix3d.m10 && m11 == matrix3d.m11 && m12 == matrix3d.m12 && m20 == matrix3d.m20 && m21 == matrix3d.m21 && m22 == matrix3d.m22;
+ }
+ catch(ClassCastException classcastexception)
+ {
+ return false;
+ }
+ catch(NullPointerException nullpointerexception)
+ {
+ return false;
+ }
+ }
+
+ public boolean epsilonEquals(Matrix3d matrix3d, double d)
+ {
+ double d1 = m00 - matrix3d.m00;
+ if((d1 >= 0.0D ? d1 : -d1) > d)
+ return false;
+ d1 = m01 - matrix3d.m01;
+ if((d1 >= 0.0D ? d1 : -d1) > d)
+ return false;
+ d1 = m02 - matrix3d.m02;
+ if((d1 >= 0.0D ? d1 : -d1) > d)
+ return false;
+ d1 = m10 - matrix3d.m10;
+ if((d1 >= 0.0D ? d1 : -d1) > d)
+ return false;
+ d1 = m11 - matrix3d.m11;
+ if((d1 >= 0.0D ? d1 : -d1) > d)
+ return false;
+ d1 = m12 - matrix3d.m12;
+ if((d1 >= 0.0D ? d1 : -d1) > d)
+ return false;
+ d1 = m20 - matrix3d.m20;
+ if((d1 >= 0.0D ? d1 : -d1) > d)
+ return false;
+ d1 = m21 - matrix3d.m21;
+ if((d1 >= 0.0D ? d1 : -d1) > d)
+ return false;
+ d1 = m22 - matrix3d.m22;
+ return (d1 >= 0.0D ? d1 : -d1) <= d;
+ }
+
+ public int hashCode()
+ {
+ long l = 1L;
+ l = 31L * l + Double.doubleToLongBits(m00);
+ l = 31L * l + Double.doubleToLongBits(m01);
+ l = 31L * l + Double.doubleToLongBits(m02);
+ l = 31L * l + Double.doubleToLongBits(m10);
+ l = 31L * l + Double.doubleToLongBits(m11);
+ l = 31L * l + Double.doubleToLongBits(m12);
+ l = 31L * l + Double.doubleToLongBits(m20);
+ l = 31L * l + Double.doubleToLongBits(m21);
+ l = 31L * l + Double.doubleToLongBits(m22);
+ return (int)(l ^ l >> 32);
+ }
+
+ public final void setZero()
+ {
+ m00 = 0.0D;
+ m01 = 0.0D;
+ m02 = 0.0D;
+ m10 = 0.0D;
+ m11 = 0.0D;
+ m12 = 0.0D;
+ m20 = 0.0D;
+ m21 = 0.0D;
+ m22 = 0.0D;
+ }
+
+ public final void negate()
+ {
+ m00 = -m00;
+ m01 = -m01;
+ m02 = -m02;
+ m10 = -m10;
+ m11 = -m11;
+ m12 = -m12;
+ m20 = -m20;
+ m21 = -m21;
+ m22 = -m22;
+ }
+
+ public final void negate(Matrix3d matrix3d)
+ {
+ m00 = -matrix3d.m00;
+ m01 = -matrix3d.m01;
+ m02 = -matrix3d.m02;
+ m10 = -matrix3d.m10;
+ m11 = -matrix3d.m11;
+ m12 = -matrix3d.m12;
+ m20 = -matrix3d.m20;
+ m21 = -matrix3d.m21;
+ m22 = -matrix3d.m22;
+ }
+
+ public final void transform(Tuple3d tuple3d)
+ {
+ double d = m00 * tuple3d.x + m01 * tuple3d.y + m02 * tuple3d.z;
+ double d1 = m10 * tuple3d.x + m11 * tuple3d.y + m12 * tuple3d.z;
+ double d2 = m20 * tuple3d.x + m21 * tuple3d.y + m22 * tuple3d.z;
+ tuple3d.set(d, d1, d2);
+ }
+
+ public final void transform(Tuple3d tuple3d, Tuple3d tuple3d1)
+ {
+ double d = m00 * tuple3d.x + m01 * tuple3d.y + m02 * tuple3d.z;
+ double d1 = m10 * tuple3d.x + m11 * tuple3d.y + m12 * tuple3d.z;
+ tuple3d1.z = m20 * tuple3d.x + m21 * tuple3d.y + m22 * tuple3d.z;
+ tuple3d1.x = d;
+ tuple3d1.y = d1;
+ }
+
+ final void getScaleRotate(double ad[], double ad1[])
+ {
+ double ad2[] = new double[9];
+ ad2[0] = m00;
+ ad2[1] = m01;
+ ad2[2] = m02;
+ ad2[3] = m10;
+ ad2[4] = m11;
+ ad2[5] = m12;
+ ad2[6] = m20;
+ ad2[7] = m21;
+ ad2[8] = m22;
+ compute_svd(ad2, ad, ad1);
+ }
+
+ static void compute_svd(double ad[], double ad1[], double ad2[])
+ {
+ double ad3[] = new double[9];
+ double ad4[] = new double[9];
+ double ad5[] = new double[9];
+ double ad6[] = new double[9];
+ double ad7[] = ad5;
+ double ad8[] = ad6;
+ double ad9[] = new double[9];
+ double ad10[] = new double[3];
+ double ad11[] = new double[3];
+ int l = 0;
+ for(int i = 0; i < 9; i++)
+ ad9[i] = ad[i];
+
+ if(ad[3] * ad[3] < 1.1102230240000001E-016D)
+ {
+ ad3[0] = 1.0D;
+ ad3[1] = 0.0D;
+ ad3[2] = 0.0D;
+ ad3[3] = 0.0D;
+ ad3[4] = 1.0D;
+ ad3[5] = 0.0D;
+ ad3[6] = 0.0D;
+ ad3[7] = 0.0D;
+ ad3[8] = 1.0D;
+ } else
+ if(ad[0] * ad[0] < 1.1102230240000001E-016D)
+ {
+ ad7[0] = ad[0];
+ ad7[1] = ad[1];
+ ad7[2] = ad[2];
+ ad[0] = ad[3];
+ ad[1] = ad[4];
+ ad[2] = ad[5];
+ ad[3] = -ad7[0];
+ ad[4] = -ad7[1];
+ ad[5] = -ad7[2];
+ ad3[0] = 0.0D;
+ ad3[1] = 1.0D;
+ ad3[2] = 0.0D;
+ ad3[3] = -1D;
+ ad3[4] = 0.0D;
+ ad3[5] = 0.0D;
+ ad3[6] = 0.0D;
+ ad3[7] = 0.0D;
+ ad3[8] = 1.0D;
+ } else
+ {
+ double d = 1.0D / Math.sqrt(ad[0] * ad[0] + ad[3] * ad[3]);
+ double d4 = ad[0] * d;
+ double d8 = ad[3] * d;
+ ad7[0] = d4 * ad[0] + d8 * ad[3];
+ ad7[1] = d4 * ad[1] + d8 * ad[4];
+ ad7[2] = d4 * ad[2] + d8 * ad[5];
+ ad[3] = -d8 * ad[0] + d4 * ad[3];
+ ad[4] = -d8 * ad[1] + d4 * ad[4];
+ ad[5] = -d8 * ad[2] + d4 * ad[5];
+ ad[0] = ad7[0];
+ ad[1] = ad7[1];
+ ad[2] = ad7[2];
+ ad3[0] = d4;
+ ad3[1] = d8;
+ ad3[2] = 0.0D;
+ ad3[3] = -d8;
+ ad3[4] = d4;
+ ad3[5] = 0.0D;
+ ad3[6] = 0.0D;
+ ad3[7] = 0.0D;
+ ad3[8] = 1.0D;
+ }
+ if(ad[6] * ad[6] >= 1.1102230240000001E-016D)
+ if(ad[0] * ad[0] < 1.1102230240000001E-016D)
+ {
+ ad7[0] = ad[0];
+ ad7[1] = ad[1];
+ ad7[2] = ad[2];
+ ad[0] = ad[6];
+ ad[1] = ad[7];
+ ad[2] = ad[8];
+ ad[6] = -ad7[0];
+ ad[7] = -ad7[1];
+ ad[8] = -ad7[2];
+ ad7[0] = ad3[0];
+ ad7[1] = ad3[1];
+ ad7[2] = ad3[2];
+ ad3[0] = ad3[6];
+ ad3[1] = ad3[7];
+ ad3[2] = ad3[8];
+ ad3[6] = -ad7[0];
+ ad3[7] = -ad7[1];
+ ad3[8] = -ad7[2];
+ } else
+ {
+ double d1 = 1.0D / Math.sqrt(ad[0] * ad[0] + ad[6] * ad[6]);
+ double d5 = ad[0] * d1;
+ double d9 = ad[6] * d1;
+ ad7[0] = d5 * ad[0] + d9 * ad[6];
+ ad7[1] = d5 * ad[1] + d9 * ad[7];
+ ad7[2] = d5 * ad[2] + d9 * ad[8];
+ ad[6] = -d9 * ad[0] + d5 * ad[6];
+ ad[7] = -d9 * ad[1] + d5 * ad[7];
+ ad[8] = -d9 * ad[2] + d5 * ad[8];
+ ad[0] = ad7[0];
+ ad[1] = ad7[1];
+ ad[2] = ad7[2];
+ ad7[0] = d5 * ad3[0];
+ ad7[1] = d5 * ad3[1];
+ ad3[2] = d9;
+ ad7[6] = -ad3[0] * d9;
+ ad7[7] = -ad3[1] * d9;
+ ad3[8] = d5;
+ ad3[0] = ad7[0];
+ ad3[1] = ad7[1];
+ ad3[6] = ad7[6];
+ ad3[7] = ad7[7];
+ }
+ if(ad[2] * ad[2] < 1.1102230240000001E-016D)
+ {
+ ad4[0] = 1.0D;
+ ad4[1] = 0.0D;
+ ad4[2] = 0.0D;
+ ad4[3] = 0.0D;
+ ad4[4] = 1.0D;
+ ad4[5] = 0.0D;
+ ad4[6] = 0.0D;
+ ad4[7] = 0.0D;
+ ad4[8] = 1.0D;
+ } else
+ if(ad[1] * ad[1] < 1.1102230240000001E-016D)
+ {
+ ad7[2] = ad[2];
+ ad7[5] = ad[5];
+ ad7[8] = ad[8];
+ ad[2] = -ad[1];
+ ad[5] = -ad[4];
+ ad[8] = -ad[7];
+ ad[1] = ad7[2];
+ ad[4] = ad7[5];
+ ad[7] = ad7[8];
+ ad4[0] = 1.0D;
+ ad4[1] = 0.0D;
+ ad4[2] = 0.0D;
+ ad4[3] = 0.0D;
+ ad4[4] = 0.0D;
+ ad4[5] = -1D;
+ ad4[6] = 0.0D;
+ ad4[7] = 1.0D;
+ ad4[8] = 0.0D;
+ } else
+ {
+ double d2 = 1.0D / Math.sqrt(ad[1] * ad[1] + ad[2] * ad[2]);
+ double d6 = ad[1] * d2;
+ double d10 = ad[2] * d2;
+ ad7[1] = d6 * ad[1] + d10 * ad[2];
+ ad[2] = -d10 * ad[1] + d6 * ad[2];
+ ad[1] = ad7[1];
+ ad7[4] = d6 * ad[4] + d10 * ad[5];
+ ad[5] = -d10 * ad[4] + d6 * ad[5];
+ ad[4] = ad7[4];
+ ad7[7] = d6 * ad[7] + d10 * ad[8];
+ ad[8] = -d10 * ad[7] + d6 * ad[8];
+ ad[7] = ad7[7];
+ ad4[0] = 1.0D;
+ ad4[1] = 0.0D;
+ ad4[2] = 0.0D;
+ ad4[3] = 0.0D;
+ ad4[4] = d6;
+ ad4[5] = -d10;
+ ad4[6] = 0.0D;
+ ad4[7] = d10;
+ ad4[8] = d6;
+ }
+ if(ad[7] * ad[7] >= 1.1102230240000001E-016D)
+ if(ad[4] * ad[4] < 1.1102230240000001E-016D)
+ {
+ ad7[3] = ad[3];
+ ad7[4] = ad[4];
+ ad7[5] = ad[5];
+ ad[3] = ad[6];
+ ad[4] = ad[7];
+ ad[5] = ad[8];
+ ad[6] = -ad7[3];
+ ad[7] = -ad7[4];
+ ad[8] = -ad7[5];
+ ad7[3] = ad3[3];
+ ad7[4] = ad3[4];
+ ad7[5] = ad3[5];
+ ad3[3] = ad3[6];
+ ad3[4] = ad3[7];
+ ad3[5] = ad3[8];
+ ad3[6] = -ad7[3];
+ ad3[7] = -ad7[4];
+ ad3[8] = -ad7[5];
+ } else
+ {
+ double d3 = 1.0D / Math.sqrt(ad[4] * ad[4] + ad[7] * ad[7]);
+ double d7 = ad[4] * d3;
+ double d11 = ad[7] * d3;
+ ad7[3] = d7 * ad[3] + d11 * ad[6];
+ ad[6] = -d11 * ad[3] + d7 * ad[6];
+ ad[3] = ad7[3];
+ ad7[4] = d7 * ad[4] + d11 * ad[7];
+ ad[7] = -d11 * ad[4] + d7 * ad[7];
+ ad[4] = ad7[4];
+ ad7[5] = d7 * ad[5] + d11 * ad[8];
+ ad[8] = -d11 * ad[5] + d7 * ad[8];
+ ad[5] = ad7[5];
+ ad7[3] = d7 * ad3[3] + d11 * ad3[6];
+ ad3[6] = -d11 * ad3[3] + d7 * ad3[6];
+ ad3[3] = ad7[3];
+ ad7[4] = d7 * ad3[4] + d11 * ad3[7];
+ ad3[7] = -d11 * ad3[4] + d7 * ad3[7];
+ ad3[4] = ad7[4];
+ ad7[5] = d7 * ad3[5] + d11 * ad3[8];
+ ad3[8] = -d11 * ad3[5] + d7 * ad3[8];
+ ad3[5] = ad7[5];
+ }
+ ad8[0] = ad[0];
+ ad8[1] = ad[4];
+ ad8[2] = ad[8];
+ ad10[0] = ad[1];
+ ad10[1] = ad[5];
+ if(ad10[0] * ad10[0] >= 1.1102230240000001E-016D || ad10[1] * ad10[1] >= 1.1102230240000001E-016D)
+ compute_qr(ad8, ad10, ad3, ad4);
+ ad11[0] = ad8[0];
+ ad11[1] = ad8[1];
+ ad11[2] = ad8[2];
+ if(almostEqual(Math.abs(ad11[0]), 1.0D) && almostEqual(Math.abs(ad11[1]), 1.0D) && almostEqual(Math.abs(ad11[2]), 1.0D))
+ {
+ for(int j = 0; j < 3; j++)
+ if(ad11[j] < 0.0D)
+ l++;
+
+ if(l == 0 || l == 2)
+ {
+ ad1[0] = ad1[1] = ad1[2] = 1.0D;
+ for(int k = 0; k < 9; k++)
+ ad2[k] = ad9[k];
+
+ return;
+ }
+ }
+ transpose_mat(ad3, ad5);
+ transpose_mat(ad4, ad6);
+ svdReorder(ad, ad5, ad6, ad11, ad2, ad1);
+ }
+
+ static void svdReorder(double ad[], double ad1[], double ad2[], double ad3[], double ad4[], double ad5[])
+ {
+ int ai[] = new int[3];
+ int ai1[] = new int[3];
+ double ad6[] = new double[3];
+ double ad7[] = new double[9];
+ if(ad3[0] < 0.0D)
+ {
+ ad3[0] = -ad3[0];
+ ad2[0] = -ad2[0];
+ ad2[1] = -ad2[1];
+ ad2[2] = -ad2[2];
+ }
+ if(ad3[1] < 0.0D)
+ {
+ ad3[1] = -ad3[1];
+ ad2[3] = -ad2[3];
+ ad2[4] = -ad2[4];
+ ad2[5] = -ad2[5];
+ }
+ if(ad3[2] < 0.0D)
+ {
+ ad3[2] = -ad3[2];
+ ad2[6] = -ad2[6];
+ ad2[7] = -ad2[7];
+ ad2[8] = -ad2[8];
+ }
+ mat_mul(ad1, ad2, ad7);
+ if(almostEqual(Math.abs(ad3[0]), Math.abs(ad3[1])) && almostEqual(Math.abs(ad3[1]), Math.abs(ad3[2])))
+ {
+ for(int j = 0; j < 9; j++)
+ ad4[j] = ad7[j];
+
+ for(int k = 0; k < 3; k++)
+ ad5[k] = ad3[k];
+
+ } else
+ {
+ if(ad3[0] > ad3[1])
+ {
+ if(ad3[0] > ad3[2])
+ {
+ if(ad3[2] > ad3[1])
+ {
+ ai[0] = 0;
+ ai[1] = 2;
+ ai[2] = 1;
+ } else
+ {
+ ai[0] = 0;
+ ai[1] = 1;
+ ai[2] = 2;
+ }
+ } else
+ {
+ ai[0] = 2;
+ ai[1] = 0;
+ ai[2] = 1;
+ }
+ } else
+ if(ad3[1] > ad3[2])
+ {
+ if(ad3[2] > ad3[0])
+ {
+ ai[0] = 1;
+ ai[1] = 2;
+ ai[2] = 0;
+ } else
+ {
+ ai[0] = 1;
+ ai[1] = 0;
+ ai[2] = 2;
+ }
+ } else
+ {
+ ai[0] = 2;
+ ai[1] = 1;
+ ai[2] = 0;
+ }
+ ad6[0] = ad[0] * ad[0] + ad[1] * ad[1] + ad[2] * ad[2];
+ ad6[1] = ad[3] * ad[3] + ad[4] * ad[4] + ad[5] * ad[5];
+ ad6[2] = ad[6] * ad[6] + ad[7] * ad[7] + ad[8] * ad[8];
+ byte byte0;
+ byte byte1;
+ byte byte2;
+ if(ad6[0] > ad6[1])
+ {
+ if(ad6[0] > ad6[2])
+ {
+ if(ad6[2] > ad6[1])
+ {
+ byte0 = 0;
+ byte2 = 1;
+ byte1 = 2;
+ } else
+ {
+ byte0 = 0;
+ byte1 = 1;
+ byte2 = 2;
+ }
+ } else
+ {
+ byte2 = 0;
+ byte0 = 1;
+ byte1 = 2;
+ }
+ } else
+ if(ad6[1] > ad6[2])
+ {
+ if(ad6[2] > ad6[0])
+ {
+ byte1 = 0;
+ byte2 = 1;
+ byte0 = 2;
+ } else
+ {
+ byte1 = 0;
+ byte0 = 1;
+ byte2 = 2;
+ }
+ } else
+ {
+ byte2 = 0;
+ byte1 = 1;
+ byte0 = 2;
+ }
+ int i = ai[byte0];
+ ad5[0] = ad3[i];
+ i = ai[byte1];
+ ad5[1] = ad3[i];
+ i = ai[byte2];
+ ad5[2] = ad3[i];
+ i = ai[byte0];
+ ad4[0] = ad7[i];
+ i = ai[byte0] + 3;
+ ad4[3] = ad7[i];
+ i = ai[byte0] + 6;
+ ad4[6] = ad7[i];
+ i = ai[byte1];
+ ad4[1] = ad7[i];
+ i = ai[byte1] + 3;
+ ad4[4] = ad7[i];
+ i = ai[byte1] + 6;
+ ad4[7] = ad7[i];
+ i = ai[byte2];
+ ad4[2] = ad7[i];
+ i = ai[byte2] + 3;
+ ad4[5] = ad7[i];
+ i = ai[byte2] + 6;
+ ad4[8] = ad7[i];
+ }
+ }
+
+ static int compute_qr(double ad[], double ad1[], double ad2[], double ad3[])
+ {
+ double ad4[] = new double[2];
+ double ad5[] = new double[2];
+ double ad6[] = new double[2];
+ double ad7[] = new double[2];
+ double ad8[] = new double[9];
+ double d10 = 1.0D;
+ double d11 = -1D;
+ boolean flag = false;
+ int j = 1;
+ if(Math.abs(ad1[1]) < 4.8900000000000002E-015D || Math.abs(ad1[0]) < 4.8900000000000002E-015D)
+ flag = true;
+ for(int i = 0; i < 10 && !flag; i++)
+ {
+ double d = compute_shift(ad[1], ad1[1], ad[2]);
+ double d8 = (Math.abs(ad[0]) - d) * (d_sign(d10, ad[0]) + d / ad[0]);
+ double d9 = ad1[0];
+ double d1 = compute_rot(d8, d9, ad7, ad5, 0, j);
+ d8 = ad5[0] * ad[0] + ad7[0] * ad1[0];
+ ad1[0] = ad5[0] * ad1[0] - ad7[0] * ad[0];
+ d9 = ad7[0] * ad[1];
+ ad[1] = ad5[0] * ad[1];
+ d1 = compute_rot(d8, d9, ad6, ad4, 0, j);
+ j = 0;
+ ad[0] = d1;
+ d8 = ad4[0] * ad1[0] + ad6[0] * ad[1];
+ ad[1] = ad4[0] * ad[1] - ad6[0] * ad1[0];
+ d9 = ad6[0] * ad1[1];
+ ad1[1] = ad4[0] * ad1[1];
+ d1 = compute_rot(d8, d9, ad7, ad5, 1, j);
+ ad1[0] = d1;
+ d8 = ad5[1] * ad[1] + ad7[1] * ad1[1];
+ ad1[1] = ad5[1] * ad1[1] - ad7[1] * ad[1];
+ d9 = ad7[1] * ad[2];
+ ad[2] = ad5[1] * ad[2];
+ d1 = compute_rot(d8, d9, ad6, ad4, 1, j);
+ ad[1] = d1;
+ d8 = ad4[1] * ad1[1] + ad6[1] * ad[2];
+ ad[2] = ad4[1] * ad[2] - ad6[1] * ad1[1];
+ ad1[1] = d8;
+ double d2 = ad2[0];
+ ad2[0] = ad4[0] * d2 + ad6[0] * ad2[3];
+ ad2[3] = -ad6[0] * d2 + ad4[0] * ad2[3];
+ d2 = ad2[1];
+ ad2[1] = ad4[0] * d2 + ad6[0] * ad2[4];
+ ad2[4] = -ad6[0] * d2 + ad4[0] * ad2[4];
+ d2 = ad2[2];
+ ad2[2] = ad4[0] * d2 + ad6[0] * ad2[5];
+ ad2[5] = -ad6[0] * d2 + ad4[0] * ad2[5];
+ d2 = ad2[3];
+ ad2[3] = ad4[1] * d2 + ad6[1] * ad2[6];
+ ad2[6] = -ad6[1] * d2 + ad4[1] * ad2[6];
+ d2 = ad2[4];
+ ad2[4] = ad4[1] * d2 + ad6[1] * ad2[7];
+ ad2[7] = -ad6[1] * d2 + ad4[1] * ad2[7];
+ d2 = ad2[5];
+ ad2[5] = ad4[1] * d2 + ad6[1] * ad2[8];
+ ad2[8] = -ad6[1] * d2 + ad4[1] * ad2[8];
+ double d5 = ad3[0];
+ ad3[0] = ad5[0] * d5 + ad7[0] * ad3[1];
+ ad3[1] = -ad7[0] * d5 + ad5[0] * ad3[1];
+ d5 = ad3[3];
+ ad3[3] = ad5[0] * d5 + ad7[0] * ad3[4];
+ ad3[4] = -ad7[0] * d5 + ad5[0] * ad3[4];
+ d5 = ad3[6];
+ ad3[6] = ad5[0] * d5 + ad7[0] * ad3[7];
+ ad3[7] = -ad7[0] * d5 + ad5[0] * ad3[7];
+ d5 = ad3[1];
+ ad3[1] = ad5[1] * d5 + ad7[1] * ad3[2];
+ ad3[2] = -ad7[1] * d5 + ad5[1] * ad3[2];
+ d5 = ad3[4];
+ ad3[4] = ad5[1] * d5 + ad7[1] * ad3[5];
+ ad3[5] = -ad7[1] * d5 + ad5[1] * ad3[5];
+ d5 = ad3[7];
+ ad3[7] = ad5[1] * d5 + ad7[1] * ad3[8];
+ ad3[8] = -ad7[1] * d5 + ad5[1] * ad3[8];
+ ad8[0] = ad[0];
+ ad8[1] = ad1[0];
+ ad8[2] = 0.0D;
+ ad8[3] = 0.0D;
+ ad8[4] = ad[1];
+ ad8[5] = ad1[1];
+ ad8[6] = 0.0D;
+ ad8[7] = 0.0D;
+ ad8[8] = ad[2];
+ if(Math.abs(ad1[1]) < 4.8900000000000002E-015D || Math.abs(ad1[0]) < 4.8900000000000002E-015D)
+ flag = true;
+ }
+
+ if(Math.abs(ad1[1]) < 4.8900000000000002E-015D)
+ {
+ compute_2X2(ad[0], ad1[0], ad[1], ad, ad6, ad4, ad7, ad5, 0);
+ double d3 = ad2[0];
+ ad2[0] = ad4[0] * d3 + ad6[0] * ad2[3];
+ ad2[3] = -ad6[0] * d3 + ad4[0] * ad2[3];
+ d3 = ad2[1];
+ ad2[1] = ad4[0] * d3 + ad6[0] * ad2[4];
+ ad2[4] = -ad6[0] * d3 + ad4[0] * ad2[4];
+ d3 = ad2[2];
+ ad2[2] = ad4[0] * d3 + ad6[0] * ad2[5];
+ ad2[5] = -ad6[0] * d3 + ad4[0] * ad2[5];
+ double d6 = ad3[0];
+ ad3[0] = ad5[0] * d6 + ad7[0] * ad3[1];
+ ad3[1] = -ad7[0] * d6 + ad5[0] * ad3[1];
+ d6 = ad3[3];
+ ad3[3] = ad5[0] * d6 + ad7[0] * ad3[4];
+ ad3[4] = -ad7[0] * d6 + ad5[0] * ad3[4];
+ d6 = ad3[6];
+ ad3[6] = ad5[0] * d6 + ad7[0] * ad3[7];
+ ad3[7] = -ad7[0] * d6 + ad5[0] * ad3[7];
+ } else
+ {
+ compute_2X2(ad[1], ad1[1], ad[2], ad, ad6, ad4, ad7, ad5, 1);
+ double d4 = ad2[3];
+ ad2[3] = ad4[0] * d4 + ad6[0] * ad2[6];
+ ad2[6] = -ad6[0] * d4 + ad4[0] * ad2[6];
+ d4 = ad2[4];
+ ad2[4] = ad4[0] * d4 + ad6[0] * ad2[7];
+ ad2[7] = -ad6[0] * d4 + ad4[0] * ad2[7];
+ d4 = ad2[5];
+ ad2[5] = ad4[0] * d4 + ad6[0] * ad2[8];
+ ad2[8] = -ad6[0] * d4 + ad4[0] * ad2[8];
+ double d7 = ad3[1];
+ ad3[1] = ad5[0] * d7 + ad7[0] * ad3[2];
+ ad3[2] = -ad7[0] * d7 + ad5[0] * ad3[2];
+ d7 = ad3[4];
+ ad3[4] = ad5[0] * d7 + ad7[0] * ad3[5];
+ ad3[5] = -ad7[0] * d7 + ad5[0] * ad3[5];
+ d7 = ad3[7];
+ ad3[7] = ad5[0] * d7 + ad7[0] * ad3[8];
+ ad3[8] = -ad7[0] * d7 + ad5[0] * ad3[8];
+ }
+ return 0;
+ }
+
+ static double max(double d, double d1)
+ {
+ if(d > d1)
+ return d;
+ else
+ return d1;
+ }
+
+ static double min(double d, double d1)
+ {
+ if(d < d1)
+ return d;
+ else
+ return d1;
+ }
+
+ static double d_sign(double d, double d1)
+ {
+ double d2 = d < 0.0D ? -d : d;
+ return d1 < 0.0D ? -d2 : d2;
+ }
+
+ static double compute_shift(double d, double d1, double d2)
+ {
+ double d11 = Math.abs(d);
+ double d12 = Math.abs(d1);
+ double d13 = Math.abs(d2);
+ double d7 = min(d11, d13);
+ double d8 = max(d11, d13);
+ double d20;
+ if(d7 == 0.0D)
+ {
+ d20 = 0.0D;
+ double d3;
+ if(d8 != 0.0D)
+ d3 = min(d8, d12) / max(d8, d12);
+ } else
+ if(d12 < d8)
+ {
+ double d14 = d7 / d8 + 1.0D;
+ double d16 = (d8 - d7) / d8;
+ double d4 = d12 / d8;
+ double d18 = d4 * d4;
+ double d9 = 2D / (Math.sqrt(d14 * d14 + d18) + Math.sqrt(d16 * d16 + d18));
+ d20 = d7 * d9;
+ } else
+ {
+ double d19 = d8 / d12;
+ if(d19 == 0.0D)
+ {
+ d20 = (d7 * d8) / d12;
+ } else
+ {
+ double d15 = d7 / d8 + 1.0D;
+ double d17 = (d8 - d7) / d8;
+ double d5 = d15 * d19;
+ double d6 = d17 * d19;
+ double d10 = 1.0D / (Math.sqrt(d5 * d5 + 1.0D) + Math.sqrt(d6 * d6 + 1.0D));
+ d20 = d7 * d10 * d19;
+ d20 += d20;
+ }
+ }
+ return d20;
+ }
+
+ static int compute_2X2(double d, double d1, double d2, double ad[], double ad1[],
+ double ad2[], double ad3[], double ad4[], int i)
+ {
+ double d3 = 2D;
+ double d4 = 1.0D;
+ double d37 = ad[0];
+ double d36 = ad[1];
+ double d32 = 0.0D;
+ double d33 = 0.0D;
+ double d34 = 0.0D;
+ double d35 = 0.0D;
+ double d21 = 0.0D;
+ double d25 = d;
+ double d22 = Math.abs(d25);
+ double d27 = d2;
+ double d24 = Math.abs(d2);
+ byte byte0 = 1;
+ boolean flag;
+ if(d24 > d22)
+ flag = true;
+ else
+ flag = false;
+ if(flag)
+ {
+ byte0 = 3;
+ double d6 = d25;
+ d25 = d27;
+ d27 = d6;
+ d6 = d22;
+ d22 = d24;
+ d24 = d6;
+ }
+ double d26 = d1;
+ double d23 = Math.abs(d26);
+ if(d23 == 0.0D)
+ {
+ ad[1] = d24;
+ ad[0] = d22;
+ d32 = 1.0D;
+ d33 = 1.0D;
+ d34 = 0.0D;
+ d35 = 0.0D;
+ } else
+ {
+ boolean flag1 = true;
+ if(d23 > d22)
+ {
+ byte0 = 2;
+ if(d22 / d23 < 1.1102230240000001E-016D)
+ {
+ flag1 = false;
+ d37 = d23;
+ if(d24 > 1.0D)
+ d36 = d22 / (d23 / d24);
+ else
+ d36 = (d22 / d23) * d24;
+ d32 = 1.0D;
+ d34 = d27 / d26;
+ d35 = 1.0D;
+ d33 = d25 / d26;
+ }
+ }
+ if(flag1)
+ {
+ double d9 = d22 - d24;
+ double d11;
+ if(d9 == d22)
+ d11 = 1.0D;
+ else
+ d11 = d9 / d22;
+ double d13 = d26 / d25;
+ double d19 = 2D - d11;
+ double d28 = d13 * d13;
+ double d30 = d19 * d19;
+ double d17 = Math.sqrt(d30 + d28);
+ double d15;
+ if(d11 == 0.0D)
+ d15 = Math.abs(d13);
+ else
+ d15 = Math.sqrt(d11 * d11 + d28);
+ double d7 = (d17 + d15) * 0.5D;
+ if(d23 > d22)
+ {
+ byte0 = 2;
+ if(d22 / d23 < 1.1102230240000001E-016D)
+ {
+ flag1 = false;
+ d37 = d23;
+ if(d24 > 1.0D)
+ d36 = d22 / (d23 / d24);
+ else
+ d36 = (d22 / d23) * d24;
+ d32 = 1.0D;
+ d34 = d27 / d26;
+ d35 = 1.0D;
+ d33 = d25 / d26;
+ }
+ }
+ if(flag1)
+ {
+ double d10 = d22 - d24;
+ double d12;
+ if(d10 == d22)
+ d12 = 1.0D;
+ else
+ d12 = d10 / d22;
+ double d14 = d26 / d25;
+ double d20 = 2D - d12;
+ double d29 = d14 * d14;
+ double d31 = d20 * d20;
+ double d18 = Math.sqrt(d31 + d29);
+ double d16;
+ if(d12 == 0.0D)
+ d16 = Math.abs(d14);
+ else
+ d16 = Math.sqrt(d12 * d12 + d29);
+ double d8 = (d18 + d16) * 0.5D;
+ d36 = d24 / d8;
+ d37 = d22 * d8;
+ if(d29 == 0.0D)
+ {
+ if(d12 == 0.0D)
+ d20 = d_sign(d3, d25) * d_sign(d4, d26);
+ else
+ d20 = d26 / d_sign(d10, d25) + d14 / d20;
+ } else
+ {
+ d20 = (d14 / (d18 + d20) + d14 / (d16 + d12)) * (d8 + 1.0D);
+ }
+ d12 = Math.sqrt(d20 * d20 + 4D);
+ d33 = 2D / d12;
+ d35 = d20 / d12;
+ d32 = (d33 + d35 * d14) / d8;
+ d34 = ((d27 / d25) * d35) / d8;
+ }
+ }
+ if(flag)
+ {
+ ad2[0] = d35;
+ ad1[0] = d33;
+ ad4[0] = d34;
+ ad3[0] = d32;
+ } else
+ {
+ ad2[0] = d32;
+ ad1[0] = d34;
+ ad4[0] = d33;
+ ad3[0] = d35;
+ }
+ if(byte0 == 1)
+ d21 = d_sign(d4, ad4[0]) * d_sign(d4, ad2[0]) * d_sign(d4, d);
+ if(byte0 == 2)
+ d21 = d_sign(d4, ad3[0]) * d_sign(d4, ad2[0]) * d_sign(d4, d1);
+ if(byte0 == 3)
+ d21 = d_sign(d4, ad3[0]) * d_sign(d4, ad1[0]) * d_sign(d4, d2);
+ ad[i] = d_sign(d37, d21);
+ double d5 = d21 * d_sign(d4, d) * d_sign(d4, d2);
+ ad[i + 1] = d_sign(d36, d5);
+ }
+ return 0;
+ }
+
+ static double compute_rot(double d, double d1, double ad[], double ad1[], int i, int j)
+ {
+ double d2;
+ double d3;
+ double d7;
+ if(d1 == 0.0D)
+ {
+ d2 = 1.0D;
+ d3 = 0.0D;
+ d7 = d;
+ } else
+ if(d == 0.0D)
+ {
+ d2 = 0.0D;
+ d3 = 1.0D;
+ d7 = d1;
+ } else
+ {
+ double d5 = d;
+ double d6 = d1;
+ double d4 = max(Math.abs(d5), Math.abs(d6));
+ if(d4 >= 4.9947976805055876E+145D)
+ {
+ int k1 = 0;
+ for(; d4 >= 4.9947976805055876E+145D; d4 = max(Math.abs(d5), Math.abs(d6)))
+ {
+ k1++;
+ d5 *= 2.0020830951831009E-146D;
+ d6 *= 2.0020830951831009E-146D;
+ }
+
+ d7 = Math.sqrt(d5 * d5 + d6 * d6);
+ d2 = d5 / d7;
+ d3 = d6 / d7;
+ int k = k1;
+ for(int i1 = 1; i1 <= k1; i1++)
+ d7 *= 4.9947976805055876E+145D;
+
+ } else
+ if(d4 <= 2.0020830951831009E-146D)
+ {
+ int l1 = 0;
+ for(; d4 <= 2.0020830951831009E-146D; d4 = max(Math.abs(d5), Math.abs(d6)))
+ {
+ l1++;
+ d5 *= 4.9947976805055876E+145D;
+ d6 *= 4.9947976805055876E+145D;
+ }
+
+ d7 = Math.sqrt(d5 * d5 + d6 * d6);
+ d2 = d5 / d7;
+ d3 = d6 / d7;
+ int l = l1;
+ for(int j1 = 1; j1 <= l1; j1++)
+ d7 *= 2.0020830951831009E-146D;
+
+ } else
+ {
+ d7 = Math.sqrt(d5 * d5 + d6 * d6);
+ d2 = d5 / d7;
+ d3 = d6 / d7;
+ }
+ if(Math.abs(d) > Math.abs(d1) && d2 < 0.0D)
+ {
+ d2 = -d2;
+ d3 = -d3;
+ d7 = -d7;
+ }
+ }
+ ad[i] = d3;
+ ad1[i] = d2;
+ return d7;
+ }
+
+ static void print_mat(double ad[])
+ {
+ for(int i = 0; i < 3; i++)
+ System.out.println(ad[i * 3 + 0] + " " + ad[i * 3 + 1] + " " + ad[i * 3 + 2] + "\n");
+
+ }
+
+ static void print_det(double ad[])
+ {
+ double d = (ad[0] * ad[4] * ad[8] + ad[1] * ad[5] * ad[6] + ad[2] * ad[3] * ad[7]) - ad[2] * ad[4] * ad[6] - ad[0] * ad[5] * ad[7] - ad[1] * ad[3] * ad[8];
+ System.out.println("det= " + d);
+ }
+
+ static void mat_mul(double ad[], double ad1[], double ad2[])
+ {
+ double ad3[] = new double[9];
+ ad3[0] = ad[0] * ad1[0] + ad[1] * ad1[3] + ad[2] * ad1[6];
+ ad3[1] = ad[0] * ad1[1] + ad[1] * ad1[4] + ad[2] * ad1[7];
+ ad3[2] = ad[0] * ad1[2] + ad[1] * ad1[5] + ad[2] * ad1[8];
+ ad3[3] = ad[3] * ad1[0] + ad[4] * ad1[3] + ad[5] * ad1[6];
+ ad3[4] = ad[3] * ad1[1] + ad[4] * ad1[4] + ad[5] * ad1[7];
+ ad3[5] = ad[3] * ad1[2] + ad[4] * ad1[5] + ad[5] * ad1[8];
+ ad3[6] = ad[6] * ad1[0] + ad[7] * ad1[3] + ad[8] * ad1[6];
+ ad3[7] = ad[6] * ad1[1] + ad[7] * ad1[4] + ad[8] * ad1[7];
+ ad3[8] = ad[6] * ad1[2] + ad[7] * ad1[5] + ad[8] * ad1[8];
+ for(int i = 0; i < 9; i++)
+ ad2[i] = ad3[i];
+
+ }
+
+ static void transpose_mat(double ad[], double ad1[])
+ {
+ ad1[0] = ad[0];
+ ad1[1] = ad[3];
+ ad1[2] = ad[6];
+ ad1[3] = ad[1];
+ ad1[4] = ad[4];
+ ad1[5] = ad[7];
+ ad1[6] = ad[2];
+ ad1[7] = ad[5];
+ ad1[8] = ad[8];
+ }
+
+ static double max3(double ad[])
+ {
+ if(ad[0] > ad[1])
+ if(ad[0] > ad[2])
+ return ad[0];
+ else
+ return ad[2];
+ if(ad[1] > ad[2])
+ return ad[1];
+ else
+ return ad[2];
+ }
+
+ private static final boolean almostEqual(double d, double d1)
+ {
+ if(d == d1)
+ return true;
+ double d2 = Math.abs(d - d1);
+ double d3 = Math.abs(d);
+ double d4 = Math.abs(d1);
+ double d5 = d3 < d4 ? d4 : d3;
+ if(d2 < 9.9999999999999995E-007D)
+ return true;
+ return d2 / d5 < 0.0001D;
+ }
+
+ public Object clone()
+ {
+ Matrix3d matrix3d = null;
+ try
+ {
+ matrix3d = (Matrix3d)super.clone();
+ }
+ catch(CloneNotSupportedException clonenotsupportedexception)
+ {
+ throw new InternalError();
+ }
+ return matrix3d;
+ }
+
+ static final long serialVersionUID = 0x5ee3cf78d011e116L;
+ public double m00;
+ public double m01;
+ public double m02;
+ public double m10;
+ public double m11;
+ public double m12;
+ public double m20;
+ public double m21;
+ public double m22;
+ private static final double EPS = 1.1102230240000001E-016D;
+ private static final double ERR_EPS = 1E-008D;
+ private static double xin;
+ private static double yin;
+ private static double zin;
+ private static double xout;
+ private static double yout;
+ private static double zout;
+}
diff --git a/src/vecmath/SingularMatrixException.java b/src/vecmath/SingularMatrixException.java
new file mode 100644
index 0000000..f06a97a
--- /dev/null
+++ b/src/vecmath/SingularMatrixException.java
@@ -0,0 +1,9 @@
+package vecmath;
+
+public class SingularMatrixException extends Exception {
+
+ public SingularMatrixException(String string) {
+ // TODO Auto-generated constructor stub
+ }
+
+}
diff --git a/src/vecmath/Tuple3d.java b/src/vecmath/Tuple3d.java
new file mode 100644
index 0000000..02d799d
--- /dev/null
+++ b/src/vecmath/Tuple3d.java
@@ -0,0 +1,465 @@
+// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
+// Jad home page: http://www.kpdus.com/jad.html
+// Decompiler options: packimports(3)
+// Source File Name: Tuple3d.java
+
+package vecmath;
+
+import java.io.Serializable;
+
+// Referenced classes of package javax.vecmath:
+// Point3d, Tuple3f
+
+public abstract class Tuple3d
+ implements Serializable, Cloneable
+{
+
+ public Tuple3d(double d, double d1, double d2)
+ {
+ x = d;
+ y = d1;
+ z = d2;
+ }
+
+ public Tuple3d(double ad[])
+ {
+ x = ad[0];
+ y = ad[1];
+ z = ad[2];
+ }
+
+ public Tuple3d(Tuple3d tuple3d)
+ {
+ x = tuple3d.x;
+ y = tuple3d.y;
+ z = tuple3d.z;
+ }
+
+// public Tuple3d(Tuple3f tuple3f)
+// {
+// x = tuple3f.x;
+// y = tuple3f.y;
+// z = tuple3f.z;
+// }
+
+ public Tuple3d()
+ {
+ x = 0.0D;
+ y = 0.0D;
+ z = 0.0D;
+ }
+
+ public final void set(double d, double d1, double d2)
+ {
+ x = d;
+ y = d1;
+ z = d2;
+ }
+
+ public final void set(double ad[])
+ {
+ x = ad[0];
+ y = ad[1];
+ z = ad[2];
+ }
+
+ public final void set(Tuple3d tuple3d)
+ {
+ x = tuple3d.x;
+ y = tuple3d.y;
+ z = tuple3d.z;
+ }
+
+// public final void set(Tuple3f tuple3f)
+// {
+// x = tuple3f.x;
+// y = tuple3f.y;
+// z = tuple3f.z;
+// }
+
+ public final void get(double ad[])
+ {
+ ad[0] = x;
+ ad[1] = y;
+ ad[2] = z;
+ }
+
+ public final void get(Tuple3d tuple3d)
+ {
+ tuple3d.x = x;
+ tuple3d.y = y;
+ tuple3d.z = z;
+ }
+
+ public final void add(Tuple3d tuple3d, Tuple3d tuple3d1)
+ {
+ x = tuple3d.x + tuple3d1.x;
+ y = tuple3d.y + tuple3d1.y;
+ z = tuple3d.z + tuple3d1.z;
+ }
+
+ public final void add(Tuple3d tuple3d)
+ {
+ x += tuple3d.x;
+ y += tuple3d.y;
+ z += tuple3d.z;
+ }
+
+ public final void sub(Tuple3d tuple3d, Tuple3d tuple3d1)
+ {
+ x = tuple3d.x - tuple3d1.x;
+ y = tuple3d.y - tuple3d1.y;
+ z = tuple3d.z - tuple3d1.z;
+ }
+
+ public final void sub(Tuple3d tuple3d)
+ {
+ x -= tuple3d.x;
+ y -= tuple3d.y;
+ z -= tuple3d.z;
+ }
+
+ public final void negate(Tuple3d tuple3d)
+ {
+ x = -tuple3d.x;
+ y = -tuple3d.y;
+ z = -tuple3d.z;
+ }
+
+ public final void negate()
+ {
+ x = -x;
+ y = -y;
+ z = -z;
+ }
+
+ public final void scale(double d, Tuple3d tuple3d)
+ {
+ x = d * tuple3d.x;
+ y = d * tuple3d.y;
+ z = d * tuple3d.z;
+ }
+
+ public final void scale(double d)
+ {
+ x *= d;
+ y *= d;
+ z *= d;
+ }
+
+ public final void scaleAdd(double d, Tuple3d tuple3d, Tuple3d tuple3d1)
+ {
+ x = d * tuple3d.x + tuple3d1.x;
+ y = d * tuple3d.y + tuple3d1.y;
+ z = d * tuple3d.z + tuple3d1.z;
+ }
+
+ /**
+ * @deprecated Method scaleAdd is deprecated
+ */
+
+// public final void scaleAdd(double d, Tuple3f tuple3f)
+// {
+// scaleAdd(d, ((Tuple3d) (new Point3d(tuple3f))));
+// }
+
+ public final void scaleAdd(double d, Tuple3d tuple3d)
+ {
+ x = d * x + tuple3d.x;
+ y = d * y + tuple3d.y;
+ z = d * z + tuple3d.z;
+ }
+
+ public String toString()
+ {
+ return "(" + x + ", " + y + ", " + z + ")";
+ }
+
+ public int hashCode()
+ {
+ long l = 1L;
+ l = 31L * l + Double.doubleToLongBits(x);
+ l = 31L * l + Double.doubleToLongBits(y);
+ l = 31L * l + Double.doubleToLongBits(z);
+ return (int)(l ^ l >> 32);
+ }
+
+ public boolean equals(Tuple3d tuple3d)
+ {
+ try
+ {
+ return x == tuple3d.x && y == tuple3d.y && z == tuple3d.z;
+ }
+ catch(NullPointerException nullpointerexception)
+ {
+ return false;
+ }
+ }
+
+ public boolean equals(Object obj)
+ {
+ try
+ {
+ Tuple3d tuple3d = (Tuple3d)obj;
+ return x == tuple3d.x && y == tuple3d.y && z == tuple3d.z;
+ }
+ catch(ClassCastException classcastexception)
+ {
+ return false;
+ }
+ catch(NullPointerException nullpointerexception)
+ {
+ return false;
+ }
+ }
+
+ public boolean epsilonEquals(Tuple3d tuple3d, double d)
+ {
+ double d1 = x - tuple3d.x;
+ if((d1 >= 0.0D ? d1 : -d1) > d)
+ return false;
+ d1 = y - tuple3d.y;
+ if((d1 >= 0.0D ? d1 : -d1) > d)
+ return false;
+ d1 = z - tuple3d.z;
+ return (d1 >= 0.0D ? d1 : -d1) <= d;
+ }
+
+ /**
+ * @deprecated Method clamp is deprecated
+ */
+
+ public final void clamp(float f, float f1, Tuple3d tuple3d)
+ {
+ clamp(f, f1, tuple3d);
+ }
+
+ public final void clamp(double d, double d1, Tuple3d tuple3d)
+ {
+ if(tuple3d.x > d1)
+ x = d1;
+ else
+ if(tuple3d.x < d)
+ x = d;
+ else
+ x = tuple3d.x;
+ if(tuple3d.y > d1)
+ y = d1;
+ else
+ if(tuple3d.y < d)
+ y = d;
+ else
+ y = tuple3d.y;
+ if(tuple3d.z > d1)
+ z = d1;
+ else
+ if(tuple3d.z < d)
+ z = d;
+ else
+ z = tuple3d.z;
+ }
+
+ /**
+ * @deprecated Method clampMin is deprecated
+ */
+
+ public final void clampMin(float f, Tuple3d tuple3d)
+ {
+ clampMin(f, tuple3d);
+ }
+
+ public final void clampMin(double d, Tuple3d tuple3d)
+ {
+ if(tuple3d.x < d)
+ x = d;
+ else
+ x = tuple3d.x;
+ if(tuple3d.y < d)
+ y = d;
+ else
+ y = tuple3d.y;
+ if(tuple3d.z < d)
+ z = d;
+ else
+ z = tuple3d.z;
+ }
+
+ /**
+ * @deprecated Method clampMax is deprecated
+ */
+
+ public final void clampMax(float f, Tuple3d tuple3d)
+ {
+ clampMax(f, tuple3d);
+ }
+
+ public final void clampMax(double d, Tuple3d tuple3d)
+ {
+ if(tuple3d.x > d)
+ x = d;
+ else
+ x = tuple3d.x;
+ if(tuple3d.y > d)
+ y = d;
+ else
+ y = tuple3d.y;
+ if(tuple3d.z > d)
+ z = d;
+ else
+ z = tuple3d.z;
+ }
+
+ public final void absolute(Tuple3d tuple3d)
+ {
+ x = Math.abs(tuple3d.x);
+ y = Math.abs(tuple3d.y);
+ z = Math.abs(tuple3d.z);
+ }
+
+ /**
+ * @deprecated Method clamp is deprecated
+ */
+
+ public final void clamp(float f, float f1)
+ {
+ clamp(f, f1);
+ }
+
+ public final void clamp(double d, double d1)
+ {
+ if(x > d1)
+ x = d1;
+ else
+ if(x < d)
+ x = d;
+ if(y > d1)
+ y = d1;
+ else
+ if(y < d)
+ y = d;
+ if(z > d1)
+ z = d1;
+ else
+ if(z < d)
+ z = d;
+ }
+
+ /**
+ * @deprecated Method clampMin is deprecated
+ */
+
+ public final void clampMin(float f)
+ {
+ clampMin(f);
+ }
+
+ public final void clampMin(double d)
+ {
+ if(x < d)
+ x = d;
+ if(y < d)
+ y = d;
+ if(z < d)
+ z = d;
+ }
+
+ /**
+ * @deprecated Method clampMax is deprecated
+ */
+
+ public final void clampMax(float f)
+ {
+ clampMax(f);
+ }
+
+ public final void clampMax(double d)
+ {
+ if(x > d)
+ x = d;
+ if(y > d)
+ y = d;
+ if(z > d)
+ z = d;
+ }
+
+ public final void absolute()
+ {
+ x = Math.abs(x);
+ y = Math.abs(y);
+ z = Math.abs(z);
+ }
+
+ /**
+ * @deprecated Method interpolate is deprecated
+ */
+
+ public final void interpolate(Tuple3d tuple3d, Tuple3d tuple3d1, float f)
+ {
+ interpolate(tuple3d, tuple3d1, f);
+ }
+
+ public final void interpolate(Tuple3d tuple3d, Tuple3d tuple3d1, double d)
+ {
+ x = (1.0D - d) * tuple3d.x + d * tuple3d1.x;
+ y = (1.0D - d) * tuple3d.y + d * tuple3d1.y;
+ z = (1.0D - d) * tuple3d.z + d * tuple3d1.z;
+ }
+
+ /**
+ * @deprecated Method interpolate is deprecated
+ */
+
+ public final void interpolate(Tuple3d tuple3d, float f)
+ {
+ interpolate(tuple3d, f);
+ }
+
+ public final void interpolate(Tuple3d tuple3d, double d)
+ {
+ x = (1.0D - d) * x + d * tuple3d.x;
+ y = (1.0D - d) * y + d * tuple3d.y;
+ z = (1.0D - d) * z + d * tuple3d.z;
+ }
+
+ public Object clone()
+ {
+ try
+ {
+ return super.clone();
+ }
+ catch(CloneNotSupportedException clonenotsupportedexception)
+ {
+ throw new InternalError();
+ }
+ }
+
+ static final long serialVersionUID = 0x4ce97b820b91b15fL;
+ public double x;
+ public double y;
+ public double z;
+ public double getX() {
+ return x;
+ }
+
+ public void setX(double x) {
+ this.x = x;
+ }
+
+ public double getY() {
+ return y;
+ }
+
+ public void setY(double y) {
+ this.y = y;
+ }
+
+ public double getZ() {
+ return z;
+ }
+
+ public void setZ(double z) {
+ this.z = z;
+ }
+
+
+}
diff --git a/src/vecmath/Tuple4d.java b/src/vecmath/Tuple4d.java
new file mode 100644
index 0000000..c2d45ef
--- /dev/null
+++ b/src/vecmath/Tuple4d.java
@@ -0,0 +1,494 @@
+// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
+// Jad home page: http://www.kpdus.com/jad.html
+// Decompiler options: packimports(3)
+// Source File Name: Tuple4d.java
+
+package vecmath;
+
+import java.io.Serializable;
+
+// Referenced classes of package javax.vecmath:
+// Tuple4f
+
+public abstract class Tuple4d
+ implements Serializable, Cloneable
+{
+
+ public Tuple4d(double d, double d1, double d2, double d3)
+ {
+ x = d;
+ y = d1;
+ z = d2;
+ w = d3;
+ }
+
+ public Tuple4d(double ad[])
+ {
+ x = ad[0];
+ y = ad[1];
+ z = ad[2];
+ w = ad[3];
+ }
+
+ public Tuple4d(Tuple4d tuple4d)
+ {
+ x = tuple4d.x;
+ y = tuple4d.y;
+ z = tuple4d.z;
+ w = tuple4d.w;
+ }
+
+// public Tuple4d(Tuple4f tuple4f)
+// {
+// x = tuple4f.x;
+// y = tuple4f.y;
+// z = tuple4f.z;
+// w = tuple4f.w;
+// }
+
+ public Tuple4d()
+ {
+ x = 0.0D;
+ y = 0.0D;
+ z = 0.0D;
+ w = 0.0D;
+ }
+
+ public final void set(double d, double d1, double d2, double d3)
+ {
+ x = d;
+ y = d1;
+ z = d2;
+ w = d3;
+ }
+
+ public final void set(double ad[])
+ {
+ x = ad[0];
+ y = ad[1];
+ z = ad[2];
+ w = ad[3];
+ }
+
+ public final void set(Tuple4d tuple4d)
+ {
+ x = tuple4d.x;
+ y = tuple4d.y;
+ z = tuple4d.z;
+ w = tuple4d.w;
+ }
+
+// public final void set(Tuple4f tuple4f)
+// {
+// x = tuple4f.x;
+// y = tuple4f.y;
+// z = tuple4f.z;
+// w = tuple4f.w;
+// }
+
+ public final void get(double ad[])
+ {
+ ad[0] = x;
+ ad[1] = y;
+ ad[2] = z;
+ ad[3] = w;
+ }
+
+ public final void get(Tuple4d tuple4d)
+ {
+ tuple4d.x = x;
+ tuple4d.y = y;
+ tuple4d.z = z;
+ tuple4d.w = w;
+ }
+
+ public final void add(Tuple4d tuple4d, Tuple4d tuple4d1)
+ {
+ x = tuple4d.x + tuple4d1.x;
+ y = tuple4d.y + tuple4d1.y;
+ z = tuple4d.z + tuple4d1.z;
+ w = tuple4d.w + tuple4d1.w;
+ }
+
+ public final void add(Tuple4d tuple4d)
+ {
+ x += tuple4d.x;
+ y += tuple4d.y;
+ z += tuple4d.z;
+ w += tuple4d.w;
+ }
+
+ public final void sub(Tuple4d tuple4d, Tuple4d tuple4d1)
+ {
+ x = tuple4d.x - tuple4d1.x;
+ y = tuple4d.y - tuple4d1.y;
+ z = tuple4d.z - tuple4d1.z;
+ w = tuple4d.w - tuple4d1.w;
+ }
+
+ public final void sub(Tuple4d tuple4d)
+ {
+ x -= tuple4d.x;
+ y -= tuple4d.y;
+ z -= tuple4d.z;
+ w -= tuple4d.w;
+ }
+
+ public final void negate(Tuple4d tuple4d)
+ {
+ x = -tuple4d.x;
+ y = -tuple4d.y;
+ z = -tuple4d.z;
+ w = -tuple4d.w;
+ }
+
+ public final void negate()
+ {
+ x = -x;
+ y = -y;
+ z = -z;
+ w = -w;
+ }
+
+ public final void scale(double d, Tuple4d tuple4d)
+ {
+ x = d * tuple4d.x;
+ y = d * tuple4d.y;
+ z = d * tuple4d.z;
+ w = d * tuple4d.w;
+ }
+
+ public final void scale(double d)
+ {
+ x *= d;
+ y *= d;
+ z *= d;
+ w *= d;
+ }
+
+ public final void scaleAdd(double d, Tuple4d tuple4d, Tuple4d tuple4d1)
+ {
+ x = d * tuple4d.x + tuple4d1.x;
+ y = d * tuple4d.y + tuple4d1.y;
+ z = d * tuple4d.z + tuple4d1.z;
+ w = d * tuple4d.w + tuple4d1.w;
+ }
+
+ /**
+ * @deprecated Method scaleAdd is deprecated
+ */
+
+ public final void scaleAdd(float f, Tuple4d tuple4d)
+ {
+ scaleAdd(f, tuple4d);
+ }
+
+ public final void scaleAdd(double d, Tuple4d tuple4d)
+ {
+ x = d * x + tuple4d.x;
+ y = d * y + tuple4d.y;
+ z = d * z + tuple4d.z;
+ w = d * w + tuple4d.w;
+ }
+
+ public String toString()
+ {
+ return "(" + x + ", " + y + ", " + z + ", " + w + ")";
+ }
+
+ public boolean equals(Tuple4d tuple4d)
+ {
+ try
+ {
+ return x == tuple4d.x && y == tuple4d.y && z == tuple4d.z && w == tuple4d.w;
+ }
+ catch(NullPointerException nullpointerexception)
+ {
+ return false;
+ }
+ }
+
+ public boolean equals(Object obj)
+ {
+ try
+ {
+ Tuple4d tuple4d = (Tuple4d)obj;
+ return x == tuple4d.x && y == tuple4d.y && z == tuple4d.z && w == tuple4d.w;
+ }
+ catch(NullPointerException nullpointerexception)
+ {
+ return false;
+ }
+ catch(ClassCastException classcastexception)
+ {
+ return false;
+ }
+ }
+
+ public boolean epsilonEquals(Tuple4d tuple4d, double d)
+ {
+ double d1 = x - tuple4d.x;
+ if((d1 >= 0.0D ? d1 : -d1) > d)
+ return false;
+ d1 = y - tuple4d.y;
+ if((d1 >= 0.0D ? d1 : -d1) > d)
+ return false;
+ d1 = z - tuple4d.z;
+ if((d1 >= 0.0D ? d1 : -d1) > d)
+ return false;
+ d1 = w - tuple4d.w;
+ return (d1 >= 0.0D ? d1 : -d1) <= d;
+ }
+
+ public int hashCode()
+ {
+ long l = 1L;
+ l = 31L * l + Double.doubleToLongBits(x);
+ l = 31L * l + Double.doubleToLongBits(y);
+ l = 31L * l + Double.doubleToLongBits(z);
+ l = 31L * l + Double.doubleToLongBits(w);
+ return (int)(l ^ l >> 32);
+ }
+
+ /**
+ * @deprecated Method clamp is deprecated
+ */
+
+ public final void clamp(float f, float f1, Tuple4d tuple4d)
+ {
+ clamp(f, f1, tuple4d);
+ }
+
+ public final void clamp(double d, double d1, Tuple4d tuple4d)
+ {
+ if(tuple4d.x > d1)
+ x = d1;
+ else
+ if(tuple4d.x < d)
+ x = d;
+ else
+ x = tuple4d.x;
+ if(tuple4d.y > d1)
+ y = d1;
+ else
+ if(tuple4d.y < d)
+ y = d;
+ else
+ y = tuple4d.y;
+ if(tuple4d.z > d1)
+ z = d1;
+ else
+ if(tuple4d.z < d)
+ z = d;
+ else
+ z = tuple4d.z;
+ if(tuple4d.w > d1)
+ w = d1;
+ else
+ if(tuple4d.w < d)
+ w = d;
+ else
+ w = tuple4d.w;
+ }
+
+ /**
+ * @deprecated Method clampMin is deprecated
+ */
+
+ public final void clampMin(float f, Tuple4d tuple4d)
+ {
+ clampMin(f, tuple4d);
+ }
+
+ public final void clampMin(double d, Tuple4d tuple4d)
+ {
+ if(tuple4d.x < d)
+ x = d;
+ else
+ x = tuple4d.x;
+ if(tuple4d.y < d)
+ y = d;
+ else
+ y = tuple4d.y;
+ if(tuple4d.z < d)
+ z = d;
+ else
+ z = tuple4d.z;
+ if(tuple4d.w < d)
+ w = d;
+ else
+ w = tuple4d.w;
+ }
+
+ /**
+ * @deprecated Method clampMax is deprecated
+ */
+
+ public final void clampMax(float f, Tuple4d tuple4d)
+ {
+ clampMax(f, tuple4d);
+ }
+
+ public final void clampMax(double d, Tuple4d tuple4d)
+ {
+ if(tuple4d.x > d)
+ x = d;
+ else
+ x = tuple4d.x;
+ if(tuple4d.y > d)
+ y = d;
+ else
+ y = tuple4d.y;
+ if(tuple4d.z > d)
+ z = d;
+ else
+ z = tuple4d.z;
+ if(tuple4d.w > d)
+ w = d;
+ else
+ w = tuple4d.z;
+ }
+
+ public final void absolute(Tuple4d tuple4d)
+ {
+ x = Math.abs(tuple4d.x);
+ y = Math.abs(tuple4d.y);
+ z = Math.abs(tuple4d.z);
+ w = Math.abs(tuple4d.w);
+ }
+
+ /**
+ * @deprecated Method clamp is deprecated
+ */
+
+ public final void clamp(float f, float f1)
+ {
+ clamp(f, f1);
+ }
+
+ public final void clamp(double d, double d1)
+ {
+ if(x > d1)
+ x = d1;
+ else
+ if(x < d)
+ x = d;
+ if(y > d1)
+ y = d1;
+ else
+ if(y < d)
+ y = d;
+ if(z > d1)
+ z = d1;
+ else
+ if(z < d)
+ z = d;
+ if(w > d1)
+ w = d1;
+ else
+ if(w < d)
+ w = d;
+ }
+
+ /**
+ * @deprecated Method clampMin is deprecated
+ */
+
+ public final void clampMin(float f)
+ {
+ clampMin(f);
+ }
+
+ public final void clampMin(double d)
+ {
+ if(x < d)
+ x = d;
+ if(y < d)
+ y = d;
+ if(z < d)
+ z = d;
+ if(w < d)
+ w = d;
+ }
+
+ /**
+ * @deprecated Method clampMax is deprecated
+ */
+
+ public final void clampMax(float f)
+ {
+ clampMax(f);
+ }
+
+ public final void clampMax(double d)
+ {
+ if(x > d)
+ x = d;
+ if(y > d)
+ y = d;
+ if(z > d)
+ z = d;
+ if(w > d)
+ w = d;
+ }
+
+ public final void absolute()
+ {
+ x = Math.abs(x);
+ y = Math.abs(y);
+ z = Math.abs(z);
+ w = Math.abs(w);
+ }
+
+ /**
+ * @deprecated Method interpolate is deprecated
+ */
+
+ public void interpolate(Tuple4d tuple4d, Tuple4d tuple4d1, float f)
+ {
+ interpolate(tuple4d, tuple4d1, f);
+ }
+
+ public void interpolate(Tuple4d tuple4d, Tuple4d tuple4d1, double d)
+ {
+ x = (1.0D - d) * tuple4d.x + d * tuple4d1.x;
+ y = (1.0D - d) * tuple4d.y + d * tuple4d1.y;
+ z = (1.0D - d) * tuple4d.z + d * tuple4d1.z;
+ w = (1.0D - d) * tuple4d.w + d * tuple4d1.w;
+ }
+
+ /**
+ * @deprecated Method interpolate is deprecated
+ */
+
+ public void interpolate(Tuple4d tuple4d, float f)
+ {
+ interpolate(tuple4d, f);
+ }
+
+ public void interpolate(Tuple4d tuple4d, double d)
+ {
+ x = (1.0D - d) * x + d * tuple4d.x;
+ y = (1.0D - d) * y + d * tuple4d.y;
+ z = (1.0D - d) * z + d * tuple4d.z;
+ w = (1.0D - d) * w + d * tuple4d.w;
+ }
+
+ public Object clone()
+ {
+ try
+ {
+ return super.clone();
+ }
+ catch(CloneNotSupportedException clonenotsupportedexception)
+ {
+ throw new InternalError();
+ }
+ }
+
+ static final long serialVersionUID = 0xbe1853c7936b40b4L;
+ public double x;
+ public double y;
+ public double z;
+ public double w;
+}
diff --git a/src/vecmath/VecMathI18N.java b/src/vecmath/VecMathI18N.java
new file mode 100644
index 0000000..0980c71
--- /dev/null
+++ b/src/vecmath/VecMathI18N.java
@@ -0,0 +1,33 @@
+// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
+// Jad home page: http://www.kpdus.com/jad.html
+// Decompiler options: packimports(3)
+// Source File Name: VecMathI18N.java
+
+package vecmath;
+
+import java.io.PrintStream;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+class VecMathI18N
+{
+
+ VecMathI18N()
+ {
+ }
+
+ static String getString(String s)
+ {
+ String s1;
+ try
+ {
+ s1 = ResourceBundle.getBundle("javax.vecmath.ExceptionStrings").getString(s);
+ }
+ catch(MissingResourceException missingresourceexception)
+ {
+ System.err.println("VecMathI18N: Error looking up: " + s);
+ s1 = s;
+ }
+ return s1;
+ }
+}
diff --git a/src/vecmath/Vector3d.java b/src/vecmath/Vector3d.java
new file mode 100644
index 0000000..f1873f6
--- /dev/null
+++ b/src/vecmath/Vector3d.java
@@ -0,0 +1,102 @@
+// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
+// Jad home page: http://www.kpdus.com/jad.html
+// Decompiler options: packimports(3)
+// Source File Name: Vector3d.java
+
+package vecmath;
+
+import java.io.Serializable;
+
+// Referenced classes of package javax.vecmath:
+// Tuple3d, Vector3f, Tuple3f
+
+public class Vector3d extends Tuple3d
+ implements Serializable
+{
+
+ public Vector3d(double d, double d1, double d2)
+ {
+ super(d, d1, d2);
+ }
+
+ public Vector3d(double ad[])
+ {
+ super(ad);
+ }
+
+ public Vector3d(Vector3d vector3d)
+ {
+ super(vector3d);
+ }
+
+// public Vector3d(Vector3f vector3f)
+// {
+// super(vector3f);
+// }
+
+// public Vector3d(Tuple3f tuple3f)
+// {
+// super(tuple3f);
+// }
+
+ public Vector3d(Tuple3d tuple3d)
+ {
+ super(tuple3d);
+ }
+
+ public Vector3d()
+ {
+ }
+
+ public final void cross(Vector3d vector3d, Vector3d vector3d1)
+ {
+ double d = vector3d.y * vector3d1.z - vector3d.z * vector3d1.y;
+ double d1 = vector3d1.x * vector3d.z - vector3d1.z * vector3d.x;
+ z = vector3d.x * vector3d1.y - vector3d.y * vector3d1.x;
+ x = d;
+ y = d1;
+ }
+
+ public final void normalize(Vector3d vector3d)
+ {
+ double d = 1.0D / Math.sqrt(vector3d.x * vector3d.x + vector3d.y * vector3d.y + vector3d.z * vector3d.z);
+ x = vector3d.x * d;
+ y = vector3d.y * d;
+ z = vector3d.z * d;
+ }
+
+ public final void normalize()
+ {
+ double d = 1.0D / Math.sqrt(x * x + y * y + z * z);
+ x *= d;
+ y *= d;
+ z *= d;
+ }
+
+ public final double dot(Vector3d vector3d)
+ {
+ return x * vector3d.x + y * vector3d.y + z * vector3d.z;
+ }
+
+ public final double lengthSquared()
+ {
+ return x * x + y * y + z * z;
+ }
+
+ public final double length()
+ {
+ return Math.sqrt(x * x + y * y + z * z);
+ }
+
+ public final double angle(Vector3d vector3d)
+ {
+ double d = dot(vector3d) / (length() * vector3d.length());
+ if(d < -1D)
+ d = -1D;
+ if(d > 1.0D)
+ d = 1.0D;
+ return Math.acos(d);
+ }
+
+ static final long serialVersionUID = 0x343533bc7f4d2f2aL;
+}
diff --git a/src/vecmath/Vector4d.java b/src/vecmath/Vector4d.java
new file mode 100644
index 0000000..c08a9ca
--- /dev/null
+++ b/src/vecmath/Vector4d.java
@@ -0,0 +1,108 @@
+// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
+// Jad home page: http://www.kpdus.com/jad.html
+// Decompiler options: packimports(3)
+// Source File Name: Vector4d.java
+
+package vecmath;
+
+import java.io.Serializable;
+
+// Referenced classes of package javax.vecmath:
+// Tuple4d, Tuple3d, Vector4f, Tuple4f
+
+public class Vector4d extends Tuple4d
+ implements Serializable
+{
+
+ public Vector4d(double d, double d1, double d2, double d3)
+ {
+ super(d, d1, d2, d3);
+ }
+
+ public Vector4d(double ad[])
+ {
+ super(ad);
+ }
+
+ public Vector4d(Vector4d vector4d)
+ {
+ super(vector4d);
+ }
+
+// public Vector4d(Vector4f vector4f)
+// {
+// super(vector4f);
+// }
+//
+// public Vector4d(Tuple4f tuple4f)
+// {
+// super(tuple4f);
+// }
+
+ public Vector4d(Tuple4d tuple4d)
+ {
+ super(tuple4d);
+ }
+
+// public Vector4d(Tuple3d tuple3d)
+// {
+// super(tuple3d.x, tuple3d.y, tuple3d.z, 0.0D);
+// }
+
+ public Vector4d()
+ {
+ }
+
+// public final void set(Tuple3d tuple3d)
+// {
+// x = tuple3d.x;
+// y = tuple3d.y;
+// z = tuple3d.z;
+// w = 0.0D;
+// }
+
+ public final double length()
+ {
+ return Math.sqrt(x * x + y * y + z * z + w * w);
+ }
+
+ public final double lengthSquared()
+ {
+ return x * x + y * y + z * z + w * w;
+ }
+
+ public final double dot(Vector4d vector4d)
+ {
+ return x * vector4d.x + y * vector4d.y + z * vector4d.z + w * vector4d.w;
+ }
+
+ public final void normalize(Vector4d vector4d)
+ {
+ double d = 1.0D / Math.sqrt(vector4d.x * vector4d.x + vector4d.y * vector4d.y + vector4d.z * vector4d.z + vector4d.w * vector4d.w);
+ x = vector4d.x * d;
+ y = vector4d.y * d;
+ z = vector4d.z * d;
+ w = vector4d.w * d;
+ }
+
+ public final void normalize()
+ {
+ double d = 1.0D / Math.sqrt(x * x + y * y + z * z + w * w);
+ x *= d;
+ y *= d;
+ z *= d;
+ w *= d;
+ }
+
+ public final double angle(Vector4d vector4d)
+ {
+ double d = dot(vector4d) / (length() * vector4d.length());
+ if(d < -1D)
+ d = -1D;
+ if(d > 1.0D)
+ d = 1.0D;
+ return Math.acos(d);
+ }
+
+ static final long serialVersionUID = 0x36a70663a02a5ffcL;
+}