Search in sources :

Example 6 with Picture

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

the class AbstractShadowRenderer 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)

Example 7 with Picture

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

the class HDRRenderer method createDisplayQuad.

public Picture createDisplayQuad() /*int mode, Texture tex*/
{
    if (scene64 == null)
        return null;
    Material mat = new Material(manager, "Common/MatDefs/Hdr/LogLum.j3md");
    //        if (mode == LUMMODE_ENCODE_LUM)
    //            mat.setBoolean("EncodeLum", true);
    //        else if (mode == LUMMODE_DECODE_LUM)
    mat.setBoolean("DecodeLum", true);
    mat.setTexture("Texture", scene64);
    //        mat.setTexture("Texture", tex);
    Picture dispQuad = new Picture("Luminance Display");
    dispQuad.setMaterial(mat);
    return dispQuad;
}
Also used : Picture(com.jme3.ui.Picture) Material(com.jme3.material.Material)

Example 8 with Picture

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

the class HDRRenderer method initialize.

public void initialize(RenderManager rm, ViewPort vp) {
    if (!enabled)
        return;
    renderer = rm.getRenderer();
    renderManager = rm;
    viewPort = vp;
    // loadInitial()
    fsQuad = new Picture("HDR Fullscreen Quad");
    Format lumFmt = Format.RGB8;
    scene64FB = new FrameBuffer(64, 64, 1);
    scene64 = new Texture2D(64, 64, lumFmt);
    scene64FB.setColorTexture(scene64);
    scene64.setMagFilter(fbMagFilter);
    scene64.setMinFilter(fbMinFilter);
    scene8FB = new FrameBuffer(8, 8, 1);
    scene8 = new Texture2D(8, 8, lumFmt);
    scene8FB.setColorTexture(scene8);
    scene8.setMagFilter(fbMagFilter);
    scene8.setMinFilter(fbMinFilter);
    scene1FB[0] = new FrameBuffer(1, 1, 1);
    scene1[0] = new Texture2D(1, 1, lumFmt);
    scene1FB[0].setColorTexture(scene1[0]);
    scene1FB[1] = new FrameBuffer(1, 1, 1);
    scene1[1] = new Texture2D(1, 1, lumFmt);
    scene1FB[1].setColorTexture(scene1[1]);
    // prepare tonemap shader
    tone = new Material(manager, "Common/MatDefs/Hdr/ToneMap.j3md");
    tone.setFloat("A", 0.18f);
    tone.setFloat("White", 100);
    // load();
    int w = vp.getCamera().getWidth();
    int h = vp.getCamera().getHeight();
    reshape(vp, w, h);
}
Also used : Texture2D(com.jme3.texture.Texture2D) Format(com.jme3.texture.Image.Format) Picture(com.jme3.ui.Picture) Material(com.jme3.material.Material) FrameBuffer(com.jme3.texture.FrameBuffer)

Example 9 with Picture

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

the class TestOrtho method simpleInitApp.

public void simpleInitApp() {
    Picture p = new Picture("Picture");
    // make it appear behind stats view
    p.move(0, 0, -1);
    p.setPosition(0, 0);
    p.setWidth(settings.getWidth());
    p.setHeight(settings.getHeight());
    p.setImage(assetManager, "Interface/Logo/Monkey.png", false);
    // attach geometry to orthoNode
    guiNode.attachChild(p);
}
Also used : Picture(com.jme3.ui.Picture)

Example 10 with Picture

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

the class TestSoftwareMouse method simpleInitApp.

@Override
public void simpleInitApp() {
    flyCam.setEnabled(false);
    //        inputManager.setCursorVisible(false);
    Texture tex = assetManager.loadTexture("Interface/Logo/Cursor.png");
    cursor = new Picture("cursor");
    cursor.setTexture(assetManager, (Texture2D) tex, true);
    cursor.setWidth(64);
    cursor.setHeight(64);
    guiNode.attachChild(cursor);
    inputManager.addRawInputListener(inputListener);
//        Image img = tex.getImage();
//        ByteBuffer data = img.getData(0);
//        IntBuffer image = BufferUtils.createIntBuffer(64 * 64);
//        for (int y = 0; y < 64; y++){
//            for (int x = 0; x < 64; x++){
//                int rgba = data.getInt();
//                image.put(rgba);
//            }
//        }
//        image.clear();
//
//        try {
//            Cursor cur = new Cursor(64, 64, 2, 62, 1, image, null);
//            Mouse.setNativeCursor(cur);
//        } catch (LWJGLException ex) {
//            Logger.getLogger(TestSoftwareMouse.class.getName()).log(Level.SEVERE, null, ex);
//        }
}
Also used : Picture(com.jme3.ui.Picture) Texture(com.jme3.texture.Texture)

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