From c295a18a22aa9f18b2b960f9b1595135d1da83aa Mon Sep 17 00:00:00 2001 From: austin Date: Sun, 3 Oct 2021 13:49:40 -0400 Subject: [PATCH] Fix terrain stride with dense meshes --- assets/Data/creatures.json | 39 +++++++++- build.sh | 0 launcher/launcher | Bin 0 -> 49936 bytes .../entity/types/creature/CreatureUtils.java | 12 +-- .../net/server/ServerConnectionHandler.java | 6 +- .../java/electrosphere/renderer/Model.java | 72 +++++++++--------- .../electrosphere/renderer/ModelUtils.java | 20 ++--- 7 files changed, 95 insertions(+), 54 deletions(-) mode change 100644 => 100755 build.sh create mode 100755 launcher/launcher 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 0000000000000000000000000000000000000000..5eaf6fbfe445b16a3d387b14d222f72cd313f42f GIT binary patch literal 49936 zcmeI5U2IfE6vwA6h0+2oF&IQKi&_E%+iD~f0(A?lTq1!gsBcC|?1MZ=0x2H}`l4cdGCbgeW}9FnQIkrL^_;nLyStYUA4$xA zl9}@{XU;wIo9V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e;VX*SiMGuvU);neJFne&ZiJl}HiSz}f>PM;B}09gYA@pLN6)*7+~Ehl^| z!d3@aqjoIe43H&iq^K8lawMu&ryWa1Et4x-Jz~ZZVqH8rDB5eO$~rNb5u)~hX^So+ z8RwAgb>jQuVxE{D=K$3vGgEb}oTa{Gp%9(p^a;{Apt+`nM%R9l?M5Mjd@3TMh+4W>MP^T>m+Lmad zzKHr_>hq~DpuU9qqvB{<1cZFRSx7ns&74&}1F4Ru>e8tzQ{{25p>nx5P^oiQNn837 ddDq9gINp` 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);