fix ridiculous movement bug start arena skybox
This commit is contained in:
parent
41640ba543
commit
9a8ef5d586
BIN
assets/Models/cloudRing.fbx
Normal file
BIN
assets/Models/cloudRing.fbx
Normal file
Binary file not shown.
BIN
assets/Textures/cloudRing.png
Normal file
BIN
assets/Textures/cloudRing.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 MiB |
@ -239,6 +239,12 @@
|
||||
"/Textures/shirt1.png",
|
||||
"/Textures/shirt1.png"
|
||||
]
|
||||
},
|
||||
"Models/cloudRing.fbx" : {
|
||||
"Sphere" : [
|
||||
"/Textures/cloudRing.png",
|
||||
"/Textures/cloudRing.png"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -36,6 +36,8 @@ public class ControlHandler {
|
||||
public static final String DATA_STRING_INPUT_CODE_MOVEMENT_BACKWARD = "moveBackward";
|
||||
public static final String DATA_STRING_INPUT_CODE_MOVEMENT_LEFT = "moveLeft";
|
||||
public static final String DATA_STRING_INPUT_CODE_MOVEMENT_RIGHT = "moveRight";
|
||||
public static final String DATA_STRING_INPUT_CODE_STRAFE_LEFT = "strafeLeft";
|
||||
public static final String DATA_STRING_INPUT_CODE_STRAFE_RIGHT = "strafeRight";
|
||||
public static final String DATA_STRING_INPUT_CODE_MOVEMENT_JUMP = "jump";
|
||||
public static final String DATA_STRING_INPUT_CODE_MOVEMENT_FALL = "fall";
|
||||
public static final String DATA_STRING_INPUT_CODE_ATTACK_PRIMARY = "attackPrimary";
|
||||
@ -122,8 +124,10 @@ public class ControlHandler {
|
||||
*/
|
||||
handler.addControl(DATA_STRING_INPUT_CODE_MOVEMENT_FORWARD, new Control(true,false,GLFW_KEY_W));
|
||||
handler.addControl(DATA_STRING_INPUT_CODE_MOVEMENT_BACKWARD, new Control(true,false,GLFW_KEY_S));
|
||||
handler.addControl(DATA_STRING_INPUT_CODE_MOVEMENT_LEFT, new Control(true,false,GLFW_KEY_A));
|
||||
handler.addControl(DATA_STRING_INPUT_CODE_MOVEMENT_RIGHT, new Control(true,false,GLFW_KEY_D));
|
||||
handler.addControl(DATA_STRING_INPUT_CODE_MOVEMENT_LEFT, new Control(true,false,GLFW_KEY_F24));
|
||||
handler.addControl(DATA_STRING_INPUT_CODE_MOVEMENT_RIGHT, new Control(true,false,GLFW_KEY_F24));
|
||||
handler.addControl(DATA_STRING_INPUT_CODE_STRAFE_LEFT, new Control(true,false,GLFW_KEY_A));
|
||||
handler.addControl(DATA_STRING_INPUT_CODE_STRAFE_RIGHT, new Control(true,false,GLFW_KEY_D));
|
||||
handler.addControl(DATA_STRING_INPUT_CODE_MOVEMENT_JUMP, new Control(true,false,GLFW_KEY_SPACE));
|
||||
handler.addControl(DATA_STRING_INPUT_CODE_MOVEMENT_FALL, new Control(true,false,GLFW_KEY_LEFT_CONTROL));
|
||||
handler.addControl(DATA_STRING_INPUT_CODE_ATTACK_PRIMARY, new Control(false,true,GLFW_MOUSE_BUTTON_LEFT));
|
||||
@ -381,13 +385,75 @@ public class ControlHandler {
|
||||
Move up
|
||||
*/
|
||||
if(controls.containsKey(DATA_STRING_INPUT_CODE_MOVEMENT_JUMP) && Globals.controlCallback.getKey(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_JUMP).getKeyValue())){
|
||||
EntityUtils.getPosition(Globals.playerCharacter).add(new Vector3f(0,0.6f,0).mul(1f));
|
||||
// EntityUtils.getPosition(Globals.playerCharacter).add(new Vector3f(0,0.6f,0).mul(1f));
|
||||
}
|
||||
/*
|
||||
Move down
|
||||
*/
|
||||
if(controls.containsKey(DATA_STRING_INPUT_CODE_MOVEMENT_FALL) && Globals.controlCallback.getKey(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_FALL).getKeyValue())){
|
||||
EntityUtils.getPosition(Globals.playerCharacter).add(new Vector3f(0,-0.6f,0).mul(1f));
|
||||
// EntityUtils.getPosition(Globals.playerCharacter).add(new Vector3f(0,-0.6f,0).mul(1f));
|
||||
}
|
||||
/*
|
||||
Strafe left
|
||||
*/
|
||||
if(controls.containsKey(DATA_STRING_INPUT_CODE_STRAFE_LEFT)){
|
||||
if(controls.get(DATA_STRING_INPUT_CODE_STRAFE_LEFT).isIsKey() && Globals.controlCallback.getKey(controls.get(DATA_STRING_INPUT_CODE_STRAFE_LEFT).getKeyValue())){
|
||||
CreatureUtils.setFacingVector(Globals.playerCharacter, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).rotateY(Math.PI/2.0).normalize());
|
||||
if(
|
||||
(movementTree.getState()==MovementTreeState.IDLE || movementTree.getState()==MovementTreeState.SLOWDOWN) &&
|
||||
(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_FORWARD).isIsKey() && !Globals.controlCallback.getKey(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_FORWARD).getKeyValue())) &&
|
||||
(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_BACKWARD).isIsKey() && !Globals.controlCallback.getKey(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_BACKWARD).getKeyValue()))
|
||||
){
|
||||
movementTree.start(MovementRelativeFacing.FORWARD);
|
||||
}
|
||||
controls.get(DATA_STRING_INPUT_CODE_STRAFE_LEFT).setState(true);
|
||||
//send to server
|
||||
// Vector3f position = EntityUtils.getEntityPosition(Globals.playerCharacter);
|
||||
// EntityMessage outgoingMessage = EntityMessage.constructMoveMessage(
|
||||
// Globals.playerCharacter.getId(),
|
||||
// System.currentTimeMillis(),
|
||||
// position.x,
|
||||
// position.y,
|
||||
// position.z
|
||||
// );
|
||||
// Globals.clientConnection.queueOutgoingMessage(outgoingMessage);
|
||||
} else {
|
||||
if(controls.get(DATA_STRING_INPUT_CODE_STRAFE_LEFT).isState() == true){
|
||||
movementTree.slowdown();
|
||||
}
|
||||
controls.get(DATA_STRING_INPUT_CODE_STRAFE_LEFT).setState(false);
|
||||
}
|
||||
}
|
||||
/*
|
||||
Strafe right
|
||||
*/
|
||||
if(controls.containsKey(DATA_STRING_INPUT_CODE_STRAFE_RIGHT)){
|
||||
if(controls.get(DATA_STRING_INPUT_CODE_STRAFE_RIGHT).isIsKey() && Globals.controlCallback.getKey(controls.get(DATA_STRING_INPUT_CODE_STRAFE_RIGHT).getKeyValue())){
|
||||
CreatureUtils.setFacingVector(Globals.playerCharacter, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).rotateY(-Math.PI/2.0).normalize());
|
||||
if(
|
||||
(movementTree.getState()==MovementTreeState.IDLE || movementTree.getState()==MovementTreeState.SLOWDOWN) &&
|
||||
(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_FORWARD).isIsKey() && !Globals.controlCallback.getKey(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_FORWARD).getKeyValue())) &&
|
||||
(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_BACKWARD).isIsKey() && !Globals.controlCallback.getKey(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_BACKWARD).getKeyValue()))
|
||||
){
|
||||
movementTree.start(MovementRelativeFacing.FORWARD);
|
||||
}
|
||||
controls.get(DATA_STRING_INPUT_CODE_STRAFE_RIGHT).setState(true);
|
||||
//send to server
|
||||
// Vector3f position = EntityUtils.getEntityPosition(Globals.playerCharacter);
|
||||
// EntityMessage outgoingMessage = EntityMessage.constructMoveMessage(
|
||||
// Globals.playerCharacter.getId(),
|
||||
// System.currentTimeMillis(),
|
||||
// position.x,
|
||||
// position.y,
|
||||
// position.z
|
||||
// );
|
||||
// Globals.clientConnection.queueOutgoingMessage(outgoingMessage);
|
||||
} else {
|
||||
if(controls.get(DATA_STRING_INPUT_CODE_STRAFE_RIGHT).isState() == true){
|
||||
movementTree.slowdown();
|
||||
}
|
||||
controls.get(DATA_STRING_INPUT_CODE_STRAFE_RIGHT).setState(false);
|
||||
}
|
||||
}
|
||||
/*
|
||||
Sprint
|
||||
|
||||
@ -480,30 +480,51 @@ public class LoadingThread extends Thread {
|
||||
}
|
||||
|
||||
|
||||
static void initGameGraphicalEntities(){
|
||||
|
||||
static void initArenaGraphicalEntities(){
|
||||
|
||||
Globals.skyboxColors.add(new Vector3f(150,200,250));
|
||||
Globals.skyboxColors.add(new Vector3f(150,200,250));
|
||||
Globals.skyboxColors.add(new Vector3f(20,20,20));
|
||||
Globals.skyboxColors.add(new Vector3f(20,20,20));
|
||||
Globals.skyboxColors.add(new Vector3f(150,200,250));
|
||||
Globals.skyboxColors.add(new Vector3f(150,200,250));
|
||||
Globals.skyboxColors.add(new Vector3f(20,20,20));
|
||||
Globals.skyboxColors.add(new Vector3f(20,20,20));
|
||||
float skyR = 100;
|
||||
float skyG = 150;
|
||||
float skyB = 200;
|
||||
|
||||
float groundR = 50;
|
||||
float groundG = 100;
|
||||
float groundB = 150;
|
||||
|
||||
Globals.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
|
||||
Globals.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
|
||||
Globals.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
|
||||
Globals.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
|
||||
Globals.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
|
||||
Globals.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
|
||||
Globals.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
|
||||
Globals.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
|
||||
|
||||
}
|
||||
|
||||
static void initGameGraphicalEntities(){
|
||||
|
||||
Globals.skyboxColors.add(new Vector3f(100,150,200));
|
||||
Globals.skyboxColors.add(new Vector3f(100,150,200));
|
||||
Globals.skyboxColors.add(new Vector3f(50,100,150));
|
||||
Globals.skyboxColors.add(new Vector3f(50,100,150));
|
||||
Globals.skyboxColors.add(new Vector3f(100,150,200));
|
||||
Globals.skyboxColors.add(new Vector3f(100,150,200));
|
||||
Globals.skyboxColors.add(new Vector3f(50,100,150));
|
||||
Globals.skyboxColors.add(new Vector3f(50,100,150));
|
||||
static void initArenaGraphicalEntities(){
|
||||
|
||||
float skyR = 150;
|
||||
float skyG = 200;
|
||||
float skyB = 250;
|
||||
|
||||
float groundR = 20;
|
||||
float groundG = 20;
|
||||
float groundB = 20;
|
||||
|
||||
Globals.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
|
||||
Globals.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
|
||||
Globals.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
|
||||
Globals.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
|
||||
Globals.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
|
||||
Globals.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
|
||||
Globals.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
|
||||
Globals.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
|
||||
|
||||
Entity cloudRing = EntityUtils.spawnDrawableEntity("Models/cloudRing.fbx");
|
||||
EntityUtils.getRotation(cloudRing).rotateX((float)(-Math.PI/2.0f));
|
||||
EntityUtils.getScale(cloudRing).mul(1000.0f);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package electrosphere.entity;
|
||||
|
||||
import electrosphere.entity.state.BehaviorTree;
|
||||
import electrosphere.entity.types.attach.AttachUtils;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.main.Globals;
|
||||
@ -33,6 +34,8 @@ public class EntityManager {
|
||||
static CopyOnWriteArrayList<Entity> collidableList = new CopyOnWriteArrayList();
|
||||
static CopyOnWriteArrayList<Entity> targetableList = new CopyOnWriteArrayList();
|
||||
static CopyOnWriteArrayList<Entity> sprintableList = new CopyOnWriteArrayList();
|
||||
|
||||
static CopyOnWriteArrayList<BehaviorTree> behaviorTreeList = new CopyOnWriteArrayList<BehaviorTree>();
|
||||
|
||||
public EntityManager(){
|
||||
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
package electrosphere.entity.state;
|
||||
|
||||
import org.joml.Quaterniond;
|
||||
import org.joml.Quaternionf;
|
||||
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
|
||||
public class ApplyRotationTree implements BehaviorTree {
|
||||
|
||||
public static enum ApplyRotationTreeState {
|
||||
ROTATE,
|
||||
NO_ROTATE,
|
||||
}
|
||||
|
||||
|
||||
Quaternionf rotationToApply;
|
||||
Entity parent;
|
||||
ApplyRotationTreeState state;
|
||||
|
||||
public ApplyRotationTree(Entity parent, Quaternionf rotationToApply){
|
||||
this.parent = parent;
|
||||
this.rotationToApply = rotationToApply;
|
||||
}
|
||||
|
||||
public void start(){
|
||||
state = ApplyRotationTreeState.ROTATE;
|
||||
}
|
||||
|
||||
public void stop(){
|
||||
state = ApplyRotationTreeState.NO_ROTATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simulate(){
|
||||
switch(state){
|
||||
case ROTATE:
|
||||
EntityUtils.getRotation(parent).slerp(rotationToApply, 1.0f);
|
||||
break;
|
||||
case NO_ROTATE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package electrosphere.entity.state;
|
||||
|
||||
public interface BehaviorTree {
|
||||
|
||||
public void simulate();
|
||||
|
||||
}
|
||||
@ -118,6 +118,7 @@ public class GroundMovementTree {
|
||||
Vector3d movementVector = new Vector3d(facingVector);
|
||||
switch(facing){
|
||||
case FORWARD:
|
||||
movementVector.normalize();
|
||||
break;
|
||||
case LEFT:
|
||||
movementVector.rotateY((float)(90 * Math.PI / 180)).normalize();
|
||||
@ -128,6 +129,7 @@ public class GroundMovementTree {
|
||||
case BACKWARD:
|
||||
movementVector.x = -movementVector.x;
|
||||
movementVector.z = -movementVector.z;
|
||||
movementVector.normalize();
|
||||
break;
|
||||
case FORWARD_LEFT:
|
||||
movementVector.rotateY((float)(45 * Math.PI / 180)).normalize();
|
||||
@ -211,14 +213,12 @@ public class GroundMovementTree {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// System.out.println(movementVector + " " + velocity * Main.deltaTime);
|
||||
|
||||
//state machine
|
||||
switch(state){
|
||||
case STARTUP:
|
||||
//run startup code
|
||||
velocity = velocity + acceleration * Main.deltaTime;
|
||||
CreatureUtils.setVelocity(parent, velocity);
|
||||
if(entityActor != null){
|
||||
String animationToPlay = determineCorrectAnimation();
|
||||
if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(animationToPlay)){
|
||||
@ -226,11 +226,14 @@ public class GroundMovementTree {
|
||||
entityActor.incrementAnimationTime(0.01);
|
||||
}
|
||||
}
|
||||
//run startup code
|
||||
velocity = velocity + acceleration * Main.deltaTime;
|
||||
//check if can transition state
|
||||
if(velocity >= maxNaturalVelocity){
|
||||
velocity = maxNaturalVelocity;
|
||||
state = MovementTreeState.MOVE;
|
||||
}
|
||||
CreatureUtils.setVelocity(parent, velocity);
|
||||
// body.applyCentralForce(PhysicsUtils.jomlToVecmathVector3f(new Vector3f(movementVector.x,0,movementVector.z).normalize().mul(velocity)));
|
||||
EntityUtils.getRotation(parent).set(movementQuaternion);
|
||||
// //move the entity
|
||||
@ -306,6 +309,7 @@ public class GroundMovementTree {
|
||||
}
|
||||
if(velocity != maxNaturalVelocity){
|
||||
velocity = maxNaturalVelocity;
|
||||
CreatureUtils.setVelocity(parent, velocity);
|
||||
}
|
||||
// body.applyCentralForce(PhysicsUtils.jomlToVecmathVector3f(force));
|
||||
EntityUtils.getRotation(parent).set(movementQuaternion);
|
||||
@ -371,8 +375,6 @@ public class GroundMovementTree {
|
||||
break;
|
||||
case SLOWDOWN:
|
||||
//run slowdown code
|
||||
velocity = velocity - acceleration * Main.deltaTime;
|
||||
CreatureUtils.setVelocity(parent, velocity);
|
||||
if(entityActor != null){
|
||||
String animationToPlay = determineCorrectAnimation();
|
||||
if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(animationToPlay)){
|
||||
@ -380,11 +382,20 @@ public class GroundMovementTree {
|
||||
entityActor.incrementAnimationTime(0.01);
|
||||
}
|
||||
}
|
||||
//velocity stuff
|
||||
velocity = velocity - acceleration * Main.deltaTime;
|
||||
//check if can transition state
|
||||
if(velocity <= 0){
|
||||
velocity = 0;
|
||||
state = MovementTreeState.IDLE;
|
||||
if(entityActor != null){
|
||||
String animationToPlay = determineCorrectAnimation();
|
||||
if(entityActor.isPlayingAnimation() && entityActor.isPlayingAnimation(animationToPlay)){
|
||||
entityActor.stopAnimation(animationToPlay);
|
||||
}
|
||||
}
|
||||
}
|
||||
CreatureUtils.setVelocity(parent, velocity);
|
||||
// body.applyCentralForce(PhysicsUtils.jomlToVecmathVector3f(new Vector3f(movementVector).mul(-1.0f).normalize().mul(velocity)));
|
||||
EntityUtils.getRotation(parent).rotationTo(new Vector3f(0,0,1), new Vector3f((float)movementVector.x,(float)movementVector.y,(float)movementVector.z));
|
||||
//move the entity
|
||||
@ -448,12 +459,7 @@ public class GroundMovementTree {
|
||||
break;
|
||||
case IDLE:
|
||||
// body.clearForces();
|
||||
if(entityActor != null){
|
||||
String animationToPlay = determineCorrectAnimation();
|
||||
if(entityActor.isPlayingAnimation() && entityActor.isPlayingAnimation(animationToPlay)){
|
||||
entityActor.stopAnimation(animationToPlay);
|
||||
}
|
||||
}
|
||||
|
||||
// if(Globals.collisionEngine.gravityCheck(Globals.commonWorldData, parent)){
|
||||
// position.set(Globals.collisionEngine.suggestMovementPosition(Globals.commonWorldData,parent,new Vector3f(position.x,position.y - 9.8f,position.z)));
|
||||
// }
|
||||
|
||||
@ -129,7 +129,13 @@ public class DataCellManager {
|
||||
}
|
||||
|
||||
public void sendNetworkMessageToChunk(NetworkMessage message, int worldX, int worldY){
|
||||
if(dataCells[worldX][worldY] != null){
|
||||
if(
|
||||
//in bounds of array
|
||||
worldX >= 0 && worldX < dataCells.length &&
|
||||
worldY >= 0 && worldY < dataCells[0].length &&
|
||||
//isn't null
|
||||
dataCells[worldX][worldY] != null
|
||||
){
|
||||
dataCells[worldX][worldY].broadcastNetworkMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -740,14 +740,14 @@ public class Mesh {
|
||||
temp[2] = lightLoc.z;
|
||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.direction"), temp);
|
||||
|
||||
temp[0] = 0.4f;
|
||||
temp[1] = 0.4f;
|
||||
temp[2] = 0.4f;
|
||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.ambient"), temp);
|
||||
|
||||
temp[0] = 0.3f;
|
||||
temp[1] = 0.3f;
|
||||
temp[2] = 0.3f;
|
||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.ambient"), temp);
|
||||
|
||||
temp[0] = 0.5f;
|
||||
temp[1] = 0.5f;
|
||||
temp[2] = 0.5f;
|
||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.diffuse"), temp);
|
||||
|
||||
temp[0] = 0.1f;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user