Airplane movement tree/jet asset
This commit is contained in:
parent
9aa5cadb62
commit
6b29863016
@ -223,6 +223,7 @@
|
||||
],
|
||||
"files" : [
|
||||
"Data/creatures/human.json",
|
||||
"Data/creatures/elf.json"
|
||||
"Data/creatures/elf.json",
|
||||
"Data/creatures/test.json"
|
||||
]
|
||||
}
|
||||
|
||||
154
assets/Data/creatures/test.json
Normal file
154
assets/Data/creatures/test.json
Normal file
@ -0,0 +1,154 @@
|
||||
{
|
||||
"creatures" : [
|
||||
{
|
||||
"creatureId" : "tank",
|
||||
"hitboxes" : [
|
||||
{
|
||||
"type": "hurt",
|
||||
"bone": "Bone",
|
||||
"radius": 0.04
|
||||
}
|
||||
],
|
||||
"tokens" : [
|
||||
"ATTACKER",
|
||||
"GRAVITY",
|
||||
"TARGETABLE",
|
||||
"OUTLINE",
|
||||
"PLAYABLE"
|
||||
],
|
||||
"visualAttributes" : [
|
||||
],
|
||||
"movementSystems" : [
|
||||
{
|
||||
"type" : "GROUND",
|
||||
"acceleration" : 10.0,
|
||||
"maxVelocity" : 0.035,
|
||||
"animationStartup" : {
|
||||
"name" : "Idle1",
|
||||
"length" : 1,
|
||||
"loops" : false
|
||||
},
|
||||
"animationLoop" : {
|
||||
"name" : "Idle1",
|
||||
"length" : 1,
|
||||
"loops" : false
|
||||
},
|
||||
"animationWindDown" : {
|
||||
"name" : "Idle1",
|
||||
"length" : 1,
|
||||
"loops" : false
|
||||
}
|
||||
},
|
||||
{
|
||||
"type" : "FALL",
|
||||
"animationFall" : {
|
||||
"name" : "Idle1",
|
||||
"length" : 1,
|
||||
"loops" : true
|
||||
},
|
||||
"animationLand" : {
|
||||
"name" : "Idle1",
|
||||
"length" : 1,
|
||||
"loops" : true
|
||||
}
|
||||
}
|
||||
],
|
||||
"rotatorSystem" : {
|
||||
"rotatorItems" : [
|
||||
{
|
||||
"boneName" : "Bone",
|
||||
"constraints" : [
|
||||
{
|
||||
"followsView" : true,
|
||||
"followsBone" : false,
|
||||
"parentBone" : "",
|
||||
"allowedMarginPitch" : 0.2
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"equipPoints" : [
|
||||
],
|
||||
"collidable" : {
|
||||
"type" : "CYLINDER",
|
||||
"dimension1" : 0.1,
|
||||
"dimension2" : 0.45,
|
||||
"dimension3" : 0.1,
|
||||
"offsetX" : 0,
|
||||
"offsetY" : 0.45,
|
||||
"offsetZ" : 0
|
||||
},
|
||||
"attackMoves" : [
|
||||
],
|
||||
"healthSystem" : {
|
||||
"maxHealth" : 100,
|
||||
"onDamageIFrames" : 30
|
||||
},
|
||||
"modelPath" : "Models/tank1.fbx"
|
||||
},
|
||||
{
|
||||
"creatureId" : "fighter",
|
||||
"hitboxes" : [
|
||||
{
|
||||
"type": "hurt",
|
||||
"bone": "Bone",
|
||||
"radius": 0.04
|
||||
}
|
||||
],
|
||||
"tokens" : [
|
||||
"BLENDER_TRANSFORM",
|
||||
"ATTACKER",
|
||||
"GRAVITY",
|
||||
"TARGETABLE",
|
||||
"OUTLINE",
|
||||
"PLAYABLE"
|
||||
],
|
||||
"visualAttributes" : [
|
||||
],
|
||||
"movementSystems" : [
|
||||
{
|
||||
"type" : "AIRPLANE",
|
||||
"acceleration" : 10.0,
|
||||
"maxVelocity" : 0.035,
|
||||
"minVelocity": 0.001,
|
||||
"maxRotationSpeed" : 1.0
|
||||
}
|
||||
],
|
||||
"rotatorSystem" : {
|
||||
"rotatorItems" : [
|
||||
{
|
||||
"boneName" : "Bone",
|
||||
"constraints" : [
|
||||
{
|
||||
"followsView" : true,
|
||||
"followsBone" : false,
|
||||
"parentBone" : "",
|
||||
"allowedMarginPitch" : 0.2
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"equipPoints" : [
|
||||
],
|
||||
"collidable" : {
|
||||
"type" : "CYLINDER",
|
||||
"dimension1" : 0.1,
|
||||
"dimension2" : 0.45,
|
||||
"dimension3" : 0.1,
|
||||
"offsetX" : 0,
|
||||
"offsetY" : 0.45,
|
||||
"offsetZ" : 0
|
||||
},
|
||||
"attackMoves" : [
|
||||
],
|
||||
"healthSystem" : {
|
||||
"maxHealth" : 100,
|
||||
"onDamageIFrames" : 30
|
||||
},
|
||||
"modelPath" : "Models/f15.fbx"
|
||||
}
|
||||
],
|
||||
"files" : []
|
||||
}
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
{
|
||||
"objectId" : "terrain1",
|
||||
"modelPath" : "Models/startingarea1.fbx",
|
||||
"modelPath" : "Models/testvalley.fbx",
|
||||
"tokens" : [
|
||||
"DISABLE_COLLISION_REACTION",
|
||||
"GENERATE_COLLISION_TERRAIN"
|
||||
|
||||
BIN
assets/Models/f15.fbx
Normal file
BIN
assets/Models/f15.fbx
Normal file
Binary file not shown.
BIN
assets/Models/tank1.fbx
Normal file
BIN
assets/Models/tank1.fbx
Normal file
Binary file not shown.
BIN
assets/Models/testvalley.fbx
Normal file
BIN
assets/Models/testvalley.fbx
Normal file
Binary file not shown.
@ -413,6 +413,18 @@
|
||||
"/Textures/floatingisland1.png",
|
||||
"/Textures/floatingisland1.png"
|
||||
]
|
||||
},
|
||||
"Models/testvalley.fbx" : {
|
||||
"Plane.001" : [
|
||||
"/Textures/grass1.png",
|
||||
"/Textures/grass1.png"
|
||||
]
|
||||
},
|
||||
"Models/f15.fbx" : {
|
||||
"Cube.001" : [
|
||||
"/Textures/f15.png",
|
||||
"/Textures/f15.png"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
assets/Textures/f15.png
Normal file
BIN
assets/Textures/f15.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 214 KiB |
BIN
assets/Textures/grass1.png
Normal file
BIN
assets/Textures/grass1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 596 B |
@ -76,6 +76,7 @@ import electrosphere.controls.Control.ControlMethod;
|
||||
import electrosphere.controls.Control.ControlType;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.state.AttackTree;
|
||||
import electrosphere.entity.state.BehaviorTree;
|
||||
import electrosphere.entity.state.equip.EquipState;
|
||||
import electrosphere.entity.state.inventory.InventoryUtils;
|
||||
import electrosphere.entity.state.inventory.UnrelationalInventoryState;
|
||||
@ -418,46 +419,55 @@ public class ControlHandler {
|
||||
mainGameControlList.add(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_FORWARD));
|
||||
controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_FORWARD).setOnPress(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
GroundMovementTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
BehaviorTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
GroundMovementTree groundTree = (GroundMovementTree) movementTree;
|
||||
Vector3f cameraEyeVector = CameraEntityUtils.getCameraEye(Globals.playerCamera);
|
||||
if(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_LEFT).isState()){
|
||||
Vector3d newFacingVector = new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).rotateY(Math.PI/4.0).normalize();
|
||||
CreatureUtils.setFacingVector(Globals.playerEntity, newFacingVector);
|
||||
movementTree.start(MovementRelativeFacing.FORWARD);
|
||||
groundTree.start(MovementRelativeFacing.FORWARD);
|
||||
} else if(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_RIGHT).isState()){
|
||||
Vector3d newFacingVector = new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).rotateY(-Math.PI/4.0).normalize();
|
||||
CreatureUtils.setFacingVector(Globals.playerEntity, newFacingVector);
|
||||
movementTree.start(MovementRelativeFacing.FORWARD);
|
||||
groundTree.start(MovementRelativeFacing.FORWARD);
|
||||
} else {
|
||||
Vector3d newFacingVector = new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).normalize();
|
||||
CreatureUtils.setFacingVector(Globals.playerEntity, newFacingVector);
|
||||
movementTree.start(MovementRelativeFacing.FORWARD);
|
||||
groundTree.start(MovementRelativeFacing.FORWARD);
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_FORWARD).setOnRepeat(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
GroundMovementTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
BehaviorTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
GroundMovementTree groundTree = (GroundMovementTree) movementTree;
|
||||
Vector3f cameraEyeVector = CameraEntityUtils.getCameraEye(Globals.playerCamera);
|
||||
if(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_LEFT).isState()){
|
||||
Vector3d newFacingVector = new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).rotateY(Math.PI/4.0).normalize();
|
||||
CreatureUtils.setFacingVector(Globals.playerEntity, newFacingVector);
|
||||
movementTree.start(MovementRelativeFacing.FORWARD);
|
||||
groundTree.start(MovementRelativeFacing.FORWARD);
|
||||
} else if(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_RIGHT).isState()){
|
||||
Vector3d newFacingVector = new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).rotateY(-Math.PI/4.0).normalize();
|
||||
CreatureUtils.setFacingVector(Globals.playerEntity, newFacingVector);
|
||||
movementTree.start(MovementRelativeFacing.FORWARD);
|
||||
groundTree.start(MovementRelativeFacing.FORWARD);
|
||||
} else {
|
||||
Vector3d newFacingVector = new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).normalize();
|
||||
CreatureUtils.setFacingVector(Globals.playerEntity, newFacingVector);
|
||||
movementTree.start(MovementRelativeFacing.FORWARD);
|
||||
groundTree.start(MovementRelativeFacing.FORWARD);
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_FORWARD).setOnRelease(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
GroundMovementTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
movementTree.slowdown();
|
||||
BehaviorTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
GroundMovementTree groundTree = (GroundMovementTree) movementTree;
|
||||
groundTree.slowdown();
|
||||
}
|
||||
}
|
||||
}});
|
||||
/*
|
||||
@ -466,40 +476,49 @@ public class ControlHandler {
|
||||
mainGameControlList.add(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_BACKWARD));
|
||||
controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_BACKWARD).setOnPress(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
GroundMovementTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
BehaviorTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
GroundMovementTree groundTree = (GroundMovementTree) movementTree;
|
||||
Vector3f cameraEyeVector = CameraEntityUtils.getCameraEye(Globals.playerCamera);
|
||||
if(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_LEFT).isState()){
|
||||
CreatureUtils.setFacingVector(Globals.playerEntity, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).rotateY(3.0/4.0*Math.PI).normalize());
|
||||
movementTree.start(MovementRelativeFacing.FORWARD);
|
||||
groundTree.start(MovementRelativeFacing.FORWARD);
|
||||
} else if(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_RIGHT).isState()){
|
||||
CreatureUtils.setFacingVector(Globals.playerEntity, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).rotateY(5.0/4.0*Math.PI).normalize());
|
||||
movementTree.start(MovementRelativeFacing.FORWARD);
|
||||
groundTree.start(MovementRelativeFacing.FORWARD);
|
||||
} else {
|
||||
CreatureUtils.setFacingVector(Globals.playerEntity, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).rotateY(Math.PI).normalize());
|
||||
movementTree.start(MovementRelativeFacing.FORWARD);
|
||||
groundTree.start(MovementRelativeFacing.FORWARD);
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_BACKWARD).setOnRepeat(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
GroundMovementTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
BehaviorTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
GroundMovementTree groundTree = (GroundMovementTree) movementTree;
|
||||
Vector3f cameraEyeVector = CameraEntityUtils.getCameraEye(Globals.playerCamera);
|
||||
if(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_LEFT).isState()){
|
||||
CreatureUtils.setFacingVector(Globals.playerEntity, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).rotateY(3.0/4.0*Math.PI).normalize());
|
||||
movementTree.start(MovementRelativeFacing.FORWARD);
|
||||
groundTree.start(MovementRelativeFacing.FORWARD);
|
||||
} else if(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_RIGHT).isState()){
|
||||
CreatureUtils.setFacingVector(Globals.playerEntity, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).rotateY(5.0/4.0*Math.PI).normalize());
|
||||
movementTree.start(MovementRelativeFacing.FORWARD);
|
||||
groundTree.start(MovementRelativeFacing.FORWARD);
|
||||
} else {
|
||||
CreatureUtils.setFacingVector(Globals.playerEntity, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).rotateY(Math.PI).normalize());
|
||||
movementTree.start(MovementRelativeFacing.FORWARD);
|
||||
groundTree.start(MovementRelativeFacing.FORWARD);
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_BACKWARD).setOnRelease(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
GroundMovementTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
movementTree.slowdown();
|
||||
BehaviorTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
GroundMovementTree groundTree = (GroundMovementTree) movementTree;
|
||||
groundTree.slowdown();
|
||||
}
|
||||
}
|
||||
}});
|
||||
/*
|
||||
@ -508,34 +527,43 @@ public class ControlHandler {
|
||||
mainGameControlList.add(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_LEFT));
|
||||
controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_LEFT).setOnPress(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
GroundMovementTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
BehaviorTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
GroundMovementTree groundTree = (GroundMovementTree) movementTree;
|
||||
Vector3f cameraEyeVector = CameraEntityUtils.getCameraEye(Globals.playerCamera);
|
||||
if(
|
||||
(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()))
|
||||
){
|
||||
CreatureUtils.setFacingVector(Globals.playerEntity, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).rotateY(Math.PI/2.0).normalize());
|
||||
movementTree.start(MovementRelativeFacing.FORWARD);
|
||||
groundTree.start(MovementRelativeFacing.FORWARD);
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_LEFT).setOnRepeat(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
GroundMovementTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
BehaviorTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
GroundMovementTree groundTree = (GroundMovementTree) movementTree;
|
||||
Vector3f cameraEyeVector = CameraEntityUtils.getCameraEye(Globals.playerCamera);
|
||||
if(
|
||||
(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()))
|
||||
){
|
||||
CreatureUtils.setFacingVector(Globals.playerEntity, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).rotateY(Math.PI/2.0).normalize());
|
||||
movementTree.start(MovementRelativeFacing.FORWARD);
|
||||
groundTree.start(MovementRelativeFacing.FORWARD);
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_LEFT).setOnRelease(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
GroundMovementTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
movementTree.slowdown();
|
||||
BehaviorTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
GroundMovementTree groundTree = (GroundMovementTree) movementTree;
|
||||
groundTree.slowdown();
|
||||
}
|
||||
}
|
||||
}});
|
||||
/*
|
||||
@ -544,34 +572,43 @@ public class ControlHandler {
|
||||
mainGameControlList.add(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_RIGHT));
|
||||
controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_RIGHT).setOnPress(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
GroundMovementTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
BehaviorTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
GroundMovementTree groundTree = (GroundMovementTree) movementTree;
|
||||
Vector3f cameraEyeVector = CameraEntityUtils.getCameraEye(Globals.playerCamera);
|
||||
if(
|
||||
(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()))
|
||||
){
|
||||
CreatureUtils.setFacingVector(Globals.playerEntity, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).rotateY(-Math.PI/2.0).normalize());
|
||||
movementTree.start(MovementRelativeFacing.FORWARD);
|
||||
groundTree.start(MovementRelativeFacing.FORWARD);
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_RIGHT).setOnRepeat(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
GroundMovementTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
BehaviorTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
GroundMovementTree groundTree = (GroundMovementTree) movementTree;
|
||||
Vector3f cameraEyeVector = CameraEntityUtils.getCameraEye(Globals.playerCamera);
|
||||
if(
|
||||
(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()))
|
||||
){
|
||||
CreatureUtils.setFacingVector(Globals.playerEntity, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).rotateY(-Math.PI/2.0).normalize());
|
||||
movementTree.start(MovementRelativeFacing.FORWARD);
|
||||
groundTree.start(MovementRelativeFacing.FORWARD);
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_RIGHT).setOnRelease(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
GroundMovementTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
movementTree.slowdown();
|
||||
BehaviorTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
GroundMovementTree groundTree = (GroundMovementTree) movementTree;
|
||||
groundTree.slowdown();
|
||||
}
|
||||
}
|
||||
}});
|
||||
|
||||
@ -589,36 +626,45 @@ public class ControlHandler {
|
||||
mainGameControlList.add(controls.get(DATA_STRING_INPUT_CODE_STRAFE_LEFT));
|
||||
controls.get(DATA_STRING_INPUT_CODE_STRAFE_LEFT).setOnPress(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
GroundMovementTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
BehaviorTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
GroundMovementTree groundTree = (GroundMovementTree) movementTree;
|
||||
Vector3f cameraEyeVector = CameraEntityUtils.getCameraEye(Globals.playerCamera);
|
||||
CreatureUtils.setFacingVector(Globals.playerEntity, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z));
|
||||
if(
|
||||
(movementTree.getState()==MovementTreeState.IDLE || movementTree.getState()==MovementTreeState.SLOWDOWN) &&
|
||||
(groundTree.getState()==MovementTreeState.IDLE || groundTree.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.LEFT);
|
||||
groundTree.start(MovementRelativeFacing.LEFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
controls.get(DATA_STRING_INPUT_CODE_STRAFE_LEFT).setOnRepeat(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
GroundMovementTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
BehaviorTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
GroundMovementTree groundTree = (GroundMovementTree) movementTree;
|
||||
Vector3f cameraEyeVector = CameraEntityUtils.getCameraEye(Globals.playerCamera);
|
||||
CreatureUtils.setFacingVector(Globals.playerEntity, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z));
|
||||
if(
|
||||
(movementTree.getState()==MovementTreeState.IDLE || movementTree.getState()==MovementTreeState.SLOWDOWN) &&
|
||||
(groundTree.getState()==MovementTreeState.IDLE || groundTree.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.LEFT);
|
||||
groundTree.start(MovementRelativeFacing.LEFT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
controls.get(DATA_STRING_INPUT_CODE_STRAFE_LEFT).setOnRelease(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
GroundMovementTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
movementTree.slowdown();
|
||||
BehaviorTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
GroundMovementTree groundTree = (GroundMovementTree) movementTree;
|
||||
groundTree.slowdown();
|
||||
}
|
||||
}
|
||||
}});
|
||||
/*
|
||||
@ -627,36 +673,45 @@ public class ControlHandler {
|
||||
mainGameControlList.add(controls.get(DATA_STRING_INPUT_CODE_STRAFE_RIGHT));
|
||||
controls.get(DATA_STRING_INPUT_CODE_STRAFE_RIGHT).setOnPress(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
GroundMovementTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
BehaviorTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
GroundMovementTree groundTree = (GroundMovementTree) movementTree;
|
||||
Vector3f cameraEyeVector = CameraEntityUtils.getCameraEye(Globals.playerCamera);
|
||||
CreatureUtils.setFacingVector(Globals.playerEntity, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z));
|
||||
if(
|
||||
(movementTree.getState()==MovementTreeState.IDLE || movementTree.getState()==MovementTreeState.SLOWDOWN) &&
|
||||
(groundTree.getState()==MovementTreeState.IDLE || groundTree.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.RIGHT);
|
||||
groundTree.start(MovementRelativeFacing.RIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
controls.get(DATA_STRING_INPUT_CODE_STRAFE_RIGHT).setOnRepeat(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
GroundMovementTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
BehaviorTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
GroundMovementTree groundTree = (GroundMovementTree) movementTree;
|
||||
Vector3f cameraEyeVector = CameraEntityUtils.getCameraEye(Globals.playerCamera);
|
||||
CreatureUtils.setFacingVector(Globals.playerEntity, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z));
|
||||
if(
|
||||
(movementTree.getState()==MovementTreeState.IDLE || movementTree.getState()==MovementTreeState.SLOWDOWN) &&
|
||||
(groundTree.getState()==MovementTreeState.IDLE || groundTree.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.RIGHT);
|
||||
groundTree.start(MovementRelativeFacing.RIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}});
|
||||
controls.get(DATA_STRING_INPUT_CODE_STRAFE_RIGHT).setOnRelease(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
GroundMovementTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
movementTree.slowdown();
|
||||
BehaviorTree movementTree = CreatureUtils.getEntityMovementTree(Globals.playerEntity);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
GroundMovementTree groundTree = (GroundMovementTree) movementTree;
|
||||
groundTree.slowdown();
|
||||
}
|
||||
}
|
||||
}});
|
||||
/*
|
||||
|
||||
@ -743,15 +743,15 @@ public class LoadingThread extends Thread {
|
||||
// OpportunisticAttacker.attachToCreature(goblin);
|
||||
|
||||
//sword
|
||||
Entity sword = ItemUtils.spawnBasicItem("Katana");
|
||||
EntityUtils.initiallyPositionEntity(sword, new Vector3d(1,0.4f,2));
|
||||
EntityUtils.getRotation(sword).set(new Quaternionf().rotationY((float)(Math.PI/2.0)));
|
||||
// Entity sword = ItemUtils.spawnBasicItem("Katana");
|
||||
// EntityUtils.initiallyPositionEntity(sword, new Vector3d(1,0.4f,2));
|
||||
// EntityUtils.getRotation(sword).set(new Quaternionf().rotationY((float)(Math.PI/2.0)));
|
||||
|
||||
//floating island 1
|
||||
Entity island1 = ObjectUtils.spawnBasicObject("floatingisland1");
|
||||
EntityUtils.getRotation(island1).set(new Quaternionf().rotationX(-(float)(Math.PI/2.0)));
|
||||
EntityUtils.getScale(island1).set(0.3f);
|
||||
EntityUtils.initiallyPositionEntity(island1, new Vector3d(5,0.5,5));
|
||||
// Entity island1 = ObjectUtils.spawnBasicObject("floatingisland1");
|
||||
// EntityUtils.getRotation(island1).set(new Quaternionf().rotationX(-(float)(Math.PI/2.0)));
|
||||
// EntityUtils.getScale(island1).set(0.3f);
|
||||
// EntityUtils.initiallyPositionEntity(island1, new Vector3d(5,0.5,5));
|
||||
|
||||
//work on ez volumetrics shader
|
||||
// Entity myCube = EntityUtils.spawnDrawableEntity("Models/unitcube.fbx");
|
||||
|
||||
@ -5,6 +5,7 @@ import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.collidable.Impulse;
|
||||
import electrosphere.entity.state.equip.EquipState;
|
||||
import electrosphere.entity.state.movement.GroundMovementTree;
|
||||
import electrosphere.entity.state.rotator.RotatorTree;
|
||||
import electrosphere.entity.types.attach.AttachUtils;
|
||||
import electrosphere.entity.types.collision.CollisionObjUtils;
|
||||
@ -116,7 +117,10 @@ public class AttackTree {
|
||||
currentMoveCanHold = currentMove.getHoldAnimationName() != null;
|
||||
//stop movement tree
|
||||
if(parent.containsKey(EntityDataStrings.DATA_STRING_MOVEMENT_BT)){
|
||||
CreatureUtils.getEntityMovementTree(parent).interrupt();
|
||||
BehaviorTree movementTree = CreatureUtils.getEntityMovementTree(parent);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
((GroundMovementTree)movementTree).interrupt();
|
||||
}
|
||||
}
|
||||
Vector3d movementVector = CreatureUtils.getFacingVector(parent);
|
||||
EntityUtils.getRotation(parent).rotationTo(new Vector3f(0,0,1), new Vector3f((float)movementVector.x,(float)movementVector.y,(float)movementVector.z));
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package electrosphere.entity.state;
|
||||
|
||||
import electrosphere.entity.state.movement.AirplaneMovementTree;
|
||||
import electrosphere.entity.state.movement.GroundMovementTree;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
@ -7,6 +8,7 @@ import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.AttackTree.AttackTreeState;
|
||||
import electrosphere.entity.state.movement.GroundMovementTree.MovementTreeState;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.net.parser.net.message.EntityMessage;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
import electrosphere.renderer.anim.Animation;
|
||||
@ -57,11 +59,7 @@ public class IdleTree {
|
||||
public void simulate(){
|
||||
Actor entityActor = EntityUtils.getActor(parent);
|
||||
|
||||
boolean hasMovementTree = parent.containsKey(EntityDataStrings.DATA_STRING_MOVEMENT_BT);
|
||||
GroundMovementTree movementTree = null;
|
||||
if(hasMovementTree){
|
||||
movementTree = CreatureUtils.getEntityMovementTree(parent);
|
||||
}
|
||||
boolean movementTreeIsIdle = movementTreeIsIdle();
|
||||
|
||||
boolean hasAttackTree = parent.containsKey(EntityDataStrings.ATTACK_TREE);
|
||||
AttackTree attackTree = null;
|
||||
@ -106,17 +104,18 @@ public class IdleTree {
|
||||
switch(state){
|
||||
case IDLE:
|
||||
if(entityActor != null){
|
||||
if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(Animation.ANIMATION_IDLE_1)){
|
||||
if(
|
||||
(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(Animation.ANIMATION_IDLE_1)) &&
|
||||
(Globals.assetManager.fetchModel(entityActor.getModelPath()) != null && Globals.assetManager.fetchModel(entityActor.getModelPath()).getAnimation(Animation.ANIMATION_IDLE_1) != null)
|
||||
){
|
||||
entityActor.playAnimation(Animation.ANIMATION_IDLE_1,3);
|
||||
entityActor.incrementAnimationTime(0.0001);
|
||||
}
|
||||
}
|
||||
isIdle = true;
|
||||
if(hasMovementTree){
|
||||
if(movementTree.getState() != MovementTreeState.IDLE){
|
||||
if(!movementTreeIsIdle){
|
||||
isIdle = false;
|
||||
}
|
||||
}
|
||||
if(hasAttackTree){
|
||||
if(attackTree.getState() != AttackTreeState.IDLE){
|
||||
isIdle = false;
|
||||
@ -128,11 +127,9 @@ public class IdleTree {
|
||||
break;
|
||||
case NOT_IDLE:
|
||||
isIdle = true;
|
||||
if(hasMovementTree){
|
||||
if(movementTree.getState() != MovementTreeState.IDLE){
|
||||
if(!movementTreeIsIdle){
|
||||
isIdle = false;
|
||||
}
|
||||
}
|
||||
if(hasAttackTree){
|
||||
if(attackTree.getState() != AttackTreeState.IDLE){
|
||||
isIdle = false;
|
||||
@ -145,6 +142,22 @@ public class IdleTree {
|
||||
}
|
||||
}
|
||||
|
||||
boolean movementTreeIsIdle(){
|
||||
boolean rVal = false;
|
||||
boolean hasMovementTree = parent.containsKey(EntityDataStrings.DATA_STRING_MOVEMENT_BT);
|
||||
if(hasMovementTree){
|
||||
BehaviorTree movementTree = CreatureUtils.getEntityMovementTree(parent);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
if(((GroundMovementTree)movementTree).getState() == MovementTreeState.IDLE){
|
||||
rVal = true;
|
||||
}
|
||||
} else if(movementTree instanceof AirplaneMovementTree){
|
||||
rVal = false;
|
||||
}
|
||||
}
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public void addNetworkMessage(EntityMessage networkMessage) {
|
||||
networkMessageQueue.add(networkMessage);
|
||||
}
|
||||
|
||||
@ -0,0 +1,281 @@
|
||||
package electrosphere.entity.state.movement;
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.BehaviorTree;
|
||||
import electrosphere.entity.state.collidable.Impulse;
|
||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.game.collision.collidable.Collidable;
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.main.Main;
|
||||
import electrosphere.net.parser.net.message.EntityMessage;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
import electrosphere.renderer.anim.Animation;
|
||||
|
||||
public class AirplaneMovementTree implements BehaviorTree {
|
||||
|
||||
public static enum AirplaneMovementTreeState {
|
||||
ACCELERATING,
|
||||
DECELERATING,
|
||||
}
|
||||
|
||||
float minVelocity = 0;
|
||||
float maxRotationSpeed = 1.0f;
|
||||
|
||||
static final double STATE_DIFFERENCE_HARD_UPDATE_THRESHOLD = 1.0;
|
||||
static final double STATE_DIFFERENCE_SOFT_UPDATE_THRESHOLD = 0.2;
|
||||
static final double SOFT_UPDATE_MULTIPLIER = 0.1;
|
||||
|
||||
AirplaneMovementTreeState state;
|
||||
|
||||
Entity parent;
|
||||
|
||||
Collidable collidable;
|
||||
|
||||
CopyOnWriteArrayList<EntityMessage> networkMessageQueue = new CopyOnWriteArrayList<EntityMessage>();
|
||||
|
||||
//when the latest network message for this tree was received
|
||||
//used to filter out packets before the most recent one
|
||||
long lastUpdateTime = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Constructs an airplane movement tree
|
||||
* @param e The entity this tree will be attached to
|
||||
* @param collidable The collidable of the entity that parents this tree
|
||||
*/
|
||||
public AirplaneMovementTree(Entity e, Collidable collidable){
|
||||
state = AirplaneMovementTreeState.ACCELERATING;
|
||||
parent = e;
|
||||
this.collidable = collidable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simulates a step of the behavior tree
|
||||
*/
|
||||
public void simulate(){
|
||||
//
|
||||
//Get important initial values
|
||||
//
|
||||
float velocity = CreatureUtils.getVelocity(parent);
|
||||
float acceleration = CreatureUtils.getAcceleration(parent);
|
||||
float maxNaturalVelocity = CreatureUtils.getMaxNaturalVelocity(parent);
|
||||
Actor entityActor = EntityUtils.getActor(parent);
|
||||
Vector3d position = EntityUtils.getPosition(parent);
|
||||
Vector3d facingVector = CreatureUtils.getFacingVector(parent);
|
||||
Quaternionf movementQuaternion = new Quaternionf().rotationTo(new Vector3f(0,0,1), new Vector3f((float)facingVector.x,0,(float)facingVector.z)).normalize();
|
||||
Quaternionf rotation = EntityUtils.getRotation(parent);
|
||||
//
|
||||
//handle network messages
|
||||
//
|
||||
for(EntityMessage message : networkMessageQueue){
|
||||
networkMessageQueue.remove(message);
|
||||
long updateTime = message.gettime();
|
||||
switch(message.getMessageSubtype()){
|
||||
case MOVE: {
|
||||
if(Globals.RUN_CLIENT){
|
||||
position.set(message.getpositionX(), message.getpositionY(), message.getpositionZ());
|
||||
}
|
||||
} break;
|
||||
//received a message to update the tree
|
||||
case MOVEUPDATE: {
|
||||
if(updateTime > lastUpdateTime){
|
||||
lastUpdateTime = updateTime;
|
||||
//update the behavior tree state
|
||||
switch(message.gettreeState()){
|
||||
case 0:
|
||||
state = AirplaneMovementTreeState.ACCELERATING;
|
||||
break;
|
||||
case 1:
|
||||
state = AirplaneMovementTreeState.DECELERATING;
|
||||
break;
|
||||
}
|
||||
//if we're the client snap to the reported position as appropriate
|
||||
if(!Globals.RUN_SERVER){
|
||||
if(position.distance(message.getpositionX(),message.getpositionY(),message.getpositionZ()) > STATE_DIFFERENCE_HARD_UPDATE_THRESHOLD){
|
||||
EntityUtils.getPosition(parent).set(message.getpositionX(),message.getpositionY(),message.getpositionZ());
|
||||
} else if(position.distance(message.getpositionX(),message.getpositionY(),message.getpositionZ()) > STATE_DIFFERENCE_SOFT_UPDATE_THRESHOLD){
|
||||
EntityUtils.getPosition(parent).add(new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ()).mul(SOFT_UPDATE_MULTIPLIER));
|
||||
}
|
||||
}
|
||||
//we want to always update the server facing vector with where the client says they're facing
|
||||
CreatureUtils.setFacingVector(parent, new Vector3d(message.getrotationX(),message.getrotationY(),message.getrotationZ()));
|
||||
}
|
||||
} break;
|
||||
case SETBEHAVIORTREE: {
|
||||
|
||||
} break;
|
||||
case SETFACING: {
|
||||
|
||||
} break;
|
||||
case SETPOSITION: {
|
||||
|
||||
} break;
|
||||
case ATTACHENTITYTOENTITY:
|
||||
case ATTACKUPDATE:
|
||||
case CREATE:
|
||||
case DESTROY:
|
||||
case KILL:
|
||||
case SETPROPERTY:
|
||||
case SPAWNCREATURE:
|
||||
case SPAWNITEM:
|
||||
//do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
//
|
||||
// Actual simulation
|
||||
//
|
||||
switch(state){
|
||||
case ACCELERATING: {
|
||||
//velocity calculation
|
||||
velocity = velocity + acceleration;
|
||||
if(velocity > maxNaturalVelocity){
|
||||
velocity = maxNaturalVelocity;
|
||||
}
|
||||
CreatureUtils.setVelocity(parent, velocity);
|
||||
//update rotation
|
||||
updateRotation(rotation,facingVector);
|
||||
//add movement impulse
|
||||
addMovementForce(velocity,facingVector,collidable);
|
||||
//if server, update all clients to simulation changes
|
||||
serverUpdateTree(position,facingVector,velocity);
|
||||
} break;
|
||||
case DECELERATING: {
|
||||
//velocity calculation
|
||||
velocity = velocity - acceleration;
|
||||
if(velocity < minVelocity){
|
||||
velocity = minVelocity;
|
||||
}
|
||||
CreatureUtils.setVelocity(parent, velocity);
|
||||
//update rotation
|
||||
updateRotation(rotation,facingVector);
|
||||
//add movement impulse
|
||||
addMovementForce(velocity,facingVector,collidable);
|
||||
//if server, update all clients to simulation changes
|
||||
serverUpdateTree(position,facingVector,velocity);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the rotation of the airplane
|
||||
* @param rotation Rotation quaternion
|
||||
* @param rotationVector Rotation vector
|
||||
*/
|
||||
void updateRotation(Quaternionf rotation, Vector3d rotationVector){
|
||||
if(Globals.RUN_CLIENT && this.parent == Globals.playerEntity){
|
||||
Vector3f cameraEyeVector = CameraEntityUtils.getCameraEye(Globals.playerCamera);
|
||||
rotationVector.set(new Vector3f((float)rotationVector.x,(float)rotationVector.y,(float)rotationVector.z).mul(1.0f - this.maxRotationSpeed).add(new Vector3f(cameraEyeVector).mul(-this.maxRotationSpeed)));
|
||||
rotation.set(new Quaternionf().rotationTo(new Vector3f(0,0,1), new Vector3f((float)rotationVector.x,(float)rotationVector.y,(float)rotationVector.z)).normalize());
|
||||
// rotation.slerp(new Quaternionf().rotationTo(new Vector3f((float)rotationVector.x,(float)rotationVector.y,(float)rotationVector.z), cameraEyeVector), this.maxRotationSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the force to actually move the airplane entity
|
||||
* @param velocity The current velocity
|
||||
* @param facingVector The current facing vector
|
||||
* @param collidable The collidable of the entity
|
||||
*/
|
||||
void addMovementForce(float velocity, Vector3d facingVector, Collidable collidable){
|
||||
collidable.addImpulse(new Impulse(new Vector3d(facingVector), new Vector3d(0,0,0), new Vector3d(0,0,0), velocity * Main.deltaFrames, "movement"));
|
||||
}
|
||||
|
||||
/**
|
||||
* If the instance is a server, update all clients within the chunk as appropriate
|
||||
* @param position The position of the airplane
|
||||
* @param facingVector The facing vector of the airplane
|
||||
* @param velocity The velocity of the airplane
|
||||
*/
|
||||
void serverUpdateTree(Vector3d position, Vector3d facingVector, float velocity){
|
||||
if(Globals.RUN_SERVER){
|
||||
int stateNumber = 0;
|
||||
switch(this.state){
|
||||
case ACCELERATING:
|
||||
stateNumber = 0;
|
||||
break;
|
||||
case DECELERATING:
|
||||
stateNumber = 1;
|
||||
break;
|
||||
}
|
||||
Globals.dataCellManager.sendNetworkMessageToChunk(
|
||||
EntityMessage.constructmoveUpdateMessage(
|
||||
parent.getId(),
|
||||
Main.getCurrentFrame(),
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
facingVector.x,
|
||||
facingVector.y,
|
||||
facingVector.z,
|
||||
velocity,
|
||||
stateNumber
|
||||
),
|
||||
Globals.serverWorldData.convertRealToChunkSpace(position.x),
|
||||
Globals.serverWorldData.convertRealToChunkSpace(position.z)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a network message relavent to this tree
|
||||
* @param networkMessage The network message to register
|
||||
*/
|
||||
public void addNetworkMessage(EntityMessage networkMessage) {
|
||||
networkMessageQueue.add(networkMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the animation to play at a given point in the simulation loop
|
||||
* @return The animation to play as a string
|
||||
*/
|
||||
public String determineCorrectAnimation(){
|
||||
String rVal = "";
|
||||
|
||||
switch(state){
|
||||
case ACCELERATING:
|
||||
rVal = Animation.ANIMATION_IDLE_1;
|
||||
break;
|
||||
case DECELERATING:
|
||||
rVal = Animation.ANIMATION_IDLE_1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the current state of the behavior tree
|
||||
* @return The current state of the behavior tree
|
||||
*/
|
||||
public AirplaneMovementTreeState getState(){
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minimum velocity of this airplane tree
|
||||
* @param minVelocity The minimum velocity
|
||||
*/
|
||||
public void setMinimumVelocity(float minVelocity){
|
||||
this.minVelocity = minVelocity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the max rotation speed of this airplane movement tree
|
||||
* @param maxRotationSpeed The max rotation speed
|
||||
*/
|
||||
public void setMaxRotationSpeed(float maxRotationSpeed){
|
||||
this.maxRotationSpeed = maxRotationSpeed;
|
||||
}
|
||||
|
||||
}
|
||||
@ -11,6 +11,7 @@ import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.AttackTree;
|
||||
import electrosphere.entity.state.BehaviorTree;
|
||||
import electrosphere.entity.state.AttackTree.AttackTreeState;
|
||||
import electrosphere.entity.state.movement.SprintTree.SprintTreeState;
|
||||
import electrosphere.game.collision.CollisionEngine;
|
||||
@ -34,7 +35,7 @@ import org.joml.Vector3f;
|
||||
/*
|
||||
Behavior tree for movement in an entity
|
||||
*/
|
||||
public class GroundMovementTree {
|
||||
public class GroundMovementTree implements BehaviorTree {
|
||||
|
||||
public static enum MovementTreeState {
|
||||
STARTUP,
|
||||
|
||||
@ -5,6 +5,7 @@ import electrosphere.dynamics.RigidBody;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.movement.AirplaneMovementTree;
|
||||
import electrosphere.entity.state.movement.FallTree;
|
||||
import electrosphere.entity.state.movement.GroundMovementTree;
|
||||
import electrosphere.entity.state.movement.JumpTree;
|
||||
@ -32,6 +33,7 @@ import electrosphere.game.data.creature.type.CollidableTemplate;
|
||||
import electrosphere.game.data.creature.type.SprintSystem;
|
||||
import electrosphere.game.data.creature.type.attack.AttackMove;
|
||||
import electrosphere.game.data.creature.type.equip.EquipPoint;
|
||||
import electrosphere.game.data.creature.type.movement.AirplaneMovementSystem;
|
||||
import electrosphere.game.data.creature.type.movement.FallMovementSystem;
|
||||
import electrosphere.game.data.creature.type.movement.GroundMovementSystem;
|
||||
import electrosphere.game.data.creature.type.movement.JumpMovementSystem;
|
||||
@ -165,8 +167,15 @@ public class CreatureUtils {
|
||||
break;
|
||||
}
|
||||
}
|
||||
//
|
||||
//
|
||||
// MOVEMENT SYSTEMS
|
||||
//
|
||||
//
|
||||
for(MovementSystem movementSystem : rawType.getMovementSystems()){
|
||||
switch(movementSystem.getType()){
|
||||
//
|
||||
// Generic ground
|
||||
case GroundMovementSystem.GROUND_MOVEMENT_SYSTEM:
|
||||
GroundMovementSystem groundMovementSystem = (GroundMovementSystem)movementSystem;
|
||||
GroundMovementTree moveTree = new GroundMovementTree(rVal,CollisionObjUtils.getCollidable(rVal));
|
||||
@ -179,6 +188,7 @@ public class CreatureUtils {
|
||||
if(groundMovementSystem.getAnimationWindDown()!= null){
|
||||
moveTree.setAnimationSlowDown(groundMovementSystem.getAnimationWindDown().getName());
|
||||
}
|
||||
//sprint system
|
||||
if(groundMovementSystem.getSprintSystem() != null){
|
||||
SprintSystem sprintSystem = groundMovementSystem.getSprintSystem();
|
||||
SprintTree sprintTree = new SprintTree(rVal,sprintSystem.getMaxVelocity(),sprintSystem.getStaminaMax());
|
||||
@ -204,14 +214,16 @@ public class CreatureUtils {
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_VELOCITY, 0f);
|
||||
Globals.entityManager.registerMoveableEntity(rVal);
|
||||
break;
|
||||
//
|
||||
// Jump
|
||||
case JumpMovementSystem.JUMP_MOVEMENT_SYSTEM:
|
||||
JumpMovementSystem jumpMovementSystem = (JumpMovementSystem)movementSystem;
|
||||
JumpTree jumpTree = new JumpTree(rVal, jumpMovementSystem.getJumpFrames(), jumpMovementSystem.getJumpForce());
|
||||
if(jumpMovementSystem.getAnimationJump() != null){
|
||||
jumpTree.setAnimationJump(jumpMovementSystem.getAnimationJump().getName());
|
||||
}
|
||||
if(CreatureUtils.getEntityMovementTree(rVal) != null){
|
||||
CreatureUtils.getEntityMovementTree(rVal).setJumpTree(jumpTree);
|
||||
if(CreatureUtils.getEntityMovementTree(rVal) != null && CreatureUtils.getEntityMovementTree(rVal) instanceof GroundMovementTree){
|
||||
((GroundMovementTree)CreatureUtils.getEntityMovementTree(rVal)).setJumpTree(jumpTree);
|
||||
}
|
||||
if(FallTree.getFallTree(rVal)!=null){
|
||||
FallTree.getFallTree(rVal).setJumpTree(jumpTree);
|
||||
@ -219,6 +231,8 @@ public class CreatureUtils {
|
||||
rVal.putData(EntityDataStrings.JUMP_TREE, jumpTree);
|
||||
Globals.entityManager.registerBehaviorTree(jumpTree);
|
||||
break;
|
||||
//
|
||||
// Falling
|
||||
case FallMovementSystem.FALL_MOVEMENT_SYSTEM:
|
||||
FallMovementSystem fallMovementSystem = (FallMovementSystem)movementSystem;
|
||||
FallTree fallTree = new FallTree(rVal);
|
||||
@ -228,8 +242,8 @@ public class CreatureUtils {
|
||||
if(fallMovementSystem.getAnimationLand()!=null){
|
||||
fallTree.setAnimationLand(fallMovementSystem.getAnimationLand().getName());
|
||||
}
|
||||
if(CreatureUtils.getEntityMovementTree(rVal) != null){
|
||||
CreatureUtils.getEntityMovementTree(rVal).setFallTree(fallTree);
|
||||
if(CreatureUtils.getEntityMovementTree(rVal) != null && CreatureUtils.getEntityMovementTree(rVal) instanceof GroundMovementTree){
|
||||
((GroundMovementTree)CreatureUtils.getEntityMovementTree(rVal)).setFallTree(fallTree);
|
||||
}
|
||||
if(JumpTree.getJumpTree(rVal)!=null){
|
||||
fallTree.setJumpTree(JumpTree.getJumpTree(rVal));
|
||||
@ -237,6 +251,22 @@ public class CreatureUtils {
|
||||
rVal.putData(EntityDataStrings.FALL_TREE, fallTree);
|
||||
Globals.entityManager.registerBehaviorTree(fallTree);
|
||||
break;
|
||||
//
|
||||
// Airplane
|
||||
case AirplaneMovementSystem.AIRPLANE_MOVEMENT_SYSTEM: {
|
||||
//construct tree
|
||||
AirplaneMovementSystem airplaneMovementSystem = (AirplaneMovementSystem) movementSystem;
|
||||
AirplaneMovementTree airplaneMovementTree = new AirplaneMovementTree(rVal, CollisionObjUtils.getCollidable(rVal));
|
||||
//set properties
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_MAX_NATURAL_VELOCITY, airplaneMovementSystem.getMaxVelocity());
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_ACCELERATION, airplaneMovementSystem.getAcceleration());
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_VELOCITY, 0f);
|
||||
airplaneMovementTree.setMinimumVelocity(airplaneMovementSystem.getMinVelocity());
|
||||
//register misc stuff
|
||||
rVal.putData(EntityDataStrings.DATA_STRING_MOVEMENT_BT, airplaneMovementTree);
|
||||
CreatureUtils.setFacingVector(rVal, new Vector3d(0,0,0));
|
||||
Globals.entityManager.registerMoveableEntity(rVal);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
if(rawType.getEquipPoints() != null && rawType.getEquipPoints().size() > 0){
|
||||
@ -441,12 +471,17 @@ public class CreatureUtils {
|
||||
e.putData(EntityDataStrings.DATA_STRING_MAX_NATURAL_VELOCITY, scalar);
|
||||
}
|
||||
|
||||
public static GroundMovementTree getEntityMovementTree(Entity e){
|
||||
return (GroundMovementTree)e.getData(EntityDataStrings.DATA_STRING_MOVEMENT_BT);
|
||||
public static BehaviorTree getEntityMovementTree(Entity e){
|
||||
return (BehaviorTree)e.getData(EntityDataStrings.DATA_STRING_MOVEMENT_BT);
|
||||
}
|
||||
|
||||
public static void attachEntityMessageToMovementTree(Entity e, EntityMessage em){
|
||||
getEntityMovementTree(e).addNetworkMessage(em);
|
||||
BehaviorTree movementTree = getEntityMovementTree(e);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
((GroundMovementTree)movementTree).addNetworkMessage(em);
|
||||
} else if(movementTree instanceof AirplaneMovementTree){
|
||||
((AirplaneMovementTree)movementTree).addNetworkMessage(em);
|
||||
}
|
||||
}
|
||||
|
||||
public static AttackTree getEntityAttackTree(Entity e){
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
package electrosphere.game.data.creature.type.movement;
|
||||
|
||||
public class AirplaneMovementSystem implements MovementSystem {
|
||||
|
||||
public static final String AIRPLANE_MOVEMENT_SYSTEM = "AIRPLANE";
|
||||
|
||||
float acceleration;
|
||||
float maxVelocity;
|
||||
float minVelocity;
|
||||
float maxRotationSpeed;
|
||||
|
||||
String type;
|
||||
|
||||
public float getAcceleration() {
|
||||
return acceleration;
|
||||
}
|
||||
|
||||
public float getMaxVelocity() {
|
||||
return maxVelocity;
|
||||
}
|
||||
|
||||
public float getMinVelocity(){
|
||||
return minVelocity;
|
||||
}
|
||||
|
||||
public float maxRotationSpeed(){
|
||||
return maxRotationSpeed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
||||
@ -19,6 +19,8 @@ public class MovementSystemSerializer implements JsonDeserializer<MovementSystem
|
||||
return context.deserialize(json, JumpMovementSystem.class);
|
||||
case FallMovementSystem.FALL_MOVEMENT_SYSTEM:
|
||||
return context.deserialize(json, FallMovementSystem.class);
|
||||
case AirplaneMovementSystem.AIRPLANE_MOVEMENT_SYSTEM:
|
||||
return context.deserialize(json, AirplaneMovementSystem.class);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -78,12 +78,12 @@ public class MillAbout extends AI {
|
||||
if(moveTargetPosition.distance(position) > 0.4){
|
||||
Vector3d moveVector = new Vector3d(moveTargetPosition).sub(position).normalize();
|
||||
CreatureUtils.setFacingVector(character, new Vector3d((float)moveVector.x,(float)moveVector.y,(float)moveVector.z));
|
||||
GroundMovementTree characterMoveTree = CreatureUtils.getEntityMovementTree(character);
|
||||
GroundMovementTree characterMoveTree = (GroundMovementTree)CreatureUtils.getEntityMovementTree(character);
|
||||
if(characterMoveTree.getState()==GroundMovementTree.MovementTreeState.IDLE || characterMoveTree.getState()==GroundMovementTree.MovementTreeState.SLOWDOWN){
|
||||
characterMoveTree.start(MovementRelativeFacing.FORWARD);
|
||||
}
|
||||
} else {
|
||||
GroundMovementTree characterMoveTree = CreatureUtils.getEntityMovementTree(character);
|
||||
GroundMovementTree characterMoveTree = (GroundMovementTree)CreatureUtils.getEntityMovementTree(character);
|
||||
characterMoveTree.slowdown();
|
||||
// System.out.println("Made it to destination");
|
||||
moveToTarget = false;
|
||||
|
||||
@ -71,7 +71,7 @@ public class MindlessAttacker extends AI{
|
||||
Vector3d characterPosition = EntityUtils.getPosition(character);
|
||||
Vector3d moveVector = new Vector3d(targetPosition).sub(characterPosition).normalize();
|
||||
CreatureUtils.setFacingVector(character, new Vector3d((float)moveVector.x,(float)moveVector.y,(float)moveVector.z));
|
||||
GroundMovementTree characterMoveTree = CreatureUtils.getEntityMovementTree(character);
|
||||
GroundMovementTree characterMoveTree = (GroundMovementTree)CreatureUtils.getEntityMovementTree(character);
|
||||
if(characterMoveTree.getState()==GroundMovementTree.MovementTreeState.IDLE || characterMoveTree.getState()==GroundMovementTree.MovementTreeState.SLOWDOWN){
|
||||
characterMoveTree.start(MovementRelativeFacing.FORWARD);
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ public class OpportunisticAttacker extends AI {
|
||||
Vector3d characterPosition = EntityUtils.getPosition(character);
|
||||
Vector3d moveVector = new Vector3d(targetPosition).sub(characterPosition).normalize();
|
||||
CreatureUtils.setFacingVector(character, new Vector3d((float)moveVector.x,(float)moveVector.y,(float)moveVector.z));
|
||||
GroundMovementTree characterMoveTree = CreatureUtils.getEntityMovementTree(character);
|
||||
GroundMovementTree characterMoveTree = (GroundMovementTree)CreatureUtils.getEntityMovementTree(character);
|
||||
if(characterMoveTree.getState()==GroundMovementTree.MovementTreeState.IDLE || characterMoveTree.getState()==GroundMovementTree.MovementTreeState.SLOWDOWN){
|
||||
characterMoveTree.start(MovementRelativeFacing.FORWARD);
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.AttackTree;
|
||||
import electrosphere.entity.state.BehaviorTree;
|
||||
import electrosphere.entity.state.IdleTree;
|
||||
import electrosphere.entity.state.movement.GroundMovementTree;
|
||||
import electrosphere.entity.state.ParticleTree;
|
||||
@ -62,7 +63,7 @@ public class MicroSimulation {
|
||||
}
|
||||
//simulate creature behavior trees
|
||||
for(Entity currentMoveable : Globals.entityManager.getMoveable()){
|
||||
GroundMovementTree behaviorTree = CreatureUtils.getEntityMovementTree(currentMoveable);
|
||||
BehaviorTree behaviorTree = CreatureUtils.getEntityMovementTree(currentMoveable);
|
||||
behaviorTree.simulate();
|
||||
}
|
||||
//sprint tree
|
||||
|
||||
@ -13,6 +13,7 @@ import electrosphere.engine.cli.CLIParser;
|
||||
import electrosphere.game.client.ClientFunctions;
|
||||
import electrosphere.game.config.UserSettings;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.renderer.Model;
|
||||
import electrosphere.renderer.RenderingEngine;
|
||||
|
||||
|
||||
@ -129,9 +130,9 @@ public class Main {
|
||||
|
||||
//uncomment to test loading a model into engine
|
||||
// if(1==1){
|
||||
// Globals.assetManager.addModelPathToQueue("/Models/baseman.fbx");
|
||||
// Globals.assetManager.addModelPathToQueue("/Models/tank1.fbx");
|
||||
// Globals.assetManager.loadAssetsInQueue();
|
||||
// Model model = Globals.assetManager.fetchModel("/Models/baseman.fbx");
|
||||
// Model model = Globals.assetManager.fetchModel("/Models/tank1.fbx");
|
||||
// // for(electrosphere.renderer.anim.Animation anim : model.animations){
|
||||
// // if(anim.name.equals("Armature|Idle1")){
|
||||
// // System.out.println(anim.duration);
|
||||
@ -144,7 +145,8 @@ public class Main {
|
||||
// // break;
|
||||
// // }
|
||||
// // }
|
||||
// model.describeHighLevel();
|
||||
// model.animations.get(0).fullDescribeAnimation();
|
||||
// // model.describeHighLevel();
|
||||
// System.exit(0);
|
||||
// }
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ import electrosphere.game.data.creature.type.visualattribute.AttributeVariant;
|
||||
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
|
||||
import electrosphere.main.Globals;
|
||||
import electrosphere.net.parser.net.message.CharacterMessage;
|
||||
import electrosphere.renderer.Model;
|
||||
import electrosphere.renderer.RenderingEngine;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
import electrosphere.renderer.actor.ActorStaticMorph;
|
||||
|
||||
@ -423,135 +423,6 @@ public class Mesh {
|
||||
|
||||
}
|
||||
|
||||
// public void draw() {
|
||||
// glUseProgram(shader.shaderProgram);
|
||||
//
|
||||
// //Until we switch to uniform buffer objects we will have to buffer lighting data here manually each time we draw
|
||||
// //side note: :(
|
||||
// if(light_buffer == null){
|
||||
// float temp[] = new float[3];
|
||||
// temp[0] = 0.2f;
|
||||
// temp[1] = -1.0f;
|
||||
// temp[2] = 0.3f;
|
||||
// glUniform3fv(glGetUniformLocation(shader.shaderProgram, "dirLight.direction"), temp);
|
||||
//
|
||||
// temp[0] = 0.1f;
|
||||
// temp[1] = 0.1f;
|
||||
// temp[2] = 0.1f;
|
||||
// glUniform3fv(glGetUniformLocation(shader.shaderProgram, "dirLight.ambient"), temp);
|
||||
//
|
||||
// temp[0] = 0.8f;
|
||||
// temp[1] = 0.8f;
|
||||
// temp[2] = 0.8f;
|
||||
// glUniform3fv(glGetUniformLocation(shader.shaderProgram, "dirLight.diffuse"), temp);
|
||||
//
|
||||
// temp[0] = 0.1f;
|
||||
// temp[1] = 0.1f;
|
||||
// temp[2] = 0.1f;
|
||||
// glUniform3fv(glGetUniformLocation(shader.shaderProgram, "dirLight.specular"), temp);
|
||||
//
|
||||
// temp[0] = 32f;
|
||||
// glUniform1fv(glGetUniformLocation(shader.shaderProgram, "material.shininess"), temp);
|
||||
//
|
||||
// GL20.glUniformMatrix4fv(glGetUniformLocation(shader.shaderProgram, "model"), false, parent.modelMatrix.get(new float[16]));
|
||||
//
|
||||
// Vector3f cam_Loc = CameraEntityUtils.getCameraEye(Globals.playerCamera);//Globals.cameraVisible.pos_Center;
|
||||
// temp[0] = cam_Loc.x;
|
||||
// temp[1] = cam_Loc.y;
|
||||
// temp[2] = cam_Loc.z;
|
||||
// glUniform3fv(glGetUniformLocation(shader.shaderProgram, "viewPos"), temp);
|
||||
// } else {
|
||||
// GL20.glUniformMatrix4fv(glGetUniformLocation(shader.shaderProgram, "model"), false, parent.modelMatrix.get(new float[16]));
|
||||
// }
|
||||
//
|
||||
//
|
||||
// if(material == null){
|
||||
// Globals.materialDefault.apply_material(0,1);
|
||||
// GL20.glUniform1i(glGetUniformLocation(shader.shaderProgram, "hasTransparency"), 0);
|
||||
// } else {
|
||||
// material.apply_material();
|
||||
// if(material.hasTransparency){
|
||||
// GL20.glUniform1i(glGetUniformLocation(shader.shaderProgram, "hasTransparency"), 1);
|
||||
// } else {
|
||||
// GL20.glUniform1i(glGetUniformLocation(shader.shaderProgram, "hasTransparency"), 1);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// glBindVertexArray(vertexArrayObject);
|
||||
//
|
||||
//
|
||||
// glActiveTexture(GL_TEXTURE3);
|
||||
// glBindTexture(GL_TEXTURE_2D, Globals.shadowMapTextureLoc);
|
||||
// glUniform1i(glGetUniformLocation(shader.shaderProgram, "shadowMap"), 3);
|
||||
//
|
||||
//
|
||||
//
|
||||
// //
|
||||
// //Handle bones
|
||||
// //
|
||||
// if(bones != null && !bones.isEmpty()){
|
||||
// glUniform1i(shader.shaderVertexHasBonesLoc, 1);
|
||||
// glUniform1i(shader.shaderVertexNumBonesLoc, bones.size());
|
||||
// Iterator<String> boneIterator = bone_id_list.iterator();
|
||||
// float bufferarray[] = new float[16];
|
||||
// int incrementer = 0;
|
||||
// while (boneIterator.hasNext()){
|
||||
// Bone currentBone = parent.boneMap.get(boneIterator.next());
|
||||
// Matrix4f currentMat = new Matrix4f(currentBone.final_transform);
|
||||
// currentMat.get(bufferarray);
|
||||
// String currentUniform = "bones[" + incrementer + "]";
|
||||
// GL20.glUniformMatrix4fv(glGetUniformLocation(shader.shaderProgram, currentUniform), false, bufferarray);
|
||||
// incrementer++;
|
||||
// }
|
||||
// } else {
|
||||
// glUniform1i(shader.shaderVertexHasBonesLoc, 0);
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// //buffer model/view/proj matrices
|
||||
// glUniformMatrix4fv(shader.shaderVertexModelLoc, false, parent.modelMatrix.get(new float[16]));
|
||||
// glUniformMatrix4fv(shader.shaderVertexViewLoc, false, Globals.viewMatrix.get(new float[16]));
|
||||
// glUniformMatrix4fv(shader.shaderVertexProjectionLoc, false, Globals.projectionMatrix.get(new float[16]));
|
||||
// glUniform3fv(shader.shaderVertexViewPosLoc, CameraEntityUtils.getCameraEye(Globals.playerCamera).get(BufferUtils.createFloatBuffer(3)));
|
||||
// glUniformMatrix4fv(glGetUniformLocation(shader.shaderProgram, "lightSpaceMatrix"), false, Globals.lightDepthMatrix.get(new float[16]));
|
||||
//
|
||||
// //
|
||||
// //
|
||||
// //Testing Lights
|
||||
// //
|
||||
// //
|
||||
// float test_Light_Data[] = new float[3];
|
||||
// test_Light_Data[0] = 0.2f;
|
||||
// test_Light_Data[1] = -1.0f;
|
||||
// test_Light_Data[2] = 0.3f;
|
||||
// glUniform3fv(glGetUniformLocation(shader.shaderProgram, "dirLight.direction"), test_Light_Data);
|
||||
//
|
||||
// test_Light_Data = new float[3];
|
||||
// test_Light_Data[0] = 0.3f;
|
||||
// test_Light_Data[1] = 0.3f;
|
||||
// test_Light_Data[2] = 0.3f;
|
||||
// glUniform3fv(glGetUniformLocation(shader.shaderProgram, "dirLight.ambient"), test_Light_Data);
|
||||
//
|
||||
// test_Light_Data = new float[3];
|
||||
// test_Light_Data[0] = 0.5f;
|
||||
// test_Light_Data[1] = 0.5f;
|
||||
// test_Light_Data[2] = 0.5f;
|
||||
// glUniform3fv(glGetUniformLocation(shader.shaderProgram, "dirLight.diffuse"), test_Light_Data);
|
||||
//
|
||||
// Vector3f cam_Loc = CameraEntityUtils.getCameraEye(Globals.playerCamera);
|
||||
// test_Light_Data = new float[3];
|
||||
// test_Light_Data[0] = cam_Loc.x;
|
||||
// test_Light_Data[1] = cam_Loc.y;
|
||||
// test_Light_Data[2] = cam_Loc.z;
|
||||
// glUniform3fv(glGetUniformLocation(shader.shaderProgram, "viewPos"), test_Light_Data);
|
||||
//
|
||||
//
|
||||
// GL11.glDrawElements(GL_TRIANGLES, elementCount, GL_UNSIGNED_INT, 0);
|
||||
// glBindVertexArray(0);
|
||||
// }
|
||||
|
||||
public void buffer_vertices(FloatBuffer verticies, int vertexDimension){
|
||||
vertexBuffer = glGenBuffers();
|
||||
@ -617,76 +488,6 @@ public class Mesh {
|
||||
}
|
||||
|
||||
|
||||
// public void drawForDepthBuffer(){
|
||||
// /*
|
||||
//
|
||||
// !!!!!!!!!!!!!!!!!THERE IS NO SHADER PROGRAM HERE!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
//
|
||||
// The shader program is set in the main render function to make things easier
|
||||
//
|
||||
// */
|
||||
//
|
||||
//
|
||||
// glBindVertexArray(vertexArrayObject);
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// //
|
||||
// //Handle bones
|
||||
// //
|
||||
// if(bones != null && !bones.isEmpty()){
|
||||
// glUniform1i(glGetUniformLocation(Globals.depthMapShaderProgramLoc, "numBones"), bones.size());
|
||||
// glUniform1i(glGetUniformLocation(Globals.depthMapShaderProgramLoc, "hasBones"), 1);
|
||||
// Iterator<String> boneIterator = bone_id_list.iterator();
|
||||
// float bufferarray[] = new float[16];
|
||||
// int incrementer = 0;
|
||||
// while (boneIterator.hasNext()){
|
||||
// Bone currentBone = parent.boneMap.get(boneIterator.next());
|
||||
// Matrix4f currentMat = new Matrix4f(currentBone.final_transform);
|
||||
// currentMat.get(bufferarray);
|
||||
// String currentUniform = "bones[" + incrementer + "]";
|
||||
// GL20.glUniformMatrix4fv(glGetUniformLocation(Globals.depthMapShaderProgramLoc, currentUniform), false, bufferarray);
|
||||
// incrementer++;
|
||||
// }
|
||||
// } else {
|
||||
// glUniform1i(glGetUniformLocation(Globals.depthMapShaderProgramLoc, "hasBones"), 0);
|
||||
// }
|
||||
//
|
||||
// //buffer model/view/proj matrices
|
||||
// glUniformMatrix4fv(glGetUniformLocation(Globals.depthMapShaderProgramLoc, "model"), false, parent.modelMatrix.get(new float[16]));
|
||||
// glUniformMatrix4fv(glGetUniformLocation(Globals.depthMapShaderProgramLoc, "lightSpaceMatrix"), false, Globals.lightDepthMatrix.get(new float[16]));
|
||||
//
|
||||
//
|
||||
// GL11.glDrawElements(GL_TRIANGLES, elementCount, GL_UNSIGNED_INT, 0);
|
||||
// glBindVertexArray(0);
|
||||
// }
|
||||
|
||||
// public void drawUI(){
|
||||
// glUseProgram(shader.shaderProgram);
|
||||
//
|
||||
// glBindVertexArray(vertexArrayObject);
|
||||
//
|
||||
// if(material == null){
|
||||
// Globals.materialDefault.apply_material(0,1);
|
||||
// GL20.glUniform1i(glGetUniformLocation(shader.shaderProgram, "hasTransparency"), 0);
|
||||
// } else {
|
||||
// material.apply_material();
|
||||
// if(material.hasTransparency){
|
||||
// GL20.glUniform1i(glGetUniformLocation(shader.shaderProgram, "hasTransparency"), 1);
|
||||
// } else {
|
||||
// GL20.glUniform1i(glGetUniformLocation(shader.shaderProgram, "hasTransparency"), 1);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //buffers contents of uniforms map to gpu
|
||||
// bufferAllUniforms();
|
||||
//
|
||||
// glUniformMatrix4fv(glGetUniformLocation(shader.shaderProgram, "model"), false, parent.modelMatrix.get(new float[16]));
|
||||
//
|
||||
// GL11.glDrawElements(GL_TRIANGLES, elementCount, GL_UNSIGNED_INT, 0);
|
||||
// glBindVertexArray(0);
|
||||
// }
|
||||
|
||||
public void setUniform(String key, Object o){
|
||||
uniforms.put(key, o);
|
||||
|
||||
@ -88,8 +88,13 @@ public class ActorPanel implements DrawableElement, DraggableElement {
|
||||
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
Model actorModel = Globals.assetManager.fetchModel(actor.getModelPath());
|
||||
|
||||
if(currentAnim != null){
|
||||
if(!actor.isPlayingAnimation() || !actor.isPlayingAnimation(currentAnim)){
|
||||
if((!actor.isPlayingAnimation() || !actor.isPlayingAnimation(currentAnim)) &&
|
||||
actorModel != null &&
|
||||
actorModel.getAnimation(currentAnim) != null
|
||||
){
|
||||
actor.playAnimation(currentAnim,3);
|
||||
actor.incrementAnimationTime(0.0001);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user