3

I am having an issue where I am trying to get touch input and move the camera along the x and y axis. What I assume would happen is that I would swipe a finger across the scene and the scene would move along in the motion of my finger.

https://i.stack.imgur.com/LVoYv.jpg //Images of the scene

This is how it starts, I'd like to be able to move my finger from the top to the bottom and have the multicolored squares move down. Unfortunately it gets skewed and I can't seem to figure out why.

Here is the code I'm using to set up the camera.

public void onDrawFrame(GL10 unused)
{

    // Draw background color
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);

    // Set the camera position (View matrix)
    Matrix.setLookAtM(mVMatrix, 0, m_pos_x, m_pos_y,  -100, m_pos_x, m_pos_y, 0, 0.0f, 1.0f, 0.0f);
    PrintMatrix(mVMatrix);
    Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mVMatrix, 0);        

    // Draw triangle
    mTriangle.draw(mMVPMatrix);
    //Draw the square grids
    for(int i = 0; i < row_size; i++)
    {
        for(int j = 0; j < row_size; j++)
        {
            // Draw square
            mSquare[i*row_size + j].draw(mMVPMatrix);
        }
    }
}

m_pos_x and m_pos_y are both being set in another class and is based off of the difference in touch input from frame to frame.

Any ideas what I am doing wrong?

TheKracken
  • 37
  • 1
  • 5
  • Nothing's jumping out to me as obviously incorrect here. Can you add a little more context? Maybe the setting of mProjMatrix and the draw() method. – Tim Aug 11 '12 at 20:07
  • I am having the exact same problem. Keeping the same (X,Y) coordinates for the eye and the center ought to have a drag effect of our "stuff", without changing it's orientation... But that's not happening :( – jmacedo Aug 11 '12 at 23:09
  • possible duplicate of [Android OpenGL weirdness with the setLookAtM method](http://stackoverflow.com/questions/11924020/android-opengl-weirdness-with-the-setlookatm-method) – Tim Aug 12 '12 at 21:15
  • I put an answer that may help you in the duplicate question. Also I currently believe that the Android tutorial is set up incorrectly, and I've asked my own **[question](http://stackoverflow.com/questions/11925647/is-the-android-opengl-tutorial-teaching-incorrect-linear-algebra)** about it, which you may find helpful to read. – Tim Aug 12 '12 at 21:17

0 Answers0