Search in sources :

Example 26 with Picture

use of com.jme3.ui.Picture in project jmonkeyengine by jMonkeyEngine.

the class TestLoadKtx method simpleInitApp.

@Override
public void simpleInitApp() {
    viewPort.setBackgroundColor(ColorRGBA.DarkGray);
    assetManager.registerLoader(KTXLoader.class, "ktx");
    Texture2D t = (Texture2D) assetManager.loadTexture("Textures/ktx/down-reference.ktx");
    Picture p = new Picture("bla", false);
    p.setTexture(assetManager, t, false);
    p.setLocalTranslation(200, 200, 0);
    p.setWidth(t.getImage().getWidth());
    p.setHeight(t.getImage().getHeight());
    guiNode.attachChild(p);
    Texture2D t2 = (Texture2D) assetManager.loadTexture("Textures/ktx/up-reference.ktx");
    Picture p2 = new Picture("bla", false);
    p2.setTexture(assetManager, t2, false);
    p2.setLocalTranslation(400, 200, 0);
    p2.setWidth(t2.getImage().getWidth());
    p2.setHeight(t2.getImage().getHeight());
    guiNode.attachChild(p2);
    Texture2D t3 = (Texture2D) assetManager.loadTexture("Textures/ktx/rgba-reference.ktx");
    Picture p3 = new Picture("bla", false);
    p3.setTexture(assetManager, t3, false);
    p3.setLocalTranslation(200, 400, 0);
    p3.setWidth(t3.getImage().getWidth());
    p3.setHeight(t3.getImage().getHeight());
    guiNode.attachChild(p3);
    Texture2D t4 = (Texture2D) assetManager.loadTexture("Textures/ktx/rgb-amg-reference.ktx");
    Picture p4 = new Picture("bla", false);
    p4.setTexture(assetManager, t4, false);
    p4.setLocalTranslation(400, 400, 0);
    p4.setWidth(t4.getImage().getWidth());
    p4.setHeight(t4.getImage().getHeight());
    guiNode.attachChild(p4);
    flyCam.setDragToRotate(true);
}
Also used : Texture2D(com.jme3.texture.Texture2D) Picture(com.jme3.ui.Picture)

Example 27 with Picture

use of com.jme3.ui.Picture in project jmonkeyengine by jMonkeyEngine.

the class VRViewManagerOSVR method setupMirrorBuffers.

private ViewPort setupMirrorBuffers(Camera cam, Texture tex, boolean expand) {
    if (environment != null) {
        if (environment.getApplication() != null) {
            Camera clonecam = cam.clone();
            ViewPort viewPort = environment.getApplication().getRenderManager().createPostView("MirrorView", clonecam);
            clonecam.setParallelProjection(true);
            viewPort.setClearFlags(true, true, true);
            viewPort.setBackgroundColor(ColorRGBA.Black);
            Picture pic = new Picture("fullscene");
            pic.setLocalTranslation(-0.75f, -0.5f, 0f);
            if (expand) {
                pic.setLocalScale(3f, 1f, 1f);
            } else {
                pic.setLocalScale(1.5f, 1f, 1f);
            }
            pic.setQueueBucket(Bucket.Opaque);
            pic.setTexture(environment.getApplication().getAssetManager(), (Texture2D) tex, false);
            viewPort.attachScene(pic);
            viewPort.setOutputFrameBuffer(null);
            pic.updateGeometricState();
            return viewPort;
        } else {
            throw new IllegalStateException("This VR environment is not attached to any application.");
        }
    } else {
        throw new IllegalStateException("This VR view manager is not attached to any VR environment.");
    }
}
Also used : Picture(com.jme3.ui.Picture) ViewPort(com.jme3.renderer.ViewPort) Camera(com.jme3.renderer.Camera)

Example 28 with Picture

use of com.jme3.ui.Picture in project jmonkeyengine by jMonkeyEngine.

the class AbstractShadowRendererVR method init.

private void init(AssetManager assetManager, int nbShadowMaps, int shadowMapSize) {
    this.postshadowMat = new Material(assetManager, "Common/MatDefs/Shadow/PostShadow.j3md");
    shadowFB = new FrameBuffer[nbShadowMaps];
    shadowMaps = new Texture2D[nbShadowMaps];
    dispPic = new Picture[nbShadowMaps];
    lightViewProjectionsMatrices = new Matrix4f[nbShadowMaps];
    shadowMapStringCache = new String[nbShadowMaps];
    lightViewStringCache = new String[nbShadowMaps];
    //DO NOT COMMENT THIS (it prevent the OSX incomplete read buffer crash)
    dummyTex = new Texture2D(shadowMapSize, shadowMapSize, Format.RGBA8);
    preshadowMat = new Material(assetManager, "Common/MatDefs/Shadow/PreShadow.j3md");
    postshadowMat.setFloat("ShadowMapSize", shadowMapSize);
    for (int i = 0; i < nbShadowMaps; i++) {
        lightViewProjectionsMatrices[i] = new Matrix4f();
        shadowFB[i] = new FrameBuffer(shadowMapSize, shadowMapSize, 1);
        shadowMaps[i] = new Texture2D(shadowMapSize, shadowMapSize, Format.Depth);
        shadowFB[i].setDepthTexture(shadowMaps[i]);
        //DO NOT COMMENT THIS (it prevent the OSX incomplete read buffer crash)
        shadowFB[i].setColorTexture(dummyTex);
        shadowMapStringCache[i] = "ShadowMap" + i;
        lightViewStringCache[i] = "LightViewProjectionMatrix" + i;
        postshadowMat.setTexture(shadowMapStringCache[i], shadowMaps[i]);
        //quads for debuging purpose
        dispPic[i] = new Picture("Picture" + i);
        dispPic[i].setTexture(assetManager, shadowMaps[i], false);
    }
    setShadowCompareMode(shadowCompareMode);
    setEdgeFilteringMode(edgeFilteringMode);
    setShadowIntensity(shadowIntensity);
    initForcedRenderState();
}
Also used : Texture2D(com.jme3.texture.Texture2D) Matrix4f(com.jme3.math.Matrix4f) Picture(com.jme3.ui.Picture) Material(com.jme3.material.Material) FrameBuffer(com.jme3.texture.FrameBuffer)

Aggregations

Picture (com.jme3.ui.Picture)22 Texture2D (com.jme3.texture.Texture2D)11 Material (com.jme3.material.Material)9 Geometry (com.jme3.scene.Geometry)5 FrameBuffer (com.jme3.texture.FrameBuffer)5 Quaternion (com.jme3.math.Quaternion)4 Vector3f (com.jme3.math.Vector3f)4 Node (com.jme3.scene.Node)4 Image (com.jme3.texture.Image)4 ViewPort (com.jme3.renderer.ViewPort)3 Quad (com.jme3.scene.shape.Quad)3 ActionListener (com.jme3.input.controls.ActionListener)2 KeyTrigger (com.jme3.input.controls.KeyTrigger)2 Matrix4f (com.jme3.math.Matrix4f)2 Camera (com.jme3.renderer.Camera)2 Sphere (com.jme3.scene.shape.Sphere)2 Format (com.jme3.texture.Image.Format)2 ByteBuffer (java.nio.ByteBuffer)2 TextureKey (com.jme3.asset.TextureKey)1 EnvironmentCamera (com.jme3.environment.EnvironmentCamera)1