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 3c9b284..8aaabb5 100644 --- a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/PlayerActivity.java +++ b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/PlayerActivity.java @@ -47,7 +47,6 @@ private float touchY = 0.0f; RWTPad pad = null; - protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -139,8 +138,9 @@ 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 - touchY)); + curV.setZ(pocha.getDirection().getZ() * 200.0 * (0.5f - touchX)); pocha.setVelocity(curV); + } else { curV.setX(0.0); curV.setZ(0.0); @@ -158,7 +158,7 @@ @SuppressLint("NewApi") - @Override + /*@Override public boolean onTouchEvent (MotionEvent event){ Vector3d charaVector3d = pocha.getDirection(); charaVector3d.normalize();//キャラの向きを単位ベクトルに @@ -170,17 +170,11 @@ 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(); - touchX = (event.getX() - minX) / (maxX - minX); - touchY = (event.getY() - minY) / (maxY - minY); - - 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 (event.getAction() == MotionEvent.ACTION_UP) { isTouched = false; } return true; - } + }*/ public void onCreateFragmentEvent(RWTUIFragment f) { pad = (RWTPad) f.findViewById(org.ntlab.radishforandroidstudio.R.id.button3); @@ -200,9 +194,11 @@ 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 = (motionEvent.getX() - minX) / (maxX - minX); - touchY = (motionEvent.getY() - minY) / (maxY - minY); + 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));//視線