Wireframe

hi!



I have a simpleApplication class, and I was confused that I was unable to press some key and see every object as wireframes in jme3… Have default keys been changed in jme3?



Thanks!

More than that, its rewritten from scratch :wink:

1 Like
normen said:

More than that, its rewritten from scratch ;)

..so that no wireframe view mode now? :'(

Yes there is, you can create a processor that sets a forced material, something like this:


public class WireProcessor implements SceneProcessor {

    RenderManager renderManager;
    Material wireMaterial;

    public WireProcessor(AssetManager manager) {
        wireMaterial = new Material(manager, "/Common/MatDefs/Misc/WireColor.j3md");
        wireMaterial.setColor("m_Color", ColorRGBA.Blue);
    }

    public void initialize(RenderManager rm, ViewPort vp) {
        renderManager = rm;
    }

    public void reshape(ViewPort vp, int w, int h) {
    }

    public boolean isInitialized() {
        return renderManager != null;
    }

    public void preFrame(float tpf) {
    }

    public void postQueue(RenderQueue rq) {
        renderManager.setForcedMaterial(wireMaterial);
    }

    public void postFrame(FrameBuffer out) {
        renderManager.setForcedMaterial(null);
    }

    public void cleanup() {
        renderManager.setForcedMaterial(null);
    }
}


and then do viewPort.addProcessor(new WireProcessor(assetManager)); in your application.

Cheers,
Normen
3 Likes

Works as a charm!



Thanks Normen!

From where does all these method called from?

My output after using this screen processor was following,







I needed to add [java]wireMaterial.getAdditionalRenderState().setWireframe(true);[/java] line in the constructor to see the wireframe.

Weird, because the WireColo material itself has wireframe set to On: http://code.google.com/p/jmonkeyengine/source/browse/branches/jme3/src/core-data/Common/MatDefs/Misc/WireColor.j3md?r=6462





@normen?

Sorry forgot to mention, if I use WireColor.j3md, I get the following error



[java]com.jme3.asset.AssetLoadException: WireColor.j3md has been marked as obsolete. Please use Unshaded.j3md instead.[/java]





So, I switched to Unshaded.j3md.

Its a screen processor, you probably add it before the water processor.

normen said:
Its a screen processor, you probably add it before the water processor.


i dont get your point. When I try to use WireColor, game quits.

so using Unshaded with setWireframe(true) sounds ok to me.

Yeah, sorry, I was thinking you were complaining about the output in the pictures your posted. You didn’t say anything else about them and mostly people complain when they post pictures of something :wink:

I posted the screen shot cause it looked kinda funny :stuck_out_tongue:

a working version for latest release :

Code:
import com.jme3.asset.AssetManager; import com.jme3.material.Material; import com.jme3.math.ColorRGBA; import com.jme3.post.SceneProcessor; import com.jme3.renderer.RenderManager; import com.jme3.renderer.ViewPort; import com.jme3.renderer.queue.RenderQueue; import com.jme3.texture.FrameBuffer;

public class WireProcessor implements SceneProcessor {

RenderManager renderManager;
Material wireMaterial;

public WireProcessor(AssetManager manager) {
    wireMaterial = new Material(manager, "/Common/MatDefs/Misc/Unshaded.j3md");
    wireMaterial.getAdditionalRenderState().setWireframe(true);
    wireMaterial.setColor("Color", ColorRGBA.Blue);
}

public void initialize(RenderManager rm, ViewPort vp) {
    renderManager = rm;
}

public void reshape(ViewPort vp, int w, int h) {
}

public boolean isInitialized() {
    return renderManager != null;
}

public void preFrame(float tpf) {
}

public void postQueue(RenderQueue rq) {
    renderManager.setForcedMaterial(wireMaterial);
}

public void postFrame(FrameBuffer out) {
    renderManager.setForcedMaterial(null);
}

public void cleanup() {
    renderManager.setForcedMaterial(null);
}

}

1 Like

Not much have changed, eh?

@iamcreasy, could you not just use this?

[java]material.getAdditionalRenderState().setWireframe(true);[/java]





Works for me: