diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index d8704b8..7288c7f 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/models/OwnPlayer.java b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/models/OwnPlayer.java index 17f0e89..c11ffed 100644 --- a/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/models/OwnPlayer.java +++ b/app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/models/OwnPlayer.java @@ -1,10 +1,18 @@ package org.ntlab.radishforandroidstudio.cactusClient.models; import android.content.res.Resources; + +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.view.LayoutInflater; import android.view.MotionEvent; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Button; import net.arnx.jsonic.JSON; +import org.ntlab.radishforandroidstudio.R; import org.ntlab.radishforandroidstudio.cactusClient.connections.CharacterConnection; import org.ntlab.radishforandroidstudio.framework.animation.Animation3D; import org.ntlab.radishforandroidstudio.framework.event.PadEvent; @@ -76,8 +84,8 @@ Vector3d charaVector3d = actor.getDirection(); charaVector3d.normalize();//キャラの向きを単位ベクトルに camera.setViewPoint(actor.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()));//視線 } @Override @@ -98,18 +106,51 @@ vel.setY(0); actor.setVelocity(vel); isTouched = false; - } + }// ここのelse if いらなくない? + return false; } @Override public void update(double interval) { updateCamera(); + Velocity3D vel = actor.getVelocity(); + Vector3d actorVec = actor.getDirection(); if (isTouched) { - Velocity3D vel = actor.getVelocity(); - vel.setX(touchX); - vel.setY(touchY); + + Vector3d up = new Vector3d(0,1,0); + Vector3d total = new Vector3d(); + Vector3d right = new Vector3d(); + + right.cross(actorVec,up); + + Vector3d touchXVec = right.clone(); + Vector3d touchYVec = actorVec.clone(); + + touchXVec.scale(touchX * -5); + touchYVec.scale(touchY * 5); + + total.add(touchXVec); + total.add(touchYVec); + total.y = vel.getY(); + +// +// Button jumpButton = (Button) getActivity().findViewById(R.id.JumpButton); +// jumpButton.setOnClickListener(new View.OnClickListener() { +// public void onClick(View v) { +// if(actor.isOnGround()) total.y = vel.getY() + 15; +// } +// }); + + vel.setVector3d(total); + actor.setVelocity(vel); + + + } else { + vel.setX(0.0); + vel.setZ(0.0); + actor.setVelocity(vel); } 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 57a8743..2009dfb 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 @@ -6,6 +6,7 @@ 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; @@ -20,6 +21,7 @@ import org.ntlab.radishforandroidstudio.framework.gameMain.RealTime3DFragment; import org.ntlab.radishforandroidstudio.framework.model3D.BaseObject3D; 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; @@ -27,6 +29,7 @@ import org.ntlab.radishforandroidstudio.java3d.IndexedTriangleArray; import org.ntlab.radishforandroidstudio.java3d.Material; import org.ntlab.radishforandroidstudio.java3d.Point3d; +import org.ntlab.radishforandroidstudio.java3d.Vector3d; import org.ntlab.radishforandroidstudio.java3d.Vector3f; public class PlayerFragment extends RealTime3DFragment { @@ -35,6 +38,10 @@ private OwnPlayer player; private OtherPlayerCharactersModel otherPlayerCharactersModel; + private boolean isScreenTouched = false; + private float touchX = 0.0f; + private float touchY = 0.0f; + public PlayerFragment() { // Required empty public constructor } @@ -95,6 +102,7 @@ modelManager.addModel(otherPlayerCharactersModel); modelManager.setInstanceId(bundle.getString("instanceId")); initGameWindowView(); + return parentView; } @@ -120,6 +128,11 @@ public void onCreateFragmentEvent(RWTUIFragment f) { pad = (RWTPad) f.findViewById(org.ntlab.radishforandroidstudio.R.id.pad); pad.addListener(player); + + } + + public void onClickJumpButton(Vector3d total, Velocity3D vel){ + total.y = vel.getY() + 15; } } diff --git a/app/src/main/res/layout/ui_fragment.xml b/app/src/main/res/layout/ui_fragment.xml index 996ee1f..510af98 100644 --- a/app/src/main/res/layout/ui_fragment.xml +++ b/app/src/main/res/layout/ui_fragment.xml @@ -7,25 +7,25 @@