Java Code Examples for com.jme3.light.DirectionalLight

The following examples show how to use com.jme3.light.DirectionalLight. These examples are extracted from open source projects. 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 Project: jmonkeybuilder   Source File: BaseMaterialEditor3DPart.java    License: Apache License 2.0 6 votes vote down vote up
public BaseMaterialEditor3DPart(@NotNull final T fileEditor) {
    super(fileEditor);
    this.testBox = new Geometry("Box", new Box(2, 2, 2));
    this.testSphere = new Geometry("Sphere", new Sphere(30, 30, 2));
    this.testQuad = new Geometry("Quad", new Quad(4, 4));
    this.testQuad.setLocalTranslation(QUAD_OFFSET);
    this.lightEnabled = MaterialFileEditor.DEFAULT_LIGHT_ENABLED;

    TangentGenerator.useMikktspaceGenerator(testBox);
    TangentGenerator.useMikktspaceGenerator(testSphere);
    TangentGenerator.useMikktspaceGenerator(testQuad);

    final DirectionalLight light = notNull(getLightForCamera());
    light.setDirection(LIGHT_DIRECTION);

    final EditorCamera editorCamera = notNull(getEditorCamera());
    editorCamera.setDefaultHorizontalRotation(H_ROTATION);
    editorCamera.setDefaultVerticalRotation(V_ROTATION);

    getModelNode().attachChild(getNodeForCamera());
}
 
Example 2
Source Project: jmonkeybuilder   Source File: BaseMaterialEditor3DPart.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Update the light in the scene in the {@link EditorThread}.
 *
 * @param enabled true if light should be enabled.
 */
@JmeThread
protected void updateLightEnabledImpl(final boolean enabled) {
    if (enabled == isLightEnabled()) return;

    final DirectionalLight light = getLightForCamera();
    final Node stateNode = getStateNode();

    if (enabled) {
        stateNode.addLight(light);
    } else {
        stateNode.removeLight(light);
    }

    setLightEnabled(enabled);
}
 
Example 3
Source Project: jmonkeybuilder   Source File: ModelEditor3DPart.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * The process of updating the light.
 */
@JmeThread
private void updateLightEnabledImpl(boolean enabled) {

    if (enabled == isLightEnabled()) {
        return;
    }

    final DirectionalLight light = getLightForCamera();
    final Node stateNode = getStateNode();

    if (enabled) {
        stateNode.addLight(light);
    } else {
        stateNode.removeLight(light);
    }

    setLightEnabled(enabled);
}
 
Example 4
@Override
public void simpleInitApp() {
    flyCam.setMoveSpeed(20);
    Sphere sphereMesh = new Sphere(32, 32, 1);
    sphereMesh.setTextureMode(Sphere.TextureMode.Projected);
    sphereMesh.updateGeometry(32, 32, 1, false, false);
    addMesh("Sphere", sphereMesh, new Vector3f(-1, 0, 0));

    Quad quadMesh = new Quad(1, 1);
    quadMesh.updateGeometry(1, 1);
    addMesh("Quad", quadMesh, new Vector3f(1, 0, 0));

    Mesh strip = createTriangleStripMesh();
    addMesh("strip", strip, new Vector3f(0, -3, 0));
    
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(1, -1, -1).normalizeLocal());
    dl.setColor(ColorRGBA.White);
    rootNode.addLight(dl);
}
 
Example 5
private void spatialToLight(Light light) {

        final Vector3f worldTranslation = spatial.getWorldTranslation();

        if (light instanceof PointLight) {
            ((PointLight) light).setPosition(worldTranslation);
            return;
        }

        final TempVars vars = TempVars.get();
        final Vector3f vec = vars.vect1;

        if (light instanceof DirectionalLight) {
            ((DirectionalLight) light).setDirection(vec.set(worldTranslation).multLocal(-1.0f));
        }

        if (light instanceof SpotLight) {
            final SpotLight spotLight = (SpotLight) light;
            spotLight.setPosition(worldTranslation);
            spotLight.setDirection(spatial.getWorldRotation().multLocal(vec.set(Vector3f.UNIT_Y).multLocal(-1)));
        }

        vars.release();
    }
 
Example 6
@Override
protected void initialize(Application app) {
    vp = app.getRenderManager().createMainView("debug", app.getCamera());
    vp.attachScene(debugNode);
    vp.setClearDepth(true);
    this.app = app;
    for (ArmatureDebugger armatureDebugger : armatures.values()) {
        armatureDebugger.initialize(app.getAssetManager(), app.getCamera());
    }
    app.getInputManager().addListener(actionListener, "shoot", "toggleJoints");
    app.getInputManager().addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT), new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
    app.getInputManager().addMapping("toggleJoints", new KeyTrigger(KeyInput.KEY_F10));

    debugNode.addLight(new DirectionalLight(new Vector3f(-1f, -1f, -1f).normalizeLocal()));

    debugNode.addLight(new DirectionalLight(new Vector3f(1f, 1f, 1f).normalizeLocal(), new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f)));
    vp.setEnabled(false);
}
 
Example 7
@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");
}
 
Example 8
@Override
public void simpleInitApp() {
    stateManager.attach(new EnvironmentCamera(32));

    DirectionalLight light = new DirectionalLight(Vector3f.UNIT_Y.negate(), ColorRGBA.White);
    rootNode.addLight(light);

    assetManager.registerLocator("https://github.com/KhronosGroup/glTF-Sample-Models/raw/master/2.0/RiggedFigure/", UrlLocator.class);

    model = assetManager.loadModel("/glTF-Embedded/RiggedFigure.gltf");
    SkinningControl skinningControl = getSkinningControl(model);
    if (skinningControl == null || !skinningControl.isHardwareSkinningPreferred()) {
        throw new IllegalArgumentException("This test case requires a model with a SkinningControl and with Hardware skinning preferred!");
    }

    viewPort.setBackgroundColor(ColorRGBA.LightGray);
}
 
Example 9
@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);
    
    AmbientLight al = new AmbientLight();
    al.setColor(new ColorRGBA(0.44f, 0.40f, 0.20f, 1.0f));
    rootNode.addLight(al);
    
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(1,-1,-1).normalizeLocal());
    dl.setColor(new ColorRGBA(0.92f, 0.85f, 0.8f, 1.0f));
    rootNode.addLight(dl);
}
 
Example 10
Source Project: jmonkeybuilder   Source File: JmeFilePreviewManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Prepare a transfer processor to transfer preview result to a image view.
 *
 * @return the transfer processor.
 */
@JmeThread
private @NotNull FrameTransferSceneProcessor prepareScene() {

    var jmeApplication = JmeApplication.getInstance();
    var assetManager = jmeApplication.getAssetManager();
    var sky = SkyFactory.createSky(assetManager, "graphics/textures/sky/studio.hdr",
                    SkyFactory.EnvMapType.EquirectMap);

    var light = new DirectionalLight();
    light.setDirection(LIGHT_DIRECTION);

    var cameraNode = new Node("Camera node");
    var rootNode = jmeApplication.getPreviewNode();
    rootNode.addControl(this);
    rootNode.attachChild(sky);
    rootNode.addLight(light);
    rootNode.attachChild(cameraNode);
    rootNode.attachChild(modelNode);

    var camera = jmeApplication.getPreviewCamera();
    var editorCamera = new EditorCamera(camera, cameraNode);
    editorCamera.setMaxDistance(10000);
    editorCamera.setMinDistance(0.01F);
    editorCamera.setSmoothMotion(false);
    editorCamera.setRotationSensitivity(1);
    editorCamera.setZoomSensitivity(0.2F);

    //TODO added supporting moving the camera

    processor = bind(jmeApplication, imageView, imageView, jmeApplication.getPreviewViewPort(), false);
    processor.setTransferMode(ON_CHANGES);
    processor.setEnabled(false);

    return processor;
}
 
Example 11
/**
 * Create light for camera directional light.
 *
 * @return the light for the camera.
 */
@JmeThread
protected @NotNull DirectionalLight createLightForCamera() {
    final DirectionalLight directionalLight = new DirectionalLight();
    directionalLight.setColor(ColorRGBA.White);
    return directionalLight;
}
 
Example 12
Source Project: jmonkeybuilder   Source File: DirectionalLightTreeNode.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@FromAnyThread
public @NotNull String getName() {
    final DirectionalLight element = getElement();
    final String name = element.getName();
    return StringUtils.isEmpty(name) ? Messages.MODEL_FILE_EDITOR_NODE_DIRECTION_LIGHT : name;
}
 
Example 13
public void simpleInitApp() {
    this.flyCam.setMoveSpeed(10);

    // load sky
    rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", false));

    File file = new File("wildhouse.zip");
    if (!file.exists()) {
        useHttp = true;
    }
    // create the geometry and attach it
    // load the level from zip or http zip
    if (useHttp) {
        assetManager.registerLocator("http://jmonkeyengine.googlecode.com/files/wildhouse.zip", HttpZipLocator.class.getName());
    } else {
        assetManager.registerLocator("wildhouse.zip", ZipLocator.class.getName());
    }
    Spatial scene = assetManager.loadModel("main.scene");

    AmbientLight al = new AmbientLight();
    scene.addLight(al);

    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(0.69077975f, -0.6277887f, -0.35875428f).normalizeLocal());
    sun.setColor(ColorRGBA.White.clone().multLocal(2));
    scene.addLight(sun);

    rootNode.attachChild(scene);
}
 
Example 14
protected Spatial makeCharacter() {
    // load a character from jme3test-test-data
    Spatial golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
    golem.scale(0.5f);
    golem.setLocalTranslation(-1.0f, -1.5f, -0.6f);

    // We must add a light to make the model visible
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal());
    golem.addLight(sun);
    return golem;
}
 
Example 15
@Override
public void simpleInitApp() {
    // Create two boxes
    Mesh mesh1 = new Box(0.5f, 0.5f, 0.5f);
    geom1 = new Geometry("Box", mesh1);
    geom1.move(2, 2, -.5f);
    Material m1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    m1.setColor("Color", ColorRGBA.Blue);
    geom1.setMaterial(m1);
    rootNode.attachChild(geom1);

    // load a character from jme3test-test-data
    golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
    golem.scale(0.5f);
    golem.setLocalTranslation(-1.0f, -1.5f, -0.6f);

    // We must add a light to make the model visible
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal());
    golem.addLight(sun);
    rootNode.attachChild(golem);

    // Create input
    inputManager.addMapping("MoveRight", new KeyTrigger(KeyInput.KEY_L));
    inputManager.addMapping("MoveLeft", new KeyTrigger(KeyInput.KEY_J));
    inputManager.addMapping("MoveUp", new KeyTrigger(KeyInput.KEY_I));
    inputManager.addMapping("MoveDown", new KeyTrigger(KeyInput.KEY_K));

    inputManager.addListener(analogListener, new String[]{
                "MoveRight", "MoveLeft", "MoveUp", "MoveDown"
            });
}
 
Example 16
Source Project: MikuMikuStudio   Source File: WaterFilter.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
private DirectionalLight findLight(Node node) {
    for (Light light : node.getWorldLightList()) {
        if (light instanceof DirectionalLight) {
            return (DirectionalLight) light;
        }
    }
    for (Spatial child : node.getChildren()) {
        if (child instanceof Node) {
            return findLight((Node) child);
        }
    }

    return null;
}
 
Example 17
@Override
public Shader makeCurrent(AssetManager assetManager, RenderManager renderManager,
        EnumSet<Caps> rendererCaps, LightList lights, DefineList defines) {

    // TODO: if it ever changes that render isn't called
    // right away with the same geometry after makeCurrent, it would be
    // a problem.
    // Do a radix sort.
    tempDirLights.clear();
    tempPointLights.clear();
    tempSpotLights.clear();
    for (Light light : lights) {
        switch (light.getType()) {
            case Directional:
                tempDirLights.add((DirectionalLight) light);
                break;
            case Point:
                tempPointLights.add((PointLight) light);
                break;
            case Spot:
                tempSpotLights.add((SpotLight) light);
                break;
        }
    }

    defines.set(numDirLightsDefineId, tempDirLights.size());
    defines.set(numPointLightsDefineId, tempPointLights.size());
    defines.set(numSpotLightsDefineId, tempSpotLights.size());

    return techniqueDef.getShader(assetManager, rendererCaps, defines);
}
 
Example 18
public void setupLighting() {

        dl = new DirectionalLight();
        dl.setDirection(lightDir);
        dl.setColor(new ColorRGBA(.9f, .9f, .9f, 1));
        rootNode.addLight(dl);
    }
 
Example 19
@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule ic = im.getCapsule(this);
    lambda = ic.readFloat("lambda", 0.65f);
    zFarOverride = ic.readInt("zFarOverride", 0);
    light = (DirectionalLight) ic.readSavable("light", null);
    fadeInfo = (Vector2f) ic.readSavable("fadeInfo", null);
    fadeLength = ic.readFloat("fadeLength", 0f);
    init(nbShadowMaps, (int) shadowMapSize);
}
 
Example 20
private void setUpLight() {
  // We add light so we see the scene
  AmbientLight al = new AmbientLight();
  al.setColor(ColorRGBA.White.mult(1.3f));
  rootNode.addLight(al);

  DirectionalLight dl = new DirectionalLight();
  dl.setColor(ColorRGBA.White);
  dl.setDirection(new Vector3f(2.8f, -2.8f, -2.8f).normalizeLocal());
  rootNode.addLight(dl);
}
 
Example 21
protected Spatial makeCharacter() {
  // load a character from jme3test-test-data
  Spatial golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
  golem.scale(0.5f);
  golem.setLocalTranslation(-1.0f, -1.5f, -0.6f);

  // We must add a light to make the model visible
  DirectionalLight sun = new DirectionalLight();
  sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));
  golem.addLight(sun);
  return golem;
}
 
Example 22
@Override
public void simpleInitApp() {
    this.flyCam.setMoveSpeed(50);
    Node mainScene=new Node();
    cam.setLocation(new Vector3f(-34.74095f, 95.21318f, -287.4945f));
    cam.setRotation(new Quaternion(0.023536969f, 0.9361278f, -0.016098259f, -0.35050195f));

    // load sky
    mainScene.attachChild(SkyFactory.createSky(assetManager, 
            "Textures/Sky/Bright/BrightSky.dds", 
            SkyFactory.EnvMapType.CubeMap));
    createTerrain(mainScene);



    DirectionalLight sun = new DirectionalLight();
    Vector3f lightDir=new Vector3f(-0.37352666f, -0.50444174f, -0.7784704f);
    sun.setDirection(lightDir);
    sun.setColor(ColorRGBA.White.clone().multLocal(2));
    mainScene.addLight(sun);

    rootNode.attachChild(mainScene);

    fpp=new FilterPostProcessor(assetManager);
    //fpp.setNumSamples(4);
    int numSamples = getContext().getSettings().getSamples();
    if( numSamples > 0 ) {
        fpp.setNumSamples(numSamples); 
    }
    fog=new FogFilter();
    fog.setFogColor(new ColorRGBA(0.9f, 0.9f, 0.9f, 1.0f));
    fog.setFogDistance(155);
    fog.setFogDensity(1.0f);
    fpp.addFilter(fog);
    viewPort.addProcessor(fpp);
    initInputs();
}
 
Example 23
@Override
public void simpleInitApp() {
    // Create two boxes
    Mesh mesh1 = new Box(0.5f, 0.5f, 0.5f);
    geom1 = new Geometry("Box", mesh1);
    geom1.move(2, 2, -.5f);
    Material m1 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    m1.setColor("Color", ColorRGBA.Blue);
    geom1.setMaterial(m1);
    rootNode.attachChild(geom1);

    // load a character from jme3test-test-data
    golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
    golem.scale(0.5f);
    golem.setLocalTranslation(-1.0f, -1.5f, -0.6f);

    // We must add a light to make the model visible
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal());
    golem.addLight(sun);
    rootNode.attachChild(golem);

    // Create input
    inputManager.addMapping("MoveRight", new KeyTrigger(KeyInput.KEY_L));
    inputManager.addMapping("MoveLeft", new KeyTrigger(KeyInput.KEY_J));
    inputManager.addMapping("MoveUp", new KeyTrigger(KeyInput.KEY_I));
    inputManager.addMapping("MoveDown", new KeyTrigger(KeyInput.KEY_K));

    inputManager.addListener(analogListener, new String[]{
                "MoveRight", "MoveLeft", "MoveUp", "MoveDown"
            });
}
 
Example 24
public void setupLighting(){

     DirectionalLight dl = new DirectionalLight();
     dl.setDirection(new Vector3f(-1, -1, 1).normalizeLocal());
     dl.setColor(new ColorRGBA(2,2,2,1));

     rootNode.addLight(dl);
 }
 
Example 25
public void simpleInitApp() {
        DirectionalLight dl = new DirectionalLight();
        dl.setDirection(new Vector3f(-1,-1,-1).normalizeLocal());
        rootNode.addLight(dl);

        Node teapotNode = (Node) assetManager.loadModel("Models/Teapot/Teapot.mesh.xml");
        Geometry teapot = (Geometry) teapotNode.getChild(0);
        
//        Sphere sph = new Sphere(16, 16, 4);
//        Geometry teapot = new Geometry("teapot", sph);

        Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
        mat.setFloat("Shininess", 16f);
        mat.setBoolean("VertexLighting", true);
        teapot.setMaterial(mat);
        
       // show normals as material
        //Material mat = new Material(assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");

        for (int y = -10; y < 10; y++){
            for (int x = -10; x < 10; x++){
                Geometry clonePot = teapot.clone();
                
                //clonePot.setMaterial(mat);
                clonePot.setLocalTranslation(x * .5f, 0, y * .5f);
                clonePot.setLocalScale(.15f);
                
                LodControl control = new LodControl();
                clonePot.addControl(control);
                rootNode.attachChild(clonePot);
            }
        }

        cam.setLocation(new Vector3f(8.378951f, 5.4324f, 8.795956f));
        cam.setRotation(new Quaternion(-0.083419204f, 0.90370524f, -0.20599906f, -0.36595422f));
    }
 
Example 26
private void setUpLight() {
  // We add light so we see the scene
  AmbientLight al = new AmbientLight();
  al.setColor(ColorRGBA.White.mult(1.3f));
  rootNode.addLight(al);

  DirectionalLight dl = new DirectionalLight();
  dl.setColor(ColorRGBA.White);
  dl.setDirection(new Vector3f(2.8f, -2.8f, -2.8f).normalizeLocal());
  rootNode.addLight(dl);
}
 
Example 27
@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,
            SkyFactory.EnvMapType.CubeMap));

    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);
}
 
Example 28
private DirectionalLight findLight(Node node) {
    for (Light light : node.getWorldLightList()) {
        if (light instanceof DirectionalLight) {
            return (DirectionalLight) light;
        }
    }
    for (Spatial child : node.getChildren()) {
        if (child instanceof Node) {
            return findLight((Node) child);
        }
    }

    return null;
}
 
Example 29
@Override
public void simpleInitApp() {
    File file = new File("wildhouse.zip");
    if (!file.exists()) {
        useHttp = true;
    }
    
    this.flyCam.setMoveSpeed(10);

    // load sky
    rootNode.attachChild(SkyFactory.createSky(assetManager, 
            "Textures/Sky/Bright/BrightSky.dds", 
            SkyFactory.EnvMapType.CubeMap));
    
    // create the geometry and attach it
    // load the level from zip or http zip
    if (useHttp) {
        assetManager.registerLocator("https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/jmonkeyengine/wildhouse.zip", HttpZipLocator.class);
    } else {
        assetManager.registerLocator("wildhouse.zip", ZipLocator.class);
    }
    Spatial scene = assetManager.loadModel("main.scene");

    AmbientLight al = new AmbientLight();
    scene.addLight(al);

    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(0.69077975f, -0.6277887f, -0.35875428f).normalizeLocal());
    sun.setColor(ColorRGBA.White.clone().multLocal(2));
    scene.addLight(sun);

    rootNode.attachChild(scene);
}
 
Example 30
@Override
    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 = assetManager.loadModel("Models/Elephant/Elephant.mesh.xml");
        float scale = 0.05f;
        elephant.scale(scale, scale, scale);
        rootNode.attachChild(elephant);
    }