Search in sources :

Example 41 with ViewPort

use of com.jme3.renderer.ViewPort in project jmonkeyengine by jMonkeyEngine.

the class FilterPostProcessor method initialize.

public void initialize(RenderManager rm, ViewPort vp) {
    renderManager = rm;
    renderer = rm.getRenderer();
    viewPort = vp;
    fsQuad = new Picture("filter full screen quad");
    fsQuad.setWidth(1);
    fsQuad.setHeight(1);
    if (fbFormat == Format.RGB111110F && !renderer.getCaps().contains(Caps.PackedFloatTexture)) {
        fbFormat = Format.RGB8;
    }
    Camera cam = vp.getCamera();
    //save view port diensions
    left = cam.getViewPortLeft();
    right = cam.getViewPortRight();
    top = cam.getViewPortTop();
    bottom = cam.getViewPortBottom();
    originalWidth = cam.getWidth();
    originalHeight = cam.getHeight();
    //first call to reshape
    reshape(vp, cam.getWidth(), cam.getHeight());
}
Also used : Picture(com.jme3.ui.Picture)

Example 42 with ViewPort

use of com.jme3.renderer.ViewPort in project jmonkeyengine by jMonkeyEngine.

the class FilterPostProcessor method postFrame.

public void postFrame(FrameBuffer out) {
    FrameBuffer sceneBuffer = renderFrameBuffer;
    if (renderFrameBufferMS != null && !renderer.getCaps().contains(Caps.OpenGL32)) {
        renderer.copyFrameBuffer(renderFrameBufferMS, renderFrameBuffer, true);
    } else if (renderFrameBufferMS != null) {
        sceneBuffer = renderFrameBufferMS;
    }
    renderFilterChain(renderer, sceneBuffer);
    renderer.setFrameBuffer(outputBuffer);
    //viewport can be null if no filters are enabled
    if (viewPort != null) {
        renderManager.setCamera(viewPort.getCamera(), false);
    }
}
Also used : FrameBuffer(com.jme3.texture.FrameBuffer)

Example 43 with ViewPort

use of com.jme3.renderer.ViewPort in project jmonkeyengine by jMonkeyEngine.

the class HDRRenderer method reshape.

public void reshape(ViewPort vp, int w, int h) {
    if (mainSceneFB != null) {
        renderer.deleteFrameBuffer(mainSceneFB);
    }
    mainSceneFB = new FrameBuffer(w, h, 1);
    mainScene = new Texture2D(w, h, bufFormat);
    mainSceneFB.setDepthBuffer(Format.Depth);
    mainSceneFB.setColorTexture(mainScene);
    mainScene.setMagFilter(fbMagFilter);
    mainScene.setMinFilter(fbMinFilter);
    if (msFB != null) {
        renderer.deleteFrameBuffer(msFB);
    }
    tone.setTexture("Texture", mainScene);
    Collection<Caps> caps = renderer.getCaps();
    if (numSamples > 1 && caps.contains(Caps.FrameBufferMultisample)) {
        msFB = new FrameBuffer(w, h, numSamples);
        msFB.setDepthBuffer(Format.Depth);
        msFB.setColorBuffer(bufFormat);
        vp.setOutputFrameBuffer(msFB);
    } else {
        if (numSamples > 1)
            logger.warning("FBO multisampling not supported on this GPU, request ignored.");
        vp.setOutputFrameBuffer(mainSceneFB);
    }
    createLumShaders();
}
Also used : Texture2D(com.jme3.texture.Texture2D) FrameBuffer(com.jme3.texture.FrameBuffer)

Example 44 with ViewPort

use of com.jme3.renderer.ViewPort in project jmonkeyengine by jMonkeyEngine.

the class AwtPanel method attachTo.

public void attachTo(boolean overrideMainFramebuffer, ViewPort... vps) {
    if (viewPorts.size() > 0) {
        for (ViewPort vp : viewPorts) {
            vp.setOutputFrameBuffer(null);
        }
        viewPorts.get(viewPorts.size() - 1).removeProcessor(this);
    }
    viewPorts.addAll(Arrays.asList(vps));
    viewPorts.get(viewPorts.size() - 1).addProcessor(this);
    this.attachAsMain = overrideMainFramebuffer;
}
Also used : ViewPort(com.jme3.renderer.ViewPort)

Example 45 with ViewPort

use of com.jme3.renderer.ViewPort in project jmonkeyengine by jMonkeyEngine.

the class AwtPanel method reshapeInThread.

private void reshapeInThread(int width, int height) {
    byteBuf = BufferUtils.ensureLargeEnough(byteBuf, width * height * 4);
    intBuf = byteBuf.asIntBuffer();
    if (fb != null) {
        fb.dispose();
        fb = null;
    }
    fb = new FrameBuffer(width, height, 1);
    fb.setDepthBuffer(Format.Depth);
    fb.setColorBuffer(Format.RGB8);
    fb.setSrgb(srgb);
    if (attachAsMain) {
        rm.getRenderer().setMainFrameBufferOverride(fb);
    }
    synchronized (lock) {
        img = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
    }
    //        synchronized (lock){
    //            img = (BufferedImage) getGraphicsConfiguration().createCompatibleImage(width, height);
    //        }
    AffineTransform tx = AffineTransform.getScaleInstance(1, -1);
    tx.translate(0, -img.getHeight());
    transformOp = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
    for (ViewPort vp : viewPorts) {
        if (!attachAsMain) {
            vp.setOutputFrameBuffer(fb);
        }
        vp.getCamera().resize(width, height, true);
        // Main framebuffer should use RenderManager.notifyReshape().
        for (SceneProcessor sp : vp.getProcessors()) {
            sp.reshape(vp, width, height);
        }
    }
}
Also used : AffineTransform(java.awt.geom.AffineTransform) ViewPort(com.jme3.renderer.ViewPort) FrameBuffer(com.jme3.texture.FrameBuffer) BufferedImage(java.awt.image.BufferedImage) AffineTransformOp(java.awt.image.AffineTransformOp) SceneProcessor(com.jme3.post.SceneProcessor)

Aggregations

Material (com.jme3.material.Material)29 Camera (com.jme3.renderer.Camera)19 FrameBuffer (com.jme3.texture.FrameBuffer)19 Geometry (com.jme3.scene.Geometry)18 Texture2D (com.jme3.texture.Texture2D)17 ViewPort (com.jme3.renderer.ViewPort)16 Vector3f (com.jme3.math.Vector3f)14 Spatial (com.jme3.scene.Spatial)12 Box (com.jme3.scene.shape.Box)9 Node (com.jme3.scene.Node)8 FilterPostProcessor (com.jme3.post.FilterPostProcessor)7 Renderer (com.jme3.renderer.Renderer)7 Picture (com.jme3.ui.Picture)6 KeyTrigger (com.jme3.input.controls.KeyTrigger)5 Quaternion (com.jme3.math.Quaternion)5 DirectionalLight (com.jme3.light.DirectionalLight)4 SceneProcessor (com.jme3.post.SceneProcessor)4 Sphere (com.jme3.scene.shape.Sphere)4 ActionListener (com.jme3.input.controls.ActionListener)3 Vector2f (com.jme3.math.Vector2f)3