I have taken some code from TestSpatialLookAt to create a small rectangle in the lower left corner, which displays the scene using render to texture. However, I want to change the rectangle to a circle, however when I change Quad to Circle, it won't render the scene on the texture anylonger. Here's my code:
monitorNode = new Node("Monitor Node");
monitorNode.setRenderQueueMode(Renderer.QUEUE_ORTHO);
Circle quad = new Circle("Monitor", 100, 74f);
quad.setZOrder(2);
//quad.updateGeometry(150, 150);
quad.setLocalTranslation(new Vector3f(90f, 110f, 0));
monitorNode.attachChild(quad);
Circle quad2 = new Circle("Monitor", 100, 75f);
quad2.setZOrder(1);
//quad2.updateGeometry(160f, 160f);
quad2.getLocalTranslation().set(quad.getLocalTranslation());
monitorNode.attachChild(quad2);
// Ok, now lets create the Texture object that our scene will be
// rendered to.
tRenderer.setBackgroundColor(new ColorRGBA(0f, 0f, 0f, 1f));
fakeTex = new Texture2D();
fakeTex.setRenderToTextureType(Texture.RenderToTextureType.RGBA);
tRenderer.setupTexture(fakeTex);
TextureState screen = display.getRenderer().createTextureState();
screen.setTexture(fakeTex);
screen.setEnabled(true);
quad.setRenderState(screen);
monitorNode.updateGeometricState(0.0f, true);
monitorNode.updateRenderState();
camNode.lookAt(m_Terrain.getLocalTranslation(), Vector3f.UNIT_Y);
And in simpleRender:
camNode.setLocalTranslation(new Vector3f(cam.getLocation()));
camNode.getCamera().lookAt(new Vector3f(m_Terrain.getLocalTranslation()), Vector3f.UNIT_Y);
camNode.getCamera().update();
tRenderer.render(scene, fakeTex);
display.getRenderer().draw(monitorNode);
The result is simply a white circle, and then nothing - just the scene in the background (while it should be showing a circular texture with the scene). I'm probably doing something wrong here, I think I need to create a circular texture, instead of putting a rectangular one in a Circle. Any help is appreciated! thanks!
Lars