Trying to tweak collision engine
This commit is contained in:
parent
66bec8dead
commit
795e4af84b
@ -170,6 +170,8 @@ public class LoadingThread extends Thread {
|
||||
}
|
||||
}
|
||||
|
||||
setSimulationsToReady();
|
||||
|
||||
//hide cursor
|
||||
Globals.controlHandler.hideMouse();
|
||||
|
||||
@ -252,6 +254,8 @@ public class LoadingThread extends Thread {
|
||||
}
|
||||
}
|
||||
|
||||
setSimulationsToReady();
|
||||
|
||||
//hide cursor
|
||||
Globals.controlHandler.hideMouse();
|
||||
|
||||
@ -443,6 +447,7 @@ public class LoadingThread extends Thread {
|
||||
} catch (InterruptedException ex) {
|
||||
}
|
||||
}
|
||||
System.out.println("Draw Cell Manager ready");
|
||||
}
|
||||
|
||||
|
||||
@ -494,6 +499,13 @@ public class LoadingThread extends Thread {
|
||||
Globals.microSimulation = new MicroSimulation();
|
||||
}
|
||||
|
||||
static void setSimulationsToReady(){
|
||||
Globals.microSimulation.setReady(true);
|
||||
if(Globals.macroSimulation != null){
|
||||
Globals.macroSimulation.setReady(true);
|
||||
}
|
||||
}
|
||||
|
||||
static void creatingRandomEntities(){
|
||||
// String unitCubeModelPath = Globals.assetManager.registerModel(ModelUtils.createUnitCube());
|
||||
// Entity unitCube = EntityUtils.spawnDrawableEntity(unitCubeModelPath);
|
||||
@ -573,16 +585,20 @@ public class LoadingThread extends Thread {
|
||||
// AttachUtils.attachEntityToEntityAtBone(goblin, goblinSword, "Bone.031");
|
||||
// //attach ai to evil goblin
|
||||
// MindlessAttacker.attachToCreature(goblin);
|
||||
|
||||
StructureUtils.spawnBasicStructure("building1", new Vector3f(5,2.4f,5), new Quaternionf());
|
||||
|
||||
Entity fallOak = FoliageUtils.spawnBasicFoliage("FallOak1");
|
||||
EntityUtils.getPosition(fallOak).set(1,0,3);
|
||||
// Entity fallOak = FoliageUtils.spawnBasicFoliage("FallOak1");
|
||||
// EntityUtils.getPosition(fallOak).set(1,0,3);
|
||||
//
|
||||
// Entity spark = ParticleUtils.spawnBillboardParticle("Textures/animetree1leaves1.png", 150000, new Vector3f(0,0,0), 0, 0);
|
||||
// EntityUtils.getPosition(spark).set(new Vector3f(3,3,3));
|
||||
// EntityUtils.getScale(spark).mul(1f);
|
||||
|
||||
Entity spark = ParticleUtils.spawnBillboardParticle("Textures/animetree1leaves1.png", 150000, new Vector3f(0,0,0), 0, 0);
|
||||
EntityUtils.getPosition(spark).set(new Vector3f(3,3,3));
|
||||
EntityUtils.getScale(spark).mul(1f);
|
||||
// System.out.println(Globals.drawCellManager.)
|
||||
|
||||
Entity deer = CreatureUtils.spawnBasicCreature("Deer");
|
||||
EntityUtils.getPosition(deer).set(5, 0.25f, 3);
|
||||
// Entity deer = CreatureUtils.spawnBasicCreature("Deer");
|
||||
// EntityUtils.getPosition(deer).set(5, 0.25f, 3);
|
||||
|
||||
|
||||
// Model deerModel = Globals.assetManager.fetchModel("Models/deer1.fbx");
|
||||
|
||||
@ -91,8 +91,9 @@ public class CollisionEngine {
|
||||
if (contactPoint.getDistance() < 0.0f) {
|
||||
magnitude = contactPoint.getDistance();
|
||||
//linear dampen
|
||||
magnitude = magnitude * (float)Math.pow(1.0f - linearDamping,deltaTime * 2);
|
||||
magnitude = magnitude;// * (float)Math.pow(1.0f - linearDamping,deltaTime * 2);
|
||||
hit = true;
|
||||
// System.out.println(contactPoint.positionWorldOnA + " " + contactPoint.positionWorldOnB);
|
||||
normal = new Vector3f(contactPoint.normalWorldOnB.x,contactPoint.normalWorldOnB.y,contactPoint.normalWorldOnB.z);
|
||||
break;
|
||||
}
|
||||
@ -119,15 +120,18 @@ public class CollisionEngine {
|
||||
case Collidable.TYPE_CREATURE:
|
||||
switch(impactor.getType()){
|
||||
case Collidable.TYPE_TERRAIN:
|
||||
// System.out.println("Terrain-creature collision: " + normal + " mag:" + realMagnitude);
|
||||
receiver.addImpulse(new Impulse(new Vector3f(0,normal.y,0), -magnitude, Collidable.TYPE_TERRAIN));
|
||||
// System.out.println(EntityUtils.getPosition(impactor.getParent()) + " " + EntityUtils.getPosition(receiver.getParent()));
|
||||
// System.out.println();
|
||||
// System.out.println("Terrain-creature collision: " + normal + " mag:" + magnitude);
|
||||
receiver.addImpulse(new Impulse(new Vector3f(0,normal.y,0), -magnitude*2, 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));
|
||||
float realMag = 1f/(float)Math.pow(0.1, magnitude);
|
||||
System.out.println(normal + " - " + realMag);
|
||||
receiver.addImpulse(new Impulse(normal, realMag, Collidable.TYPE_STRUCTURE));
|
||||
// System.out.println("Structure-creature collision");
|
||||
break;
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ public class MicroSimulation {
|
||||
boolean isReady = false;
|
||||
|
||||
public MicroSimulation(){
|
||||
isReady = true;
|
||||
isReady = false;
|
||||
}
|
||||
|
||||
public void simulate(){
|
||||
@ -116,6 +116,10 @@ public class MicroSimulation {
|
||||
return isReady;
|
||||
}
|
||||
|
||||
public void setReady(boolean ready){
|
||||
isReady = ready;
|
||||
}
|
||||
|
||||
public void freeze(){
|
||||
isReady = false;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user