Hey guys,
I want to render a Preview Scene with a Picture as Background and an Object (TeaPot) in front of this picture.
From this scene I want to get a texture wich contains Object and Background. But my Picture is always in front of the Object and I get the background as Texture.
public Texture2D createInteriorMap(){
interiorMapView = renderManager.createPreView("Interior Map View", cam);
interiorMapView.setClearFlags(true, true, true);
FrameBuffer interiorMapBuffer = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1);
Texture2D interiorMapTex = new Texture2D(cam.getWidth(), cam.getHeight(), Image.Format.RGBA8);
interiorMapTex.setMinFilter(Texture.MinFilter.Trilinear);
interiorMapTex.setMagFilter(Texture.MagFilter.Bilinear);
interiorMapBuffer.setDepthBuffer(Image.Format.Depth);
interiorMapBuffer.setColorTexture(interiorMapTex);
interiorMapView.setOutputFrameBuffer(interiorMapBuffer);
teaPot3 = assetManager.loadModel("Models/Teapot/Teapot.obj");
Material toonMaterial = new Material(assetManager, "Materials/simpleToonMaterial.j3md");
toonMaterial.setVector3("eye_position", cam.getLocation());
toonMaterial.setVector3("light_position", light.getPosition());
teaPot3.setMaterial(toonMaterial);
Node interiorNode1 = new Node("interiorNode1");
Node interiorNode2 = new Node("interiorNode2");
interiorNode1.setLocalTranslation(0.0f, 0.0f, 0.0f);
interiorNode1.attachChild(backgroundPicture);
interiorNode2.setLocalTranslation(0.0f, 0.0f, 0.2f);
interiorNode2.attachChild(teaPot3);
interiorNode1.updateGeometricState();
interiorNode2.updateGeometricState();
interiorMapView.attachScene(interiorNode1);
interiorMapView.attachScene(interiorNode2);
return interiorMapTex;
}
The Background Picture is rendered in the SimpleInitFunction:
public void simpleInitApp() {
height = settings.getHeight();
width = settings.getWidth();
//Background
backgroundPicture = new Picture("background");
Texture backgroundTex = assetManager.loadTexture("Textures/PapierKariert.jpg");
backgroundPicture.setWidth(settings.getWidth());
backgroundPicture.setHeight(settings.getHeight());
backgroundPicture.setPosition(0, 0);
backgroundPicture.setTexture(assetManager, (Texture2D) backgroundTex, true);
ViewPort pv = renderManager.createPreView("background", cam);
pv.setClearFlags(true, true, true);
pv.attachScene(backgroundPicture);
viewPort.setClearFlags(false, true, true);
Does anyone has a solution for this Problem ?
Would be awesome