diff --git a/assets/Data/creatures.json b/assets/Data/creatures.json index 57c57e18..a51d9fd1 100644 --- a/assets/Data/creatures.json +++ b/assets/Data/creatures.json @@ -213,10 +213,10 @@ "physicsObject" : { "type" : "CYLINDER", "dimension1" : 0.1, - "dimension2" : 0.1, + "dimension2" : 0.2, "dimension3" : 0.1, "offsetX" : 0, - "offsetY" : 0.1, + "offsetY" : 0.2, "offsetZ" : 0 }, "attackMoves" : [ diff --git a/src/main/java/electrosphere/entity/state/GravityTree.java b/src/main/java/electrosphere/entity/state/GravityTree.java index 2e55a6cb..fce3888e 100644 --- a/src/main/java/electrosphere/entity/state/GravityTree.java +++ b/src/main/java/electrosphere/entity/state/GravityTree.java @@ -67,7 +67,7 @@ public class GravityTree { } static final float gravityConstant = 0.2f; - static final float linearDamping = 0.02f; + static final float linearDamping = 0.1f; public void simulate(float deltaTime){ float velocity = CreatureUtils.getVelocity(parent); @@ -107,6 +107,9 @@ public class GravityTree { case ACTIVE: if(hadGroundCollision()){ state = GravityTreeState.NOT_ACTIVE; + if(!hadStructureCollision()){ + position.set(new Vector3f(position.x,Globals.commonWorldData.getElevationAtPoint(position) + 0.0001f,position.z)); + } } else { float gravityDif = gravityConstant * (float)Math.pow(1.0f - linearDamping,deltaTime * 2); Vector3f newGravityPos = new Vector3f(position.x,position.y - gravityDif,position.z); @@ -135,6 +138,17 @@ public class GravityTree { networkMessageQueue.add(networkMessage); } + public boolean hadStructureCollision(){ + boolean rVal = false; + for(Impulse impulse : collidable.getImpulses()){ + if(impulse.getType().equals(Collidable.TYPE_STRUCTURE)){ + rVal = true; + break; + } + } + return rVal; + } + public boolean hadGroundCollision(){ boolean rVal = false; for(Impulse impulse : collidable.getImpulses()){ diff --git a/src/main/java/electrosphere/entity/state/movement/MovementTree.java b/src/main/java/electrosphere/entity/state/movement/MovementTree.java index 7f28c86e..9e434d81 100644 --- a/src/main/java/electrosphere/entity/state/movement/MovementTree.java +++ b/src/main/java/electrosphere/entity/state/movement/MovementTree.java @@ -146,7 +146,9 @@ public class MovementTree { //handle impulses for(Impulse impulse : collidable.getImpulses()){ // collidable.getImpulses().remove(impulse); - position.add(impulse.direction.mul(impulse.force)); + Vector3f impulseForce = new Vector3f(impulse.direction).mul(impulse.force); +// System.out.println("Impulse force: " + impulseForce); + position.add(impulseForce); } bodyTransformMatrix = new javax.vecmath.Matrix4f(PhysicsUtils.jomlToVecmathQuaternionf(rotation),PhysicsUtils.jomlToVecmathVector3f(position),1.0f); body.setWorldTransform(new com.bulletphysics.linearmath.Transform(bodyTransformMatrix)); diff --git a/src/main/java/electrosphere/game/collision/CollisionEngine.java b/src/main/java/electrosphere/game/collision/CollisionEngine.java index e9b4eff4..b78c1fc8 100644 --- a/src/main/java/electrosphere/game/collision/CollisionEngine.java +++ b/src/main/java/electrosphere/game/collision/CollisionEngine.java @@ -95,7 +95,7 @@ public class CollisionEngine { if (contactPoint.getDistance() < 0.0f) { magnitude = contactPoint.getDistance(); //linear dampen - magnitude = magnitude * (float)Math.pow(1.0f - linearDamping,deltaTime * 2) * deltaTime * 8; + magnitude = magnitude * (float)Math.pow(1.0f - linearDamping,deltaTime * 2); hit = true; normal = new Vector3f(contactPoint.normalWorldOnB.x,contactPoint.normalWorldOnB.y,contactPoint.normalWorldOnB.z); break; @@ -124,12 +124,13 @@ public class CollisionEngine { switch(impactor.getType()){ case Collidable.TYPE_TERRAIN: // System.out.println("Terrain-creature collision: " + normal + " mag:" + realMagnitude); - receiver.addImpulse(new Impulse(new Vector3f(0,1.0f,0), -1.0f * magnitude, Collidable.TYPE_TERRAIN)); + receiver.addImpulse(new Impulse(new Vector3f(0,normal.y,0), -magnitude, Collidable.TYPE_TERRAIN)); break; case Collidable.TYPE_CREATURE: receiver.addImpulse(new Impulse(normal, magnitude, Collidable.TYPE_CREATURE)); break; case Collidable.TYPE_STRUCTURE: + System.out.println(normal + " - " + magnitude); receiver.addImpulse(new Impulse(normal, magnitude, Collidable.TYPE_STRUCTURE)); // System.out.println("Structure-creature collision"); break; diff --git a/src/main/java/electrosphere/net/server/ServerConnectionHandler.java b/src/main/java/electrosphere/net/server/ServerConnectionHandler.java index 7ca5c5a8..3322a4c8 100644 --- a/src/main/java/electrosphere/net/server/ServerConnectionHandler.java +++ b/src/main/java/electrosphere/net/server/ServerConnectionHandler.java @@ -94,7 +94,7 @@ public class ServerConnectionHandler implements Runnable { System.exit(1); } //spawn player in world - Entity newPlayerCharacter = CreatureUtils.spawnBasicCreature("Goblin"); + Entity newPlayerCharacter = CreatureUtils.spawnBasicCreature("Human"); playerCharacterID = newPlayerCharacter.getId(); CreatureUtils.positionCharacter(newPlayerCharacter, new Vector3f(Globals.spawnPoint.x,3,Globals.spawnPoint.z)); //spawn player sword