public RenderState extract(Stack stack, Spatial spat) {
public RenderState extract(Stack stack, SceneElement spat) {
    public RenderState extract(Stack stack, Spatial spat) {        int mode = spat.getTextureCombineMode();        if (mode == REPLACE || (mode != OFF && stack.size() == 1)) // todo: use                                                                    // dummy                                                                    // state if                                                                    // off?            return (LWJGLTextureState) stack.peek();        // accumulate the textures in the stack into a single LightState object        LWJGLTextureState newTState = new LWJGLTextureState();        boolean foundEnabled = false;        Object states[] = stack.toArray();        switch (mode) {            case COMBINE_CLOSEST:            case COMBINE_RECENT_ENABLED:                for (int iIndex = states.length - 1; iIndex >= 0; iIndex--) {                    TextureState pkTState = (TextureState) states[iIndex];                    if (!pkTState.isEnabled()) {                        if (mode == COMBINE_RECENT_ENABLED)                            break;                        else                            continue;                    } else                        foundEnabled = true;                    for (int i = 0, max = pkTState.getNumberOfSetTextures(); i < max; i++) {                        Texture pkText = pkTState.getTexture(i);                        if (newTState.getTexture(i) == null) {                            newTState.setTexture(pkText, i);                        }                    }                }                break;            case COMBINE_FIRST:                for (int iIndex = 0, max = states.length; iIndex < max; iIndex++) {                    TextureState pkTState = (TextureState) states[iIndex];                    if (!pkTState.isEnabled())                        continue;                    else                        foundEnabled = true;                    for (int i = 0; i < numTexUnits; i++) {                        Texture pkText = pkTState.getTexture(i);                        if (newTState.getTexture(i) == null) {                            newTState.setTexture(pkText, i);                        }                    }                }                break;            case OFF:                break;        }        newTState.setEnabled(foundEnabled);        return newTState;    }