protected Light(ColorRGBA color) { setColor(color); }
if (!light.isEnabled()) { continue; processedLights.add(light); light.frustumCheckNeeded = false; light.intersectsFrustum = light.intersectsFrustum(camera, vars); if (!light.intersectsBox((BoundingBox)bv, vars)) { continue; if (!light.intersectsSphere((BoundingSphere)bv, vars)) { continue; if (light.getType() == Light.Type.Probe) { probeBlendStrat.registerProbe((LightProbe) light); } else {
/** * Sorts the elements in the list according to their Comparator. * There are two reasons why lights should be resorted. * First, if the lights have moved, that means their distance to * the spatial changed. * Second, if the spatial itself moved, it means the distance from it to * the individual lights might have changed. * * * @param transformChanged Whether the spatial's transform has changed */ public void sort(boolean transformChanged) { if (listSize > 1) { // resize or populate our temporary array as necessary if (tlist == null || tlist.length != list.length) { tlist = list.clone(); } else { System.arraycopy(list, 0, tlist, 0, list.length); } if (transformChanged){ // check distance of each light for (int i = 0; i < listSize; i++){ list[i].computeLastDistance(owner); } } // now merge sort tlist into list SortUtil.msort(tlist, list, 0, listSize - 1, c); } }
public void onAction(String name, boolean isPressed, float tpf) { if (name.equals("toggle") && isPressed) { if (lm == TechniqueDef.LightMode.SinglePass) { lm = TechniqueDef.LightMode.MultiPass; helloText.setText("(Multi pass)"); } else { lm = TechniqueDef.LightMode.SinglePass; helloText.setText("(Single pass) nb lights per batch : " + renderManager.getSinglePassLightBatchSize()); } renderManager.setPreferredLightMode(lm); reloadScene(g, boxGeo, cubeNodes); } if (name.equals("lightsUp") && isPressed) { renderManager.setSinglePassLightBatchSize(renderManager.getSinglePassLightBatchSize() + 1); helloText.setText("(Single pass) nb lights per batch : " + renderManager.getSinglePassLightBatchSize()); } if (name.equals("lightsDown") && isPressed) { renderManager.setSinglePassLightBatchSize(renderManager.getSinglePassLightBatchSize() - 1); helloText.setText("(Single pass) nb lights per batch : " + renderManager.getSinglePassLightBatchSize()); } if (name.equals("toggleOnOff") && isPressed) { for (final Light light : lightList) { if (light instanceof AmbientLight) { continue; } light.setEnabled(!light.isEnabled()); } } } }, "toggle", "lightsUp", "lightsDown", "toggleOnOff");
if(l.getType() == Light.Type.Ambient){ endIndex++; continue; ColorRGBA color = l.getColor(); if(l.getType() != Light.Type.Probe){ lightData.setVector4InArray(color.getRed(), color.getGreen(), color.getBlue(), l.getType().getId(), lightDataIndex); lightDataIndex++; switch (l.getType()) { case Directional: DirectionalLight dl = (DirectionalLight) l; break; default: throw new UnsupportedOperationException("Unknown type of light: " + l.getType());
@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); }
@Override public void write(JmeExporter ex) throws IOException { super.write(ex); OutputCapsule oc = ex.getCapsule(this); oc.write(direction, "direction", null); }
@Override public void read(JmeImporter im) throws IOException { super.read(im); InputCapsule ic = im.getCapsule(this); direction = (Vector3f) ic.readSavable("direction", null); }
protected static ColorRGBA getAmbientColor(LightList lightList, boolean removeLights, ColorRGBA ambientLightColor) { 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()); if (removeLights) { lightList.remove(l); } } } ambientLightColor.a = 1.0f; return ambientLightColor; }
if (l.getType() == Light.Type.Ambient || l.getType() == Light.Type.Probe) { continue; Vector4f tmpVec = vars.vect4f1; ColorRGBA color = l.getColor(); tmpLightColor.set(color); tmpLightColor.a = l.getType().getId(); lightColor.setValue(VarType.Vector4, tmpLightColor); switch (l.getType()) { case Directional: DirectionalLight dl = (DirectionalLight) l; throw new UnsupportedOperationException("Unknown type of light: " + l.getType());
public void updateLights(Spatial scene) { for (Light light : scene.getWorldLightList()) { switch (light.getType()) {
@Override public void write(JmeExporter ex) throws IOException { super.write(ex); OutputCapsule oc = ex.getCapsule(this); oc.write(position, "position", null); oc.write(radius, "radius", 0f); }
@Override public void read(JmeImporter im) throws IOException { super.read(im); InputCapsule ic = im.getCapsule(this); position = (Vector3f) ic.readSavable("position", null); radius = ic.readFloat("radius", 0f); if(radius!=0){ this.invRadius = 1 / radius; }else{ this.invRadius = 0; } }
protected void extractIndirectLights(LightList lightList, boolean removeLights) { 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()); if(removeLights){ lightList.remove(l); j--; } } if (l instanceof LightProbe) { lightProbes.add((LightProbe) l); if(removeLights){ lightList.remove(l); j--; } } } ambientLightColor.a = 1.0f; } }
if (!light.isEnabled()) { continue; processedLights.add(light); light.frustumCheckNeeded = false; light.intersectsFrustum = light.intersectsFrustum(camera, vars); if (!light.intersectsBox((BoundingBox)bv, vars)) { continue; if (!light.intersectsSphere((BoundingSphere)bv, vars)) { continue; if (light.getType() == Light.Type.Probe) { probeBlendStrat.registerProbe((LightProbe) light); } else {
if (elementStack.peek().equals("light")) { if (light != null) { light.setColor(parseColor(attribs));
if (l.getType() == Light.Type.Ambient || l.getType() == Light.Type.Probe) { endIndex++; continue; ColorRGBA color = l.getColor(); l.getType().getId(), lightDataIndex); lightDataIndex++; switch (l.getType()) { case Directional: DirectionalLight dl = (DirectionalLight) l; break; default: throw new UnsupportedOperationException("Unknown type of light: " + l.getType());
@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); }
@Override public void write(JmeExporter ex) throws IOException { super.write(ex); OutputCapsule oc = ex.getCapsule(this); oc.write(shCoeffs, "shCoeffs", null); oc.write(prefilteredEnvMap, "prefilteredEnvMap", null); oc.write(position, "position", null); oc.write(area, "area", new SphereProbeArea(Vector3f.ZERO, 1.0f)); oc.write(ready, "ready", false); oc.write(nbMipMaps, "nbMipMaps", 0); }