diff --git a/assets/Data/creatures.json b/assets/Data/creatures.json index d0bb6dd8..c96fdada 100644 --- a/assets/Data/creatures.json +++ b/assets/Data/creatures.json @@ -232,8 +232,45 @@ "onDamageIFrames" : 30 }, "modelPath" : "Models/goblin1.fbx" - } + }, + + { + "name" : "CUBE_MAN", + "bodyParts" : [ + { + "name" : "CUBE", + "type" : "CUBE_MAN" + } + ], + "hitboxes" : [], + "tokens" : [ + "BLENDER_TRANSFORM", + "SENTIENT", + "GRAVITY" + ], + "movementSystems" : [ + { + "type" : "GROUND", + "acceleration" : 0.05, + "maxVelocity" : 0.25 + } + ], + "physicsObject" : { + "type" : "CYLINDER", + "dimension1" : 0.1, + "dimension2" : 0.45, + "dimension3" : 0.1, + "offsetX" : 0, + "offsetY" : 0.45, + "offsetZ" : 0 + }, + "healthSystem" : { + "maxHealth" : 100, + "onDamageIFrames" : 30 + }, + "modelPath" : "Models/unitcube.fbx" + } diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 diff --git a/launcher/launcher b/launcher/launcher new file mode 100755 index 00000000..5eaf6fbf Binary files /dev/null and b/launcher/launcher differ diff --git a/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java b/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java index 0057c2af..02792e17 100644 --- a/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java +++ b/src/main/java/electrosphere/entity/types/creature/CreatureUtils.java @@ -122,11 +122,13 @@ public class CreatureUtils { } } //add all attack moves - for(AttackMove attackMove : rawType.getAttackMoves()){ - switch(attackMove.getType()){ - case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND: - rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND, attackMove); - break; + if(rawType.getAttackMoves() != null && rawType.getAttackMoves().size() > 0){ + for(AttackMove attackMove : rawType.getAttackMoves()){ + switch(attackMove.getType()){ + case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND: + rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND, attackMove); + break; + } } } //add health system diff --git a/src/main/java/electrosphere/net/server/ServerConnectionHandler.java b/src/main/java/electrosphere/net/server/ServerConnectionHandler.java index 7db746ab..594f079a 100644 --- a/src/main/java/electrosphere/net/server/ServerConnectionHandler.java +++ b/src/main/java/electrosphere/net/server/ServerConnectionHandler.java @@ -97,7 +97,7 @@ public class ServerConnectionHandler implements Runnable { Player newPlayerObject = new Player(this); Globals.playerManager.addPlayer(newPlayerObject); //spawn player in world - Entity newPlayerCharacter = CreatureUtils.spawnBasicCreature("Human"); + Entity newPlayerCharacter = CreatureUtils.spawnBasicCreature("CUBE_MAN"); playerCharacterID = newPlayerCharacter.getId(); CollisionObjUtils.positionCharacter(newPlayerCharacter, new Vector3f(Globals.spawnPoint.x,Globals.spawnPoint.y,Globals.spawnPoint.z)); //attach player object to player character @@ -107,8 +107,8 @@ public class ServerConnectionHandler implements Runnable { Globals.dataCellManager.addPlayer(newPlayerObject); Globals.dataCellManager.movePlayer(newPlayerObject, Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.x), Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.z)); //spawn player sword - Entity sword = ItemUtils.spawnBasicItem("Katana"); - AttachUtils.attachEntityToEntityAtBone(newPlayerCharacter, sword, "Bone.031"); +// Entity sword = ItemUtils.spawnBasicItem("Katana"); +// AttachUtils.attachEntityToEntityAtBone(newPlayerCharacter, sword, "Bone.031"); //set controller id CreatureUtils.setControllerPlayerId(newPlayerCharacter, playerID); if(Globals.RUN_SERVER && Main.playerId == -1){ diff --git a/src/main/java/electrosphere/renderer/Model.java b/src/main/java/electrosphere/renderer/Model.java index f107b267..28a1ac69 100644 --- a/src/main/java/electrosphere/renderer/Model.java +++ b/src/main/java/electrosphere/renderer/Model.java @@ -218,41 +218,43 @@ public class Model { } public void incrementTime(double time){ - boolean isDone = currentAnimation.incrementTime(time); - if(isDone){ - currentAnimation.timeCurrent = 0; - Iterator channelIterator = currentAnimation.channels.iterator(); - while(channelIterator.hasNext()){ - AnimChannel currentChannel = channelIterator.next(); - currentChannel.rewind(); - } - Iterator boneIterator = bones.iterator(); - while(boneIterator.hasNext()){ - Bone currentBone = boneIterator.next(); - currentBone.transform = new Matrix4f(); - } - currentAnimation = null; - } else { - //First we push transformFromParent into deform so that later in the pipeline bones without a current animation take on transformFromParent as their transformation to the hierarchy - //I BELIEVE this is so that control bones still apply their offset to the hierarchy even when they're not animated :tm: - //4/5/20 -// Iterator boneIterator = bones.iterator(); -// while(boneIterator.hasNext()){ -// Bone currentBone = boneIterator.next(); -//// currentBone.deform = currentBone.transformFromParent; -// } - //Once that's done, for every channel we set the corresponding bone's deform to the channels TRS - Iterator channelIterator = currentAnimation.channels.iterator(); - while(channelIterator.hasNext()){ - AnimChannel currentChannel = channelIterator.next(); - currentChannel.incrementTime(time); - Bone currentBone = boneMap.get(currentChannel.nodeID); - if(currentBone != null){ - //T * S * R - currentBone.deform = new Matrix4f(); - currentBone.deform.translate(currentChannel.getCurrentPosition()); - currentBone.deform.rotate(currentChannel.getCurrentRotation()); - currentBone.deform.scale(currentChannel.getCurrentScale()); + if(currentAnimation != null){ + boolean isDone = currentAnimation.incrementTime(time); + if(isDone){ + currentAnimation.timeCurrent = 0; + Iterator channelIterator = currentAnimation.channels.iterator(); + while(channelIterator.hasNext()){ + AnimChannel currentChannel = channelIterator.next(); + currentChannel.rewind(); + } + Iterator boneIterator = bones.iterator(); + while(boneIterator.hasNext()){ + Bone currentBone = boneIterator.next(); + currentBone.transform = new Matrix4f(); + } + currentAnimation = null; + } else { + //First we push transformFromParent into deform so that later in the pipeline bones without a current animation take on transformFromParent as their transformation to the hierarchy + //I BELIEVE this is so that control bones still apply their offset to the hierarchy even when they're not animated :tm: + //4/5/20 + // Iterator boneIterator = bones.iterator(); + // while(boneIterator.hasNext()){ + // Bone currentBone = boneIterator.next(); + //// currentBone.deform = currentBone.transformFromParent; + // } + //Once that's done, for every channel we set the corresponding bone's deform to the channels TRS + Iterator channelIterator = currentAnimation.channels.iterator(); + while(channelIterator.hasNext()){ + AnimChannel currentChannel = channelIterator.next(); + currentChannel.incrementTime(time); + Bone currentBone = boneMap.get(currentChannel.nodeID); + if(currentBone != null){ + //T * S * R + currentBone.deform = new Matrix4f(); + currentBone.deform.translate(currentChannel.getCurrentPosition()); + currentBone.deform.rotate(currentChannel.getCurrentRotation()); + currentBone.deform.scale(currentChannel.getCurrentScale()); + } } } } diff --git a/src/main/java/electrosphere/renderer/ModelUtils.java b/src/main/java/electrosphere/renderer/ModelUtils.java index 3d96c0ac..6aecda2b 100644 --- a/src/main/java/electrosphere/renderer/ModelUtils.java +++ b/src/main/java/electrosphere/renderer/ModelUtils.java @@ -210,31 +210,31 @@ public class ModelUtils { vertices.put(heightfield[x][y]); vertices.put(y); //1,0 - vertices.put(x + 1); - vertices.put(heightfield[x+1][y]); + vertices.put(x + stride); + vertices.put(heightfield[x+stride][y]); vertices.put(y); //0,1 vertices.put(x); - vertices.put(heightfield[x][y+1]); - vertices.put(y + 1); + vertices.put(heightfield[x][y+stride]); + vertices.put(y + stride); //1,1 - vertices.put(x + 1); - vertices.put(heightfield[x+1][y+1]); - vertices.put(y + 1); + vertices.put(x + stride); + vertices.put(heightfield[x+stride][y+stride]); + vertices.put(y + stride); //deal with normal Vector3f normal = calculateTerrainNormal(heightfield, actualWidth, actualHeight, stride, x, y); normals.put(normal.x); normals.put(normal.y); normals.put(normal.z); - normal = calculateTerrainNormal(heightfield, actualWidth, actualHeight, stride, x + 1, y); + normal = calculateTerrainNormal(heightfield, actualWidth, actualHeight, stride, x + stride, y); normals.put(normal.x); normals.put(normal.y); normals.put(normal.z); - normal = calculateTerrainNormal(heightfield, actualWidth, actualHeight, stride, x, y + 1); + normal = calculateTerrainNormal(heightfield, actualWidth, actualHeight, stride, x, y + stride); normals.put(normal.x); normals.put(normal.y); normals.put(normal.z); - normal = calculateTerrainNormal(heightfield, actualWidth, actualHeight, stride, x + 1, y + 1); + normal = calculateTerrainNormal(heightfield, actualWidth, actualHeight, stride, x + stride, y + stride); normals.put(normal.x); normals.put(normal.y); normals.put(normal.z);