Java Code Examples for com.jme3.bullet.BulletAppState#setThreadingType()

The following examples show how to use com.jme3.bullet.BulletAppState#setThreadingType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestWalkingChar.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void simpleInitApp() {
    bulletAppState = new BulletAppState();
    bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
    stateManager.attach(bulletAppState);
    setupKeys();
    prepareBullet();
    prepareEffect();
    createLight();
    createSky();
    createTerrain();
    createWall();
    createCharacter();
    setupChaseCamera();
    setupAnimationController();
    setupFilter();
}
 
Example 2
Source File: TestIssue928.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void simpleUpdate(float tpf) {
    if (frame % 4 == 0) {
        System.out.println(++count);
        bulletAppState = new BulletAppState();
        bulletAppState.setThreadingType(ThreadingType.PARALLEL);
        stateManager.attach(bulletAppState);
    } else if (frame % 4 == 2) {
        stateManager.detach(bulletAppState);
    }

    frame++;
    if (count == 70) {
        System.exit(0);
    }
}
 
Example 3
Source File: TestBrickTower.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void simpleInitApp() {
    bulletAppState = new BulletAppState();
    bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
 //   bulletAppState.setEnabled(false);
    stateManager.attach(bulletAppState);
    bullet = new Sphere(32, 32, 0.4f, true, false);
    bullet.setTextureMode(TextureMode.Projected);
    bulletCollisionShape = new SphereCollisionShape(0.4f);

    brick = new Box(brickWidth, brickHeight, brickDepth);
    brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
    //bulletAppState.getPhysicsSpace().enableDebug(assetManager);
    initMaterial();
    initTower();
    initFloor();
    initCrossHairs();
    this.cam.setLocation(new Vector3f(0, 25f, 8f));
    cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0));
    cam.setFrustumFar(80);
    inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    inputManager.addListener(actionListener, "shoot");
    rootNode.setShadowMode(ShadowMode.Off);
}
 
Example 4
Source File: TestWalkingChar.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void simpleInitApp() {
    bulletAppState = new BulletAppState();
    bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
    stateManager.attach(bulletAppState);
    setupKeys();
    prepareBullet();
    prepareEffect();
    createLight();
    createSky();
    createTerrain();
    createWall();
    createCharacter();
    setupChaseCamera();
    setupAnimationController();
    setupFilter();
}
 
Example 5
Source File: TestHoveringTank.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
    public void simpleInitApp() {
        bulletAppState = new BulletAppState();
        bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
        stateManager.attach(bulletAppState);
//        bulletAppState.getPhysicsSpace().enableDebug(assetManager);
        bulletAppState.getPhysicsSpace().setAccuracy(1f/30f);
        rootNode.attachChild(SkyFactory.createSky(assetManager, 
                "Textures/Sky/Bright/BrightSky.dds", EnvMapType.CubeMap));

        DirectionalLightShadowRenderer dlsr 
                = new DirectionalLightShadowRenderer(assetManager, 2048, 3);
        dlsr.setLambda(0.55f);
        dlsr.setShadowIntensity(0.6f);
        dlsr.setEdgeFilteringMode(EdgeFilteringMode.Bilinear);
        viewPort.addProcessor(dlsr);

        setupKeys();
        createTerrain();
        buildPlayer();

        DirectionalLight dl = new DirectionalLight();
        dlsr.setLight(dl);
        dl.setColor(new ColorRGBA(1.0f, 0.94f, 0.8f, 1f).multLocal(1.3f));
        dl.setDirection(new Vector3f(-0.5f, -0.3f, -0.3f).normalizeLocal());
        rootNode.addLight(dl);

        Vector3f lightDir2 = new Vector3f(0.70518064f, 0.5902297f, -0.39287305f);
        DirectionalLight dl2 = new DirectionalLight();
        dl2.setColor(new ColorRGBA(0.7f, 0.85f, 1.0f, 1f));
        dl2.setDirection(lightDir2);
        rootNode.addLight(dl2);
    }
 
Example 6
Source File: TestBrickWall.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    
    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(bLength, bHeight, bWidth);
    brick.scaleTextureCoordinates(new Vector2f(1f, .5f));

    initMaterial();
    initWall();
    initFloor();
    initCrossHairs();
    this.cam.setLocation(new Vector3f(0, 6f, 6f));
    cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0));
    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);
}
 
Example 7
Source File: TestIssue883.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp() {

    BulletAppState bulletAppState = new BulletAppState() {
        @Override
        public void physicsTick(PhysicsSpace space, float timeStep) {
            physicsTime += timeStep;
        }
    };
    bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
    stateManager.attach(bulletAppState);
}
 
Example 8
Source File: TestHoveringTank.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
    public void simpleInitApp() {
        bulletAppState = new BulletAppState();
        bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
        stateManager.attach(bulletAppState);
//        bulletAppState.getPhysicsSpace().enableDebug(assetManager);
        bulletAppState.getPhysicsSpace().setAccuracy(1f/30f);
        rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", false));

        PssmShadowRenderer pssmr = new PssmShadowRenderer(assetManager, 2048, 3);
        pssmr.setDirection(new Vector3f(-0.5f, -0.3f, -0.3f).normalizeLocal());
        pssmr.setLambda(0.55f);
        pssmr.setShadowIntensity(0.6f);
        pssmr.setCompareMode(CompareMode.Hardware);
        pssmr.setFilterMode(FilterMode.Bilinear);
        viewPort.addProcessor(pssmr);

        setupKeys();
        createTerrain();
        buildPlayer();

        DirectionalLight dl = new DirectionalLight();
        dl.setColor(new ColorRGBA(1.0f, 0.94f, 0.8f, 1f).multLocal(1.3f));
        dl.setDirection(new Vector3f(-0.5f, -0.3f, -0.3f).normalizeLocal());
        rootNode.addLight(dl);

        Vector3f lightDir2 = new Vector3f(0.70518064f, 0.5902297f, -0.39287305f);
        DirectionalLight dl2 = new DirectionalLight();
        dl2.setColor(new ColorRGBA(0.7f, 0.85f, 1.0f, 1f));
        dl2.setDirection(lightDir2);
        rootNode.addLight(dl2);
    }
 
Example 9
Source File: TestBrickWall.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    
    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();
    initCrossHairs();
    this.cam.setLocation(new Vector3f(0, 6f, 6f));
    cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0));
    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);
    bsr.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    viewPort.addProcessor(bsr);
}
 
Example 10
Source File: TestBrickTower.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    bulletAppState = new BulletAppState();
    bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
 //   bulletAppState.setEnabled(false);
    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();
    initFloor();
    initCrossHairs();
    this.cam.setLocation(new Vector3f(0, 25f, 8f));
    cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0));
    cam.setFrustumFar(80);
    inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    inputManager.addListener(actionListener, "shoot");
    rootNode.setShadowMode(ShadowMode.Off);
    bsr = new PssmShadowRenderer(assetManager, 1024, 2);
    bsr.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    bsr.setLambda(0.55f);
    bsr.setShadowIntensity(0.6f);
    bsr.setCompareMode(CompareMode.Hardware);
    bsr.setFilterMode(FilterMode.PCF4);
    viewPort.addProcessor(bsr);
}
 
Example 11
Source File: TestBatchNodeTower.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    timer = new NanoTimer();
    bulletAppState = new BulletAppState();
    bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
 //   bulletAppState.setEnabled(false);
    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();
    initFloor();
    initCrossHairs();
    this.cam.setLocation(new Vector3f(0, 25f, 8f));
    cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0));
    cam.setFrustumFar(80);
    inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    inputManager.addListener(actionListener, "shoot");
    rootNode.setShadowMode(ShadowMode.Off);
    
    batchNode.batch();
    batchNode.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(batchNode);
    
    
    bsr = new PssmShadowRenderer(assetManager, 1024, 2);
    bsr.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    bsr.setLambda(0.55f);
    bsr.setShadowIntensity(0.6f);
    bsr.setCompareMode(CompareMode.Hardware);
    bsr.setFilterMode(FilterMode.PCF4);
    viewPort.addProcessor(bsr);   
}
 
Example 12
Source File: TestBatchNodeTower.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void simpleInitApp() {
    timer = new NanoTimer();
    bulletAppState = new BulletAppState();
    bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
 //   bulletAppState.setEnabled(false);
    stateManager.attach(bulletAppState);
    bullet = new Sphere(32, 32, 0.4f, true, false);
    bullet.setTextureMode(TextureMode.Projected);
    bulletCollisionShape = new SphereCollisionShape(0.4f);

    brick = new Box(brickWidth, brickHeight, brickDepth);
    brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
    //bulletAppState.getPhysicsSpace().enableDebug(assetManager);
    initMaterial();
    initTower();
    initFloor();
    initCrossHairs();
    this.cam.setLocation(new Vector3f(0, 25f, 8f));
    cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0));
    cam.setFrustumFar(80);
    inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    inputManager.addListener(actionListener, "shoot");
    rootNode.setShadowMode(ShadowMode.Off);
    
    batchNode.batch();
    batchNode.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(batchNode);
    
    
    shadowRenderer = new DirectionalLightShadowFilter(assetManager, 1024, 2);
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    shadowRenderer.setLight(dl);
    shadowRenderer.setLambda(0.55f);
    shadowRenderer.setShadowIntensity(0.6f);
    shadowRenderer.setShadowCompareMode(CompareMode.Hardware);
    shadowRenderer.setEdgeFilteringMode(EdgeFilteringMode.PCF4);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(shadowRenderer);
    viewPort.addProcessor(fpp);   
}
 
Example 13
Source File: TestBatchedTower.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public void simpleInitApp() {
    bulletAppState = new BulletAppState();
    bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
   // bulletAppState.setEnabled(false);
    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();
    initFloor();
    initCrossHairs();

    List<BatchedGeometry> bgs = batch.batch(geoms);
    for (BatchedGeometry bg : bgs) {
        RigidBodyControl rb = new RigidBodyControl(1.5f);
        rb.setCollisionShape(new BoxCollisionShape(new Vector3f(brick.getXExtent(), brick.getYExtent(), brick.getZExtent())));
        rb.setFriction(1.6f);
        bg.addControl(rb);
        this.getPhysicsSpace().add(bg);
    }

    batch.setMaterial(mat);
    batch.setShadowMode(ShadowMode.CastAndReceive);

    this.cam.setLocation(new Vector3f(0, 25f, 8f));
    cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0));
    cam.setFrustumFar(80);
    inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    inputManager.addListener(actionListener, "shoot");
    rootNode.setShadowMode(ShadowMode.Off);
    bsr = new PssmShadowRenderer(assetManager, 1024, 2);
    bsr.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    bsr.setLambda(0.50f);
    bsr.setShadowIntensity(0.6f);
    bsr.setCompareMode(CompareMode.Hardware);
    bsr.setFilterMode(FilterMode.PCF4);
    viewPort.addProcessor(bsr);
    flyCam.setMoveSpeed(50);
    rootNode.attachChild(batch);
}