Fix terrain stride with dense meshes
This commit is contained in:
parent
f004a588a4
commit
c295a18a22
@ -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"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
@ -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){
|
||||
|
||||
@ -218,41 +218,43 @@ public class Model {
|
||||
}
|
||||
|
||||
public void incrementTime(double time){
|
||||
boolean isDone = currentAnimation.incrementTime(time);
|
||||
if(isDone){
|
||||
currentAnimation.timeCurrent = 0;
|
||||
Iterator<AnimChannel> channelIterator = currentAnimation.channels.iterator();
|
||||
while(channelIterator.hasNext()){
|
||||
AnimChannel currentChannel = channelIterator.next();
|
||||
currentChannel.rewind();
|
||||
}
|
||||
Iterator<Bone> 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<Bone> 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<AnimChannel> 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<AnimChannel> channelIterator = currentAnimation.channels.iterator();
|
||||
while(channelIterator.hasNext()){
|
||||
AnimChannel currentChannel = channelIterator.next();
|
||||
currentChannel.rewind();
|
||||
}
|
||||
Iterator<Bone> 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<Bone> 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<AnimChannel> 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user