Java Code Examples for com.jme3.renderer.Camera#getViewPortTop()

The following examples show how to use com.jme3.renderer.Camera#getViewPortTop() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PickEventSession.java    From Lemur with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected boolean viewContains( Camera cam, Vector2f cursor ) {
    float x1 = cam.getViewPortLeft();
    float x2 = cam.getViewPortRight();
    float y1 = cam.getViewPortBottom();
    float y2 = cam.getViewPortTop();
    if( x1 == 0 && x2 == 1 && y1 == 0 && y2 == 1 ) {
        // No need to clip
        return true;
    }

    // Else clip it against the viewport
    float x = cursor.x / cam.getWidth();
    float y = cursor.y / cam.getHeight();
    return !(x < x1 || x > x2 || y < y1 || y > y2);
}
 
Example 2
Source File: LightScatteringFilter.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Vector3f getClipCoordinates(Vector3f worldPosition, Vector3f store, Camera cam) {

        float w = cam.getViewProjectionMatrix().multProj(worldPosition, store);
        store.divideLocal(w);

        store.x = ((store.x + 1f) * (cam.getViewPortRight() - cam.getViewPortLeft()) / 2f + cam.getViewPortLeft());
        store.y = ((store.y + 1f) * (cam.getViewPortTop() - cam.getViewPortBottom()) / 2f + cam.getViewPortBottom());
        store.z = (store.z + 1f) / 2f;

        return store;
    }
 
Example 3
Source File: ScreenshotAppState.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void postFrame(FrameBuffer out) {
    if (capture){
        capture = false;

        Camera curCamera = rm.getCurrentCamera();
        int viewX = (int) (curCamera.getViewPortLeft() * curCamera.getWidth());
        int viewY = (int) (curCamera.getViewPortBottom() * curCamera.getHeight());
        int viewWidth = (int) ((curCamera.getViewPortRight() - curCamera.getViewPortLeft()) * curCamera.getWidth());
        int viewHeight = (int) ((curCamera.getViewPortTop() - curCamera.getViewPortBottom()) * curCamera.getHeight());

        renderer.setViewPort(0, 0, width, height);
        renderer.readFrameBuffer(out, outBuf);
        renderer.setViewPort(viewX, viewY, viewWidth, viewHeight);

        File file;
        String filename;
        if (numbered) {
            shotIndex++;
            filename = shotName + shotIndex;
        } else {
            filename = shotName;
        }

        if (filePath == null) {
            file = new File(JmeSystem.getStorageFolder() + File.separator + filename + ".png").getAbsoluteFile();
        } else {
            file = new File(filePath + filename + ".png").getAbsoluteFile();
        }
        logger.log(Level.FINE, "Saving ScreenShot to: {0}", file.getAbsolutePath());

        try {
            writeImageFile(file);
        } catch (IOException ex) {
            logger.log(Level.SEVERE, "Error while saving screenshot", ex);
        }                
    }
}
 
Example 4
Source File: LightScatteringFilter.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Vector3f getClipCoordinates(Vector3f worldPosition, Vector3f store, Camera cam) {

        float w = cam.getViewProjectionMatrix().multProj(worldPosition, store);
        store.divideLocal(w);

        store.x = ((store.x + 1f) * (cam.getViewPortRight() - cam.getViewPortLeft()) / 2f + cam.getViewPortLeft());
        store.y = ((store.y + 1f) * (cam.getViewPortTop() - cam.getViewPortBottom()) / 2f + cam.getViewPortBottom());
        store.z = (store.z + 1f) / 2f;

        return store;
    }