No AlphaState in jME model format?

In JmeBinaryWriter() the function private void writeRenderState(RenderState renderState) writes several RenderStates, but no AlphaState.

Is there no way to store an alpha state in jME's binary format?

This patch adds AlphaState to the jme binary format:



(Download link, as the forum editor might destroy tabs: http://www.world-of-mystery.de/download/jme-format.patch)





Index: src/com/jmex/model/XMLparser/JmeBinaryReader.java

===================================================================

RCS file: /cvs/jme/src/com/jmex/model/XMLparser/JmeBinaryReader.java,v

retrieving revision 1.5

diff -r1.5 JmeBinaryReader.java

72a73

> import com.jme.scene.state.AlphaState;

208a210,211

>        } else if (tagName.equals("alphastate")){

>        s.push(buildAlphaState(attributes));

482a486,490

>        } else if (tagName.equals("alphastate")){

>        AlphaState childAlphaState=(AlphaState) s.pop();

>            parentSpatial=(Spatial) s.pop();

>            parentSpatial.setRenderState(childAlphaState);

>            s.push(parentSpatial);

924a933,949

>    }

>

>    /**

>      * Builds an AlphaState with the given attributes.

>      * @param atts The attributes

>      * @return A new AlphaState

>      */

>    private AlphaState buildAlphaState(HashMap atts) {

>    AlphaState a = renderer.createAlphaState();

>    a.setSrcFunction(((Integer)atts.get("srcfunc")).intValue());

>    a.setDstFunction(((Integer)atts.get("dstfunc")).intValue());

>    a.setTestFunction(((Integer)atts.get("testfunc")).intValue());

>    a.setReference(((Float)atts.get("reference")).floatValue());

>    a.setBlendEnabled(((Boolean)atts.get("blend")).booleanValue());

>    a.setTestEnabled(((Boolean)atts.get("test")).booleanValue());

>    a.setEnabled(((Boolean)atts.get("enabled")).booleanValue());

>    return a;

Index: src/com/jmex/model/XMLparser/JmeBinaryWriter.java

===================================================================

RCS file: /cvs/jme/src/com/jmex/model/XMLparser/JmeBinaryWriter.java,v

retrieving revision 1.6

diff -r1.6 JmeBinaryWriter.java

67a68

> import com.jme.scene.state.AlphaState;

865a867,868

>        else if (renderState instanceof AlphaState)

>        writeAlphaState((AlphaState)renderState);

1010a1014,1031

>    }

>

>    private void writeAlphaState(AlphaState state) throws IOException {

>    if (state == null) return;

>    HashMap atts = new HashMap();

>    atts.clear();

>    if (sharedObjects.containsKey(state))

>    atts.put("sharedident", sharedObjects.get(state));

>

>    atts.put("srcfunc", new Integer(state.getSrcFunction()));

>    atts.put("dstfunc", new Integer(state.getDstFunction()));

>    atts.put("testfunc", new Integer(state.getTestFunction()));

>    atts.put("reference", new Float(state.getReference()));

>    atts.put("blend", new Boolean(state.isBlendEnabled()));

>    atts.put("test", new Boolean(state.isTestEnabled()));

>    atts.put("enabled", new Boolean(state.isEnabled()));

>        writeTag("alphastate",atts);

>        writeEndTag("alphastate");


To make translucent objects rendered correctly, you have to put them in the transparent queue:





        } else if (tagName.equals("alphastate")){

        AlphaState childAlphaState=(AlphaState) s.pop();

            parentSpatial=(Spatial) s.pop();

            parentSpatial.setRenderState(childAlphaState);

            if (childAlphaState.isBlendEnabled()) {

            Spatial parent = parentSpatial;

            /* better set it on the root node?

            * while (parent.getParent() != null)

            *  parent = parent.getParent();

            */

            parent.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);

            }

            s.push(parentSpatial);





so the patch is : http://www.world-of-mystery.de/download/jme-format.patch