Rotation tree

This commit is contained in:
austin 2022-02-17 00:09:12 -05:00
parent f5790b6947
commit 5be3c9c2d5
5 changed files with 25 additions and 6 deletions

View File

@ -124,10 +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_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_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_STRAFE_LEFT, new Control(true,false,GLFW_KEY_F24));
handler.addControl(DATA_STRING_INPUT_CODE_STRAFE_RIGHT, new Control(true,false,GLFW_KEY_F24));
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));

View File

@ -5,6 +5,7 @@ import electrosphere.controls.ControlHandler;
import electrosphere.entity.CameraEntityUtils;
import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.state.ApplyRotationTree;
import electrosphere.game.collision.CollisionEngine;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.types.item.ItemUtils;
@ -522,9 +523,11 @@ public class LoadingThread extends Thread {
Globals.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
Globals.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
//cloud ring pseudo skybox
Entity cloudRing = EntityUtils.spawnDrawableEntity("Models/cloudRing.fbx");
EntityUtils.getRotation(cloudRing).rotateX((float)(-Math.PI/2.0f));
EntityUtils.getScale(cloudRing).mul(1000.0f);
Globals.entityManager.registerBehaviorTree(new ApplyRotationTree(cloudRing,new Quaternionf().rotationZ(0.0001f)));
}

View File

@ -157,6 +157,20 @@ public class EntityManager {
public CopyOnWriteArrayList<Entity> getSprintables(){
return sprintableList;
}
public void registerBehaviorTree(BehaviorTree tree){
behaviorTreeList.add(tree);
}
public void removeBehaviorTree(BehaviorTree tree){
behaviorTreeList.remove(tree);
}
public void simulateBehaviorTrees(){
for(BehaviorTree tree : behaviorTreeList){
tree.simulate();
}
}
public void deregisterEntity(Entity e){
if(lightList.contains(e)){

View File

@ -16,7 +16,7 @@ public class ApplyRotationTree implements BehaviorTree {
Quaternionf rotationToApply;
Entity parent;
ApplyRotationTreeState state;
ApplyRotationTreeState state = ApplyRotationTreeState.ROTATE;
public ApplyRotationTree(Entity parent, Quaternionf rotationToApply){
this.parent = parent;
@ -35,7 +35,7 @@ public class ApplyRotationTree implements BehaviorTree {
public void simulate(){
switch(state){
case ROTATE:
EntityUtils.getRotation(parent).slerp(rotationToApply, 1.0f);
EntityUtils.getRotation(parent).mul(rotationToApply).normalize();
break;
case NO_ROTATE:
break;

View File

@ -123,6 +123,8 @@ public class MicroSimulation {
if(Globals.RUN_CLIENT){
Globals.entityManager.clearOutOfBoundsEntities();
}
//simulate behavior trees
Globals.entityManager.simulateBehaviorTrees();
//data cell manager update
if(Globals.dataCellManager != null){
boolean playerHasChangedChunk = Globals.dataCellManager.updatePlayerPositions();