Please, could someone create for me example based on SimpleGame, where make two object (boxes for example) and draw/render it with different FOV on screen (change cam FOV in one render pass I mean) ?
I trying this with different ways. For example I create two boxes and I don't bind them to rootNode and then I do change in cam in method SimpleRender and explicitly call display.getRender().draw(box1), change cam FOV and render (box2) and change cam FOV back. It doesn't work.
How about you post what you have so far and we can work through it.
explicitly call display.getRender().draw(box1), change cam FOV and render (box2) and change cam FOV back. It doesn't work.
Of course it doesn't work, that's because jME queues up all draw calls! :P The latest changes to the camera are used.
In order for the draw calls to flush, you have to call display.getRenderer().renderQueue().
Momoko_Fan said:
... you have to call display.getRenderer().renderQueue().
Many thanks. It was it what I want know.
Working example of two boxes and each one is render with different FOV (JMe 2.0 and LWJGL option):
import com.jme.app.SimpleGame;
import com.jme.math.Vector3f;
import com.jme.scene.shape.Box;
import com.jme.scene.state.WireframeState;
public class TwoFovInOneScene extends SimpleGame {
public static void main(String[] args){
TwoFovInOneScene game = new TwoFovInOneScene();
game.start();
}
private Box box1;
private Box box2;
@Override
protected void simpleInitGame() {
WireframeState ws = display.getRenderer().createWireframeState();
ws.setEnabled(true);
box1 = new Box("box1", new Vector3f(30, 0, -120), 20, 20, 20);
box1.setRenderState(ws);
box1.updateRenderState();
box2 = new Box("box2", new Vector3f(-30, 0, -120), 20, 20, 20);
box2.setRenderState(ws);
box2.updateRenderState();
}
@Override
protected void simpleRender() {
super.simpleRender();
display.getRenderer().renderQueue();
cam.setFrustumPerspective(120, display.getWidth()/display.getHeight(), 1, 1000);
cam.apply();
display.getRenderer().draw(box1);
display.getRenderer().renderQueue();
cam.setFrustumPerspective(60, display.getWidth()/display.getHeight(), 1, 1000);
cam.apply();
display.getRenderer().draw(box2);
}
}