diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index 97f911f..675c8ed 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/PlayerActivity.java b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/PlayerActivity.java index 0ea50fc..1216892 100644 --- a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/PlayerActivity.java +++ b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/PlayerActivity.java @@ -35,8 +35,7 @@ import org.ntlab.radishforandroidstudio.java3d.Vector3f; - -public class PlayerActivity extends RealTime3DActivity implements PadListener{ +public class PlayerActivity extends RealTime3DActivity implements PadListener { private OvergroundActor pocha; private Ground stage; private boolean isTouched = false; @@ -74,7 +73,7 @@ Object3D pochaBody = null; try { pochaBody = ModelFactory.loadModel(getResources(), "pocha.stl", ap1).createObject(); - Animation3D pochaAnimation = null; //AnimationFactory.loadAnimation("data\\pocha\\walk.wrl"); + 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); @@ -103,20 +102,22 @@ //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)); + l.addView(view, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); FragmentManager fragmentManager = getSupportFragmentManager(); - FragmentTransaction transaction =fragmentManager.beginTransaction(); + 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); + 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); @@ -127,25 +128,24 @@ @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); + 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); - } - + } 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));//視線 + .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));//視線 } @@ -186,14 +186,14 @@ 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()); + 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));//視線 + .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; } diff --git a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/tests/SampleGame2Fragment.java b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/tests/SampleGame2Fragment.java index 7b43eeb..3d358c6 100644 --- a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/tests/SampleGame2Fragment.java +++ b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/tests/SampleGame2Fragment.java @@ -109,11 +109,10 @@ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - //ここfragment_real_time3dに紐づけ - parentView = inflater.inflate(R.layout.fragment_real_time_3d, container, false); - //ゲーム画面作成 + super.onCreateView(inflater, container, savedInstanceState); initGameWindowView(); + parentView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { @@ -153,18 +152,11 @@ } //sampleUiFragmentからそのまま持ってきた - private void initGameWindowView() { - view = new RWTSurfaceView(this.getActivity()); - view.setRenderMode(RWTSurfaceView.RENDERMODE_WHEN_DIRTY); - view.attachCamera(camera); - - FrameLayout l = parentView.findViewById(R.id.game_layout); - l.addView(view, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); - + public void initGameWindowView() { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction transaction = fragmentManager.beginTransaction(); - Fragment f = new RWTUIFragment(); + Fragment f = new RWTUIFragment(); View uiLayout = parentView.findViewById(R.id.ui_layout); uiLayout.setOnTouchListener((RWTUIFragment) f); transaction.add(R.id.ui_layout, f); diff --git a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/tests/SampleGameFragment.java b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/tests/SampleGameFragment.java index 59208a3..8e8ac2b 100644 --- a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/tests/SampleGameFragment.java +++ b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/tests/SampleGameFragment.java @@ -108,7 +108,7 @@ @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - parentView = inflater.inflate(R.layout.fragment_real_time_3d, container, false); + super.onCreateView(inflater, container, savedInstanceState); initGameWindowView(); return parentView; } @@ -133,8 +133,8 @@ public void initGameWindowView() { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction transaction = fragmentManager.beginTransaction(); - Fragment f = new RWTUIFragment(); + Fragment f = new RWTUIFragment(); View uiLayout = parentView.findViewById(R.id.ui_layout); uiLayout.setOnTouchListener((RWTUIFragment) f); transaction.add(R.id.ui_layout, f); 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 90bbf43..b56b11f 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 @@ -31,8 +31,9 @@ public void onClick(View view) { FragmentManager manager = getFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); - transaction.replace(R.id.framelayout_field, new SampleUiFragment()); - //transaction.replace(R.id.framelayout_field,new SampleGame2Fragment()); +// 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.addToBackStack(null); transaction.commit(); }