Examples of Light


Examples of ca.eandb.jmist.framework.Light

  /* (non-Javadoc)
   * @see ca.eandb.jmist.framework.SceneElement#createLight()
   */
  public Light createLight() {
    final List<Light> lights = new ArrayList<Light>();
    Light light = null;
    int numLights = 0;
    for (SceneElement child : children) {
      light = child.createLight();
      lights.add(light);
      if (light != null) {
        numLights++;
      }
    }
    final int lightCount = numLights;
    switch (numLights) {
    case 0:
      return null;
    case 1:
      return light;
    default:
      return new AbstractLight() {

        /** Serialization version ID. */
        private static final long serialVersionUID = 6299798465595032610L;

        @Override
        public double getSamplePDF(final SurfacePoint x, final PathInfo pathInfo) {
          return lights.get(x.getPrimitiveIndex()).getSamplePDF(x, pathInfo) / (double) lightCount;
        }

        @Override
        public void illuminate(SurfacePoint x, WavelengthPacket lambda,
            Random rnd, Illuminable target) {
          throw new UnimplementedException();
        }

        @Override
        public LightNode sample(PathInfo pathInfo, double ru,
            double rv, double rj) {
          SeedReference ref = new SeedReference(rj);
          int index = RandomUtil.discrete(0, lightCount - 1, ref);
          for (int i = 0, n = lights.size(); i < n; i++) {
            Light light = lights.get(i);
            if (light != null) {
              if (index-- == 0) {
                return ScaledLightNode.create(1.0 / (double) lightCount,
                    light.sample(pathInfo, ru, rv, ref.seed), rj);

              }
            }
          }
          return null;
View Full Code Here

Examples of codechicken.lib.lighting.LightModel.Light

    }

    contents_models = CCModel.parseObjModels(MekanismUtils.getResource(ResourceType.MODEL, "transmitter_contents.obj"), 7, null);
    LightModel interiorLightModel = new LightModel()
        .setAmbient(new Vector3(0.6, 0.6, 0.6))
        .addLight(new Light(new Vector3(0.3, 1, -0.7))
            .setDiffuse(new Vector3(0.6, 0.6, 0.6)))
        .addLight(new Light(new Vector3(-0.3, 1, 0.7))
            .setDiffuse(new Vector3(0.6, 0.6, 0.6)));

    for(CCModel c : contents_models.values())
    {
      c.apply(new Translation(Vector3.center));
View Full Code Here

Examples of com.ardor3d.light.Light

            if (context.getCapabilities().isOpenGL1_2Supported()) {
                setSpecularControl(state.getSeparateSpecular(), record);
            }

            for (int i = 0, max = state.getNumberOfChildren(); i < max; i++) {
                final Light light = state.get(i);
                LightRecord lr = record.getLightRecord(i);
                // TODO: use the reference to get the lightrecord - rherlitz

                if (lr == null) {
                    lr = new LightRecord();
                    record.setLightRecord(lr, i);
                }

                if (light == null) {
                    setSingleLightEnabled(false, i, record, lr);
                } else {
                    if (light.isEnabled()) {
                        setLight(i, light, state, record, lr);
                    } else {
                        setSingleLightEnabled(false, i, record, lr);
                    }
                }
View Full Code Here

Examples of com.ardor3d.light.Light

        destination.setGlobalAmbient(source.getGlobalAmbient());
        destination.setLightMask(source.getLightMask());
        destination.setNeedsRefresh(true);

        for (int i = 0, maxL = source.getLightList().size(); i < maxL; i++) {
            final Light pkLight = source.get(i);
            if (pkLight != null) {
                destination.attach(pkLight);
            }
        }
    }
View Full Code Here

Examples of com.ardor3d.light.Light

            if (caps.isOpenGL1_2Supported()) {
                setSpecularControl(state.getSeparateSpecular(), record);
            }

            for (int i = 0, max = state.getNumberOfChildren(); i < max; i++) {
                final Light light = state.get(i);
                LightRecord lr = record.getLightRecord(i);
                // TODO: use the reference to get the lightrecord - rherlitz

                if (lr == null) {
                    lr = new LightRecord();
                    record.setLightRecord(lr, i);
                }

                if (light == null) {
                    setSingleLightEnabled(false, i, record, lr);
                } else {
                    if (light.isEnabled()) {
                        setLight(i, light, record, state, lr);
                    } else {
                        setSingleLightEnabled(false, i, record, lr);
                    }
                }
View Full Code Here

Examples of com.ardor3d.light.Light

            _pssmPass.init(renderer);
        }
        updateQuadTextures(renderer);

        // Update the shadowpass "light" position. Iow it's camera.
        final Light light = _lightState.get(0);
        if (light instanceof PointLight) {
            ((PointLight) light).setLocation(lightPosition);
        } else if (light instanceof DirectionalLight) {
            ((DirectionalLight) light).setDirection(lightPosition.normalize(null).negateLocal());
        }
View Full Code Here

Examples of com.eteks.sweethome3d.model.Light

          writeProperty(writer, DefaultFurnitureCatalog.PropertyKey.DOOR_OR_WINDOW_SASH_END_ANGLE, i, sashEndAngle);
        }
      }
      if (piece instanceof Light) {
        // Write properties specific to lights
        Light light = (Light)piece;
        LightSource [] lightSources = light.getLightSources();
        if (lightSources.length > 0) {
          String lightSourceX = "";
          String lightSourceY = "";
          String lightSourceZ = "";
          String lightSourceColor = "";
          String lightSourceDiameter = null;
          for (int lightIndex = 0; lightIndex < lightSources.length; lightIndex++) {
            if (lightIndex > 0) {
              lightSourceX += " ";
              lightSourceY += " ";
              lightSourceZ += " ";
              lightSourceColor += " ";
              if (lightSourceDiameter != null) {
                lightSourceDiameter += " ";
              }
            }
            lightSourceX += lightSources [lightIndex].getX() * light.getWidth();
            lightSourceY += lightSources [lightIndex].getY() * light.getDepth();
            lightSourceZ += lightSources [lightIndex].getZ() * light.getHeight();
            lightSourceColor += "#" + Integer.toHexString(lightSources [lightIndex].getColor());
            if (lightSources [lightIndex].getDiameter() != null) {
              if (lightSourceDiameter == null) {
                lightSourceDiameter = "";
              }
              lightSourceDiameter += lightSources [lightIndex].getDiameter() * light.getWidth();
            }
          }         
          writeProperty(writer, DefaultFurnitureCatalog.PropertyKey.LIGHT_SOURCE_X, i, lightSourceX);
          writeProperty(writer, DefaultFurnitureCatalog.PropertyKey.LIGHT_SOURCE_Y, i, lightSourceY);
          writeProperty(writer, DefaultFurnitureCatalog.PropertyKey.LIGHT_SOURCE_Z, i, lightSourceZ);
View Full Code Here

Examples of com.jme3.light.Light

        // 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

Examples of com.jme3.light.Light

    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

Examples of com.jme3.light.Light

                        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
TOP
Copyright © 2018 www.massapi.com. 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.