Fix terrain stride with dense meshes
This commit is contained in:
parent
f004a588a4
commit
c295a18a22
@ -232,8 +232,45 @@
|
|||||||
"onDamageIFrames" : 30
|
"onDamageIFrames" : 30
|
||||||
},
|
},
|
||||||
"modelPath" : "Models/goblin1.fbx"
|
"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"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
BIN
launcher/launcher
Executable file
BIN
launcher/launcher
Executable file
Binary file not shown.
@ -122,11 +122,13 @@ public class CreatureUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//add all attack moves
|
//add all attack moves
|
||||||
for(AttackMove attackMove : rawType.getAttackMoves()){
|
if(rawType.getAttackMoves() != null && rawType.getAttackMoves().size() > 0){
|
||||||
switch(attackMove.getType()){
|
for(AttackMove attackMove : rawType.getAttackMoves()){
|
||||||
case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
|
switch(attackMove.getType()){
|
||||||
rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND, attackMove);
|
case EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND:
|
||||||
break;
|
rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND, attackMove);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//add health system
|
//add health system
|
||||||
|
|||||||
@ -97,7 +97,7 @@ public class ServerConnectionHandler implements Runnable {
|
|||||||
Player newPlayerObject = new Player(this);
|
Player newPlayerObject = new Player(this);
|
||||||
Globals.playerManager.addPlayer(newPlayerObject);
|
Globals.playerManager.addPlayer(newPlayerObject);
|
||||||
//spawn player in world
|
//spawn player in world
|
||||||
Entity newPlayerCharacter = CreatureUtils.spawnBasicCreature("Human");
|
Entity newPlayerCharacter = CreatureUtils.spawnBasicCreature("CUBE_MAN");
|
||||||
playerCharacterID = newPlayerCharacter.getId();
|
playerCharacterID = newPlayerCharacter.getId();
|
||||||
CollisionObjUtils.positionCharacter(newPlayerCharacter, new Vector3f(Globals.spawnPoint.x,Globals.spawnPoint.y,Globals.spawnPoint.z));
|
CollisionObjUtils.positionCharacter(newPlayerCharacter, new Vector3f(Globals.spawnPoint.x,Globals.spawnPoint.y,Globals.spawnPoint.z));
|
||||||
//attach player object to player character
|
//attach player object to player character
|
||||||
@ -107,8 +107,8 @@ public class ServerConnectionHandler implements Runnable {
|
|||||||
Globals.dataCellManager.addPlayer(newPlayerObject);
|
Globals.dataCellManager.addPlayer(newPlayerObject);
|
||||||
Globals.dataCellManager.movePlayer(newPlayerObject, Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.x), Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.z));
|
Globals.dataCellManager.movePlayer(newPlayerObject, Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.x), Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.z));
|
||||||
//spawn player sword
|
//spawn player sword
|
||||||
Entity sword = ItemUtils.spawnBasicItem("Katana");
|
// Entity sword = ItemUtils.spawnBasicItem("Katana");
|
||||||
AttachUtils.attachEntityToEntityAtBone(newPlayerCharacter, sword, "Bone.031");
|
// AttachUtils.attachEntityToEntityAtBone(newPlayerCharacter, sword, "Bone.031");
|
||||||
//set controller id
|
//set controller id
|
||||||
CreatureUtils.setControllerPlayerId(newPlayerCharacter, playerID);
|
CreatureUtils.setControllerPlayerId(newPlayerCharacter, playerID);
|
||||||
if(Globals.RUN_SERVER && Main.playerId == -1){
|
if(Globals.RUN_SERVER && Main.playerId == -1){
|
||||||
|
|||||||
@ -218,41 +218,43 @@ public class Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void incrementTime(double time){
|
public void incrementTime(double time){
|
||||||
boolean isDone = currentAnimation.incrementTime(time);
|
if(currentAnimation != null){
|
||||||
if(isDone){
|
boolean isDone = currentAnimation.incrementTime(time);
|
||||||
currentAnimation.timeCurrent = 0;
|
if(isDone){
|
||||||
Iterator<AnimChannel> channelIterator = currentAnimation.channels.iterator();
|
currentAnimation.timeCurrent = 0;
|
||||||
while(channelIterator.hasNext()){
|
Iterator<AnimChannel> channelIterator = currentAnimation.channels.iterator();
|
||||||
AnimChannel currentChannel = channelIterator.next();
|
while(channelIterator.hasNext()){
|
||||||
currentChannel.rewind();
|
AnimChannel currentChannel = channelIterator.next();
|
||||||
}
|
currentChannel.rewind();
|
||||||
Iterator<Bone> boneIterator = bones.iterator();
|
}
|
||||||
while(boneIterator.hasNext()){
|
Iterator<Bone> boneIterator = bones.iterator();
|
||||||
Bone currentBone = boneIterator.next();
|
while(boneIterator.hasNext()){
|
||||||
currentBone.transform = new Matrix4f();
|
Bone currentBone = boneIterator.next();
|
||||||
}
|
currentBone.transform = new Matrix4f();
|
||||||
currentAnimation = null;
|
}
|
||||||
} else {
|
currentAnimation = null;
|
||||||
//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
|
} else {
|
||||||
//I BELIEVE this is so that control bones still apply their offset to the hierarchy even when they're not animated :tm:
|
//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
|
||||||
//4/5/20
|
//I BELIEVE this is so that control bones still apply their offset to the hierarchy even when they're not animated :tm:
|
||||||
// Iterator<Bone> boneIterator = bones.iterator();
|
//4/5/20
|
||||||
// while(boneIterator.hasNext()){
|
// Iterator<Bone> boneIterator = bones.iterator();
|
||||||
// Bone currentBone = boneIterator.next();
|
// while(boneIterator.hasNext()){
|
||||||
//// currentBone.deform = currentBone.transformFromParent;
|
// 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<AnimChannel> channelIterator = currentAnimation.channels.iterator();
|
//Once that's done, for every channel we set the corresponding bone's deform to the channels TRS
|
||||||
while(channelIterator.hasNext()){
|
Iterator<AnimChannel> channelIterator = currentAnimation.channels.iterator();
|
||||||
AnimChannel currentChannel = channelIterator.next();
|
while(channelIterator.hasNext()){
|
||||||
currentChannel.incrementTime(time);
|
AnimChannel currentChannel = channelIterator.next();
|
||||||
Bone currentBone = boneMap.get(currentChannel.nodeID);
|
currentChannel.incrementTime(time);
|
||||||
if(currentBone != null){
|
Bone currentBone = boneMap.get(currentChannel.nodeID);
|
||||||
//T * S * R
|
if(currentBone != null){
|
||||||
currentBone.deform = new Matrix4f();
|
//T * S * R
|
||||||
currentBone.deform.translate(currentChannel.getCurrentPosition());
|
currentBone.deform = new Matrix4f();
|
||||||
currentBone.deform.rotate(currentChannel.getCurrentRotation());
|
currentBone.deform.translate(currentChannel.getCurrentPosition());
|
||||||
currentBone.deform.scale(currentChannel.getCurrentScale());
|
currentBone.deform.rotate(currentChannel.getCurrentRotation());
|
||||||
|
currentBone.deform.scale(currentChannel.getCurrentScale());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -210,31 +210,31 @@ public class ModelUtils {
|
|||||||
vertices.put(heightfield[x][y]);
|
vertices.put(heightfield[x][y]);
|
||||||
vertices.put(y);
|
vertices.put(y);
|
||||||
//1,0
|
//1,0
|
||||||
vertices.put(x + 1);
|
vertices.put(x + stride);
|
||||||
vertices.put(heightfield[x+1][y]);
|
vertices.put(heightfield[x+stride][y]);
|
||||||
vertices.put(y);
|
vertices.put(y);
|
||||||
//0,1
|
//0,1
|
||||||
vertices.put(x);
|
vertices.put(x);
|
||||||
vertices.put(heightfield[x][y+1]);
|
vertices.put(heightfield[x][y+stride]);
|
||||||
vertices.put(y + 1);
|
vertices.put(y + stride);
|
||||||
//1,1
|
//1,1
|
||||||
vertices.put(x + 1);
|
vertices.put(x + stride);
|
||||||
vertices.put(heightfield[x+1][y+1]);
|
vertices.put(heightfield[x+stride][y+stride]);
|
||||||
vertices.put(y + 1);
|
vertices.put(y + stride);
|
||||||
//deal with normal
|
//deal with normal
|
||||||
Vector3f normal = calculateTerrainNormal(heightfield, actualWidth, actualHeight, stride, x, y);
|
Vector3f normal = calculateTerrainNormal(heightfield, actualWidth, actualHeight, stride, x, y);
|
||||||
normals.put(normal.x);
|
normals.put(normal.x);
|
||||||
normals.put(normal.y);
|
normals.put(normal.y);
|
||||||
normals.put(normal.z);
|
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.x);
|
||||||
normals.put(normal.y);
|
normals.put(normal.y);
|
||||||
normals.put(normal.z);
|
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.x);
|
||||||
normals.put(normal.y);
|
normals.put(normal.y);
|
||||||
normals.put(normal.z);
|
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.x);
|
||||||
normals.put(normal.y);
|
normals.put(normal.y);
|
||||||
normals.put(normal.z);
|
normals.put(normal.z);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user