diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 4c5bc7b..163eec3 100644 --- a/.idea/caches/build_file_checksums.ser +++ b/.idea/caches/build_file_checksums.ser Binary files differ 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 8a269d2..3dc1709 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,13 +22,20 @@ 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; +import org.ntlab.radishforandroidstudio.java3d.Box; import org.ntlab.radishforandroidstudio.java3d.Color3f; import org.ntlab.radishforandroidstudio.java3d.DirectionalLight; 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; @@ -40,7 +47,10 @@ private float touchX = 0.0f; private float touchY = 0.0f; RWTPad pad = null; - double n=1.0; + double n = 1.0; + private PhysicalSystem physicalSystem; + private Transform3D initTrans; + private Solid3D diceObj; public PlayerFragment() { // Required empty public constructor @@ -83,6 +93,7 @@ e.printStackTrace(); } + //甲南ステージの生成 Appearance ap2 = new Appearance(); Material m2 = new Material(); m2.setDiffuseColor(0.1f, 0.0f, 0.02f); @@ -101,6 +112,41 @@ e.printStackTrace(); } + Appearance ap3 = new Appearance(); + 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()); + loader = new TextureLoader(getResources(), R.drawable.dice_6, TextureLoader.BY_REFERENCE | TextureLoader.Y_UP); + tex1.setImage(0, TextureCubeMap.NEGATIVE_Z, loader.getImage()); + loader = new TextureLoader(getResources(), R.drawable.dice_4, TextureLoader.BY_REFERENCE | TextureLoader.Y_UP); + tex1.setImage(0, TextureCubeMap.POSITIVE_X, loader.getImage()); + loader = new TextureLoader(getResources(), R.drawable.dice_3, TextureLoader.BY_REFERENCE | TextureLoader.Y_UP); + tex1.setImage(0, TextureCubeMap.NEGATIVE_X, loader.getImage()); + loader = new TextureLoader(getResources(), R.drawable.dice_5, TextureLoader.BY_REFERENCE | TextureLoader.Y_UP); + tex1.setImage(0, TextureCubeMap.POSITIVE_Y, loader.getImage()); + 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); + Object3D obj1 = new Object3D("box", b1); + //設置のみの時のオブジェクトの初期値 + obj1.apply(new Position3D(0.0, -118.0, 250.0), false); + //地面との当たり判定の時のオブジェクトの初期値 +// obj1.apply(new Position3D(0.0, -80.0, 250.0), false); + diceObj = new Solid3D(obj1); + diceObj.scale(1.0, 1.0, 1.0); + diceObj.apply(new AngularVelocity3D(-0.4, 0.0, -0.6), false); +// OvergroundActor actor = new OvergroundActor(obj1, null); + //地面との当たり判定するとき +// universe.place(actor); + //地面との当たり判定しないとき + 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.setFieldOfView(1.5); @@ -144,13 +190,13 @@ protected void progress(long interval) { Velocity3D curV = pocha.getVelocity(); Vector3d charaVector3d = pocha.getDirection(); - Vector3d up = new Vector3d(0,1,0); + Vector3d up = new Vector3d(0, 1, 0); Vector3d total = new Vector3d(); Vector3d right = new Vector3d(); if (isPadTouched) { - right.cross(charaVector3d,up); + right.cross(charaVector3d, up); Vector3d touchX3d = right.clone(); Vector3d touchY3d = charaVector3d.clone(); touchX3d.scale(touchX * -20); @@ -168,7 +214,7 @@ @Override public void onClick(View v) { - if(pocha.isOnGround()) { + if (pocha.isOnGround()) { total.y = curV.getY() + 15; //Yをもとどおりに! curV.setVector3d(total); pocha.setVelocity(curV);//pochaの追跡 @@ -178,14 +224,14 @@ } else if (isTouched) { pocha.rotY(0.1 * (0.5f - touchX)); - if(n <= 5 && n >= 0){ + if (n <= 5 && n >= 0) { n += (0.5f - touchY); - }else if (n >5){ + } else if (n > 5) { n = 5; - }else if (n < 0){ + } else if (n < 0) { n = 0; } - + } else { curV.setX(0.0); curV.setZ(0.0); @@ -195,7 +241,7 @@ // 向き設定 camera.setViewPoint(pocha.getPosition().add(5.0 * charaVector3d.getX(), charaVector3d.getY() + 5.5 - n, 5.0 * charaVector3d.getZ()));//視点 camera.setViewLine(new Vector3d(-5.0 * charaVector3d.getX(), charaVector3d.getY() - 2.5 + n, -5.0 * charaVector3d.getZ()));//視線 -} + } //sampleUiFragmentからそのまま持ってきた public void initGameWindowView() {