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 e4d7c78..0ea50fc 100644 --- a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/PlayerActivity.java +++ b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/PlayerActivity.java @@ -130,8 +130,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); @@ -149,7 +150,7 @@ @SuppressLint("NewApi") - @Override + /*@Override public boolean onTouchEvent (MotionEvent event){ Vector3d charaVector3d = pocha.getDirection(); charaVector3d.normalize();//キャラの向きを単位ベクトルに @@ -161,17 +162,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.pad); @@ -191,9 +186,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));//視線