Package com.jme3.light

Examples of com.jme3.light.Light


    });
  }
 
  public void setAmbientLight(final boolean on) {
    if (al == null) {
      al = new AmbientLight();
      al.setColor(new ColorRGBA(1.0f, 0.92f, 0.75f, 1f));
    }
    this.enqueue(new Callable<Integer>(){
      public Integer call() throws Exception {
        if (on) {
View Full Code Here


    //addEntity(ship);
   
   
   
    //addEntity(new RoidField("Roids", "Models/RoidField/Roid.mesh.xml"));
    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White.mult(0.5f));
    mapNode.addLight(al);
   
   
    /*
    DirectionalLight sun = new DirectionalLight();
View Full Code Here

  }
 
  public void setDirectionalLight(final boolean on) {
    if (dl == null) {
      Vector3f lightDir = new Vector3f(-0.8719428f, -0.46824604f, 0.14304268f);
      dl = new DirectionalLight();
      dl.setColor(new ColorRGBA(1.0f, 0.92f, 0.75f, 1f));
      dl.setDirection(lightDir);

      Vector3f lightDir2 = new Vector3f(0.70518064f, 0.5902297f, -0.39287305f);
      dl2 = new DirectionalLight();
      dl2.setColor(new ColorRGBA(0.7f, 0.85f, 1.0f, 1f));
      dl2.setDirection(lightDir2);
    }
    this.enqueue(new Callable<Integer>(){
      public Integer call() throws Exception {
View Full Code Here

        // can render (even incorrectly).
        lightList.clear();
        materialAmbientColor.set(0, 0, 0, 0);
       
        for (int i = 0; i < list.size(); i++){
            Light l = list.get(i);
            if (l.getType() == Light.Type.Ambient){
                // Gather
                materialAmbientColor.addLocal(l.getColor());
            }else{
                // Add to list
                lightList.add(l);
               
                // Once maximum lights reached, exit loop.
                if (lightList.size() >= maxLights){
                    break;
                }
            }
        }
       
        applyFixedFuncBindings(true);
       
        glEnable(GL_LIGHTING);
       
        fb16.clear();
        fb16.put(materialAmbientColor.r)
            .put(materialAmbientColor.g)
            .put(materialAmbientColor.b)
            .put(1).flip();
       
        glLightModel(GL_LIGHT_MODEL_AMBIENT, fb16);
       
        if (context.matrixMode != GL_MODELVIEW) {
            glMatrixMode(GL_MODELVIEW);
            context.matrixMode = GL_MODELVIEW;
        }
        // Lights are already in world space, so just convert
        // them to view space.
        glLoadMatrix(storeMatrix(viewMatrix, fb16));
       
        for (int i = 0; i < lightList.size(); i++){
            int glLightIndex = GL_LIGHT0 + i;
            Light light = lightList.get(i);
            Light.Type lightType = light.getType();
            ColorRGBA col = light.getColor();
            Vector3f pos;
           
            // Enable the light
            glEnable(glLightIndex);
           
View Full Code Here

    public LightNode toLight(Structure structure, BlenderContext blenderContext) throws BlenderFileException {
        LightNode result = (LightNode) blenderContext.getLoadedFeature(structure.getOldMemoryAddress(), LoadedFeatureDataType.LOADED_FEATURE);
        if (result != null) {
            return result;
        }
        Light light = null;
        int type = ((Number) structure.getFieldValue("type")).intValue();
        switch (type) {
            case 0:// Lamp
                light = new PointLight();
                float distance = ((Number) structure.getFieldValue("dist")).floatValue();
                ((PointLight) light).setRadius(distance);
                break;
            case 1:// Sun
                LOGGER.log(Level.WARNING, "'Sun' lamp is not supported in jMonkeyEngine.");
                break;
            case 2:// Spot
                light = new SpotLight();
                // range
                ((SpotLight) light).setSpotRange(((Number) structure.getFieldValue("dist")).floatValue());
                // outer angle
                float outerAngle = ((Number) structure.getFieldValue("spotsize")).floatValue() * FastMath.DEG_TO_RAD * 0.5f;
                ((SpotLight) light).setSpotOuterAngle(outerAngle);

                // inner angle
                float spotblend = ((Number) structure.getFieldValue("spotblend")).floatValue();
                spotblend = FastMath.clamp(spotblend, 0, 1);
                float innerAngle = outerAngle * (1 - spotblend);
                ((SpotLight) light).setSpotInnerAngle(innerAngle);
                break;
            case 3:// Hemi
                LOGGER.log(Level.WARNING, "'Hemi' lamp is not supported in jMonkeyEngine.");
                break;
            case 4:// Area
                light = new DirectionalLight();
                break;
            default:
                throw new BlenderFileException("Unknown light source type: " + type);
        }
        if (light != null) {
            float r = ((Number) structure.getFieldValue("r")).floatValue();
            float g = ((Number) structure.getFieldValue("g")).floatValue();
            float b = ((Number) structure.getFieldValue("b")).floatValue();
            light.setColor(new ColorRGBA(r, g, b, 1.0f));
            result = new LightNode(null, light);
        }
        return result;
    }
View Full Code Here

                        if (blenderKey.shouldLoad(FeaturesToLoad.WORLD)) {
                            Structure worldStructure = block.getStructure(blenderContext);
                            String worldName = worldStructure.getName();
                            if (blenderKey.getUsedWorld() == null || blenderKey.getUsedWorld().equals(worldName)) {
                                LandscapeHelper landscapeHelper = blenderContext.getHelper(LandscapeHelper.class);
                                Light ambientLight = landscapeHelper.toAmbientLight(worldStructure);
                                if(ambientLight != null) {
                                    loadingResults.addLight(new LightNode(null, ambientLight));
                                }
                                loadingResults.setSky(landscapeHelper.toSky(worldStructure));
                                loadingResults.addFilter(landscapeHelper.toFog(worldStructure));
View Full Code Here

    if (obj instanceof VisibleObject) {
      VisibleObject vo = (VisibleObject)obj;
      Spatial vos = vo.getSpatial();
      if (vos != null)
        rootNode.attachChild(vos);
      Light vol = vo.getLight();
      if (vol != null)
        rootNode.addLight(vol);
    }
    if (obj instanceof PhysicalObject) {
      PhysicalObject po = (PhysicalObject)obj;
View Full Code Here

    if (obj instanceof VisibleObject) {
      VisibleObject vo = (VisibleObject)obj;
      Spatial vos = vo.getSpatial();
      if (vos != null)
        rootNode.detachChild(vos);
      Light vol = vo.getLight();
      if (vol != null)
        rootNode.removeLight(vol);
    }
    if (obj instanceof PhysicalObject) {
      PhysicalObject po = (PhysicalObject)obj;
View Full Code Here

      }
    });
  }
 
  private PointLight getPointLight() {
    PointLight ll = new PointLight();
    ll.setColor(new ColorRGBA(1.0f, 0.92f, 0.75f, 1f));
    ll.setRadius(20f);
    return ll;
  }
View Full Code Here

        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(3f);
        rootNode.addLight(pl);
    }
View Full Code Here

TOP

Related Classes of com.jme3.light.Light

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.