0

ズームされたGLSurfaceviewの最後まで垂直および水平スクロールを追加する方法の例を教えてください。Matrix.Translate と Matrix.Rotate を 0deg の角度で使用してみましたが、どれも機能しません。

私が使用した方法。ここで dx と dy は、onTouch から取得したスクロール量に一定の係数を掛けたものです。

方法 1:

@Override public void onDrawFrame(GL10未使用) {

mOffset = mPositionX + mPositionY;

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

// Set the camera position (View matrix)
Matrix.setLookAtM(mVMatrix, 0, mOffset, mOffset, -3, mOffset, mOffset, 0f, 0.0f, 1.0f, 0.0f);

// Calculate the projection and view transformation
Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mVMatrix, 0);

mGraph.draw(mMVPMatrix);

mLine.draw(mMVPMatrix);

}

方法 2:

@Override public void onDrawFrame(GL10未使用) {

mOffset = mPositionX + mPositionY;
Matrix.frustumM(mProjMatrix, 0, mSurfaceRatio * zoomFactor, -mSurfaceRatio * zoomFactor, -1 * (zoomFactor + mOffset), zoomFactor + mOffset, 3, 7);
// Draw background color
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);

// Set the camera position (View matrix)
Matrix.setLookAtM(mVMatrix, 0, 0, 0, -3, 0f, 0f, 0f, 0.0f, 1.0f, 0.0f);

// Calculate the projection and view transformation
Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mVMatrix, 0);

mGraph.draw(mMVPMatrix);

mLine.draw(mMVPMatrix);

}

方法 3:

@Override public void onDrawFrame(GL10未使用) {

mOffset = mPositionX + mPositionY;
// Draw background color
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);

Matrix.rotateM(mRotationMatrix, 0, 0, 0, mOffset, 0);

Matrix.multiplyMM(mProjMatrix, 0, mProjMatrix, 0, mRotationMatrix, 0);

// Set the camera position (View matrix)
Matrix.setLookAtM(mVMatrix, 0, 0, 0, -3, 0f, 0f, 0f, 0.0f, 1.0f, 0.0f);

// Calculate the projection and view transformation
Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mVMatrix, 0);

mGraph.draw(mMVPMatrix);

mLine.draw(mMVPMatrix);

}

4

1 に答える 1

0

Android OpenGL の例の頂点シェーダーが間違っていることがわかりました。ドキュメントでは正しいですが、サンプルをダウンロードすると、シェーダー コードが間違っています。次のリンクでティムが示唆しているように:

setLookAtM メソッドによる Android OpenGL の奇妙さ

于 2013-01-23T18:51:02.280 に答える