LightState lightState = mesh.getLightState(); if (lightState == null) { lightState = new LightState(); mesh.setLightState(lightState); lightState.detachAll(); copyLightState(copyLightState, lightState); } else { for (int iIndex = states.length - 1; iIndex >= 0; iIndex--) { final LightState pkLState = (LightState) states[iIndex]; if (!pkLState.isEnabled()) { if (mode == LightCombineMode.CombineClosestEnabled) { break; copyLightState(pkLState, lightState); for (int iIndex = 0, max = states.length; iIndex < max; iIndex++) { final LightState pkLState = (LightState) states[iIndex]; if (!pkLState.isEnabled()) { continue; copyLightState(pkLState, lightState); break; lightState.setEnabled(foundEnabled);
private static void copyLightState(final LightState source, final LightState destination) { destination.setTwoSidedLighting(source.getTwoSidedLighting()); destination.setLocalViewer(source.getLocalViewer()); destination.setSeparateSpecular(source.getSeparateSpecular()); destination.setEnabled(source.isEnabled()); 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); } } }
private static void copyLightState(final LightState source, final LightState destination) { destination.setEnabled(source.isEnabled()); 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); } } }
context.setCurrentState(StateType.Light, state); if (state.isEnabled() && LightState.LIGHTS_ENABLED) { setLightEnabled(true, record); setTwoSided(state.getTwoSidedLighting(), record); setLocalViewer(state.getLocalViewer(), record); 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); for (int i = state.getNumberOfChildren(); i < LightState.MAX_LIGHTS_ALLOWED; i++) { LightRecord lr = record.getLightRecord(i); if ((state.getLightMask() & LightState.MASK_GLOBALAMBIENT) == 0) { setModelAmbient(record, state.getGlobalAmbient()); } else { setModelAmbient(record, ColorRGBA.BLACK_NO_ALPHA);
_cullFrontFace.setEnabled(true); _cullFrontFace.setCullFace(CullState.Face.Front); _noLights = new LightState(); _noLights.setEnabled(false);
public OutlinePass(final boolean antialiased) { _wireframeState = new WireframeState(); _wireframeState.setFace(WireframeState.Face.FrontAndBack); _wireframeState.setLineWidth(DEFAULT_LINE_WIDTH); _wireframeState.setEnabled(true); _frontCull = new CullState(); _frontCull.setCullFace(Face.Front); _backCull = new CullState(); _backCull.setCullFace(Face.Back); _wireframeState.setAntialiased(antialiased); _noLights = new LightState(); _noLights.setGlobalAmbient(DEFAULT_OUTLINE_COLOR); _noLights.setEnabled(true); _noTexture = new TextureState(); _noTexture.setEnabled(true); _blendState = new BlendState(); _blendState.setSourceFunction(BlendState.SourceFunction.SourceAlpha); _blendState.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha); _blendState.setBlendEnabled(true); _blendState.setEnabled(true); }
public static RenderState createState(final StateType type) { switch (type) { case Blend: return new BlendState(); case ColorMask: return new ColorMaskState(); case Cull: return new CullState(); case Light: return new LightState(); case Offset: return new OffsetState(); case Stencil: return new StencilState(); case Texture: return new TextureState(); case Wireframe: return new WireframeState(); case ZBuffer: return new ZBufferState(); } throw new IllegalArgumentException("Unknown state type: " + type); } }
private static String calcMeshMaterial(final Mesh mesh) { final StringBuilder material = new StringBuilder(); // First, check if we are lit or not final LightState ls = mesh.getWorldRenderState(StateType.Light); final boolean lit = (ls != null && ls.isEnabled() && ls.count() > 0); material.append(lit ? "lit/" : "unlit/"); // Now check if we are textured final TextureState ts = mesh.getWorldRenderState(StateType.Texture); final boolean textured = (ts != null && ts.isEnabled() && ts.getNumberOfSetTextures() > 0); material.append(textured ? "textured/" : "untextured/"); // Check if we are using vertex colors final boolean vertColor = mesh.getMeshData().containsKey(MeshData.KEY_ColorCoords); material.append(vertColor ? "vertex_color" : "basic"); material.append(lit ? "_phong" : ""); // Finally, check if we are using fog final boolean foggy = mesh.hasProperty(FogParams.DefaultPropertyKey); material.append(foggy ? "_fog" : ""); material.append(".yaml"); System.out.println(material + " - " + mesh.getName()); return material.toString(); } }
setSingleLightEnabled(true, index, record, lr); if ((state.getLightMask() & LightState.MASK_AMBIENT) == 0 && (light.getLightMask() & LightState.MASK_AMBIENT) == 0) { setAmbient(index, record, light.getAmbient(), lr); if ((state.getLightMask() & LightState.MASK_DIFFUSE) == 0 && (light.getLightMask() & LightState.MASK_DIFFUSE) == 0) { setDiffuse(index, record, light.getDiffuse(), lr); if ((state.getLightMask() & LightState.MASK_SPECULAR) == 0 && (light.getLightMask() & LightState.MASK_SPECULAR) == 0) { setSpecular(index, record, light.getSpecular(), lr);
public ReadOnlyColorRGBA getOutlineColor() { return _noLights.getGlobalAmbient(); }
context.setCurrentState(StateType.Light, state); if (state.isEnabled() && LightState.LIGHTS_ENABLED) { setLightEnabled(true, record); setTwoSided(state.getTwoSidedLighting(), record); setLocalViewer(state.getLocalViewer(), record); 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); for (int i = state.getNumberOfChildren(); i < LightState.MAX_LIGHTS_ALLOWED; i++) { LightRecord lr = record.getLightRecord(i); if ((state.getLightMask() & LightState.MASK_GLOBALAMBIENT) == 0) { setModelAmbient(record, state.getGlobalAmbient()); } else { setModelAmbient(record, ColorRGBA.BLACK_NO_ALPHA);
_cullFrontFace.setEnabled(true); _cullFrontFace.setCullFace(CullState.Face.Front); _noLights = new LightState(); _noLights.setEnabled(false);
return new GLSLShaderObjectsState(); case Light: return new LightState(); case Material: return new MaterialState();
setSingleLightEnabled(true, index, record, lr); if ((state.getLightMask() & LightState.MASK_AMBIENT) == 0 && (light.getLightMask() & LightState.MASK_AMBIENT) == 0) { setAmbient(index, record, light.getAmbient(), lr); if ((state.getLightMask() & LightState.MASK_DIFFUSE) == 0 && (light.getLightMask() & LightState.MASK_DIFFUSE) == 0) { if ((state.getLightMask() & LightState.MASK_SPECULAR) == 0 && (light.getLightMask() & LightState.MASK_SPECULAR) == 0) {
LightState lightState = mesh.getLightState(); if (lightState == null) { lightState = new LightState(); mesh.setLightState(lightState); lightState.detachAll(); copyLightState(copyLightState, lightState); } else { for (int iIndex = states.length - 1; iIndex >= 0; iIndex--) { final LightState pkLState = (LightState) states[iIndex]; if (!pkLState.isEnabled()) { if (mode == LightCombineMode.CombineClosestEnabled) { break; copyLightState(pkLState, lightState); for (int iIndex = 0, max = states.length; iIndex < max; iIndex++) { final LightState pkLState = (LightState) states[iIndex]; if (!pkLState.isEnabled()) { continue; copyLightState(pkLState, lightState); break; lightState.setEnabled(foundEnabled);