本文整理匯總了Java中android.opengl.Matrix.setRotateM方法的典型用法代碼示例。如果您正苦於以下問題:Java Matrix.setRotateM方法的具體用法?Java Matrix.setRotateM怎麽用?Java Matrix.setRotateM使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.opengl.Matrix
的用法示例。
在下文中一共展示了Matrix.setRotateM方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onDrawFrame
import android.opengl.Matrix; //導入方法依賴的package包/類
public void onDrawFrame(GL10 glUnused) {
// Ignore the passed-in GL10 interface, and use the GLES20
// class's static methods instead.
GLES20.glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glUseProgram(mProgram);
checkGlError("glUseProgram");
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureID);
mTriangleVertices.position(TRIANGLE_VERTICES_DATA_POS_OFFSET);
GLES20.glVertexAttribPointer(maPositionHandle, 3, GLES20.GL_FLOAT, false,
TRIANGLE_VERTICES_DATA_STRIDE_BYTES, mTriangleVertices);
checkGlError("glVertexAttribPointer maPosition");
mTriangleVertices.position(TRIANGLE_VERTICES_DATA_UV_OFFSET);
GLES20.glEnableVertexAttribArray(maPositionHandle);
checkGlError("glEnableVertexAttribArray maPositionHandle");
GLES20.glVertexAttribPointer(maTextureHandle, 2, GLES20.GL_FLOAT, false,
TRIANGLE_VERTICES_DATA_STRIDE_BYTES, mTriangleVertices);
checkGlError("glVertexAttribPointer maTextureHandle");
GLES20.glEnableVertexAttribArray(maTextureHandle);
checkGlError("glEnableVertexAttribArray maTextureHandle");
long time = SystemClock.uptimeMillis() % 4000L;
float angle = 0.090f * ((int) time);
Matrix.setRotateM(mMMatrix, 0, angle, 0, 0, 1.0f);
Matrix.multiplyMM(mMVPMatrix, 0, mVMatrix, 0, mMMatrix, 0);
Matrix.multiplyMM(mMVPMatrix, 0, mProjMatrix, 0, mMVPMatrix, 0);
GLES20.glUniformMatrix4fv(muMVPMatrixHandle, 1, false, mMVPMatrix, 0);
GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 3);
checkGlError("glDrawArrays");
}
示例2: onDrawFrame
import android.opengl.Matrix; //導入方法依賴的package包/類
@Override
public void onDrawFrame(GL10 unused) {
float[] scratch = new float[16];
// Draw background color
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
// Set the camera position (View matrix)
Matrix.setLookAtM(mViewMatrix, 0, 0, 0, -3, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
// Calculate the projection and view transformation
Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mViewMatrix, 0);
// Draw square
mSquare.draw(mMVPMatrix);
// Create a rotation for the triangle
// Use the following code to generate constant rotation.
// Leave this code out when using TouchEvents.
// long time = SystemClock.uptimeMillis() % 4000L;
// float angle = 0.090f * ((int) time);
Matrix.setRotateM(mRotationMatrix, 0, mAngle, 0, 0, 1.0f);
// Combine the rotation matrix with the projection and camera view
// Note that the mMVPMatrix factor *must be first* in order
// for the matrix multiplication product to be correct.
Matrix.multiplyMM(scratch, 0, mMVPMatrix, 0, mRotationMatrix, 0);
// Draw triangle
mTriangle.draw(scratch);
}
示例3: rotateTextureMatrix
import android.opengl.Matrix; //導入方法依賴的package包/類
/**
* Returns texture matrix that will have the effect of rotating the frame |rotationDegree|
* clockwise when rendered.
*/
public static float[] rotateTextureMatrix(float[] textureMatrix, float rotationDegree) {
final float[] rotationMatrix = new float[16];
Matrix.setRotateM(rotationMatrix, 0, rotationDegree, 0, 0, 1);
adjustOrigin(rotationMatrix);
return multiplyMatrices(textureMatrix, rotationMatrix);
}
示例4: rotate
import android.opengl.Matrix; //導入方法依賴的package包/類
@Override
public void rotate(float angle, float x, float y, float z) {
if (angle == 0f) {
return;
}
float[] temp = mTempMatrix;
Matrix.setRotateM(temp, 0, angle, x, y, z);
float[] matrix = mMatrices;
int index = mCurrentMatrixIndex;
Matrix.multiplyMM(temp, MATRIX_SIZE, matrix, index, temp, 0);
System.arraycopy(temp, MATRIX_SIZE, matrix, index, MATRIX_SIZE);
}
示例5: drawSelf
import android.opengl.Matrix; //導入方法依賴的package包/類
public void drawSelf() {
//指定使用著色器程序
GLES20.glUseProgram(mProgram);
//初始化變換矩陣
Matrix.setRotateM(mMMatrix , 0 , 0 , 0 , 1 , 0);
//設置沿Z軸正方向唯一1
Matrix.translateM(mMMatrix , 0 , 0 , 0 , 1);
//設置繞Y軸旋轉角度yAngle
Matrix.rotateM(mMMatrix , 0 , yAngle , 0 , 1 , 0);
//設置繞X軸旋轉角度xAngle
Matrix.rotateM(mMMatrix , 0 , xAngle , 1 , 0 , 0);
//將最終變換矩陣傳入渲染管線
GLES20.glUniformMatrix4fv(muMVPMatrixHandle , 1 , false , MatrixState.getFinalMatrix(mMMatrix) , 0);
GLES20.glVertexAttribPointer(maPositionHandle ,//頂點位置屬性引用
3 ,//每頂點一組的數據個數(X Y Z 坐標 所以是3)
GLES20.GL_FLOAT ,//數據類型
false ,//是否規格化
3 * 4 ,//每組數據的尺寸,這裏每組3個浮點數據,每個浮點4byte,所以是3*4
mVertexBuffer//存放了數據的緩衝區
);
//把顏色數據傳送進渲染管線
GLES20.glVertexAttribPointer(maColorHandle , 4 , GLES20.GL_FLOAT , false , 4 * 4 , mColorBuffer);
//啟用頂點位置數據和顏色數據
GLES20.glEnableVertexAttribArray(maPositionHandle);
GLES20.glEnableVertexAttribArray(maColorHandle);
//開始繪製,繪製三角形
GLES20.glDrawArrays(GLES20.GL_TRIANGLES , 0 , vCount);
}
示例6: onDrawFrame
import android.opengl.Matrix; //導入方法依賴的package包/類
@Override
public void onDrawFrame(GL10 gl) {
float[] scratch = new float[16];
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
Matrix.setLookAtM(viewMatrix, 0, 0, 0, -3, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
Matrix.multiplyMM(mVPMatrix, 0, projectionMatrix, 0, viewMatrix, 0);
// long time = SystemClock.uptimeMillis() % 4000L;
// float angle = 0.090f * ((int) time);
// Log.e("angle", "angle=" + angle);
Matrix.setRotateM(RotationMatrix, 0, angle, 0, 0, -1.0f);
Matrix.multiplyMM(scratch, 0, mVPMatrix, 0, RotationMatrix, 0);
triangle.draw(scratch);
}
示例7: onDrawFrame
import android.opengl.Matrix; //導入方法依賴的package包/類
@Override
public void onDrawFrame(GL10 unused) {
// Update the spin animation.
long now = System.currentTimeMillis();
float deltaT = Math.min((now - lastFrameTime) * 0.001f, 0.1f);
lastFrameTime = now;
angleDegrees += deltaT * MODEL_ROTATION_SPEED_DPS;
// Draw background color.
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
// Make a model matrix that rotates the model about the Y axis so it appears to spin.
Matrix.setRotateM(modelMatrix, 0, angleDegrees, 0, 1, 0);
// Set the camera position (View matrix)
Matrix.setLookAtM(viewMatrix, 0,
// Camera position.
EYE_X, EYE_Y, EYE_Z,
// Point that the camera is looking at.
TARGET_X, TARGET_Y, TARGET_Z,
// The vector that defines which way is up.
UP_X, UP_Y, UP_Z);
// Calculate the MVP matrix (model-view-projection) by multiplying the model, view, and
// projection matrices together.
Matrix.multiplyMM(tmpMatrix, 0, viewMatrix, 0, modelMatrix, 0); // V * M
Matrix.multiplyMM(mvpMatrix, 0, projMatrix, 0, tmpMatrix, 0); // P * V * M
// objectToRender is volatile, so we capture it in a local variable.
RawObject obj = objectToRender;
if (readyToRender) {
// We're ready to render, so just render using our existing VBOs and IBO.
myShader.render(mvpMatrix, indexCount, ibo, positionsVbo, colorsVbo);
} else if (obj != null) {
// The object is ready, but we haven't consumed it yet. We need to create the VBOs and IBO
// to render the object.
indexCount = obj.indexCount;
ibo = MyGLUtils.createIbo(obj.indices);
positionsVbo = MyGLUtils.createVbo(obj.positions);
colorsVbo = MyGLUtils.createVbo(obj.colors);
// Now we're ready to render the object.
readyToRender = true;
Log.d(TAG, "VBOs/IBO created. Now ready to render object.");
}
}
示例8: drawFrame
import android.opengl.Matrix; //導入方法依賴的package包/類
public void drawFrame(SurfaceTexture st) {
checkGlError("onDrawFrame start");
st.getTransformMatrix(mSTMatrix);
GLES20.glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glUseProgram(mProgram);
checkGlError("glUseProgram");
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTextureID);
mTriangleVertices.position(TRIANGLE_VERTICES_DATA_POS_OFFSET);
GLES20.glVertexAttribPointer(maPositionHandle, 3, GLES20.GL_FLOAT, false,
TRIANGLE_VERTICES_DATA_STRIDE_BYTES, mTriangleVertices);
checkGlError("glVertexAttribPointer maPosition");
GLES20.glEnableVertexAttribArray(maPositionHandle);
checkGlError("glEnableVertexAttribArray maPositionHandle");
mTriangleVertices.position(TRIANGLE_VERTICES_DATA_UV_OFFSET);
GLES20.glVertexAttribPointer(maTextureHandle, 2, GLES20.GL_FLOAT, false,
TRIANGLE_VERTICES_DATA_STRIDE_BYTES, mTriangleVertices);
checkGlError("glVertexAttribPointer maTextureHandle");
GLES20.glEnableVertexAttribArray(maTextureHandle);
checkGlError("glEnableVertexAttribArray maTextureHandle");
Matrix.setIdentityM(mMVPMatrix, 0);
GLES20.glUniformMatrix4fv(muMVPMatrixHandle, 1, false, mMVPMatrix, 0);
GLES20.glUniformMatrix4fv(muSTMatrixHandle, 1, false, mSTMatrix, 0);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
checkGlError("glDrawArrays");
if (mFingerDown) {
float[] scratch = new float[16];
// Set the camera position (View matrix)
Matrix.setLookAtM(mViewMatrix, 0, 0, 0, -3, 0f, 0f, 0f, 0f, 1.0f, 0.0f);
mViewMatrix[12] = (float) (mTouchX * 2.0f / mWidth - 1.0);
mViewMatrix[13] = (float) (mTouchY * -2.0f / mHeight + 1.0);
// Calculate the projection and view transformation
Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mViewMatrix, 0);
// Create a rotation for the triangle
// Use the following code to generate constant rotation.
// Leave this code out when using TouchEvents.
long time = SystemClock.uptimeMillis() % 4000L;
float mAngle = 0.090f * ((int) time);
Matrix.setRotateM(mRotationMatrix, 0, mAngle, 0, 0, 1.0f);
// Combine the rotation matrix with the projection and camera view
// Note that the mMVPMatrix factor *must be first* in order
// for the matrix multiplication product to be correct.
Matrix.multiplyMM(scratch, 0, mMVPMatrix, 0, mRotationMatrix, 0);
// Draw triangle
mTriangle.draw(scratch);
}
GLES20.glFinish();
}
示例9: setInitStack
import android.opengl.Matrix; //導入方法依賴的package包/類
public static void setInitStack(){
currMatrix = new float[16];
Matrix.setRotateM(currMatrix , 0 , 0 ,1 ,0 ,0);
}
示例10: rotate
import android.opengl.Matrix; //導入方法依賴的package包/類
public void rotate(float[] matrix, float degree) {
Matrix.setRotateM(mTemp, 0, degree, 0, 0, 1);
RendererCommon.adjustOrigin(mTemp);
Matrix.multiplyMM(mTemp, 16, mTemp, 0, matrix, 0);
System.arraycopy(mTemp, 16, matrix, 0, 16);
}
示例11: glRotatef
import android.opengl.Matrix; //導入方法依賴的package包/類
public void glRotatef(float angle, float x, float y, float z) {
Matrix.setRotateM(mTemp, 0, angle, x, y, z);
System.arraycopy(mMatrix, mTop, mTemp, MATRIX_SIZE, MATRIX_SIZE);
Matrix.multiplyMM(mMatrix, mTop, mTemp, MATRIX_SIZE, mTemp, 0);
}