戻したver2.0
1 parent 1ab54d9 commit 33f8a15ca0834b12917e7b70d1a2cec714227d43
a-matsumoto authored on 23 Oct 2018
Showing 4 changed files
View
.idea/caches/build_file_checksums.ser
Not supported
View
84
app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/models/OwnPlayer.java
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;
import org.ntlab.radishforandroidstudio.framework.gameMain.GameBaseModel;
public void updateCamera() {
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
public boolean onEvent(PadEvent event) {
vel.setX(0);
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);
}
 
nextConnectRenaimdTime -= interval;
View
13
app/src/main/java/org/ntlab/radishforandroidstudio/cactusClient/views/PlayerFragment.java
import android.support.annotation.Nullable;
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 org.ntlab.radishforandroidstudio.R;
import org.ntlab.radishforandroidstudio.framework.gameMain.OvergroundActor;
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;
import org.ntlab.radishforandroidstudio.java3d.DirectionalLight;
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 {
private OvergroundActor pocha;
RWTPad pad = null;
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
}
otherPlayerCharactersModel.setPlayerId(playerId);
modelManager.addModel(otherPlayerCharactersModel);
modelManager.setInstanceId(bundle.getString("instanceId"));
initGameWindowView();
 
return parentView;
}
 
@Override
 
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;
}
}
 
View
app/src/main/res/layout/ui_fragment.xml