Can I render an object ontop of everything, but under gui?

A viewport app state would be something like this… I’m having to clean some things out I depend on in my own code but hopefully it’s close:



[java]

public class ViewPortState extends AbstractAppState {

private Camera cam;

private ViewPort view;

private Node root;



public ViewPortState() {

}



public Node getRoot() {

return root;

}



public Camera getCamera() {

return cam;

}



@Override

protected void initialize( Application app )

{

root = new Node( “Viewport Root” );

root.setCullHint(CullHint.Never);



Camera originalCam = app.getCamera();

cam = new Camera(originalCam.getWidth(), originalCam.getHeight());



view = app.getRenderManager().createMainView( getName() + " ViewPort", cam);

view.setEnabled(true);

view.setClearFlags(false, true, false);

view.attachScene( root );



// You can leave this out or change it if you have different lighting needs

DirectionalLight light = new DirectionalLight();

light.setDirection( new Vector3f( 1, 0.2f, -1.5f ).normalizeLocal() );

root.addLight(light);



root.updateLogicalState(1);

root.updateGeometricState();

}



@Override

public void render(RenderManager rm) {

root.updateGeometricState();

}



@Override

public void update( float tpf ) {

root.updateLogicalState(tpf);

}



}[/java]



I’ve left out the setEnabled() because I have a base class that makes that nicer in my own code and I think it is obvious.



Once added, from anywhere in your app that you can access the state manager then you can easily look-up this class and get the root node. It’s self-managing once attached.

2 Likes