当前位置: 首页>>代码示例>>Java>>正文


Java Matrix.setRotateM方法代码示例

本文整理汇总了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");
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:35,代码来源:GLES20TriangleRenderer.java

示例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);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:34,代码来源:MyGLRenderer.java

示例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);
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:11,代码来源:RendererCommon.java

示例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);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:13,代码来源:GLES20Canvas.java

示例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);
}
 
开发者ID:ynztlxdeai,项目名称:GLhexagram,代码行数:30,代码来源:Hexagram.java

示例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);
    }
 
开发者ID:FreeSunny,项目名称:Amazing,代码行数:21,代码来源:MyRender.java

示例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.");
  }
}
 
开发者ID:googlevr,项目名称:poly-sample-android,代码行数:47,代码来源:MyGLRenderer.java

示例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();
}
 
开发者ID:livio,项目名称:sdl_video_streaming_android_sample,代码行数:52,代码来源:TextureRender.java

示例9: setInitStack

import android.opengl.Matrix; //导入方法依赖的package包/类
public static void setInitStack(){
    currMatrix = new float[16];
    Matrix.setRotateM(currMatrix , 0 , 0 ,1 ,0 ,0);
}
 
开发者ID:ynztlxdeai,项目名称:GLproject,代码行数:5,代码来源:MatrixState.java

示例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);
}
 
开发者ID:Piasy,项目名称:VideoCRE,代码行数:7,代码来源:MatrixHelper.java

示例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);
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:6,代码来源:MatrixStack.java


注:本文中的android.opengl.Matrix.setRotateM方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。