- remove static fields from physics tests

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7339 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 14 years ago
parent 4b4c5e89d9
commit a9f544fbf8
  1. 18
      engine/src/test/jme3test/bullet/TestBoneRagdoll.java
  2. 20
      engine/src/test/jme3test/bullet/TestBrickTower.java
  3. 34
      engine/src/test/jme3test/bullet/TestBrickWall.java
  4. 13
      engine/src/test/jme3test/bullet/TestCcd.java
  5. 13
      engine/src/test/jme3test/bullet/TestCollisionListener.java
  6. 18
      engine/src/test/jme3test/bullet/TestPhysicsCharacter.java

@ -80,6 +80,10 @@ public class TestBoneRagdoll extends SimpleApplication implements RagdollCollisi
Node model;
RagdollControl ragdoll;
float bulletSize = 1f;
Material mat;
Material mat3;
private Sphere bullet;
private SphereCollisionShape bulletCollisionShape;
public static void main(String[] args) {
TestBoneRagdoll app = new TestBoneRagdoll();
@ -90,6 +94,10 @@ public class TestBoneRagdoll extends SimpleApplication implements RagdollCollisi
initCrossHairs();
initMaterial();
bullet = new Sphere(32, 32, 1.0f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(1.0f);
cam.setLocation(new Vector3f(0.26924422f, 6.646658f, 22.265987f));
cam.setRotation(new Quaternion(-2.302544E-4f, 0.99302495f, -0.117888905f, -0.0019395084f));
@ -231,16 +239,6 @@ public class TestBoneRagdoll extends SimpleApplication implements RagdollCollisi
private PhysicsSpace getPhysicsSpace() {
return bulletAppState.getPhysicsSpace();
}
Material mat;
Material mat3;
private static final Sphere bullet;
private static SphereCollisionShape bulletCollisionShape;
static {
bullet = new Sphere(32, 32, 1.0f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(1.0f);
}
public void initMaterial() {

@ -79,18 +79,10 @@ public class TestBrickTower extends SimpleApplication {
Material mat2;
Material mat3;
PssmShadowRenderer bsr;
private static final Sphere bullet;
private static final Box brick;
private static final SphereCollisionShape bulletCollisionShape;
private Sphere bullet;
private Box brick;
private SphereCollisionShape bulletCollisionShape;
static {
bullet = new Sphere(32, 32, 0.4f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(0.4f);
brick = new Box(Vector3f.ZERO, brickWidth, brickHeight, brickDepth);
brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
}
private BulletAppState bulletAppState;
public static void main(String args[]) {
@ -103,6 +95,12 @@ public class TestBrickTower extends SimpleApplication {
bulletAppState = new BulletAppState();
bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
stateManager.attach(bulletAppState);
bullet = new Sphere(32, 32, 0.4f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(0.4f);
brick = new Box(Vector3f.ZERO, brickWidth, brickHeight, brickDepth);
brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
// bulletAppState.getPhysicsSpace().enableDebug(assetManager);
initMaterial();
initTower();

@ -39,8 +39,10 @@ import com.jme3.bullet.collision.shapes.BoxCollisionShape;
import com.jme3.bullet.collision.shapes.SphereCollisionShape;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.font.BitmapText;
import com.jme3.input.KeyInput;
import com.jme3.input.MouseInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.input.controls.MouseButtonTrigger;
import com.jme3.material.Material;
import com.jme3.math.Vector2f;
@ -67,18 +69,10 @@ public class TestBrickWall extends SimpleApplication {
Material mat2;
Material mat3;
BasicShadowRenderer bsr;
private static final Sphere bullet;
private static final Box brick;
private static final SphereCollisionShape bulletCollisionShape;
private static Sphere bullet;
private static Box brick;
private static SphereCollisionShape bulletCollisionShape;
static {
bullet = new Sphere(32, 32, 0.4f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(0.4f);
brick = new Box(Vector3f.ZERO, bLength, bHeight, bWidth);
brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
}
private BulletAppState bulletAppState;
public static void main(String args[]) {
@ -88,9 +82,20 @@ public class TestBrickWall extends SimpleApplication {
@Override
public void simpleInitApp() {
System.loadLibrary("bulletjme");
PhysicsSpace.initNativePhysics();
System.out.println("processors: " + Runtime.getRuntime().availableProcessors());
bulletAppState = new BulletAppState();
bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
stateManager.attach(bulletAppState);
bullet = new Sphere(32, 32, 0.4f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(0.4f);
brick = new Box(Vector3f.ZERO, bLength, bHeight, bWidth);
brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
initMaterial();
initWall();
initFloor();
@ -100,6 +105,8 @@ public class TestBrickWall extends SimpleApplication {
cam.setFrustumFar(15);
inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addListener(actionListener, "shoot");
inputManager.addMapping("gc", new KeyTrigger(KeyInput.KEY_X));
inputManager.addListener(actionListener, "gc");
rootNode.setShadowMode(ShadowMode.Off);
bsr = new BasicShadowRenderer(assetManager, 256);
@ -118,6 +125,8 @@ public class TestBrickWall extends SimpleApplication {
bulletg.setMaterial(mat2);
bulletg.setShadowMode(ShadowMode.CastAndReceive);
bulletg.setLocalTranslation(cam.getLocation());
SphereCollisionShape bulletCollisionShape = new SphereCollisionShape(0.4f);
RigidBodyControl bulletNode = new BombControl(assetManager, bulletCollisionShape, 1);
// RigidBodyControl bulletNode = new RigidBodyControl(bulletCollisionShape, 1);
bulletNode.setLinearVelocity(cam.getDirection().mult(25));
@ -125,6 +134,9 @@ public class TestBrickWall extends SimpleApplication {
rootNode.attachChild(bulletg);
getPhysicsSpace().add(bulletNode);
}
if (name.equals("gc") && !keyPressed) {
System.gc();
}
}
};

@ -61,16 +61,10 @@ public class TestCcd extends SimpleApplication implements ActionListener{
private Material mat;
private Material mat2;
private static final Sphere bullet;
private static final SphereCollisionShape bulletCollisionShape;
private Sphere bullet;
private SphereCollisionShape bulletCollisionShape;
private BulletAppState bulletAppState;
static {
bullet = new Sphere(32, 32, 0.4f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(0.1f);
}
public static void main(String[] args) {
TestCcd app = new TestCcd();
app.start();
@ -88,6 +82,9 @@ public class TestCcd extends SimpleApplication implements ActionListener{
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
bullet = new Sphere(32, 32, 0.4f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(0.1f);
setupKeys();
mat = new Material(getAssetManager(), "Common/MatDefs/Misc/WireColor.j3md");

@ -52,14 +52,8 @@ public class TestCollisionListener extends SimpleApplication implements PhysicsC
private BulletAppState bulletAppState;
private Material mat;
private static final Sphere bullet;
private static final SphereCollisionShape bulletCollisionShape;
static {
bullet = new Sphere(32, 32, 0.4f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(0.4f);
}
private Sphere bullet;
private SphereCollisionShape bulletCollisionShape;
public static void main(String[] args) {
TestCollisionListener app = new TestCollisionListener();
@ -71,6 +65,9 @@ public class TestCollisionListener extends SimpleApplication implements PhysicsC
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
bullet = new Sphere(32, 32, 0.4f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(0.4f);
PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
PhysicsTestHelper.createBallShooter(this, rootNode, bulletAppState.getPhysicsSpace());

@ -59,14 +59,8 @@ public class TestPhysicsCharacter extends SimpleApplication implements ActionLis
private CharacterControl physicsCharacter;
private Vector3f walkDirection = new Vector3f();
private Material mat;
private static final Sphere bullet;
private static final SphereCollisionShape bulletCollisionShape;
static {
bullet = new Sphere(32, 32, 0.4f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(0.4f);
}
private Sphere bullet;
private SphereCollisionShape bulletCollisionShape;
public static void main(String[] args) {
TestPhysicsCharacter app = new TestPhysicsCharacter();
@ -86,12 +80,17 @@ public class TestPhysicsCharacter extends SimpleApplication implements ActionLis
inputManager.addListener(this, "Ups");
inputManager.addListener(this, "Downs");
inputManager.addListener(this, "Space");
inputManager.addMapping("gc", new KeyTrigger(KeyInput.KEY_X));
inputManager.addListener(this, "gc");
}
@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
bullet = new Sphere(32, 32, 0.4f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(0.4f);
PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
setupKeys();
@ -151,5 +150,8 @@ public class TestPhysicsCharacter extends SimpleApplication implements ActionLis
} else if (binding.equals("Space")) {
physicsCharacter.jump();
}
if (binding.equals("gc") && !value) {
System.gc();
}
}
}

Loading…
Cancel
Save