diff --git a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/PlayerFragment.java b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/PlayerFragment.java index 86aa3d8..becbb3a 100644 --- a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/PlayerFragment.java +++ b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/PlayerFragment.java @@ -22,7 +22,10 @@ import org.ntlab.radishforandroidstudio.framework.model3D.ModelFactory; import org.ntlab.radishforandroidstudio.framework.model3D.Object3D; import org.ntlab.radishforandroidstudio.framework.model3D.Position3D; +import org.ntlab.radishforandroidstudio.framework.physics.AngularVelocity3D; import org.ntlab.radishforandroidstudio.framework.physics.Ground; +import org.ntlab.radishforandroidstudio.framework.physics.PhysicalSystem; +import org.ntlab.radishforandroidstudio.framework.physics.Solid3D; import org.ntlab.radishforandroidstudio.framework.physics.Velocity3D; import org.ntlab.radishforandroidstudio.java3d.AmbientLight; import org.ntlab.radishforandroidstudio.java3d.Appearance; @@ -32,6 +35,7 @@ import org.ntlab.radishforandroidstudio.java3d.Material; import org.ntlab.radishforandroidstudio.java3d.TextureCubeMap; import org.ntlab.radishforandroidstudio.java3d.TextureLoader; +import org.ntlab.radishforandroidstudio.java3d.Transform3D; import org.ntlab.radishforandroidstudio.java3d.Vector3d; import org.ntlab.radishforandroidstudio.java3d.Vector3f; @@ -44,6 +48,9 @@ private float touchY = 0.0f; RWTPad pad = null; private Player player; + private PhysicalSystem physicalSystem; + private Transform3D initTrans; + private Solid3D diceObj; public PlayerFragment() { // Required empty public constructor @@ -104,11 +111,8 @@ } catch (Exception e) { e.printStackTrace(); } - //オブジェクトの生成 + // サイコロの作成 Appearance ap3 = new Appearance(); - Material material = new Material(); - m.setDiffuseColor(1.0f, 1.0f, 1.0f); - ap3.setMaterial(m); TextureCubeMap tex1 = new TextureCubeMap(TextureCubeMap.BASE_LEVEL, TextureCubeMap.RGB, 0); TextureLoader loader = new TextureLoader(getResources(), R.drawable.dice_1, TextureLoader.BY_REFERENCE | TextureLoader.Y_UP); tex1.setImage(0, TextureCubeMap.POSITIVE_Z, loader.getImage()); @@ -123,17 +127,22 @@ loader = new TextureLoader(getResources(), R.drawable.dice_2, TextureLoader.BY_REFERENCE | TextureLoader.Y_UP); tex1.setImage(0, TextureCubeMap.NEGATIVE_Y, loader.getImage()); ap3.setTexture(tex1); + physicalSystem = new PhysicalSystem(); Box b1 = new Box(1.0f, 1.0f, 1.0f, ap3); - final Object3D obj1 = new Object3D("box", b1); - obj1.scale(100.0, 100.0, 100.0); - obj1.apply(new Position3D(0.0 , 300.0, 0.0), false); - OvergroundActor obj_actor = new OvergroundActor(obj1, null); - universe.place(obj_actor); - + Object3D obj1 = new Object3D("box", b1); + obj1.apply(new Position3D(0.0 , -100.0, 350.0), false); + diceObj = new Solid3D(obj1); + diceObj.scale(100.0, 100.0, 100.0); + diceObj.apply(new AngularVelocity3D(-0.4, 0.0, -0.6), false); + universe.place(diceObj); + physicalSystem.add(diceObj); + initTrans = new Transform3D(); + obj1.rot.getTransform(initTrans); + //カメラの設定(視点) camera.setViewPoint(pocha.getPosition().add(0.0, 1.5, 0.0)); camera.setViewLine(pocha.getDirection()); - + camera.addTarget(diceObj); camera.setFieldOfView(1.5); camera.setBackClipDistance(10000.0); start(1000L, 50L, true);