3d-Model over the Gui

Yeah I moved it.



I edit the Code, because of some problems…



[java]import com.jme3.renderer.Camera;

import com.jme3.renderer.RenderManager;

import com.jme3.renderer.ViewPort;

import com.jme3.scene.Geometry;

import com.jme3.scene.Spatial;

import com.jme3.texture.FrameBuffer;

import com.jme3.texture.Image;

import com.jme3.texture.Texture;

import com.jme3.texture.Texture2D;

public class ScreenCaptureHelper {

private ViewPort offScreenView;

private Texture2D texture;

private Camera mainCamera;

private Spatial scene;

private RenderManager renderManager;



public ScreenCaptureHelper(Camera mainCamera, Spatial scene, RenderManager renderManager) {

this.mainCamera = mainCamera;

this.scene = scene;

this.renderManager = renderManager;

offScreenView = new ViewPort(“Offscreen View”, mainCamera.clone());

offScreenView.setClearColor(true);

texture = new Texture2D(mainCamera.getWidth(), mainCamera.getHeight(), Image.Format.ABGR8); //<-ABGR to get a transparent Background (if you need one)

texture.setMinFilter(Texture.MinFilter.Trilinear);





FrameBuffer offScreenBuffer = new FrameBuffer(mainCamera.getWidth(), mainCamera.getHeight(), 0);

offScreenBuffer.setColorTexture(texture);

//Couldn’t see the mesh, he was the evil ->

//offScreenBuffer.setDepthBuffer(Image.Format.Depth);

offScreenView.setOutputFrameBuffer(offScreenBuffer);

offScreenView.attachScene(this.scene);

}

/**

  • Captured data will be available in {@link #getTexture()} and can be applied to Picture.
  • Other ways of using derived texture may result unexpected behavior

    */

    public void captureScreen() {

    //It makes problem while moving, so just disable it->

    //offScreenView.getCamera().setLocation(mainCamera.getLocation());

    //offScreenView.getCamera().setRotation(mainCamera.getRotation());



    scene.scale(4f);//The Image was to little so just scale the Model up

    scene.updateGeometricState();

    renderManager.renderViewPort(offScreenView, 0);

    scene.scale(0.25f); //And Down :smiley:



    }

    public Texture2D getTexture() {

    return texture;

    }

    }[/java]

@mainclain:



Sorry I reply so late. I test your fixed code out… Work good but :



[java]offScreenView.getCamera().setRotation(mainCamera.getRotation());[/java]



is the code that I want to keep. Thanks for point me the error! Nice day my friend.