Search in sources :

Example 6 with Vector2f

use of javax.vecmath.Vector2f in project bdx by GoranM.

the class Viewport method update.

public void update(int displayWidth, int displayHeight) {
    Vector2f resolution = resolution();
    x = Math.round(positionNormalized.x * displayWidth);
    y = Math.round(positionNormalized.y * displayHeight);
    if (type == Type.SCREEN) {
        w = Math.round(sizeNormalized.x * resolution.x);
        h = Math.round(sizeNormalized.y * resolution.y);
        scene.camera.size(resolution);
    } else {
        w = Math.round(sizeNormalized.x * displayWidth);
        h = Math.round(sizeNormalized.y * displayHeight);
        if (type == Type.SCALE) {
            scene.camera.size(resolution);
        } else {
            float dRatio = (float) w / h;
            if (type == Type.LETTERBOX) {
                float rRatio = resolution.x / resolution.y;
                if (dRatio < rRatio) {
                    int h2 = Math.round(w / rRatio);
                    y += (h - h2) / 2;
                    h = h2;
                } else if (dRatio > rRatio) {
                    int w2 = Math.round(h * rRatio);
                    x += (w - w2) / 2;
                    w = w2;
                }
                if (scene.camera.type == Camera.Type.PERSPECTIVE) {
                    scene.camera.size(w, h);
                }
            } else if (type == Type.EXTEND) {
                scene.camera.size(Math.round(resolution.y * dRatio), (int) resolution.y);
            }
        }
    }
    apply();
}
Also used : Vector2f(javax.vecmath.Vector2f)

Example 7 with Vector2f

use of javax.vecmath.Vector2f in project bdx by GoranM.

the class Viewport method viewportPositionNormalized.

public Vector2f viewportPositionNormalized(Vector3f position) {
    Vector2f p = scene.camera.screenPositionNormalized(position);
    p.sub(new Vector2f(x, y).div(Bdx.display.size()));
    p = p.mul(Bdx.display.size().div(new Vector2f(w, h)));
    return p;
}
Also used : Vector2f(javax.vecmath.Vector2f)

Example 8 with Vector2f

use of javax.vecmath.Vector2f in project bdx by GoranM.

the class Pointer method init.

public void init(Scene scene) {
    this.scene = scene;
    position = new Vector2f(Gdx.input.getX(id), Bdx.display.height() - Gdx.input.getY(id));
    rayData = null;
}
Also used : Vector2f(javax.vecmath.Vector2f)

Aggregations

Vector2f (javax.vecmath.Vector2f)8 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)1 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)1 Vector3 (com.badlogic.gdx.math.Vector3)1 Json (com.badlogic.gdx.utils.Json)1 Viewport (com.nilunder.bdx.gl.Viewport)1 HashMap (java.util.HashMap)1 Vector3f (javax.vecmath.Vector3f)1