Search in sources :

Example 6 with PointLight

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

the class PointLightShadowRenderer method read.

@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule ic = im.getCapsule(this);
    light = (PointLight) ic.readSavable("light", null);
    init((int) shadowMapSize);
}
Also used : InputCapsule(com.jme3.export.InputCapsule)

Example 7 with PointLight

use of com.jme3.light.PointLight 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)

Example 8 with PointLight

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

the class TestShadowBug method simpleInitApp.

@Override
public void simpleInitApp() {
    flyCam.setMoveSpeed(100f);
    rootNode.attachChild(makeFloor());
    Node characters = new Node("Characters");
    characters.setShadowMode(ShadowMode.Cast);
    rootNode.attachChild(characters);
    Spatial golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
    golem.scale(0.5f);
    golem.setLocalTranslation(200.0f, -6f, 200f);
    golem.setShadowMode(ShadowMode.CastAndReceive);
    characters.attachChild(golem);
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(-1f, -1f, 1f));
    sun.setColor(ColorRGBA.White.mult(1.3f));
    rootNode.addLight(sun);
    characters.addLight(sun);
    SpotLight spot = new SpotLight();
    // distance
    spot.setSpotRange(13f);
    // inner light cone (central beam)
    spot.setSpotInnerAngle(15f * FastMath.DEG_TO_RAD);
    // outer light cone (edge of the light)
    spot.setSpotOuterAngle(20f * FastMath.DEG_TO_RAD);
    // light color
    spot.setColor(ColorRGBA.White.mult(1.3f));
    spot.setPosition(new Vector3f(192.0f, -1f, 192f));
    spot.setDirection(new Vector3f(1, -0.5f, 1));
    rootNode.addLight(spot);
    PointLight lamp_light = new PointLight();
    lamp_light.setColor(ColorRGBA.Yellow);
    lamp_light.setRadius(20f);
    lamp_light.setPosition(new Vector3f(210.0f, 0f, 210f));
    rootNode.addLight(lamp_light);
    SpotLightShadowRenderer slsr = new SpotLightShadowRenderer(assetManager, 512);
    slsr.setLight(spot);
    slsr.setEdgeFilteringMode(EdgeFilteringMode.Nearest);
    slsr.setShadowIntensity(0.6f);
    slsr.setFlushQueues(false);
    viewPort.addProcessor(slsr);
    PointLightShadowRenderer plsr = new PointLightShadowRenderer(assetManager, 512);
    plsr.setLight(lamp_light);
    plsr.setShadowIntensity(0.6f);
    plsr.setEdgeFilteringMode(EdgeFilteringMode.Nearest);
    plsr.setFlushQueues(false);
    viewPort.addProcessor(plsr);
    viewPort.getCamera().setLocation(new Vector3f(192.0f, 10f, 192f));
    float[] angles = new float[] { 3.14f / 2, 3.14f / 2, 0 };
    viewPort.getCamera().setRotation(new Quaternion(angles));
}
Also used : Spatial(com.jme3.scene.Spatial) Quaternion(com.jme3.math.Quaternion) Node(com.jme3.scene.Node) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) PointLightShadowRenderer(com.jme3.shadow.PointLightShadowRenderer) PointLight(com.jme3.light.PointLight) SpotLightShadowRenderer(com.jme3.shadow.SpotLightShadowRenderer) SpotLight(com.jme3.light.SpotLight)

Example 9 with PointLight

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

the class TestSimpleLighting method simpleInitApp.

@Override
public void simpleInitApp() {
    Geometry teapot = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj");
    TangentBinormalGenerator.generate(teapot.getMesh(), true);
    teapot.setLocalScale(2f);
    Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    //        mat.selectTechnique("GBuf");
    mat.setFloat("Shininess", 25);
    mat.setBoolean("UseMaterialColors", true);
    cam.setLocation(new Vector3f(0.015041917f, 0.4572918f, 5.2874837f));
    cam.setRotation(new Quaternion(-1.8875003E-4f, 0.99882424f, 0.04832061f, 0.0039016632f));
    //        mat.setTexture("ColorRamp", assetManager.loadTexture("Textures/ColorRamp/cloudy.png"));
    //
    //        mat.setBoolean("VTangent", true);
    //        mat.setBoolean("Minnaert", true);
    //        mat.setBoolean("WardIso", true);
    //        mat.setBoolean("VertexLighting", true);
    //        mat.setBoolean("LowQuality", true);
    //        mat.setBoolean("HighQuality", true);
    mat.setColor("Ambient", ColorRGBA.Black);
    mat.setColor("Diffuse", ColorRGBA.Gray);
    mat.setColor("Specular", ColorRGBA.Gray);
    teapot.setMaterial(mat);
    rootNode.attachChild(teapot);
    lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
    lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
    lightMdl.getMesh().setStatic();
    rootNode.attachChild(lightMdl);
    pl = new PointLight();
    pl.setColor(ColorRGBA.White);
    pl.setRadius(4f);
    rootNode.addLight(pl);
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
    dl.setColor(ColorRGBA.Green);
    rootNode.addLight(dl);
    MaterialDebugAppState debug = new MaterialDebugAppState();
    debug.registerBinding("Common/ShaderLib/BlinnPhongLighting.glsllib", teapot);
    stateManager.attach(debug);
    setPauseOnLostFocus(false);
    flyCam.setDragToRotate(true);
}
Also used : Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) Quaternion(com.jme3.math.Quaternion) MaterialDebugAppState(com.jme3.util.MaterialDebugAppState) Vector3f(com.jme3.math.Vector3f) DirectionalLight(com.jme3.light.DirectionalLight) Material(com.jme3.material.Material) PointLight(com.jme3.light.PointLight)

Example 10 with PointLight

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

the class TestBumpModel method simpleInitApp.

@Override
public void simpleInitApp() {
    Spatial signpost = (Spatial) assetManager.loadAsset(new OgreMeshKey("Models/Sign Post/Sign Post.mesh.xml"));
    signpost.setMaterial((Material) assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"));
    TangentBinormalGenerator.generate(signpost);
    rootNode.attachChild(signpost);
    lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
    lightMdl.setMaterial((Material) assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
    rootNode.attachChild(lightMdl);
    // flourescent main light
    pl = new PointLight();
    pl.setColor(new ColorRGBA(0.88f, 0.92f, 0.95f, 1.0f));
    rootNode.addLight(pl);
    // sunset light
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-0.1f, -0.7f, 1).normalizeLocal());
    dl.setColor(new ColorRGBA(0.44f, 0.30f, 0.20f, 1.0f));
    rootNode.addLight(dl);
    // skylight
    dl = new DirectionalLight();
    dl.setDirection(new Vector3f(-0.6f, -1, -0.6f).normalizeLocal());
    dl.setColor(new ColorRGBA(0.10f, 0.22f, 0.44f, 1.0f));
    rootNode.addLight(dl);
    // white ambient light
    dl = new DirectionalLight();
    dl.setDirection(new Vector3f(1, -0.5f, -0.1f).normalizeLocal());
    dl.setColor(new ColorRGBA(0.50f, 0.40f, 0.50f, 1.0f));
    rootNode.addLight(dl);
}
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) OgreMeshKey(com.jme3.scene.plugins.ogre.OgreMeshKey) PointLight(com.jme3.light.PointLight)

Aggregations

PointLight (com.jme3.light.PointLight)30 Vector3f (com.jme3.math.Vector3f)28 Geometry (com.jme3.scene.Geometry)22 DirectionalLight (com.jme3.light.DirectionalLight)21 Sphere (com.jme3.scene.shape.Sphere)18 SpotLight (com.jme3.light.SpotLight)14 Material (com.jme3.material.Material)12 ColorRGBA (com.jme3.math.ColorRGBA)12 Quaternion (com.jme3.math.Quaternion)9 AmbientLight (com.jme3.light.AmbientLight)8 Node (com.jme3.scene.Node)8 Light (com.jme3.light.Light)5 Spatial (com.jme3.scene.Spatial)5 TempVars (com.jme3.util.TempVars)5 FilterPostProcessor (com.jme3.post.FilterPostProcessor)4 Box (com.jme3.scene.shape.Box)4 SpotLightShadowRenderer (com.jme3.shadow.SpotLightShadowRenderer)4 ActionListener (com.jme3.input.controls.ActionListener)3 KeyTrigger (com.jme3.input.controls.KeyTrigger)3 Uniform (com.jme3.shader.Uniform)3