Search in sources :

Example 1 with Camera2D

use of org.rajawali3d.cameras.Camera2D in project Rajawali by Rajawali.

the class ScreenQuad method init.

private void init(boolean createVBOs) {
    int i, j;
    int numVertices = (mSegmentsW + 1) * (mSegmentsH + 1);
    float[] vertices = new float[numVertices * 3];
    float[] textureCoords = null;
    if (mCreateTextureCoords)
        textureCoords = new float[numVertices * 2];
    float[] normals = new float[numVertices * 3];
    float[] colors = null;
    if (mCreateVertexColorBuffer)
        colors = new float[numVertices * 4];
    int[] indices = new int[mSegmentsW * mSegmentsH * 6];
    int vertexCount = 0;
    int texCoordCount = 0;
    mCamera = new Camera2D();
    mCamera.setProjectionMatrix(0, 0);
    mVPMatrix = new Matrix4();
    for (i = 0; i <= mSegmentsW; i++) {
        for (j = 0; j <= mSegmentsH; j++) {
            float v1 = ((float) i / (float) mSegmentsW - 0.5f);
            float v2 = ((float) j / (float) mSegmentsH - 0.5f);
            vertices[vertexCount] = v1;
            vertices[vertexCount + 1] = v2;
            vertices[vertexCount + 2] = 0;
            if (mCreateTextureCoords) {
                float u = (float) i / (float) mSegmentsW;
                textureCoords[texCoordCount++] = u * mNumTextureTiles;
                float v = (float) j / (float) mSegmentsH;
                textureCoords[texCoordCount++] = (1.0f - v) * mNumTextureTiles;
            }
            normals[vertexCount] = 0;
            normals[vertexCount + 1] = 0;
            normals[vertexCount + 2] = 1;
            vertexCount += 3;
        }
    }
    int colspan = mSegmentsH + 1;
    int indexCount = 0;
    for (int col = 0; col < mSegmentsW; col++) {
        for (int row = 0; row < mSegmentsH; row++) {
            int ul = col * colspan + row;
            int ll = ul + 1;
            int ur = (col + 1) * colspan + row;
            int lr = ur + 1;
            indices[indexCount++] = (int) ur;
            indices[indexCount++] = (int) lr;
            indices[indexCount++] = (int) ul;
            indices[indexCount++] = (int) lr;
            indices[indexCount++] = (int) ll;
            indices[indexCount++] = (int) ul;
        }
    }
    if (mCreateVertexColorBuffer) {
        int numColors = numVertices * 4;
        for (j = 0; j < numColors; j += 4) {
            colors[j] = 1.0f;
            colors[j + 1] = 1.0f;
            colors[j + 2] = 1.0f;
            colors[j + 3] = 1.0f;
        }
    }
    setData(vertices, normals, textureCoords, colors, indices, createVBOs);
    vertices = null;
    normals = null;
    textureCoords = null;
    colors = null;
    indices = null;
    mEnableDepthTest = false;
    mEnableDepthMask = false;
}
Also used : Camera2D(org.rajawali3d.cameras.Camera2D) Matrix4(org.rajawali3d.math.Matrix4)

Example 2 with Camera2D

use of org.rajawali3d.cameras.Camera2D in project Rajawali by Rajawali.

the class WorkaroundScreenQuad method init.

private void init(boolean createVBOs) {
    mCamera = new Camera2D();
    mCamera.setProjectionMatrix(0, 0);
    mVPMatrix = new Matrix4();
    float[] vertices = new float[] { -.5f, .5f, 0, .5f, .5f, 0, .5f, -.5f, 0, -.5f, -.5f, 0 };
    float[] textureCoords = new float[] { 0, 1, 1, 1, 1, 0, 0, 0 };
    float[] normals = new float[] { 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 };
    int[] indices = new int[] { 0, 2, 1, 0, 3, 2 };
    setData(vertices, normals, textureCoords, null, indices, createVBOs);
    vertices = null;
    normals = null;
    textureCoords = null;
    indices = null;
    mEnableDepthTest = false;
    mEnableDepthMask = false;
}
Also used : Camera2D(org.rajawali3d.cameras.Camera2D) Matrix4(org.rajawali3d.math.Matrix4)

Aggregations

Camera2D (org.rajawali3d.cameras.Camera2D)2 Matrix4 (org.rajawali3d.math.Matrix4)2