Search in sources :

Example 1 with BasicShadowRenderer

use of com.jme3.shadow.BasicShadowRenderer in project jmonkeyengine by jMonkeyEngine.

the class TestBrickWall method simpleInitApp.

@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);
    bsr = new BasicShadowRenderer(assetManager, 256);
    bsr.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    viewPort.addProcessor(bsr);
}
Also used : Sphere(com.jme3.scene.shape.Sphere) SphereCollisionShape(com.jme3.bullet.collision.shapes.SphereCollisionShape) Vector2f(com.jme3.math.Vector2f) BulletAppState(com.jme3.bullet.BulletAppState) Vector3f(com.jme3.math.Vector3f) KeyTrigger(com.jme3.input.controls.KeyTrigger) Box(com.jme3.scene.shape.Box) MouseButtonTrigger(com.jme3.input.controls.MouseButtonTrigger) BasicShadowRenderer(com.jme3.shadow.BasicShadowRenderer)

Example 2 with BasicShadowRenderer

use of com.jme3.shadow.BasicShadowRenderer in project jmonkeyengine by jMonkeyEngine.

the class TestFancyCar method simpleInitApp.

@Override
public void simpleInitApp() {
    bulletAppState = new BulletAppState();
    stateManager.attach(bulletAppState);
    //        bulletAppState.getPhysicsSpace().enableDebug(assetManager);
    if (settings.getRenderer().startsWith("LWJGL")) {
        BasicShadowRenderer bsr = new BasicShadowRenderer(assetManager, 512);
        bsr.setDirection(new Vector3f(-0.5f, -0.3f, -0.3f).normalizeLocal());
    //   viewPort.addProcessor(bsr);
    }
    cam.setFrustumFar(150f);
    flyCam.setMoveSpeed(10);
    setupKeys();
    PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());
    //        setupFloor();
    buildPlayer();
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-0.5f, -1f, -0.3f).normalizeLocal());
    rootNode.addLight(dl);
    dl = new DirectionalLight();
    dl.setDirection(new Vector3f(0.5f, -0.1f, 0.3f).normalizeLocal());
//   rootNode.addLight(dl);
}
Also used : BulletAppState(com.jme3.bullet.BulletAppState) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) BasicShadowRenderer(com.jme3.shadow.BasicShadowRenderer)

Example 3 with BasicShadowRenderer

use of com.jme3.shadow.BasicShadowRenderer in project jmonkeyengine by jMonkeyEngine.

the class TestEverything method setupBasicShadow.

public void setupBasicShadow() {
    if (renderer.getCaps().contains(Caps.GLSL100)) {
        bsr = new BasicShadowRenderer(assetManager, 1024);
        bsr.setDirection(lightDir);
        viewPort.addProcessor(bsr);
    }
}
Also used : BasicShadowRenderer(com.jme3.shadow.BasicShadowRenderer)

Example 4 with BasicShadowRenderer

use of com.jme3.shadow.BasicShadowRenderer in project jmonkeyengine by jMonkeyEngine.

the class TestShadow method simpleInitApp.

@Override
public void simpleInitApp() {
    // put the camera in a bad position
    cam.setLocation(new Vector3f(0.7804813f, 1.7502685f, -2.1556435f));
    cam.setRotation(new Quaternion(0.1961598f, -0.7213164f, 0.2266092f, 0.6243975f));
    cam.setFrustumFar(10);
    Material mat = assetManager.loadMaterial("Common/Materials/WhiteColor.j3m");
    rootNode.setShadowMode(ShadowMode.Off);
    Box floor = new Box(3, 0.1f, 3);
    Geometry floorGeom = new Geometry("Floor", floor);
    floorGeom.setMaterial(mat);
    floorGeom.setLocalTranslation(0, -0.2f, 0);
    floorGeom.setShadowMode(ShadowMode.Receive);
    rootNode.attachChild(floorGeom);
    teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
    teapot.setLocalScale(2f);
    teapot.setMaterial(mat);
    teapot.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(teapot);
    //        lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
    //        lightMdl.setMaterial(mat);
    //        // disable shadowing for light representation
    //        lightMdl.setShadowMode(ShadowMode.Off);
    //        rootNode.attachChild(lightMdl);
    bsr = new BasicShadowRenderer(assetManager, 512);
    bsr.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    viewPort.addProcessor(bsr);
    frustum = new WireFrustum(bsr.getPoints());
    frustumMdl = new Geometry("f", frustum);
    frustumMdl.setCullHint(Spatial.CullHint.Never);
    frustumMdl.setShadowMode(ShadowMode.Off);
    frustumMdl.setMaterial(new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"));
    frustumMdl.getMaterial().getAdditionalRenderState().setWireframe(true);
    frustumMdl.getMaterial().setColor("Color", ColorRGBA.Red);
    rootNode.attachChild(frustumMdl);
}
Also used : Geometry(com.jme3.scene.Geometry) Quaternion(com.jme3.math.Quaternion) WireFrustum(com.jme3.scene.debug.WireFrustum) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material) Box(com.jme3.scene.shape.Box) BasicShadowRenderer(com.jme3.shadow.BasicShadowRenderer)

Aggregations

BasicShadowRenderer (com.jme3.shadow.BasicShadowRenderer)4 Vector3f (com.jme3.math.Vector3f)3 BulletAppState (com.jme3.bullet.BulletAppState)2 Box (com.jme3.scene.shape.Box)2 SphereCollisionShape (com.jme3.bullet.collision.shapes.SphereCollisionShape)1 KeyTrigger (com.jme3.input.controls.KeyTrigger)1 MouseButtonTrigger (com.jme3.input.controls.MouseButtonTrigger)1 DirectionalLight (com.jme3.light.DirectionalLight)1 Material (com.jme3.material.Material)1 Quaternion (com.jme3.math.Quaternion)1 Vector2f (com.jme3.math.Vector2f)1 Geometry (com.jme3.scene.Geometry)1 WireFrustum (com.jme3.scene.debug.WireFrustum)1 Sphere (com.jme3.scene.shape.Sphere)1