diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser
index 0e9093e..2f45dc9 100644
--- a/.idea/caches/build_file_checksums.ser
+++ b/.idea/caches/build_file_checksums.ser
Binary files differ
diff --git a/app/build.gradle b/app/build.gradle
index e97b488..02b0f1a 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -30,7 +30,7 @@
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
- implementation 'com.android.support.constraint:constraint-layout:1.1.0'
+ implementation 'com.android.support.constraint:constraint-layout:1.1.1'
implementation 'com.android.support:support-v4:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 698b143..a083902 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -23,6 +23,16 @@
+
+
+
+
+
+
+
+
@@ -30,26 +40,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/PlayerActivity.java b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/PlayerActivity.java
deleted file mode 100644
index 1216892..0000000
--- a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/PlayerActivity.java
+++ /dev/null
@@ -1,202 +0,0 @@
-package org.ntlab.radishforandroidstudio.cactusClient;
-
-import android.annotation.SuppressLint;
-
-import android.os.Bundle;
-
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentTransaction;
-import android.view.MotionEvent;
-
-import android.view.View;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
-
-import org.ntlab.radishforandroidstudio.R;
-import org.ntlab.radishforandroidstudio.framework.RWT.RWTPad;
-import org.ntlab.radishforandroidstudio.framework.RWT.RWTSurfaceView;
-import org.ntlab.radishforandroidstudio.framework.RWT.RWTUIFragment;
-import org.ntlab.radishforandroidstudio.framework.animation.Animation3D;
-import org.ntlab.radishforandroidstudio.framework.event.PadEvent;
-import org.ntlab.radishforandroidstudio.framework.gameMain.OvergroundActor;
-import org.ntlab.radishforandroidstudio.framework.gameMain.RealTime3DActivity;
-import org.ntlab.radishforandroidstudio.framework.listener.PadListener;
-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.Ground;
-import org.ntlab.radishforandroidstudio.framework.physics.Velocity3D;
-import org.ntlab.radishforandroidstudio.java3d.AmbientLight;
-import org.ntlab.radishforandroidstudio.java3d.Appearance;
-import org.ntlab.radishforandroidstudio.java3d.Color3f;
-import org.ntlab.radishforandroidstudio.java3d.DirectionalLight;
-import org.ntlab.radishforandroidstudio.java3d.Material;
-import org.ntlab.radishforandroidstudio.java3d.Vector3d;
-import org.ntlab.radishforandroidstudio.java3d.Vector3f;
-
-
-public class PlayerActivity extends RealTime3DActivity implements PadListener {
- private OvergroundActor pocha;
- private Ground stage;
- private boolean isTouched = false;
- private float touchX = 0.0f;
- private float touchY = 0.0f;
- RWTPad pad = null;
-
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
-
- //環境光
- AmbientLight amblight = new AmbientLight(new Color3f(1.0f, 1.0f, 1.0f));
-
-// amblight.setInfluencingBounds(new BoundingSphere(new Point3d(), 10000.0));
- universe.placeLight(amblight);
-
- //平行光源
- DirectionalLight dirlight = new DirectionalLight(
- new Color3f(1.0f, 1.0f, 1.0f), //光の色
- new Vector3f(0.0f, -1.0f, -0.5f) //光の方向ベクトル
- );
-// dirlight.setInfluencingBounds(new BoundingSphere(new Point3d(), 10000.0));
- universe.placeLight(dirlight);
-
- Appearance ap1 = new Appearance();
- Material m = new Material();
- m.setDiffuseColor(0.0f, 0.3f, 1.0f);
- m.setAmbientColor(0.0f, 0.0f, 0.0f);
- m.setEmissiveColor(0.0f, 0.0f, 0.0f);
- m.setSpecularColor(0.0f, 0.0f, 0.0f);
- m.setShininess(5.0f);
- ap1.setMaterial(m);
-
- Object3D pochaBody = null;
- try {
- pochaBody = ModelFactory.loadModel(getResources(), "pocha.stl", ap1).createObject();
- Animation3D pochaAnimation = null; //AnimationFactory.loadAnimation("data\\pocha\\walk.wrl");
- pocha = new OvergroundActor(pochaBody, pochaAnimation);
- pocha.setPosition(new Position3D(0.0, -100.0, 250.0));
- universe.place(pocha);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- Appearance ap2 = new Appearance();
- Material m2 = new Material();
- m2.setDiffuseColor(0.1f, 0.0f, 0.02f);
- m2.setAmbientColor(0.1f, 0.1f, 0.1f);
- m2.setEmissiveColor(0.0f, 0.0f, 0.0f);
- m2.setSpecularColor(0.2f, 0.2f, 0.2f);
- m2.setShininess(5.0f);
- ap2.setMaterial(m2);
-
- Object3D stageObj = null;
- try {
- stageObj = ModelFactory.loadModel(getResources(), "konan/konan.obj").createObject();
- stage = new Ground(stageObj);
- universe.place(stage);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- //pad 追加部分
-
- setContentView(R.layout.fragment_real_time_3d);
-
- FrameLayout l = findViewById(R.id.game_layout);
- view = new RWTSurfaceView(this);
- view.attachCamera(camera);
- l.addView(view, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
-
- FragmentManager fragmentManager = getSupportFragmentManager();
- FragmentTransaction transaction = fragmentManager.beginTransaction();
- RWTUIFragment f = new RWTUIFragment();
- f.setListener(this);
- View uiLayout = (View) findViewById(R.id.ui_layout);
- uiLayout.setOnTouchListener((RWTUIFragment) f);
- transaction.add(R.id.ui_layout, f);
- transaction.commit();
-
-
- /*camera.setViewPoint(pocha.getPosition().add(0.0, 1.5, 0.0));
- camera.setViewLine(pocha.getDirection());
- camera.setFieldOfView(1.5);
- camera.setBackClipDistance(10000.0);*/
- start(1000L, 50L, true);
- }
-
- @Override
- public void progress(long interval) {
- Velocity3D curV = pocha.getVelocity();
- if (isTouched) {
- pocha.rotY(0.001 * (0.5f - touchX) * (double) (interval / 15.0));
- curV.setX(pocha.getDirection().getX() * 200.0 * (0.5f - touchY));
- curV.setZ(pocha.getDirection().getZ() * 200.0 * (0.5f - touchX));
- pocha.setVelocity(curV);
-
- } else {
- curV.setX(0.0);
- curV.setZ(0.0);
- pocha.setVelocity(curV);
- }
-
-
- Vector3d charaVector3d = pocha.getDirection();
- charaVector3d.normalize();//キャラの向きを単位ベクトルに
- camera.setViewPoint(pocha.getPosition()
- .add(-5.0 * charaVector3d.getX(), charaVector3d.getY() + 5.0, -5.0 * charaVector3d.getZ()));//視点
- camera.setViewLine(new Vector3d(5.0 * charaVector3d.getX(), charaVector3d.getY() - 2.5, 5.0 * charaVector3d.getZ() + touchX));//視線
- }
-
-
- @SuppressLint("NewApi")
- /*@Override
- public boolean onTouchEvent (MotionEvent event){
- Vector3d charaVector3d = pocha.getDirection();
- charaVector3d.normalize();//キャラの向きを単位ベクトルに
- super.onTouchEvent(event);
-
- if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) {
- isTouched = true;
- float maxX = event.getDevice().getMotionRange(MotionEvent.AXIS_X).getMax() / 2.0f;
- float minX = event.getDevice().getMotionRange(MotionEvent.AXIS_X).getMin();
- float maxY = event.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMax();
- float minY = event.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMin();
- } else if (event.getAction() == MotionEvent.ACTION_UP) {
- isTouched = false;
- }
- return true;
- }*/
-
- public void onCreateFragmentEvent(RWTUIFragment f) {
- pad = (RWTPad) f.findViewById(org.ntlab.radishforandroidstudio.R.id.pad);
- pad.addListener(this);
- }
-
- @Override
- public boolean onEvent(PadEvent event) {
- Vector3d charaVector3d = pocha.getDirection();
- charaVector3d.normalize();//キャラの向きを単位ベクトルに
- MotionEvent motionEvent = event.getMotionEvent();
- super.onTouchEvent(motionEvent);
-
- if (motionEvent.getAction() == MotionEvent.ACTION_DOWN || motionEvent.getAction() == MotionEvent.ACTION_MOVE) {
- isTouched = true;
- float maxX = motionEvent.getDevice().getMotionRange(MotionEvent.AXIS_X).getMax() / 2.0f;
- float minX = motionEvent.getDevice().getMotionRange(MotionEvent.AXIS_X).getMin();
- float maxY = motionEvent.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMax();
- float minY = motionEvent.getDevice().getMotionRange(MotionEvent.AXIS_Y).getMin();
- touchX = (float) (Math.cos(event.getAngle()) * event.getLength());
- touchY = (float) (Math.sin(event.getAngle()) * event.getLength());
-
- //motion.eventをevent.getLengthみたいに変えればいい?
- //touchYのもとは(motionEvent.getY() - minY) / (maxY - minY),X (motionEvent.getX() - minX) / (maxX - minX)
- camera.setViewPoint(pocha.getPosition()
- .add(-5.0 * charaVector3d.getX(), charaVector3d.getY() + 5.0, -5.0 * charaVector3d.getZ()));//視点
- camera.setViewLine(new Vector3d(5.0 * charaVector3d.getX(), charaVector3d.getY() - 2.5, 5.0 * charaVector3d.getZ() + touchX));//視線
- } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
- isTouched = false;
- }
- return false;
- }
-}
diff --git a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/tests/StartFragment.java b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/tests/StartFragment.java
index b56b11f..61c2011 100644
--- a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/tests/StartFragment.java
+++ b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/tests/StartFragment.java
@@ -11,6 +11,7 @@
import android.widget.Button;
import org.ntlab.radishforandroidstudio.R;
+import org.ntlab.radishforandroidstudio.cactusClient.views.PlayerFragment;
public class StartFragment extends Fragment {
@@ -33,7 +34,8 @@
FragmentTransaction transaction = manager.beginTransaction();
// transaction.replace(R.id.framelayout_field, new SampleUiFragment());
// transaction.replace(R.id.framelayout_field, new SampleGameFragment());
- transaction.replace(R.id.framelayout_field,new SampleGame2Fragment());
+// transaction.replace(R.id.framelayout_field,new SampleGame2Fragment());
+ transaction.replace(R.id.framelayout_field,new PlayerFragment());
transaction.addToBackStack(null);
transaction.commit();
}
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
new file mode 100644
index 0000000..2e89066
--- /dev/null
+++ b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/PlayerFragment.java
@@ -0,0 +1,184 @@
+package org.ntlab.radishforandroidstudio.cactusClient.views;
+
+
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+
+import org.ntlab.radishforandroidstudio.R;
+import org.ntlab.radishforandroidstudio.framework.RWT.RWTPad;
+import org.ntlab.radishforandroidstudio.framework.RWT.RWTSurfaceView;
+import org.ntlab.radishforandroidstudio.framework.RWT.RWTUIFragment;
+import org.ntlab.radishforandroidstudio.framework.animation.Animation3D;
+import org.ntlab.radishforandroidstudio.framework.event.PadEvent;
+import org.ntlab.radishforandroidstudio.framework.gameMain.OvergroundActor;
+import org.ntlab.radishforandroidstudio.framework.gameMain.RealTime3DFragment;
+import org.ntlab.radishforandroidstudio.framework.listener.PadListener;
+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.Ground;
+import org.ntlab.radishforandroidstudio.framework.physics.Velocity3D;
+import org.ntlab.radishforandroidstudio.java3d.AmbientLight;
+import org.ntlab.radishforandroidstudio.java3d.Appearance;
+import org.ntlab.radishforandroidstudio.java3d.Color3f;
+import org.ntlab.radishforandroidstudio.java3d.DirectionalLight;
+import org.ntlab.radishforandroidstudio.java3d.Material;
+import org.ntlab.radishforandroidstudio.java3d.Vector3d;
+import org.ntlab.radishforandroidstudio.java3d.Vector3f;
+
+public class PlayerFragment extends RealTime3DFragment implements PadListener {
+ private OvergroundActor pocha;
+ private Ground stage;
+ private boolean isTouched = false;
+ private float touchX = 0.0f;
+ private float touchY = 0.0f;
+ RWTPad pad = null;
+
+ public PlayerFragment() {
+ // Required empty public constructor
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+
+ super.onCreate(savedInstanceState);
+ //環境光
+ AmbientLight amblight = new AmbientLight(new Color3f(1.0f, 1.0f, 1.0f));
+
+// amblight.setInfluencingBounds(new BoundingSphere(new Point3d(), 10000.0));
+ universe.placeLight(amblight);
+
+ //平行光源
+ DirectionalLight dirlight = new DirectionalLight(
+ new Color3f(1.0f, 1.0f, 1.0f), //光の色
+ new Vector3f(0.0f, -1.0f, -0.5f) //光の方向ベクトル
+ );
+// dirlight.setInfluencingBounds(new BoundingSphere(new Point3d(), 10000.0));
+ universe.placeLight(dirlight);
+
+ Appearance ap1 = new Appearance();
+ Material m = new Material();
+ m.setDiffuseColor(0.0f, 0.3f, 1.0f);
+ m.setAmbientColor(0.0f, 0.0f, 0.0f);
+ m.setEmissiveColor(0.0f, 0.0f, 0.0f);
+ m.setSpecularColor(0.0f, 0.0f, 0.0f);
+ m.setShininess(5.0f);
+ ap1.setMaterial(m);
+
+ Object3D pochaBody = null;
+ try {
+ pochaBody = ModelFactory.loadModel(getResources(), "pocha.stl", ap1).createObject();
+ Animation3D pochaAnimation = null; //AnimationFactory.loadAnimation("data\\pocha\\walk.wrl");
+ pocha = new OvergroundActor(pochaBody, pochaAnimation);
+ pocha.setPosition(new Position3D(0.0, -100.0, 250.0));
+ universe.place(pocha);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ Appearance ap2 = new Appearance();
+ Material m2 = new Material();
+ m2.setDiffuseColor(0.1f, 0.0f, 0.02f);
+ m2.setAmbientColor(0.1f, 0.1f, 0.1f);
+ m2.setEmissiveColor(0.0f, 0.0f, 0.0f);
+ m2.setSpecularColor(0.2f, 0.2f, 0.2f);
+ m2.setShininess(5.0f);
+ ap2.setMaterial(m2);
+
+ Object3D stageObj = null;
+ try {
+ stageObj = ModelFactory.loadModel(getResources(), "konan/konan.obj").createObject();
+ stage = new Ground(stageObj);
+ universe.place(stage);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ camera.setViewPoint(pocha.getPosition().add(0.0, 1.5, 0.0));
+ camera.setViewLine(pocha.getDirection());
+ camera.setFieldOfView(1.5);
+ camera.setBackClipDistance(10000.0);
+ start(1000L, 50L, true);
+ }
+
+
+ @Nullable
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ super.onCreateView(inflater, container, savedInstanceState);
+ initGameWindowView();
+ return parentView;
+ }
+
+ @Override
+ protected void progress(long interval) {
+ Velocity3D curV = pocha.getVelocity();
+ if (isTouched) {
+ pocha.rotY(0.1 * (0.5f - touchX) * (double) (interval / 15.0));
+ curV.setX(pocha.getDirection().getX() * 200.0 * (0.5f - touchY));
+ curV.setZ(pocha.getDirection().getZ() * 200.0 * (0.5f - touchY));
+ pocha.setVelocity(curV);
+ } else {
+ curV.setX(0.0);
+ curV.setZ(0.0);
+ pocha.setVelocity(curV);
+ }
+ Vector3d charaVector3d = pocha.getDirection();
+ charaVector3d.normalize();//キャラの向きを単位ベクトルに
+ camera.setViewPoint(pocha.getPosition()
+ .add(-5.0 * charaVector3d.getX(), charaVector3d.getY() + 5.0, -5.0 * charaVector3d.getZ()));//視点
+ camera.setViewLine(new Vector3d(5.0 * charaVector3d.getX(), charaVector3d.getY() - 2.5, 5.0 * charaVector3d.getZ() + touchX));//視線
+ }
+
+
+ //sampleUiFragmentからそのまま持ってきた
+ public void initGameWindowView() {
+ FragmentManager fragmentManager = getFragmentManager();
+ FragmentTransaction transaction = fragmentManager.beginTransaction();
+
+ RWTUIFragment f = new RWTUIFragment();
+ f.setListener(this);
+ View uiLayout = parentView.findViewById(R.id.ui_layout);
+ uiLayout.setOnTouchListener(f);
+ transaction.add(R.id.ui_layout, f);
+ transaction.commit();
+ }
+
+ public void onCreateFragmentEvent(RWTUIFragment f) {
+ pad = (RWTPad) f.findViewById(org.ntlab.radishforandroidstudio.R.id.pad);
+ pad.addListener((PadListener) this);
+ }
+
+ @Override
+ public boolean onEvent(PadEvent event) {
+ Vector3d charaVector3d = pocha.getDirection();
+ charaVector3d.normalize();//キャラの向きを単位ベクトルに
+ MotionEvent motionEvent = event.getMotionEvent();
+
+ if (motionEvent.getAction() == MotionEvent.ACTION_DOWN || motionEvent.getAction() == MotionEvent.ACTION_MOVE) {
+ isTouched = true;
+ touchX = (float) (Math.cos(event.getAngle()) * event.getLength());
+ touchY = (float) (Math.sin(event.getAngle()) * event.getLength());
+
+ //motion.eventをevent.getLengthみたいに変えればいい?
+ //touchYのもとは(motionEvent.getY() - minY) / (maxY - minY),X (motionEvent.getX() - minX) / (maxX - minX)
+ camera.setViewPoint(pocha.getPosition()
+ .add(-5.0 * charaVector3d.getX(), charaVector3d.getY() + 5.0, -5.0 * charaVector3d.getZ()));//視点
+ camera.setViewLine(new Vector3d(5.0 * charaVector3d.getX(), charaVector3d.getY() - 2.5, 5.0 * charaVector3d.getZ() + touchX));//視線
+ } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
+ isTouched = false;
+ }
+ return false;
+ }
+}
+
diff --git a/app/src/main/java/org/ntlab/radishforandroidstudio/framework/RWT/RWTUIFragment.java b/app/src/main/java/org/ntlab/radishforandroidstudio/framework/RWT/RWTUIFragment.java
index 67e4e74..5082cd9 100644
--- a/app/src/main/java/org/ntlab/radishforandroidstudio/framework/RWT/RWTUIFragment.java
+++ b/app/src/main/java/org/ntlab/radishforandroidstudio/framework/RWT/RWTUIFragment.java
@@ -10,14 +10,14 @@
import org.ntlab.radishforandroidstudio.R;
-import org.ntlab.radishforandroidstudio.cactusClient.PlayerActivity;
+import org.ntlab.radishforandroidstudio.cactusClient.views.PlayerFragment;
import org.ntlab.radishforandroidstudio.framework.event.PadEvent;
import org.ntlab.radishforandroidstudio.framework.listener.PadListener;
import static android.view.View.*;
public class RWTUIFragment extends Fragment implements OnTouchListener,PadListener {
- PlayerActivity listener = null;
+ PlayerFragment listener = null;
View v = null;
public RWTUIFragment() {}
@@ -52,12 +52,11 @@
return false;
}
- public void setListener(PlayerActivity activity) {
- listener = activity;
- }
-
public View findViewById(int id) {
return v.findViewById(id);
}
+ public void setListener(PlayerFragment playerFragment) {
+ listener = playerFragment;
+ }
}
diff --git a/app/src/main/res/layout/fragment_player.xml b/app/src/main/res/layout/fragment_player.xml
new file mode 100644
index 0000000..40446a1
--- /dev/null
+++ b/app/src/main/res/layout/fragment_player.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
\ No newline at end of file