Search in sources :

Example 96 with DirectionalLight

use of com.jme3.light.DirectionalLight in project jmonkeyengine by jMonkeyEngine.

the class TestOgreLoading method simpleInitApp.

public void simpleInitApp() {
    //        PointLight pl = new PointLight();
    //        pl.setPosition(new Vector3f(10, 10, -10));
    //        rootNode.addLight(pl);
    flyCam.setMoveSpeed(10f);
    // sunset light
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-0.1f, -0.7f, 1).normalizeLocal());
    dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
    rootNode.addLight(dl);
    lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
    lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
    rootNode.attachChild(lightMdl);
    lightMd2 = new Geometry("Light", new Sphere(10, 10, 0.1f));
    lightMd2.setMaterial(assetManager.loadMaterial("Common/Materials/WhiteColor.j3m"));
    rootNode.attachChild(lightMd2);
    pl = new PointLight();
    pl.setColor(new ColorRGBA(1, 0.9f, 0.9f, 0));
    pl.setPosition(new Vector3f(0f, 0f, 4f));
    rootNode.addLight(pl);
    p2 = new PointLight();
    p2.setColor(new ColorRGBA(0.9f, 1, 0.9f, 0));
    p2.setPosition(new Vector3f(0f, 0f, 3f));
    rootNode.addLight(p2);
    // create the geometry and attach it
    Spatial elephant = (Spatial) assetManager.loadModel("Models/Elephant/Elephant.mesh.xml");
    float scale = 0.05f;
    elephant.scale(scale, scale, scale);
    rootNode.attachChild(elephant);
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) ColorRGBA(com.jme3.math.ColorRGBA) Spatial(com.jme3.scene.Spatial) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) PointLight(com.jme3.light.PointLight)

Example 97 with DirectionalLight

use of com.jme3.light.DirectionalLight in project jmonkeyengine by jMonkeyEngine.

the class TestAnimationFactory method simpleInitApp.

@Override
public void simpleInitApp() {
    AmbientLight al = new AmbientLight();
    rootNode.addLight(al);
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(Vector3f.UNIT_XYZ.negate());
    rootNode.addLight(dl);
    // Create model
    Box box = new Box(1, 1, 1);
    Geometry geom = new Geometry("box", box);
    geom.setMaterial(assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m"));
    Node model = new Node("model");
    model.attachChild(geom);
    Box child = new Box(0.5f, 0.5f, 0.5f);
    Geometry childGeom = new Geometry("box", child);
    childGeom.setMaterial(assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m"));
    Node childModel = new Node("childmodel");
    childModel.setLocalTranslation(2, 2, 2);
    childModel.attachChild(childGeom);
    model.attachChild(childModel);
    TangentBinormalGenerator.generate(model);
    //creating quite complex animation witht the AnimationHelper
    // animation of 6 seconds named "anim" and with 25 frames per second
    AnimationFactory animationFactory = new AnimationFactory(6, "anim", 25);
    //creating a translation keyFrame at time = 3 with a translation on the x axis of 5 WU        
    animationFactory.addTimeTranslation(3, new Vector3f(5, 0, 0));
    //reseting the translation to the start position at time = 6
    animationFactory.addTimeTranslation(6, new Vector3f(0, 0, 0));
    //Creating a scale keyFrame at time = 2 with the unit scale.
    animationFactory.addTimeScale(2, new Vector3f(1, 1, 1));
    //Creating a scale keyFrame at time = 4 scaling to 1.5
    animationFactory.addTimeScale(4, new Vector3f(1.5f, 1.5f, 1.5f));
    //reseting the scale to the start value at time = 5
    animationFactory.addTimeScale(5, new Vector3f(1, 1, 1));
    //Creating a rotation keyFrame at time = 0.5 of quarter PI around the Z axis
    animationFactory.addTimeRotation(0.5f, new Quaternion().fromAngleAxis(FastMath.QUARTER_PI, Vector3f.UNIT_Z));
    //rotating back to initial rotation value at time = 1
    animationFactory.addTimeRotation(1, Quaternion.IDENTITY);
    //Creating a rotation keyFrame at time = 2. Note that i used the Euler angle version because the angle is higher than PI
    //this should result in a complete revolution of the spatial around the x axis in 1 second (from 1 to 2)
    animationFactory.addTimeRotationAngles(2, FastMath.TWO_PI, 0, 0);
    AnimControl control = new AnimControl();
    control.addAnim(animationFactory.buildAnimation());
    model.addControl(control);
    rootNode.attachChild(model);
    //run animation
    control.createChannel().setAnim("anim");
}
Also used : Geometry(com.jme3.scene.Geometry) AnimationFactory(com.jme3.animation.AnimationFactory) Quaternion(com.jme3.math.Quaternion) DirectionalLight(com.jme3.light.DirectionalLight) Node(com.jme3.scene.Node) Vector3f(com.jme3.math.Vector3f) Box(com.jme3.scene.shape.Box) AnimControl(com.jme3.animation.AnimControl) AmbientLight(com.jme3.light.AmbientLight)

Example 98 with DirectionalLight

use of com.jme3.light.DirectionalLight in project jmonkeyengine by jMonkeyEngine.

the class TestBlenderAnim method simpleInitApp.

@Override
public void simpleInitApp() {
    flyCam.setMoveSpeed(10f);
    cam.setLocation(new Vector3f(6.4013605f, 7.488437f, 12.843031f));
    cam.setRotation(new Quaternion(-0.060740203f, 0.93925786f, -0.2398315f, -0.2378785f));
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal());
    dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
    rootNode.addLight(dl);
    BlenderKey blenderKey = new BlenderKey("Blender/2.4x/BaseMesh_249.blend");
    Spatial scene = (Spatial) assetManager.loadModel(blenderKey);
    rootNode.attachChild(scene);
    Spatial model = this.findNode(rootNode, "BaseMesh_01");
    model.center();
    control = model.getControl(AnimControl.class);
    channel = control.createChannel();
    channel.setAnim("run_01");
}
Also used : ColorRGBA(com.jme3.math.ColorRGBA) Quaternion(com.jme3.math.Quaternion) Spatial(com.jme3.scene.Spatial) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) BlenderKey(com.jme3.asset.BlenderKey) AnimControl(com.jme3.animation.AnimControl)

Example 99 with DirectionalLight

use of com.jme3.light.DirectionalLight in project jmonkeyengine by jMonkeyEngine.

the class TestBlenderObjectAnim method simpleInitApp.

@Override
public void simpleInitApp() {
    flyCam.setMoveSpeed(10f);
    cam.setLocation(new Vector3f(6.4013605f, 7.488437f, 12.843031f));
    cam.setRotation(new Quaternion(-0.060740203f, 0.93925786f, -0.2398315f, -0.2378785f));
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal());
    dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
    rootNode.addLight(dl);
    BlenderKey blenderKey = new BlenderKey("Blender/2.4x/animtest.blend");
    Spatial scene = (Spatial) assetManager.loadModel(blenderKey);
    rootNode.attachChild(scene);
    Spatial model = this.findNode(rootNode, "TestAnim");
    model.center();
    control = model.getControl(AnimControl.class);
    channel = control.createChannel();
    channel.setAnim("TestAnim");
}
Also used : ColorRGBA(com.jme3.math.ColorRGBA) Quaternion(com.jme3.math.Quaternion) Spatial(com.jme3.scene.Spatial) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) BlenderKey(com.jme3.asset.BlenderKey) AnimControl(com.jme3.animation.AnimControl)

Example 100 with DirectionalLight

use of com.jme3.light.DirectionalLight in project jmonkeyengine by jMonkeyEngine.

the class TestPosterization method simpleInitApp.

@Override
public void simpleInitApp() {
    // put the camera in a bad position
    cam.setLocation(new Vector3f(-2.336393f, 11.91392f, -7.139601f));
    cam.setRotation(new Quaternion(0.23602544f, 0.11321983f, -0.027698677f, 0.96473104f));
    Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    mat.setFloat("Shininess", 15f);
    mat.setBoolean("UseMaterialColors", true);
    mat.setColor("Ambient", ColorRGBA.Yellow.mult(0.2f));
    mat.setColor("Diffuse", ColorRGBA.Yellow.mult(0.2f));
    mat.setColor("Specular", ColorRGBA.Yellow.mult(0.8f));
    Material matSoil = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    matSoil.setFloat("Shininess", 15f);
    matSoil.setBoolean("UseMaterialColors", true);
    matSoil.setColor("Ambient", ColorRGBA.Gray);
    matSoil.setColor("Diffuse", ColorRGBA.Black);
    matSoil.setColor("Specular", ColorRGBA.Gray);
    teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
    teapot.setLocalTranslation(0, 0, 10);
    teapot.setMaterial(mat);
    teapot.setShadowMode(ShadowMode.CastAndReceive);
    teapot.setLocalScale(10.0f);
    rootNode.attachChild(teapot);
    Geometry soil = new Geometry("soil", new Box(800, 10, 700));
    soil.setLocalTranslation(0, -13, 550);
    soil.setMaterial(matSoil);
    soil.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(soil);
    DirectionalLight light = new DirectionalLight();
    light.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    light.setColor(ColorRGBA.White.mult(1.5f));
    rootNode.addLight(light);
    // load sky
    Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/Bright/FullskiesBlueClear03.dds", SkyFactory.EnvMapType.CubeMap);
    sky.setCullHint(Spatial.CullHint.Never);
    rootNode.attachChild(sky);
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    int numSamples = getContext().getSettings().getSamples();
    if (numSamples > 0) {
        fpp.setNumSamples(numSamples);
    }
    pf = new PosterizationFilter();
    fpp.addFilter(pf);
    viewPort.addProcessor(fpp);
    initInputs();
}
Also used : Geometry(com.jme3.scene.Geometry) Quaternion(com.jme3.math.Quaternion) Spatial(com.jme3.scene.Spatial) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) Material(com.jme3.material.Material) Box(com.jme3.scene.shape.Box) FilterPostProcessor(com.jme3.post.FilterPostProcessor) PosterizationFilter(com.jme3.post.filters.PosterizationFilter)

Aggregations

DirectionalLight (com.jme3.light.DirectionalLight)104 Vector3f (com.jme3.math.Vector3f)87 Geometry (com.jme3.scene.Geometry)55 Material (com.jme3.material.Material)48 Spatial (com.jme3.scene.Spatial)41 ColorRGBA (com.jme3.math.ColorRGBA)34 Quaternion (com.jme3.math.Quaternion)30 Node (com.jme3.scene.Node)29 Box (com.jme3.scene.shape.Box)27 Sphere (com.jme3.scene.shape.Sphere)26 AmbientLight (com.jme3.light.AmbientLight)25 FilterPostProcessor (com.jme3.post.FilterPostProcessor)24 PointLight (com.jme3.light.PointLight)23 KeyTrigger (com.jme3.input.controls.KeyTrigger)22 ActionListener (com.jme3.input.controls.ActionListener)14 SpotLight (com.jme3.light.SpotLight)14 Texture (com.jme3.texture.Texture)12 AnimControl (com.jme3.animation.AnimControl)9 BulletAppState (com.jme3.bullet.BulletAppState)8 Quad (com.jme3.scene.shape.Quad)8