Search in sources :

Example 1 with Vector2f

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

the class Mesh method serialized.

public String serialized() {
    HashMap<String, Float[]> out = new HashMap<String, Float[]>();
    Float[] d;
    for (int i = 0; i < materials.size(); i++) {
        d = new Float[getVertexCount(i) * Bdx.VERT_STRIDE];
        for (int v = 0; v < getVertexCount(i); v++) {
            int vi = v * 8;
            Vector3f p = vertPos(i, v);
            d[vi] = p.x;
            d[vi + 1] = p.y;
            d[vi + 2] = p.z;
            p = vertNor(i, v);
            d[vi + 3] = p.x;
            d[vi + 4] = p.y;
            d[vi + 5] = p.z;
            Vector2f u = vertUV(i, v);
            d[vi + 6] = u.x;
            d[vi + 7] = u.y;
        }
        out.put(materials.get(i).name(), d);
    }
    return new Json().toJson(out);
}
Also used : HashMap(java.util.HashMap) Vector2f(javax.vecmath.Vector2f) Vector3f(javax.vecmath.Vector3f) Json(com.badlogic.gdx.utils.Json)

Example 2 with Vector2f

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

the class Mouse method positionNormalized.

public void positionNormalized(float x, float y) {
    Vector2f c = Bdx.display.center();
    position((int) (x * c.x * 2), (int) ((1 - y) * c.y * 2));
}
Also used : Vector2f(javax.vecmath.Vector2f)

Example 3 with Vector2f

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

the class Camera method initData.

public void initData(Type type) {
    this.type = type;
    if (type == Type.PERSPECTIVE) {
        data = new PerspectiveCamera();
    } else {
        data = new OrthographicCamera();
    }
    resolution = new Vector2f();
    ignoreObjects = new ArrayListNamed<GameObject>();
}
Also used : Vector2f(javax.vecmath.Vector2f) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera)

Example 4 with Vector2f

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

the class Camera method screenPosition.

public Vector2f screenPosition(Vector3f p) {
    Viewport vp = scene.viewport;
    Vector3 out = data.project(new Vector3(p.x, p.y, p.z), vp.x, vp.y, vp.w, vp.h);
    return new Vector2f(Math.round(out.x), Math.round(out.y));
}
Also used : Vector2f(javax.vecmath.Vector2f) Viewport(com.nilunder.bdx.gl.Viewport) Vector3(com.badlogic.gdx.math.Vector3)

Example 5 with Vector2f

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

the class ScreenShader method check.

private void check() {
    if (!isCompiled()) {
        String msg = "Shader compilation error in ScreenShader at:\n" + getLog() + "\n\n\n< Vertex Shader >\n\n" + vertexShaderPath + "\n\n< Fragment Shader >\n\n" + fragmentShaderPath + "\n\n";
        throw new RuntimeException(msg);
    }
    renderScale = new Vector2f(1, 1);
    overlay = false;
}
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