- 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; Node model;
RagdollControl ragdoll; RagdollControl ragdoll;
float bulletSize = 1f; float bulletSize = 1f;
Material mat;
Material mat3;
private Sphere bullet;
private SphereCollisionShape bulletCollisionShape;
public static void main(String[] args) { public static void main(String[] args) {
TestBoneRagdoll app = new TestBoneRagdoll(); TestBoneRagdoll app = new TestBoneRagdoll();
@ -90,6 +94,10 @@ public class TestBoneRagdoll extends SimpleApplication implements RagdollCollisi
initCrossHairs(); initCrossHairs();
initMaterial(); 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.setLocation(new Vector3f(0.26924422f, 6.646658f, 22.265987f));
cam.setRotation(new Quaternion(-2.302544E-4f, 0.99302495f, -0.117888905f, -0.0019395084f)); 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() { private PhysicsSpace getPhysicsSpace() {
return bulletAppState.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() { public void initMaterial() {

@ -79,18 +79,10 @@ public class TestBrickTower extends SimpleApplication {
Material mat2; Material mat2;
Material mat3; Material mat3;
PssmShadowRenderer bsr; PssmShadowRenderer bsr;
private static final Sphere bullet; private Sphere bullet;
private static final Box brick; private Box brick;
private static final SphereCollisionShape bulletCollisionShape; 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; private BulletAppState bulletAppState;
public static void main(String args[]) { public static void main(String args[]) {
@ -103,6 +95,12 @@ public class TestBrickTower extends SimpleApplication {
bulletAppState = new BulletAppState(); bulletAppState = new BulletAppState();
bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL); bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
stateManager.attach(bulletAppState); 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); // bulletAppState.getPhysicsSpace().enableDebug(assetManager);
initMaterial(); initMaterial();
initTower(); initTower();

@ -39,8 +39,10 @@ import com.jme3.bullet.collision.shapes.BoxCollisionShape;
import com.jme3.bullet.collision.shapes.SphereCollisionShape; import com.jme3.bullet.collision.shapes.SphereCollisionShape;
import com.jme3.bullet.control.RigidBodyControl; import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.font.BitmapText; import com.jme3.font.BitmapText;
import com.jme3.input.KeyInput;
import com.jme3.input.MouseInput; import com.jme3.input.MouseInput;
import com.jme3.input.controls.ActionListener; import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.input.controls.MouseButtonTrigger; import com.jme3.input.controls.MouseButtonTrigger;
import com.jme3.material.Material; import com.jme3.material.Material;
import com.jme3.math.Vector2f; import com.jme3.math.Vector2f;
@ -67,18 +69,10 @@ public class TestBrickWall extends SimpleApplication {
Material mat2; Material mat2;
Material mat3; Material mat3;
BasicShadowRenderer bsr; BasicShadowRenderer bsr;
private static final Sphere bullet; private static Sphere bullet;
private static final Box brick; private static Box brick;
private static final SphereCollisionShape bulletCollisionShape; 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; private BulletAppState bulletAppState;
public static void main(String args[]) { public static void main(String args[]) {
@ -88,9 +82,20 @@ public class TestBrickWall extends SimpleApplication {
@Override @Override
public void simpleInitApp() { public void simpleInitApp() {
System.loadLibrary("bulletjme");
PhysicsSpace.initNativePhysics();
System.out.println("processors: " + Runtime.getRuntime().availableProcessors());
bulletAppState = new BulletAppState(); bulletAppState = new BulletAppState();
bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL); bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
stateManager.attach(bulletAppState); 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(); initMaterial();
initWall(); initWall();
initFloor(); initFloor();
@ -100,6 +105,8 @@ public class TestBrickWall extends SimpleApplication {
cam.setFrustumFar(15); cam.setFrustumFar(15);
inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT)); inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addListener(actionListener, "shoot"); inputManager.addListener(actionListener, "shoot");
inputManager.addMapping("gc", new KeyTrigger(KeyInput.KEY_X));
inputManager.addListener(actionListener, "gc");
rootNode.setShadowMode(ShadowMode.Off); rootNode.setShadowMode(ShadowMode.Off);
bsr = new BasicShadowRenderer(assetManager, 256); bsr = new BasicShadowRenderer(assetManager, 256);
@ -118,6 +125,8 @@ public class TestBrickWall extends SimpleApplication {
bulletg.setMaterial(mat2); bulletg.setMaterial(mat2);
bulletg.setShadowMode(ShadowMode.CastAndReceive); bulletg.setShadowMode(ShadowMode.CastAndReceive);
bulletg.setLocalTranslation(cam.getLocation()); bulletg.setLocalTranslation(cam.getLocation());
SphereCollisionShape bulletCollisionShape = new SphereCollisionShape(0.4f);
RigidBodyControl bulletNode = new BombControl(assetManager, bulletCollisionShape, 1); RigidBodyControl bulletNode = new BombControl(assetManager, bulletCollisionShape, 1);
// RigidBodyControl bulletNode = new RigidBodyControl(bulletCollisionShape, 1); // RigidBodyControl bulletNode = new RigidBodyControl(bulletCollisionShape, 1);
bulletNode.setLinearVelocity(cam.getDirection().mult(25)); bulletNode.setLinearVelocity(cam.getDirection().mult(25));
@ -125,6 +134,9 @@ public class TestBrickWall extends SimpleApplication {
rootNode.attachChild(bulletg); rootNode.attachChild(bulletg);
getPhysicsSpace().add(bulletNode); 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 mat;
private Material mat2; private Material mat2;
private static final Sphere bullet; private Sphere bullet;
private static final SphereCollisionShape bulletCollisionShape; private SphereCollisionShape bulletCollisionShape;
private BulletAppState bulletAppState; 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) { public static void main(String[] args) {
TestCcd app = new TestCcd(); TestCcd app = new TestCcd();
app.start(); app.start();
@ -88,6 +82,9 @@ public class TestCcd extends SimpleApplication implements ActionListener{
bulletAppState = new BulletAppState(); bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState); stateManager.attach(bulletAppState);
bulletAppState.getPhysicsSpace().enableDebug(assetManager); bulletAppState.getPhysicsSpace().enableDebug(assetManager);
bullet = new Sphere(32, 32, 0.4f, true, false);
bullet.setTextureMode(TextureMode.Projected);
bulletCollisionShape = new SphereCollisionShape(0.1f);
setupKeys(); setupKeys();
mat = new Material(getAssetManager(), "Common/MatDefs/Misc/WireColor.j3md"); mat = new Material(getAssetManager(), "Common/MatDefs/Misc/WireColor.j3md");

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

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

Loading…
Cancel
Save