Search in sources :

Example 96 with Vector3f

use of com.jme3.math.Vector3f in project jmonkeyengine by jMonkeyEngine.

the class TestDirectionalLightShadow method simpleUpdate.

@Override
public void simpleUpdate(float tpf) {
    if (up) {
        Vector3f v = l.getDirection();
        v.y += tpf / s;
        setDir(v);
    }
    if (down) {
        Vector3f v = l.getDirection();
        v.y -= tpf / s;
        setDir(v);
    }
    if (right) {
        Vector3f v = l.getDirection();
        v.x += tpf / s;
        setDir(v);
    }
    if (left) {
        Vector3f v = l.getDirection();
        v.x -= tpf / s;
        setDir(v);
    }
    if (fwd) {
        Vector3f v = l.getDirection();
        v.z += tpf / s;
        setDir(v);
    }
    if (back) {
        Vector3f v = l.getDirection();
        v.z -= tpf / s;
        setDir(v);
    }
}
Also used : Vector3f(com.jme3.math.Vector3f)

Example 97 with Vector3f

use of com.jme3.math.Vector3f in project jmonkeyengine by jMonkeyEngine.

the class TestDirectionalLightShadow method loadScene.

public void loadScene() {
    obj = new Spatial[2];
    // Setup first view
    mat = new Material[2];
    mat[0] = assetManager.loadMaterial("Common/Materials/RedColor.j3m");
    mat[1] = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    mat[1].setBoolean("UseMaterialColors", true);
    mat[1].setColor("Ambient", ColorRGBA.White);
    mat[1].setColor("Diffuse", ColorRGBA.White.clone());
    obj[0] = new Geometry("sphere", new Sphere(30, 30, 2));
    obj[0].setShadowMode(ShadowMode.CastAndReceive);
    obj[1] = new Geometry("cube", new Box(1.0f, 1.0f, 1.0f));
    obj[1].setShadowMode(ShadowMode.CastAndReceive);
    TangentBinormalGenerator.generate(obj[1]);
    TangentBinormalGenerator.generate(obj[0]);
    Spatial t = obj[0].clone(false);
    t.setLocalScale(10f);
    t.setMaterial(mat[1]);
    rootNode.attachChild(t);
    t.setLocalTranslation(0, 25, 0);
    for (int i = 0; i < 60; i++) {
        t = obj[FastMath.nextRandomInt(0, obj.length - 1)].clone(false);
        t.setLocalScale(FastMath.nextRandomFloat() * 10f);
        t.setMaterial(mat[FastMath.nextRandomInt(0, mat.length - 1)]);
        rootNode.attachChild(t);
        t.setLocalTranslation(FastMath.nextRandomFloat() * 200f, FastMath.nextRandomFloat() * 30f + 20, 30f * (i + 2f));
    }
    Box b = new Box(1000, 2, 1000);
    b.scaleTextureCoordinates(new Vector2f(10, 10));
    ground = new Geometry("soil", b);
    ground.setLocalTranslation(0, 10, 550);
    matGroundU = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    matGroundU.setColor("Color", ColorRGBA.Green);
    matGroundL = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Texture grass = assetManager.loadTexture("Textures/Terrain/splat/grass.jpg");
    grass.setWrap(WrapMode.Repeat);
    matGroundL.setTexture("DiffuseMap", grass);
    ground.setMaterial(matGroundL);
    ground.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(ground);
    l = new DirectionalLight();
    //l.setDirection(new Vector3f(0.5973172f, -0.16583486f, 0.7846725f).normalizeLocal());
    l.setDirection(new Vector3f(-1, -1, -1));
    rootNode.addLight(l);
    al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(0.02f));
    rootNode.addLight(al);
    Spatial sky = SkyFactory.createSky(assetManager, "Scenes/Beach/FullskiesSunset0068.dds", false);
    sky.setLocalScale(350);
    rootNode.attachChild(sky);
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) Spatial(com.jme3.scene.Spatial) Vector2f(com.jme3.math.Vector2f) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) Box(com.jme3.scene.shape.Box) Material(com.jme3.material.Material) Texture(com.jme3.texture.Texture) AmbientLight(com.jme3.light.AmbientLight)

Example 98 with Vector3f

use of com.jme3.math.Vector3f in project jmonkeyengine by jMonkeyEngine.

the class TestDirectionalLightShadow method simpleInitApp.

@Override
public void simpleInitApp() {
    // put the camera in a bad position
    //        cam.setLocation(new Vector3f(65.25412f, 44.38738f, 9.087874f));
    //        cam.setRotation(new Quaternion(0.078139365f, 0.050241485f, -0.003942559f, 0.9956679f));
    cam.setLocation(new Vector3f(3.3720117f, 42.838284f, -83.43792f));
    cam.setRotation(new Quaternion(0.13833192f, -0.08969371f, 0.012581267f, 0.9862358f));
    flyCam.setMoveSpeed(100);
    loadScene();
    dlsr = new DirectionalLightShadowRenderer(assetManager, SHADOWMAP_SIZE, 3);
    dlsr.setLight(l);
    dlsr.setLambda(0.55f);
    dlsr.setShadowIntensity(0.8f);
    dlsr.setEdgeFilteringMode(EdgeFilteringMode.Nearest);
    dlsr.displayDebug();
    viewPort.addProcessor(dlsr);
    dlsf = new DirectionalLightShadowFilter(assetManager, SHADOWMAP_SIZE, 3);
    dlsf.setLight(l);
    dlsf.setLambda(0.55f);
    dlsf.setShadowIntensity(0.8f);
    dlsf.setEdgeFilteringMode(EdgeFilteringMode.Nearest);
    dlsf.setEnabled(false);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    fpp.addFilter(dlsf);
    viewPort.addProcessor(fpp);
    initInputs();
}
Also used : Quaternion(com.jme3.math.Quaternion) Vector3f(com.jme3.math.Vector3f) DirectionalLightShadowRenderer(com.jme3.shadow.DirectionalLightShadowRenderer) FilterPostProcessor(com.jme3.post.FilterPostProcessor) DirectionalLightShadowFilter(com.jme3.shadow.DirectionalLightShadowFilter)

Example 99 with Vector3f

use of com.jme3.math.Vector3f in project jmonkeyengine by jMonkeyEngine.

the class TestEnvironmentMapping method simpleInitApp.

@Override
public void simpleInitApp() {
    final Node buggy = (Node) assetManager.loadModel("Models/Buggy/Buggy.j3o");
    TextureKey key = new TextureKey("Textures/Sky/Bright/BrightSky.dds", true);
    key.setGenerateMips(true);
    key.setTextureTypeHint(Texture.Type.CubeMap);
    final Texture tex = assetManager.loadTexture(key);
    for (Spatial geom : buggy.getChildren()) {
        if (geom instanceof Geometry) {
            Material m = ((Geometry) geom).getMaterial();
            m.setTexture("EnvMap", tex);
            m.setVector3("FresnelParams", new Vector3f(0.05f, 0.18f, 0.11f));
        }
    }
    flyCam.setEnabled(false);
    ChaseCamera chaseCam = new ChaseCamera(cam, inputManager);
    chaseCam.setLookAtOffset(new Vector3f(0, 0.5f, -1.0f));
    buggy.addControl(chaseCam);
    rootNode.attachChild(buggy);
    rootNode.attachChild(SkyFactory.createSky(assetManager, tex, false));
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    BloomFilter bf = new BloomFilter(BloomFilter.GlowMode.Objects);
    bf.setBloomIntensity(2.3f);
    bf.setExposurePower(0.6f);
    fpp.addFilter(bf);
    DirectionalLight l = new DirectionalLight();
    l.setDirection(new Vector3f(0, -1, -1));
    rootNode.addLight(l);
    viewPort.addProcessor(fpp);
}
Also used : Geometry(com.jme3.scene.Geometry) TextureKey(com.jme3.asset.TextureKey) Spatial(com.jme3.scene.Spatial) Node(com.jme3.scene.Node) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) ChaseCamera(com.jme3.input.ChaseCamera) Material(com.jme3.material.Material) FilterPostProcessor(com.jme3.post.FilterPostProcessor) Texture(com.jme3.texture.Texture) BloomFilter(com.jme3.post.filters.BloomFilter)

Example 100 with Vector3f

use of com.jme3.math.Vector3f in project jmonkeyengine by jMonkeyEngine.

the class TestLightNode method simpleInitApp.

@Override
public void simpleInitApp() {
    Torus torus = new Torus(10, 6, 1, 3);
    //        Torus torus = new Torus(50, 30, 1, 3);
    Geometry g = new Geometry("Torus Geom", torus);
    g.rotate(-FastMath.HALF_PI, 0, 0);
    g.center();
    //        g.move(0, 1, 0);
    Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    mat.setFloat("Shininess", 32f);
    mat.setBoolean("UseMaterialColors", true);
    mat.setColor("Ambient", ColorRGBA.Black);
    mat.setColor("Diffuse", ColorRGBA.White);
    mat.setColor("Specular", ColorRGBA.White);
    //        mat.setBoolean("VertexLighting", true);
    //        mat.setBoolean("LowQuality", true);
    g.setMaterial(mat);
    rootNode.attachChild(g);
    Geometry lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
    lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
    movingNode = new Node("lightParentNode");
    movingNode.attachChild(lightMdl);
    rootNode.attachChild(movingNode);
    PointLight pl = new PointLight();
    pl.setColor(ColorRGBA.Green);
    pl.setRadius(4f);
    rootNode.addLight(pl);
    LightNode lightNode = new LightNode("pointLight", pl);
    movingNode.attachChild(lightNode);
    DirectionalLight dl = new DirectionalLight();
    dl.setColor(ColorRGBA.Red);
    dl.setDirection(new Vector3f(0, 1, 0));
    rootNode.addLight(dl);
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) LightNode(com.jme3.scene.LightNode) Torus(com.jme3.scene.shape.Torus) Node(com.jme3.scene.Node) LightNode(com.jme3.scene.LightNode) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material) PointLight(com.jme3.light.PointLight)

Aggregations

Vector3f (com.jme3.math.Vector3f)536 Material (com.jme3.material.Material)126 Geometry (com.jme3.scene.Geometry)118 DirectionalLight (com.jme3.light.DirectionalLight)95 Quaternion (com.jme3.math.Quaternion)94 TempVars (com.jme3.util.TempVars)67 ColorRGBA (com.jme3.math.ColorRGBA)64 Node (com.jme3.scene.Node)63 Spatial (com.jme3.scene.Spatial)57 Box (com.jme3.scene.shape.Box)57 Sphere (com.jme3.scene.shape.Sphere)51 Texture (com.jme3.texture.Texture)41 KeyTrigger (com.jme3.input.controls.KeyTrigger)36 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)35 Vector2f (com.jme3.math.Vector2f)35 FilterPostProcessor (com.jme3.post.FilterPostProcessor)34 FloatBuffer (java.nio.FloatBuffer)34 InputCapsule (com.jme3.export.InputCapsule)33 BoundingBox (com.jme3.bounding.BoundingBox)30 AmbientLight (com.jme3.light.AmbientLight)30