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();
}
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;
}
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;
}
Aggregations