Example usage for android.opengl Matrix translateM

List of usage examples for android.opengl Matrix translateM

Introduction

In this page you can find the example usage for android.opengl Matrix translateM.

Prototype

public static void translateM(float[] m, int mOffset, float x, float y, float z) 

Source Link

Document

Translates matrix m by x, y, and z in place.

Usage

From source file:Main.java

public static float[] translateModel(float[] animateResult, float[] mvpMatrix) {
    float[] newMatrix = copyMatrix(mvpMatrix);
    if (animateResult != null) {
        Matrix.translateM(newMatrix, 0, animateResult[0], animateResult[1], animateResult[2]);
    }//  w w w.  j  ava2 s. c  om
    return newMatrix;
}

From source file:Main.java

public static float[] animateObject(float[] animateResult, float[] mvpMatrix) {
    float[] newMatrix = copyMatrix(mvpMatrix);
    if (animateResult != null) {
        Matrix.translateM(newMatrix, 0, animateResult[2], animateResult[3], animateResult[4]);
        rotateModel(newMatrix, null, null, animateResult[0], true, 20f, // TODO
                // values
                30f, 0f);/*from  w  w w.j  a  v a 2  s.co m*/
    }
    return newMatrix;
}

From source file:Main.java

public static void rotateModel(float[] mModelMatrix, Float x, Float y, Float z, boolean rotateAroundCenter,
        Float width, Float length, Float height) {
    // translation for rotating the model around its center
    if (rotateAroundCenter) {
        Matrix.translateM(mModelMatrix, 0, length / 2f, width / 2f, height / 2f);
    }/* w  w  w  . ja v  a 2 s  .  co m*/
    if (x != null) {
        Matrix.rotateM(mModelMatrix, 0, x, 1.0f, 0.0f, 0.0f);
    }
    if (y != null) {
        Matrix.rotateM(mModelMatrix, 0, y, 0.0f, 1.0f, 0.0f);
    }
    if (z != null) {
        Matrix.rotateM(mModelMatrix, 0, z, 0.0f, 0.0f, 1.0f);
    }

    // translation back to the origin
    if (rotateAroundCenter) {
        Matrix.translateM(mModelMatrix, 0, -length / 2, -width / 2f, -height / 2f);
    }
}

From source file:com.kentdisplays.synccardboarddemo.Page.java

/**
 * Sets up the drawing object data for use in an OpenGL ES context.
 *
 * @param is InputStream to the page to load the path data from.
 *//*from w w w  .j a  v a2 s. com*/
public Page(InputStream is, int glProgram, int direction) {

    this.mModel = new float[16];
    this.mGlProgram = glProgram;

    // Calculate the coordinates from the given path.
    ArrayList<Path> paths = pathsFromSamplePageInputStream(is);
    float finalCoords[] = {};
    float finalNormals[] = {};
    float finalColors[] = {};
    mNumberOfPaths = paths.size();
    for (int i = 0; i < mNumberOfPaths; i++) {
        Path path = paths.get(i);
        float x1 = (path.x1 / 13942 * 2) - 1;
        float y1 = (path.y1 / 20280 * 2) - 1;
        float x2 = (path.x2 / 13942 * 2) - 1;
        float y2 = (path.y2 / 20280 * 2) - 1;
        float width = path.width / 3000;
        width = width < 0.013f ? 0.013f : width; // Width should be at least 0.013

        float distance = (float) Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
        float angle = (float) Math.PI / 2 - (float) Math.asin((x2 - x1) / distance);
        float xdiff = (width / 2) * (float) Math.sin(angle);
        float ydiff = (width / 2) * (float) Math.cos(angle);

        float coords[] = { x1 - xdiff, y1 - ydiff, 1.0f, // top left
                x2 - xdiff, y2 - ydiff, 1.0f, // bottom left
                x1 + xdiff, y1 + ydiff, 1.0f, // top right
                x2 - xdiff, y2 - ydiff, 1.0f, // bottom left
                x2 + xdiff, y2 + ydiff, 1.0f, // bottom right
                x1 + xdiff, y1 + ydiff, 1.0f, // top right
        };

        float normals[] = { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
                1.0f, 0.0f, 0.0f, 1.0f, };

        float colors[] = { 0.2f, 0.709803922f, 0.898039216f, 1.0f, 0.2f, 0.709803922f, 0.898039216f, 1.0f, 0.2f,
                0.709803922f, 0.898039216f, 1.0f, 0.2f, 0.709803922f, 0.898039216f, 1.0f, 0.2f, 0.709803922f,
                0.898039216f, 1.0f, 0.2f, 0.709803922f, 0.898039216f, 1.0f, };

        finalCoords = Floats.concat(finalCoords, coords);
        finalNormals = Floats.concat(finalNormals, normals);
        finalColors = Floats.concat(finalColors, colors);
    }

    ByteBuffer bbVertices = ByteBuffer.allocateDirect(finalCoords.length * 4);
    bbVertices.order(ByteOrder.nativeOrder());
    mPageVertices = bbVertices.asFloatBuffer();
    mPageVertices.put(finalCoords);
    mPageVertices.position(0);

    ByteBuffer bbNormals = ByteBuffer.allocateDirect(finalNormals.length * 4);
    bbNormals.order(ByteOrder.nativeOrder());
    mPageNormals = bbNormals.asFloatBuffer();
    mPageNormals.put(finalNormals);
    mPageNormals.position(0);

    ByteBuffer bbColors = ByteBuffer.allocateDirect(finalColors.length * 4);
    bbColors.order(ByteOrder.nativeOrder());
    mPageColors = bbColors.asFloatBuffer();
    mPageColors.put(finalColors);
    mPageColors.position(0);

    // Correctly place the page in the world.
    Matrix.setIdentityM(mModel, 0);
    switch (direction) {
    case 0:
        Matrix.translateM(mModel, 0, 0, 0, -mDistance); //Front.
        break;
    case 1:
        Matrix.translateM(mModel, 0, -mDistance, 0, 0); // Left.
        Matrix.rotateM(mModel, 0, 90, 0, 1f, 0);
        break;
    case 2:
        Matrix.translateM(mModel, 0, 0, 0, mDistance); // Behind.
        Matrix.rotateM(mModel, 0, 180, 0, 1f, 0);
        break;
    case 3:
        Matrix.translateM(mModel, 0, mDistance, 0, 0); // Right.
        Matrix.rotateM(mModel, 0, 270, 0, 1f, 0);
        break;
    }
}

From source file:com.google.fpl.liquidfunpaint.ParticleRenderer.java

public void onSurfaceChanged(int width, int height) {

    // Set up the transform
    float ratio = (float) height / width;
    Matrix.setIdentityM(mTransformFromTexture, 0);
    Matrix.scaleM(mTransformFromTexture, 0, 1, 1 / ratio, 1);

    Matrix.setIdentityM(mTransformFromWorld, 0);
    Matrix.translateM(mTransformFromWorld, 0, -1, -ratio, 0);
    Matrix.scaleM(mTransformFromWorld, 0, 2f / Renderer.getInstance().sRenderWorldWidth,
            2 * ratio / Renderer.getInstance().sRenderWorldHeight, 1);
}

From source file:com.kentdisplays.synccardboarddemo.MainActivity.java

/**
 * Creates the buffers we use to store information about the 3D world. OpenGL doesn't use Java
 * arrays, but rather needs data in a format it can understand. Hence we use ByteBuffers.
 * @param config The EGL configuration used when creating the surface.
 */// ww w . j a  va  2 s .  c  om
@Override
public void onSurfaceCreated(EGLConfig config) {
    Log.i(TAG, "onSurfaceCreated");

    // make a floor
    ByteBuffer bbFloorVertices = ByteBuffer.allocateDirect(DATA.FLOOR_COORDS.length * 4);
    bbFloorVertices.order(ByteOrder.nativeOrder());
    mFloorVertices = bbFloorVertices.asFloatBuffer();
    mFloorVertices.put(DATA.FLOOR_COORDS);
    mFloorVertices.position(0);

    ByteBuffer bbFloorNormals = ByteBuffer.allocateDirect(DATA.FLOOR_NORMALS.length * 4);
    bbFloorNormals.order(ByteOrder.nativeOrder());
    mFloorNormals = bbFloorNormals.asFloatBuffer();
    mFloorNormals.put(DATA.FLOOR_NORMALS);
    mFloorNormals.position(0);

    ByteBuffer bbFloorColors = ByteBuffer.allocateDirect(DATA.FLOOR_COLORS.length * 4);
    bbFloorColors.order(ByteOrder.nativeOrder());
    mFloorColors = bbFloorColors.asFloatBuffer();
    mFloorColors.put(DATA.FLOOR_COLORS);
    mFloorColors.position(0);

    int vertexShader = loadGLShader(GLES20.GL_VERTEX_SHADER, R.raw.light_vertex);
    int gridShader = loadGLShader(GLES20.GL_FRAGMENT_SHADER, R.raw.grid_fragment);

    mGlProgram = GLES20.glCreateProgram();
    GLES20.glAttachShader(mGlProgram, vertexShader);
    GLES20.glAttachShader(mGlProgram, gridShader);
    GLES20.glLinkProgram(mGlProgram);

    GLES20.glEnable(GLES20.GL_DEPTH_TEST);

    Matrix.setIdentityM(mModelFloor, 0);
    Matrix.translateM(mModelFloor, 0, 0, -mFloorDepth, 0); // Floor appears below user

    // Create the placeholder pages.
    mPages = new Page[4];
    mPages[0] = new Page(getResources().openRawResource(R.raw.boogie_board), mGlProgram, 0);
    mPages[1] = new Page(getResources().openRawResource(R.raw.house), mGlProgram, 1);
    mPages[2] = new Page(getResources().openRawResource(R.raw.placeholder), mGlProgram, 2);
    mPages[3] = new Page(getResources().openRawResource(R.raw.cylinder), mGlProgram, 3);

    checkGLError("onSurfaceCreated");
}

From source file:com.google.vrtoolkit.cardboard.samples.treasurehunt.MainActivity.java

/**
 * Creates the buffers we use to store information about the 3D world.
 *
 * <p>OpenGL doesn't use Java arrays, but rather needs data in a format it can understand.
 * Hence we use ByteBuffers./*from   ww  w .  j  a v  a2 s .co m*/
 *
 * @param config The EGL configuration used when creating the surface.
 */
@Override
public void onSurfaceCreated(EGLConfig config) {
    Log.i(TAG, "onSurfaceCreated");
    GLES20.glClearColor(0.1f, 0.1f, 0.1f, 0.5f); // Dark background so text shows up well.

    ByteBuffer bbVertices = ByteBuffer.allocateDirect(WorldLayoutData.CUBE_COORDS.length * 4);
    bbVertices.order(ByteOrder.nativeOrder());
    cubeVertices = bbVertices.asFloatBuffer();
    cubeVertices.put(WorldLayoutData.CUBE_COORDS);
    cubeVertices.position(0);

    ByteBuffer bbColors = ByteBuffer.allocateDirect(WorldLayoutData.CUBE_COLORS.length * 4);
    bbColors.order(ByteOrder.nativeOrder());
    cubeColors = bbColors.asFloatBuffer();
    cubeColors.put(WorldLayoutData.CUBE_COLORS);
    cubeColors.position(0);

    ByteBuffer bbFoundColors = ByteBuffer.allocateDirect(WorldLayoutData.CUBE_FOUND_COLORS.length * 4);
    bbFoundColors.order(ByteOrder.nativeOrder());
    cubeFoundColors = bbFoundColors.asFloatBuffer();
    cubeFoundColors.put(WorldLayoutData.CUBE_FOUND_COLORS);
    cubeFoundColors.position(0);

    ByteBuffer bbNormals = ByteBuffer.allocateDirect(WorldLayoutData.CUBE_NORMALS.length * 4);
    bbNormals.order(ByteOrder.nativeOrder());
    cubeNormals = bbNormals.asFloatBuffer();
    cubeNormals.put(WorldLayoutData.CUBE_NORMALS);
    cubeNormals.position(0);

    ByteBuffer mcbbVertices = ByteBuffer.allocateDirect(WorldLayoutData.MINI_CUBE_COORDS.length * 4);
    mcbbVertices.order(ByteOrder.nativeOrder());
    miniCubeVertices = mcbbVertices.asFloatBuffer();
    miniCubeVertices.put(WorldLayoutData.MINI_CUBE_COORDS);
    miniCubeVertices.position(0);

    ByteBuffer mcbbColors = ByteBuffer.allocateDirect(WorldLayoutData.MINI_CUBE_COLORS.length * 4);
    mcbbColors.order(ByteOrder.nativeOrder());
    miniCubeColors = mcbbColors.asFloatBuffer();
    miniCubeColors.put(WorldLayoutData.MINI_CUBE_COLORS);
    miniCubeColors.position(0);

    ByteBuffer mcbbNormals = ByteBuffer.allocateDirect(WorldLayoutData.CUBE_NORMALS.length * 4);
    mcbbNormals.order(ByteOrder.nativeOrder());
    miniCubeNormals = mcbbNormals.asFloatBuffer();
    miniCubeNormals.put(WorldLayoutData.CUBE_NORMALS);
    miniCubeNormals.position(0);

    // make a floor
    ByteBuffer bbFloorVertices = ByteBuffer.allocateDirect(WorldLayoutData.FLOOR_COORDS.length * 4);
    bbFloorVertices.order(ByteOrder.nativeOrder());
    floorVertices = bbFloorVertices.asFloatBuffer();
    floorVertices.put(WorldLayoutData.FLOOR_COORDS);
    floorVertices.position(0);

    ByteBuffer bbFloorNormals = ByteBuffer.allocateDirect(WorldLayoutData.FLOOR_NORMALS.length * 4);
    bbFloorNormals.order(ByteOrder.nativeOrder());
    floorNormals = bbFloorNormals.asFloatBuffer();
    floorNormals.put(WorldLayoutData.FLOOR_NORMALS);
    floorNormals.position(0);

    ByteBuffer bbFloorColors = ByteBuffer.allocateDirect(WorldLayoutData.FLOOR_COLORS.length * 4);
    bbFloorColors.order(ByteOrder.nativeOrder());
    floorColors = bbFloorColors.asFloatBuffer();
    floorColors.put(WorldLayoutData.FLOOR_COLORS);
    floorColors.position(0);

    int vertexShader = loadGLShader(GLES20.GL_VERTEX_SHADER, R.raw.light_vertex);
    int gridShader = loadGLShader(GLES20.GL_FRAGMENT_SHADER, R.raw.grid_fragment);
    int passthroughShader = loadGLShader(GLES20.GL_FRAGMENT_SHADER, R.raw.passthrough_fragment);

    cubeProgram = GLES20.glCreateProgram();
    GLES20.glAttachShader(cubeProgram, vertexShader);
    GLES20.glAttachShader(cubeProgram, passthroughShader);
    GLES20.glLinkProgram(cubeProgram);
    GLES20.glUseProgram(cubeProgram);

    checkGLError("Cube program");

    cubePositionParam = GLES20.glGetAttribLocation(cubeProgram, "a_Position");
    cubeNormalParam = GLES20.glGetAttribLocation(cubeProgram, "a_Normal");
    cubeColorParam = GLES20.glGetAttribLocation(cubeProgram, "a_Color");

    cubeModelParam = GLES20.glGetUniformLocation(cubeProgram, "u_Model");
    cubeModelViewParam = GLES20.glGetUniformLocation(cubeProgram, "u_MVMatrix");
    cubeModelViewProjectionParam = GLES20.glGetUniformLocation(cubeProgram, "u_MVP");
    cubeLightPosParam = GLES20.glGetUniformLocation(cubeProgram, "u_LightPos");

    GLES20.glEnableVertexAttribArray(cubePositionParam);
    GLES20.glEnableVertexAttribArray(cubeNormalParam);
    GLES20.glEnableVertexAttribArray(cubeColorParam);

    checkGLError("Cube program params");

    //Minicube
    miniCubeProgram = GLES20.glCreateProgram();
    GLES20.glAttachShader(miniCubeProgram, vertexShader);
    GLES20.glAttachShader(miniCubeProgram, passthroughShader);
    GLES20.glLinkProgram(miniCubeProgram);
    GLES20.glUseProgram(miniCubeProgram);

    checkGLError("Cube program");

    miniCubePositionParam = GLES20.glGetAttribLocation(miniCubeProgram, "a_Position");
    miniCubeNormalParam = GLES20.glGetAttribLocation(miniCubeProgram, "a_Normal");
    miniCubeColorParam = GLES20.glGetAttribLocation(miniCubeProgram, "a_Color");

    miniCubeModelParam = GLES20.glGetUniformLocation(miniCubeProgram, "u_Model");
    miniCubeModelViewParam = GLES20.glGetUniformLocation(miniCubeProgram, "u_MVMatrix");
    miniCubeModelViewProjectionParam = GLES20.glGetUniformLocation(miniCubeProgram, "u_MVP");
    miniCubeLightPosParam = GLES20.glGetUniformLocation(miniCubeProgram, "u_LightPos");

    GLES20.glEnableVertexAttribArray(miniCubePositionParam);
    GLES20.glEnableVertexAttribArray(miniCubeNormalParam);
    GLES20.glEnableVertexAttribArray(miniCubeColorParam);

    checkGLError("Cube program params");

    floorProgram = GLES20.glCreateProgram();
    GLES20.glAttachShader(floorProgram, vertexShader);
    GLES20.glAttachShader(floorProgram, gridShader);
    GLES20.glLinkProgram(floorProgram);
    GLES20.glUseProgram(floorProgram);

    checkGLError("Floor program");

    floorModelParam = GLES20.glGetUniformLocation(floorProgram, "u_Model");
    floorModelViewParam = GLES20.glGetUniformLocation(floorProgram, "u_MVMatrix");
    floorModelViewProjectionParam = GLES20.glGetUniformLocation(floorProgram, "u_MVP");
    floorLightPosParam = GLES20.glGetUniformLocation(floorProgram, "u_LightPos");

    floorPositionParam = GLES20.glGetAttribLocation(floorProgram, "a_Position");
    floorNormalParam = GLES20.glGetAttribLocation(floorProgram, "a_Normal");
    floorColorParam = GLES20.glGetAttribLocation(floorProgram, "a_Color");

    GLES20.glEnableVertexAttribArray(floorPositionParam);
    GLES20.glEnableVertexAttribArray(floorNormalParam);
    GLES20.glEnableVertexAttribArray(floorColorParam);

    checkGLError("Floor program params");

    Matrix.setIdentityM(modelFloor, 0);
    Matrix.translateM(modelFloor, 0, 0, -floorDepth, 0); // Floor appears below user.

    // Avoid any delays during start-up due to decoding of sound files.
    new Thread(new Runnable() {
        public void run() {
            // Start spatial audio playback of SOUND_FILE at the model postion. The returned
            //soundId handle is stored and allows for repositioning the sound object whenever
            // the cube position changes.
            cardboardAudioEngine.preloadSoundFile(SOUND_FILE);
            soundId = cardboardAudioEngine.createSoundObject(SOUND_FILE);
            cardboardAudioEngine.setSoundObjectPosition(soundId, modelPosition[0], modelPosition[1],
                    modelPosition[2]);
            cardboardAudioEngine.playSound(soundId, true /* looped playback */);
        }
    }).start();

    updateModelPosition();

    checkGLError("onSurfaceCreated");
}

From source file:com.google.vrtoolkit.cardboard.samples.treasurehunt.MainActivity.java

/**
 * Updates the cube model position.//from  w  ww  .  j  ava2 s.  c o m
 */
private void updateModelPosition() {
    Matrix.setIdentityM(modelCube, 0);
    Matrix.translateM(modelCube, 0, modelPosition[0], modelPosition[1], modelPosition[2]);

    // Update the sound location to match it with the new cube position.
    if (soundId != CardboardAudioEngine.INVALID_ID) {
        cardboardAudioEngine.setSoundObjectPosition(soundId, modelPosition[0], modelPosition[1],
                modelPosition[2]);
    }
    checkGLError("updateCubePosition");
}

From source file:com.tumblr.cardboard.Tumblr3DActivity.java

/**
 * Creates the buffers we use to store information about the 3D world. OpenGL doesn't use Java
 * arrays, but rather needs data in a format it can understand. Hence we use ByteBuffers.
 *
 * @param config The EGL configuration used when creating the surface.
 *///from  w ww.java  2  s .c  o  m
@Override
public void onSurfaceCreated(EGLConfig config) {
    Log.i(TAG, "onSurfaceCreated");
    GLES20.glClearColor(0.1f, 0.1f, 0.1f, 0.5f); // Dark background so text shows up well

    ByteBuffer bbVertices = ByteBuffer.allocateDirect(WorldLayoutData.RECT_COORDS.length * 4);
    bbVertices.order(ByteOrder.nativeOrder());
    mRectVertices = bbVertices.asFloatBuffer();
    mRectVertices.put(WorldLayoutData.RECT_COORDS);
    mRectVertices.position(0);

    ByteBuffer bbColors = ByteBuffer.allocateDirect(WorldLayoutData.RECT_COLORS.length * 4);
    bbColors.order(ByteOrder.nativeOrder());
    mRectColors = bbColors.asFloatBuffer();
    mRectColors.put(WorldLayoutData.RECT_COLORS);
    mRectColors.position(0);

    ByteBuffer bbFoundColors = ByteBuffer.allocateDirect(WorldLayoutData.RECT_FOUND_COLORS.length * 4);
    bbFoundColors.order(ByteOrder.nativeOrder());
    mRectFoundColors = bbFoundColors.asFloatBuffer();
    mRectFoundColors.put(WorldLayoutData.RECT_FOUND_COLORS);
    mRectFoundColors.position(0);

    ByteBuffer bbNormals = ByteBuffer.allocateDirect(WorldLayoutData.RECT_NORMALS.length * 4);
    bbNormals.order(ByteOrder.nativeOrder());
    mRectNormals = bbNormals.asFloatBuffer();
    mRectNormals.put(WorldLayoutData.RECT_NORMALS);
    mRectNormals.position(0);

    ByteBuffer bbTextureCoordinates = ByteBuffer.allocateDirect(WorldLayoutData.RECT_TEX_COORDS.length * 4);
    bbTextureCoordinates.order(ByteOrder.nativeOrder());
    mRectTexCoords = bbTextureCoordinates.asFloatBuffer();
    mRectTexCoords.put(WorldLayoutData.RECT_TEX_COORDS);
    mRectTexCoords.position(0);

    // make a floor
    ByteBuffer bbFloorVertices = ByteBuffer.allocateDirect(WorldLayoutData.FLOOR_COORDS.length * 4);
    bbFloorVertices.order(ByteOrder.nativeOrder());
    mFloorVertices = bbFloorVertices.asFloatBuffer();
    mFloorVertices.put(WorldLayoutData.FLOOR_COORDS);
    mFloorVertices.position(0);

    ByteBuffer bbFloorNormals = ByteBuffer.allocateDirect(WorldLayoutData.FLOOR_NORMALS.length * 4);
    bbFloorNormals.order(ByteOrder.nativeOrder());
    mFloorNormals = bbFloorNormals.asFloatBuffer();
    mFloorNormals.put(WorldLayoutData.FLOOR_NORMALS);
    mFloorNormals.position(0);

    ByteBuffer bbFloorColors = ByteBuffer.allocateDirect(WorldLayoutData.FLOOR_COLORS.length * 4);
    bbFloorColors.order(ByteOrder.nativeOrder());
    mFloorColors = bbFloorColors.asFloatBuffer();
    mFloorColors.put(WorldLayoutData.FLOOR_COLORS);
    mFloorColors.position(0);

    int vertexShader = loadGLShader(GLES20.GL_VERTEX_SHADER, R.raw.light_vertex);
    int gridShader = loadGLShader(GLES20.GL_FRAGMENT_SHADER, R.raw.flat_fragment);

    mGlProgram = GLES20.glCreateProgram();
    GLES20.glAttachShader(mGlProgram, vertexShader);
    GLES20.glAttachShader(mGlProgram, gridShader);
    GLES20.glLinkProgram(mGlProgram);

    GLES20.glEnable(GLES20.GL_DEPTH_TEST);

    Matrix.setIdentityM(mModelFloor, 0);
    Matrix.translateM(mModelFloor, 0, 0, -FLOOR_DEPTH, 0); // Floor appears below user

    checkGLError("onSurfaceCreated");
}

From source file:com.google.vrtoolkit.cardboard.samples.treasurehunt.MainActivity.java

private void updateMiniCubePosition(float x, float y, float z, float w) {
    //Matrix.setIdentityM(modelMiniCube, 0);
    //We normalize the distance as well
    //Matrix.translateM(modelMiniCube, 0, handPos[0]/(float)50.0, handPos[1]/(float)50.0, handPos[2]/(float)50.0);
    //This accounts for the reversing
    //Matrix.translateM(modelMiniCube, 0, -handPos[0]/(float)50.0, -handPos[2]/(float)50.0, -handPos[1]/(float)50.0);

    float[] temp_modelMiniCube = new float[16];
    float[] temp_mRotate = new float[16];
    Matrix.setIdentityM(temp_modelMiniCube, 0);
    Matrix.translateM(temp_modelMiniCube, 0, -handPos[0] / (float) 50.0, -handPos[2] / (float) 50.0,
            -handPos[1] / (float) 50.0);
    //Matrix.setIdentityM(temp_mRotate, 0);
    //Matrix.rotateM(temp_mRotate, 0, 45, 1, 0, 0); //This rotates the cube
    quaternionToMatrix(temp_mRotate, -x, -y, -z, w);

    Matrix.multiplyMM(modelMiniCube, 0, temp_mRotate, 0, temp_modelMiniCube, 0);

    Log.i("Armo", String.format("%f", -handPos[1] / (float) 50));
    if (-handPos[1] / (float) 50 < -WALL_DIST + 1) { //offset because this is cube center, we want the wall position
        sendArmoRequest(true);//from  w  w w  .  j a v a2 s  .  c  om
        Log.i("Armo", "Sending_lock");
    } else {
        sendArmoRequest(false);
        Log.i("Armo", "Sending_unlock");
    }

}