Search in sources :

Example 61 with ViewPort

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

the class TestDepthStencil method simpleRender.

@Override
public void simpleRender(RenderManager rm) {
    Renderer r = rm.getRenderer();
    //do FBO rendering
    r.setFrameBuffer(fb);
    // FBO uses current camera
    rm.setCamera(cam, false);
    r.clearBuffers(true, true, true);
    rm.renderScene(fbNode, viewPort);
    rm.flushQueue(viewPort);
    //go back to default rendering and let
    //SimpleApplication render the default scene
    r.setFrameBuffer(null);
}
Also used : Renderer(com.jme3.renderer.Renderer)

Example 62 with ViewPort

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

the class TestMultiViews method simpleInitApp.

public void simpleInitApp() {
    // create the geometry and attach it
    Geometry teaGeom = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj");
    teaGeom.scale(3);
    DirectionalLight dl = new DirectionalLight();
    dl.setColor(ColorRGBA.White);
    dl.setDirection(Vector3f.UNIT_XYZ.negate());
    rootNode.addLight(dl);
    rootNode.attachChild(teaGeom);
    // Setup first view
    viewPort.setBackgroundColor(ColorRGBA.Blue);
    cam.setViewPort(.5f, 1f, 0f, 0.5f);
    cam.setLocation(new Vector3f(3.3212643f, 4.484704f, 4.2812433f));
    cam.setRotation(new Quaternion(-0.07680723f, 0.92299235f, -0.2564353f, -0.27645364f));
    // Setup second view
    Camera cam2 = cam.clone();
    cam2.setViewPort(0f, 0.5f, 0f, 0.5f);
    cam2.setLocation(new Vector3f(-0.10947256f, 1.5760219f, 4.81758f));
    cam2.setRotation(new Quaternion(0.0010108891f, 0.99857414f, -0.04928594f, 0.020481428f));
    ViewPort view2 = renderManager.createMainView("Bottom Left", cam2);
    view2.setClearFlags(true, true, true);
    view2.attachScene(rootNode);
    // Setup third view
    Camera cam3 = cam.clone();
    cam3.setViewPort(0f, .5f, .5f, 1f);
    cam3.setLocation(new Vector3f(0.2846221f, 6.4271426f, 0.23380789f));
    cam3.setRotation(new Quaternion(0.004381671f, 0.72363687f, -0.69015175f, 0.0045953835f));
    ViewPort view3 = renderManager.createMainView("Top Left", cam3);
    view3.setClearFlags(true, true, true);
    view3.attachScene(rootNode);
    // Setup fourth view
    Camera cam4 = cam.clone();
    cam4.setViewPort(.5f, 1f, .5f, 1f);
    cam4.setLocation(new Vector3f(4.775564f, 1.4548365f, 0.11491505f));
    cam4.setRotation(new Quaternion(0.02356979f, -0.74957186f, 0.026729556f, 0.66096294f));
    ViewPort view4 = renderManager.createMainView("Top Right", cam4);
    view4.setClearFlags(true, true, true);
    view4.attachScene(rootNode);
    //test multiview for gui 
    guiViewPort.getCamera().setViewPort(.5f, 1f, .5f, 1f);
    // Setup second gui view
    Camera guiCam2 = guiViewPort.getCamera().clone();
    guiCam2.setViewPort(0f, 0.5f, 0f, 0.5f);
    ViewPort guiViewPort2 = renderManager.createPostView("Gui 2", guiCam2);
    guiViewPort2.setClearFlags(false, false, false);
    guiViewPort2.attachScene(guiViewPort.getScenes().get(0));
}
Also used : Geometry(com.jme3.scene.Geometry) Quaternion(com.jme3.math.Quaternion) DirectionalLight(com.jme3.light.DirectionalLight) Vector3f(com.jme3.math.Vector3f) ViewPort(com.jme3.renderer.ViewPort) Camera(com.jme3.renderer.Camera)

Example 63 with ViewPort

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

the class EnvironmentCamera method initialize.

@Override
protected void initialize(Application app) {
    this.backGroundColor = app.getViewPort().getBackgroundColor();
    final Camera[] cameras = new Camera[6];
    Texture2D[] textures = new Texture2D[6];
    viewports = new ViewPort[6];
    framebuffers = new FrameBuffer[6];
    buffers = new ByteBuffer[6];
    images = new Image[6];
    for (int i = 0; i < 6; i++) {
        cameras[i] = createOffCamera(size, position, axisX[i], axisY[i], axisZ[i]);
        viewports[i] = createOffViewPort("EnvView" + i, cameras[i]);
        framebuffers[i] = createOffScreenFrameBuffer(size, viewports[i]);
        textures[i] = new Texture2D(size, size, imageFormat);
        framebuffers[i].setColorTexture(textures[i]);
    }
}
Also used : Texture2D(com.jme3.texture.Texture2D) Camera(com.jme3.renderer.Camera)

Example 64 with ViewPort

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

the class EnvironmentCamera method createOffViewPort.

/**
     * creates an offsceen VP
     *
     * @param name
     * @param offCamera
     * @return
     */
protected ViewPort createOffViewPort(final String name, final Camera offCamera) {
    final ViewPort offView = new ViewPort(name, offCamera);
    offView.setClearFlags(true, true, true);
    offView.setBackgroundColor(backGroundColor);
    return offView;
}
Also used : ViewPort(com.jme3.renderer.ViewPort)

Example 65 with ViewPort

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

the class ParticleEmitter method renderFromControl.

/**
     * Callback from Control.render(), do not use.
     *
     * @param rm
     * @param vp
     */
private void renderFromControl(RenderManager rm, ViewPort vp) {
    Camera cam = vp.getCamera();
    if (meshType == ParticleMesh.Type.Point) {
        float C = cam.getProjectionMatrix().m00;
        C *= cam.getWidth() * 0.5f;
        // send attenuation params
        this.getMaterial().setFloat("Quadratic", C);
    }
    Matrix3f inverseRotation = Matrix3f.IDENTITY;
    TempVars vars = null;
    if (!worldSpace) {
        vars = TempVars.get();
        inverseRotation = this.getWorldRotation().toRotationMatrix(vars.tempMat3).invertLocal();
    }
    particleMesh.updateParticleData(particles, cam, inverseRotation);
    if (!worldSpace) {
        vars.release();
    }
}
Also used : Matrix3f(com.jme3.math.Matrix3f) Camera(com.jme3.renderer.Camera) TempVars(com.jme3.util.TempVars)

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