com.jme3.light.AmbientLight Java Examples

The following examples show how to use com.jme3.light.AmbientLight. 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 File: JmeAmbientLight.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
protected Sheet createSheet() {
    //TODO: multithreading..
    Sheet sheet = super.createSheet();
    Sheet.Set set = Sheet.createPropertiesSet();
    set.setDisplayName("AmbientLight");
    set.setName(AmbientLight.class.getName());
    AmbientLight obj = AmbientLight;//getLookup().lookup(Spatial.class);
    if (obj == null) {
        return sheet;
    }

    sheet.put(set);
    return sheet;

}
 
Example #2
Source File: TestUnshadedModel.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void simpleInitApp() {
    Sphere sphMesh = new Sphere(32, 32, 1);
    sphMesh.setTextureMode(Sphere.TextureMode.Projected);
    sphMesh.updateGeometry(32, 32, 1, false, false);
    TangentBinormalGenerator.generate(sphMesh);

    Geometry sphere = new Geometry("Rock Ball", sphMesh);
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    mat.setColor("Ambient", ColorRGBA.DarkGray);
    mat.setColor("Diffuse", ColorRGBA.White);
    mat.setBoolean("UseMaterialColors", true);
    sphere.setMaterial(mat);
    rootNode.attachChild(sphere);

    PointLight pl = new PointLight();
    pl.setColor(ColorRGBA.White);
    pl.setPosition(new Vector3f(4f, 0f, 0f));
    rootNode.addLight(pl);

    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White);
    rootNode.addLight(al);
}
 
Example #3
Source File: TestObjGroupsLoading.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void simpleInitApp() {

    // load scene with following structure:
    // Chair 1 (just mesh without name) and named groups: Chair 2, Pillow 2, Podium
    Spatial scene = assetManager.loadModel(new ModelKey("OBJLoaderTest/TwoChairs.obj"));
    // add light to make it visible
    scene.addLight(new AmbientLight(ColorRGBA.White));
    // attach scene to the root
    rootNode.attachChild(scene);
    
    // configure camera for best scene viewing
    cam.setLocation(new Vector3f(-3, 4, 3));
    cam.lookAtDirection(new Vector3f(0, -0.5f, -1), Vector3f.UNIT_Y);
    flyCam.setMoveSpeed(10);
    
    // create display to indicate pointed geometry name
    pointerDisplay = new BitmapText(guiFont);
    pointerDisplay.setBox(new Rectangle(0, settings.getHeight(), settings.getWidth(), settings.getHeight()/2));
    pointerDisplay.setAlignment(BitmapFont.Align.Center);
    pointerDisplay.setVerticalAlignment(BitmapFont.VAlign.Center);
    guiNode.attachChild(pointerDisplay);
    
    initCrossHairs();
}
 
Example #4
Source File: TestSpotLightTerrain.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void simpleInitApp() {  
    makeTerrain();
    flyCam.setMoveSpeed(50);

    sl = new SpotLight();
    sl.setSpotRange(100);
    sl.setSpotOuterAngle(20 * FastMath.DEG_TO_RAD);
    sl.setSpotInnerAngle(15 * FastMath.DEG_TO_RAD);
    sl.setDirection(new Vector3f(-0.39820394f, -0.73094344f, 0.55421597f));
    sl.setPosition(new Vector3f(-64.61567f, -87.615425f, -202.41328f));
    rootNode.addLight(sl);

    AmbientLight ambLight = new AmbientLight();
    ambLight.setColor(ColorRGBA.Black);
    rootNode.addLight(ambLight);

    cam.setLocation(new Vector3f(-41.219646f, 0.8363f, -171.67267f));
    cam.setRotation(new Quaternion(-0.04562731f, 0.89917684f, -0.09668826f, -0.4243236f));
    sl.setDirection(cam.getDirection());
    sl.setPosition(cam.getLocation());

}
 
Example #5
Source File: TestUnshadedModel.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void simpleInitApp() {
    Sphere sphMesh = new Sphere(32, 32, 1);
    sphMesh.setTextureMode(Sphere.TextureMode.Projected);
    sphMesh.updateGeometry(32, 32, 1, false, false);
    TangentBinormalGenerator.generate(sphMesh);

    Geometry sphere = new Geometry("Rock Ball", sphMesh);
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    mat.setColor("Ambient", ColorRGBA.DarkGray);
    mat.setColor("Diffuse", ColorRGBA.White);
    mat.setBoolean("UseMaterialColors", true);
    sphere.setMaterial(mat);
    rootNode.attachChild(sphere);

    PointLight pl = new PointLight();
    pl.setColor(ColorRGBA.White);
    pl.setPosition(new Vector3f(4f, 0f, 0f));
    rootNode.addLight(pl);

    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White);
    rootNode.addLight(al);
}
 
Example #6
Source File: TestBumpModel.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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 #7
Source File: TestSpotLightTerrain.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void simpleInitApp() {  
    makeTerrain();
    flyCam.setMoveSpeed(50);

    sl = new SpotLight();
    sl.setSpotRange(100);
    sl.setSpotOuterAngle(20 * FastMath.DEG_TO_RAD);
    sl.setSpotInnerAngle(15 * FastMath.DEG_TO_RAD);
    sl.setDirection(new Vector3f(-0.39820394f, -0.73094344f, 0.55421597f));
    sl.setPosition(new Vector3f(-64.61567f, -87.615425f, -202.41328f));
    rootNode.addLight(sl);

    AmbientLight ambLight = new AmbientLight();
    ambLight.setColor(new ColorRGBA(0.8f, 0.8f, 0.8f, 0.2f));
    rootNode.addLight(ambLight);

    cam.setLocation(new Vector3f(-41.219646f, -84.8363f, -171.67267f));
    cam.setRotation(new Quaternion(-0.04562731f, 0.89917684f, -0.09668826f, -0.4243236f));
    sl.setDirection(cam.getDirection());
    sl.setPosition(cam.getLocation());

}
 
Example #8
Source File: TestUnshadedModel.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void simpleInitApp() {
    Sphere sphMesh = new Sphere(32, 32, 1);
    sphMesh.setTextureMode(Sphere.TextureMode.Projected);
    sphMesh.updateGeometry(32, 32, 1, false, false);
    TangentBinormalGenerator.generate(sphMesh);

    Geometry sphere = new Geometry("Rock Ball", sphMesh);
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    mat.setColor("Ambient", ColorRGBA.DarkGray);
    mat.setColor("Diffuse", ColorRGBA.White);
    mat.setBoolean("UseMaterialColors", true);
    sphere.setMaterial(mat);
    rootNode.attachChild(sphere);

    PointLight pl = new PointLight();
    pl.setColor(ColorRGBA.White);
    pl.setPosition(new Vector3f(4f, 0f, 0f));
    rootNode.addLight(pl);

    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White);
    rootNode.addLight(al);
}
 
Example #9
Source File: TestSaveGame.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp() {

    //node that is used to store player data
    Node myPlayer = new Node();
    myPlayer.setName("PlayerNode");
    myPlayer.setUserData("name", "Mario");
    myPlayer.setUserData("health", 100.0f);
    myPlayer.setUserData("points", 0);

    //the actual model would be attached to this node
    Spatial model = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
    myPlayer.attachChild(model);

    //before saving the game, the model should be detached so it's not saved along with the node
    myPlayer.detachAllChildren();
    SaveGame.saveGame("mycompany/mygame", "savegame_001", myPlayer);

    //later the game is loaded again
    Node player = (Node) SaveGame.loadGame("mycompany/mygame", "savegame_001");
    player.attachChild(model);
    rootNode.attachChild(player);

    //and the data is available
    System.out.println("Name: " + player.getUserData("name"));
    System.out.println("Health: " + player.getUserData("health"));
    System.out.println("Points: " + player.getUserData("points"));

    AmbientLight al = new AmbientLight();
    rootNode.addLight(al);
    
    //note you can also implement your own classes that implement the Savable interface.
}
 
Example #10
Source File: HelloCollision.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 #11
Source File: CreateAmbientLightAction.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
protected @NotNull Light createLight() {
    final AmbientLight ambientLight = new AmbientLight();
    ambientLight.setName(Messages.MODEL_NODE_TREE_ACTION_AMBIENT_LIGHT);
    return ambientLight;
}
 
Example #12
Source File: TestSceneLoading.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@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 #13
Source File: TestIssue1138.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    Node cgModel = (Node) assetManager.loadModel(
            "Models/Elephant/Elephant.mesh.xml");
    rootNode.attachChild(cgModel);
    cgModel.rotate(0f, -1f, 0f);
    cgModel.scale(0.04f);

    AnimComposer composer = cgModel.getControl(AnimComposer.class);
    composer.setCurrentAction("legUp");
    sControl = cgModel.getControl(SkinningControl.class);

    AmbientLight light = new AmbientLight();
    rootNode.addLight(light);
}
 
Example #14
Source File: TerrainTestModifyHeight.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    loadHintText();
    initCrossHairs();
    setupKeys();
    
    createMarker();

    // WIREFRAME material
    matWire = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    matWire.getAdditionalRenderState().setWireframe(true);
    matWire.setColor("Color", ColorRGBA.Green);
    
    createTerrain();
    //createTerrainGrid();
    
    DirectionalLight light = new DirectionalLight();
    light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize());
    rootNode.addLight(light);

    AmbientLight ambLight = new AmbientLight();
    ambLight.setColor(new ColorRGBA(1f, 1f, 0.8f, 0.2f));
    rootNode.addLight(ambLight);

    cam.setLocation(new Vector3f(0, 256, 0));
    cam.setRotation(new Quaternion(0.25966f, 0.690398f, -0.2952f, 0.60727f));
}
 
Example #15
Source File: TestSpotLight.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setupLighting(){
      AmbientLight al=new AmbientLight();
      al.setColor(ColorRGBA.White.mult(0.02f));
      rootNode.addLight(al);
        
      spot=new SpotLight();
      
      spot.setSpotRange(1000);
      spot.setSpotInnerAngle(5*FastMath.DEG_TO_RAD);
      spot.setSpotOuterAngle(10*FastMath.DEG_TO_RAD);
      spot.setPosition(new Vector3f(77.70334f, 34.013165f, 27.1017f));
      spot.setDirection(lightTarget.subtract(spot.getPosition()));     
      spot.setColor(ColorRGBA.White.mult(2));
      rootNode.addLight(spot);
      
      
//        PointLight pl=new PointLight();
//      pl.setPosition(new Vector3f(77.70334f, 34.013165f, 27.1017f));
//      pl.setRadius(1000);     
//      pl.setColor(ColorRGBA.White.mult(2));
//      rootNode.addLight(pl);
       lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
      lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
      lightMdl.setLocalTranslation(new Vector3f(77.70334f, 34.013165f, 27.1017f));
      lightMdl.setLocalScale(5);
      rootNode.attachChild(lightMdl);
        
//        DirectionalLight dl = new DirectionalLight();
//        dl.setDirection(lightTarget.subtract(new Vector3f(77.70334f, 34.013165f, 27.1017f)));
//        dl.setColor(ColorRGBA.White.mult(2));
//        rootNode.addLight(dl);
      
      
    }
 
Example #16
Source File: TestJaime.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setupLights() {
    AmbientLight al = new AmbientLight();
    al.setColor(new ColorRGBA(0.1f, 0.1f, 0.1f, 1));
    rootNode.addLight(al);
    
    SpotLight sl = new SpotLight();
    sl.setColor(ColorRGBA.White.mult(1.0f));
    sl.setPosition(new Vector3f(1.2074411f, 10.6868908f, 4.1489987f));
    sl.setDirection(sl.getPosition().mult(-1)); 
    sl.setSpotOuterAngle(0.1f);
    sl.setSpotInnerAngle(0.004f);      
    rootNode.addLight(sl);
    
    //pointlight to fake indirect light coming from the ground
    PointLight pl = new PointLight();
    pl.setColor(ColorRGBA.White.mult(1.5f));
    pl.setPosition(new Vector3f(0, 0, 1));
    pl.setRadius(2);
    rootNode.addLight(pl);
    
    SpotLightShadowRenderer shadows = new SpotLightShadowRenderer(assetManager, 1024);
    shadows.setLight(sl);
    shadows.setShadowIntensity(0.3f);
    shadows.setEdgeFilteringMode(EdgeFilteringMode.PCF8);
    viewPort.addProcessor(shadows);

    
    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    SSAOFilter filter = new SSAOFilter(0.10997847f,0.440001f,0.39999998f,-0.008000026f);;
    fpp.addFilter(filter);
    fpp.addFilter(new FXAAFilter());
    fpp.addFilter(new FXAAFilter());     
    
    viewPort.addProcessor(fpp);
}
 
Example #17
Source File: TestIssue1283.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Add lighting to the scene.
 */
private void addLighting() {
    ColorRGBA ambientColor = new ColorRGBA(0.2f, 0.2f, 0.2f, 1f);
    AmbientLight ambient = new AmbientLight(ambientColor);
    rootNode.addLight(ambient);

    Vector3f direction = new Vector3f(1f, -2f, -2f).normalizeLocal();
    ColorRGBA sunColor = new ColorRGBA(0.5f, 0.5f, 0.5f, 1f);
    DirectionalLight sun = new DirectionalLight(direction, sunColor);
    rootNode.addLight(sun);
}
 
Example #18
Source File: AmbientLightTreeNode.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FromAnyThread
public @NotNull String getName() {
    final AmbientLight element = getElement();
    final String name = element.getName();
    return StringUtils.isEmpty(name) ? Messages.MODEL_FILE_EDITOR_NODE_AMBIENT_LIGHT : name;
}
 
Example #19
Source File: NewLightPopup.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
    SceneApplication.getApplication().enqueue(new Callable<Void>() {

        public Void call() throws Exception {
            AmbientLight light = new AmbientLight();
            light.setColor(ColorRGBA.White);
            node.addLight(light);
            addLightUndo(node, light);
            setModified();
            return null;
        }
    });
}
 
Example #20
Source File: TestTextureAtlas.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    flyCam.setMoveSpeed(50);
    Node scene = new Node("Scene");
    Spatial obj1 = assetManager.loadModel("Models/Ferrari/Car.scene");
    obj1.setLocalTranslation(-4, 0, 0);
    Spatial obj2 = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
    obj2.setLocalTranslation(-2, 0, 0);
    Spatial obj3 = assetManager.loadModel("Models/Ninja/Ninja.mesh.xml");
    obj3.setLocalTranslation(-0, 0, 0);
    Spatial obj4 = assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml");
    obj4.setLocalTranslation(2, 0, 0);
    Spatial obj5 = assetManager.loadModel("Models/Tree/Tree.mesh.j3o");
    obj5.setLocalTranslation(4, 0, 0);
    scene.attachChild(obj1);
    scene.attachChild(obj2);
    scene.attachChild(obj3);
    scene.attachChild(obj4);
    scene.attachChild(obj5);

    Geometry geom = TextureAtlas.makeAtlasBatch(scene, assetManager, 2048);

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

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

    rootNode.attachChild(geom);

    //quad to display material
    Geometry box = new Geometry("displayquad", new Quad(4, 4));
    box.setMaterial(geom.getMaterial());
    box.setLocalTranslation(0, 1, 3);
    rootNode.attachChild(box);
}
 
Example #21
Source File: TestSceneLoading.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #22
Source File: Material.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private ColorRGBA getAmbientColor(LightList lightList) {
    ambientLightColor.set(0, 0, 0, 1);
    for (int j = 0; j < lightList.size(); j++) {
        Light l = lightList.get(j);
        if (l instanceof AmbientLight) {
            ambientLightColor.addLocal(l.getColor());
        }
    }
    ambientLightColor.a = 1.0f;
    return ambientLightColor;
}
 
Example #23
Source File: TestSaveGame.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void simpleInitApp() {

        //node that is used to store player data
        Node myPlayer = new Node();
        myPlayer.setName("PlayerNode");
        myPlayer.setUserData("name", "Mario");
        myPlayer.setUserData("health", 100.0f);
        myPlayer.setUserData("points", 0);

        //the actual model would be attached to this node
        Spatial model = (Spatial) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
        myPlayer.attachChild(model);

        //before saving the game, the model should be detached so its not saved along with the node
        myPlayer.detachAllChildren();
        SaveGame.saveGame("mycompany/mygame", "savegame_001", myPlayer);

        //later the game is loaded again
        Node player = (Node) SaveGame.loadGame("mycompany/mygame", "savegame_001");
        player.attachChild(model);
        rootNode.attachChild(player);

        //and the data is available
        System.out.println("Name: " + player.getUserData("name"));
        System.out.println("Health: " + player.getUserData("health"));
        System.out.println("Points: " + player.getUserData("points"));

        AmbientLight al = new AmbientLight();
        rootNode.addLight(al);
        
        //note you can also implement your own classes that implement the Savable interface.
    }
 
Example #24
Source File: TestNormalMapping.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    Sphere sphMesh = new Sphere(32, 32, 1);
    sphMesh.setTextureMode(Sphere.TextureMode.Projected);
    sphMesh.updateGeometry(32, 32, 1, false, false);
    TangentBinormalGenerator.generate(sphMesh);

    Geometry sphere = new Geometry("Rock Ball", sphMesh);
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    sphere.setMaterial(mat);
    rootNode.attachChild(sphere);

    lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
    lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
    rootNode.attachChild(lightMdl);

    pl = new PointLight();
    pl.setColor(ColorRGBA.White);
    pl.setPosition(new Vector3f(0f, 0f, 4f));
    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 #25
Source File: TestMovingParticle.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    emit = new ParticleEmitter("Emitter", Type.Triangle, 300);
    emit.setGravity(0, 0, 0);
    emit.setVelocityVariation(1);
    emit.setLowLife(1);
    emit.setHighLife(1);
    emit.setInitialVelocity(new Vector3f(0, .5f, 0));
    emit.setImagesX(15);
    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Particle.j3md");
    mat.setTexture("Texture", assetManager.loadTexture("Effects/Smoke/Smoke.png"));
    emit.setMaterial(mat);
    
    rootNode.attachChild(emit);
    
    AmbientLight al = new AmbientLight();
    al.setColor(new ColorRGBA(0.84f, 0.80f, 0.80f, 1.0f));
    rootNode.addLight(al);
    
    
    
    inputManager.addListener(new ActionListener() {
        
        public void onAction(String name, boolean isPressed, float tpf) {
            if ("setNum".equals(name) && isPressed) {
                emit.setNumParticles(1000);
            }
        }
    }, "setNum");
    
    inputManager.addMapping("setNum", new KeyTrigger(KeyInput.KEY_SPACE));
}
 
Example #26
Source File: AbstractBlenderLoader.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * This method returns the data read from the WORLD file block. The block contains data that can be stored as
 * separate jme features and therefore cannot be returned as a single jME scene feature.
 * @param structure
 *            the structure with WORLD block data
 * @return data read from the WORLD block that can be added to the scene
 */
public WorldData toWorldData(Structure structure) {
    WorldData result = new WorldData();

    // reading ambient light
    AmbientLight ambientLight = new AmbientLight();
    float ambr = ((Number) structure.getFieldValue("ambr")).floatValue();
    float ambg = ((Number) structure.getFieldValue("ambg")).floatValue();
    float ambb = ((Number) structure.getFieldValue("ambb")).floatValue();
    ambientLight.setColor(new ColorRGBA(ambr, ambg, ambb, 0.0f));
    result.setAmbientLight(ambientLight);

    return result;
}
 
Example #27
Source File: TerrainTestModifyHeight.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    loadHintText();
    initCrossHairs();
    setupKeys();
    
    createMarker();

    // WIREFRAME material
    matWire = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    matWire.getAdditionalRenderState().setWireframe(true);
    matWire.setColor("Color", ColorRGBA.Green);
    
    createTerrain();
    //createTerrainGrid();
    
    DirectionalLight light = new DirectionalLight();
    light.setDirection((new Vector3f(-0.5f, -1f, -0.5f)).normalize());
    rootNode.addLight(light);

    AmbientLight ambLight = new AmbientLight();
    ambLight.setColor(new ColorRGBA(1f, 1f, 0.8f, 0.2f));
    rootNode.addLight(ambLight);

    cam.setLocation(new Vector3f(0, 256, 0));
    cam.lookAtDirection(new Vector3f(0, -1f, 0).normalizeLocal(), Vector3f.UNIT_X);
}
 
Example #28
Source File: HelloCollision.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #29
Source File: TestSSAO.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    cam.setLocation(new Vector3f(68.45442f, 8.235511f, 7.9676695f));
    cam.setRotation(new Quaternion(0.046916496f, -0.69500375f, 0.045538206f, 0.7160271f));


    flyCam.setMoveSpeed(50);

    Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    Texture diff = assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg");
    diff.setWrap(Texture.WrapMode.Repeat);
    Texture norm = assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall_normal.jpg");
    norm.setWrap(Texture.WrapMode.Repeat);
    mat.setTexture("DiffuseMap", diff);
    mat.setTexture("NormalMap", norm);
    mat.setFloat("Shininess", 2.0f);


    AmbientLight al = new AmbientLight();
    al.setColor(new ColorRGBA(1.8f, 1.8f, 1.8f, 1.0f));

    rootNode.addLight(al);

    model = (Geometry) assetManager.loadModel("Models/Sponza/Sponza.j3o");
    model.getMesh().scaleTextureCoordinates(new Vector2f(2, 2));

    model.setMaterial(mat);

    rootNode.attachChild(model);

    FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
    SSAOFilter ssaoFilter = new SSAOFilter(12.940201f, 43.928635f, 0.32999992f, 0.6059958f);
    fpp.addFilter(ssaoFilter);
    SSAOUI ui = new SSAOUI(inputManager, ssaoFilter);

    viewPort.addProcessor(fpp);
}
 
Example #30
Source File: TestSpotLight.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setupLighting(){
      AmbientLight al=new AmbientLight();
      al.setColor(ColorRGBA.White.mult(0.8f));
      rootNode.addLight(al);
        
      spot=new SpotLight();
      
      spot.setSpotRange(1000);
      spot.setSpotInnerAngle(5*FastMath.DEG_TO_RAD);
      spot.setSpotOuterAngle(10*FastMath.DEG_TO_RAD);
      spot.setPosition(new Vector3f(77.70334f, 34.013165f, 27.1017f));
      spot.setDirection(lightTarget.subtract(spot.getPosition()));     
      spot.setColor(ColorRGBA.White.mult(2));
      rootNode.addLight(spot);
      
      
//        PointLight pl=new PointLight();
//      pl.setPosition(new Vector3f(77.70334f, 34.013165f, 27.1017f));
//      pl.setRadius(1000);     
//      pl.setColor(ColorRGBA.White.mult(2));
//      rootNode.addLight(pl);
       lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
      lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
      lightMdl.setLocalTranslation(new Vector3f(77.70334f, 34.013165f, 27.1017f));
      lightMdl.setLocalScale(5);
      rootNode.attachChild(lightMdl);
        
//        DirectionalLight dl = new DirectionalLight();
//        dl.setDirection(lightTarget.subtract(new Vector3f(77.70334f, 34.013165f, 27.1017f)));
//        dl.setColor(ColorRGBA.White.mult(2));
//        rootNode.addLight(dl);
      
      
    }