本文整理匯總了Java中android.opengl.Matrix.setIdentityM方法的典型用法代碼示例。如果您正苦於以下問題:Java Matrix.setIdentityM方法的具體用法?Java Matrix.setIdentityM怎麽用?Java Matrix.setIdentityM使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.opengl.Matrix
的用法示例。
在下文中一共展示了Matrix.setIdentityM方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onSurfaceCreated
import android.opengl.Matrix; //導入方法依賴的package包/類
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
Log.d(TAG, "onSurfaceCreated");
final CameraView cameraView = mCameraViewRef.get();
if (cameraView != null) {
cameraView.mGLSurfaceFilter = new GLSurfaceFilter();
Matrix.setIdentityM(mMvpMatrix, 0);
mTextureId = cameraView.mGLSurfaceFilter.createTexture();
cameraView.mSurfaceTexture = new SurfaceTexture(mTextureId);
cameraView.mSurfaceTexture.setOnFrameAvailableListener(cameraView);
if (cameraView.mCameraSurfaceListener != null) {
cameraView.mCameraSurfaceListener.onCameraSurfaceCreate(cameraView.mSurfaceTexture);
}
}
}
示例2: getLayoutMatrix
import android.opengl.Matrix; //導入方法依賴的package包/類
/**
* Returns layout transformation matrix that applies an optional mirror effect and compensates
* for video vs display aspect ratio.
*/
public static void getLayoutMatrix(
final float matrix[], boolean mirror, float videoAspectRatio, float displayAspectRatio) {
float scaleX = 1;
float scaleY = 1;
// Scale X or Y dimension so that video and display size have same aspect ratio.
if (displayAspectRatio > videoAspectRatio) {
scaleY = videoAspectRatio / displayAspectRatio;
} else {
scaleX = displayAspectRatio / videoAspectRatio;
}
// Apply optional horizontal flip.
if (mirror) {
scaleX *= -1;
}
Matrix.setIdentityM(matrix, 0);
Matrix.scaleM(matrix, 0, scaleX, scaleY, 1);
adjustOrigin(matrix);
}
示例3: StereoDiveEffect
import android.opengl.Matrix; //導入方法依賴的package包/類
public StereoDiveEffect(Context context) {
mDpm = new DisplayMetrics();
mActivity = context;
getWindowManager(context).getDefaultDisplay().getMetrics(mDpm);
generateVideoVertices();
generateVideoTextures();
generateUITextures();
mCamera = new float[16];
mPersp = new float[16];
mMVP = new float[16];
mHeadTransform = new float[16];
mAngleOrigin = new float[3];
Matrix.setIdentityM(mHeadTransform, 0);
Matrix.perspectiveM(mPersp, 0, EYE_FOV, 1.0f, 0.0f, -(1.5f*SCREEN_FAR));
mRightEyePos = new float[] { 0.0f, -IPD/2.0f, 0.0f };
mLeftEyePos = new float[] { 0.0f, IPD/2.0f, 0.0f };
}
示例4: onDrawFrame
import android.opengl.Matrix; //導入方法依賴的package包/類
@Override
public void onDrawFrame(GL10 glUnused) {
GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
// Do a complete rotation every 10 seconds.
long time = SystemClock.uptimeMillis() % 10000L;
float angleInDegrees = (360.0f / 10000.0f) * ((int) time);
// Draw the triangle facing straight on.
Matrix.setIdentityM(mModelMatrix, 0);
Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 0.0f, 0.0f, 1.0f);
drawTriangle(mTriangle1Vertices);
// Draw one translated a bit down and rotated to be flat on the ground.
Matrix.setIdentityM(mModelMatrix, 0);
Matrix.translateM(mModelMatrix, 0, 0.0f, -1.0f, 0.0f);
Matrix.rotateM(mModelMatrix, 0, 90.0f, 1.0f, 0.0f, 0.0f);
Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 0.0f, 0.0f, 1.0f);
drawTriangle(mTriangle2Vertices);
// Draw one translated a bit to the right and rotated to be facing to the left.
Matrix.setIdentityM(mModelMatrix, 0);
Matrix.translateM(mModelMatrix, 0, 1.0f, 0.0f, 0.0f);
Matrix.rotateM(mModelMatrix, 0, 90.0f, 0.0f, 1.0f, 0.0f);
Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 0.0f, 0.0f, 1.0f);
drawTriangle(mTriangle3Vertices);
}
示例5: getLayoutMatrix
import android.opengl.Matrix; //導入方法依賴的package包/類
/**
* Returns layout transformation matrix that applies an optional mirror effect and compensates
* for video vs display aspect ratio.
*/
public static float[] getLayoutMatrix(
boolean mirror, float videoAspectRatio, float displayAspectRatio) {
float scaleX = 1;
float scaleY = 1;
// Scale X or Y dimension so that video and display size have same aspect ratio.
if (displayAspectRatio > videoAspectRatio) {
scaleY = videoAspectRatio / displayAspectRatio;
} else {
scaleX = displayAspectRatio / videoAspectRatio;
}
// Apply optional horizontal flip.
if (mirror) {
scaleX *= -1;
}
final float matrix[] = new float[16];
Matrix.setIdentityM(matrix, 0);
Matrix.scaleM(matrix, 0, scaleX, scaleY, 1);
adjustOrigin(matrix);
return matrix;
}
示例6: Bitmap3DObject
import android.opengl.Matrix; //導入方法依賴的package包/類
/**
* Returns a new 3D object with custom position, rotation and scale
* @param xPosition X position in space
* @param yPosition Y position in space
* @param zPosition Z position in space
* @param xRotation Rotation on X axis
* @param yRotation Rotation on Y axis
* @param zRotation Rotation on Z axis
* @param xScale X axis scale
* @param yScale Y axis scale
* @param zScale Z axis scale
*/
public Bitmap3DObject(float xPosition, float yPosition, float zPosition, float xRotation, float yRotation, float zRotation, float xScale, float yScale, float zScale) {
this.position = new float[3];
this.position[0] = xPosition;
this.position[1] = yPosition;
this.position[2] = zPosition;
this.rotation = new float[3];
this.rotation[0] = xRotation;
this.rotation[1] = yRotation;
this.rotation[2] = zRotation;
this.scale = new float[3];
this.scale[0] = xScale;
this.scale[1] = yScale;
this.scale[2] = zScale;
this.translationMatrix = new float[16];
this.rotationMatrix = new float[16];
this.scaleMatrix = new float[16];
Matrix.setIdentityM(translationMatrix, 0);
Matrix.setIdentityM(rotationMatrix, 0);
Matrix.setIdentityM(scaleMatrix, 0);
}
示例7: onSurfaceCreated
import android.opengl.Matrix; //導入方法依賴的package包/類
@Override public void onSurfaceCreated(GL10 gl, EGLConfig config) {
Matrix.setIdentityM(mSTMatrix, 0);
mRecordingEnabled = mVideoEncoder.isRecording();
if (mRecordingEnabled) {
mRecordingStatus = RECORDING_RESUMED;
} else {
mRecordingStatus = RECORDING_OFF;
mVideoEncoder.initFilter(mCurrentFilterType);
}
mFullScreen = new FullFrameRect(
FilterManager.getCameraFilter(mCurrentFilterType, mApplicationContext));
mTextureId = mFullScreen.createTexture();
mSurfaceTexture = new SurfaceTexture(mTextureId);
}
示例8: MediaHelper
import android.opengl.Matrix; //導入方法依賴的package包/類
/**
*
* @param cameraWidth
* @param cameraHeight
* @param isLand 橫屏
*/
public MediaHelper(int cameraWidth, int cameraHeight, boolean isLand, GLSurfaceView surfaceView){
if (!isLand) {
mCameraWidth = cameraWidth;
mCameraHeight = cameraHeight;
} else {
mCameraWidth = cameraHeight;
mCameraHeight = cameraWidth;
}
mSurfaceView=surfaceView;
Matrix.setIdentityM(mMvpMatrix,0);
Matrix.rotateM(mMvpMatrix,0,270,0,0,1);
// TODO: 2017/10/27
}
示例9: GLOESImageView
import android.opengl.Matrix; //導入方法依賴的package包/類
public GLOESImageView() {
mCubeBuffer = ByteBuffer.allocateDirect(CUBE.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
// mCubeBuffer.put(CUBE);
mTextureBuffer = ByteBuffer.allocateDirect(TEXTURE.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
mTextureBuffer.put(TEXTURE);
float[] mvp = new float[16];
Matrix.setIdentityM(mvp, 0);
mMVPBuffer = ByteBuffer.allocateDirect(mvp.length * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
mMVPBuffer.put(mvp);
}
示例10: TextureRender
import android.opengl.Matrix; //導入方法依賴的package包/類
public TextureRender() {
mTriangleVertices = ByteBuffer.allocateDirect(
mTriangleVerticesData.length * FLOAT_SIZE_BYTES)
.order(ByteOrder.nativeOrder()).asFloatBuffer();
mTriangleVertices.put(mTriangleVerticesData).position(0);
Matrix.setIdentityM(mSTMatrix, 0);
}
示例11: OESFilter
import android.opengl.Matrix; //導入方法依賴的package包/類
public OESFilter(Context context) {
super();
plane.setVerticesBuffer(BufferUtils.getFloatBuffer(TRIANGLES_DATA_CAMERA,0));
glOESProgram=new GLOESProgram(context);
glOESTexture=new GLOESTexture();
Matrix.setIdentityM(mSTMatrix, 0);
}
示例12: initMatrix
import android.opengl.Matrix; //導入方法依賴的package包/類
private void initMatrix() {
Matrix.setIdentityM(modelMatrix,0);
Matrix.rotateM(modelMatrix,0,90.0f,0f,1f,0f);
Matrix.setIdentityM(projectionMatrix,0);
Matrix.setIdentityM(viewMatrix, 0);
Matrix.setLookAtM(viewMatrix, 0,
0f,10f,10f,
0.0f, 0.0f,-1.0f,
0.0f, 1.0f, 0.0f);
}
示例13: onDrawFrame
import android.opengl.Matrix; //導入方法依賴的package包/類
@Override
public void onDrawFrame(GL10 glUnused)
{
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
// Do a complete rotation every 10 seconds.
long time = SystemClock.uptimeMillis() % 10000L;
float angleInDegrees = (360.0f / 10000.0f) * ((int) time);
// Set our per-vertex lighting program.
GLES20.glUseProgram(mPerVertexProgramHandle);
// Set program handles for cube drawing.
mMVPMatrixHandle = GLES20.glGetUniformLocation(mPerVertexProgramHandle, "u_MVPMatrix");
mMVMatrixHandle = GLES20.glGetUniformLocation(mPerVertexProgramHandle, "u_MVMatrix");
mLightPosHandle = GLES20.glGetUniformLocation(mPerVertexProgramHandle, "u_LightPos");
mPositionHandle = GLES20.glGetAttribLocation(mPerVertexProgramHandle, "a_Position");
mColorHandle = GLES20.glGetAttribLocation(mPerVertexProgramHandle, "a_Color");
mNormalHandle = GLES20.glGetAttribLocation(mPerVertexProgramHandle, "a_Normal");
// Calculate position of the light. Rotate and then push into the distance.
Matrix.setIdentityM(mLightModelMatrix, 0);
Matrix.translateM(mLightModelMatrix, 0, 0.0f, 0.0f, -5.0f);
Matrix.rotateM(mLightModelMatrix, 0, angleInDegrees, 0.0f, 1.0f, 0.0f);
Matrix.translateM(mLightModelMatrix, 0, 0.0f, 0.0f, 2.0f);
Matrix.multiplyMV(mLightPosInWorldSpace, 0, mLightModelMatrix, 0, mLightPosInModelSpace, 0);
Matrix.multiplyMV(mLightPosInEyeSpace, 0, mViewMatrix, 0, mLightPosInWorldSpace, 0);
// Draw some cubes.
Matrix.setIdentityM(mModelMatrix, 0);
Matrix.translateM(mModelMatrix, 0, 4.0f, 0.0f, -7.0f);
Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 1.0f, 0.0f, 0.0f);
drawCube();
Matrix.setIdentityM(mModelMatrix, 0);
Matrix.translateM(mModelMatrix, 0, -4.0f, 0.0f, -7.0f);
Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 0.0f, 1.0f, 0.0f);
drawCube();
Matrix.setIdentityM(mModelMatrix, 0);
Matrix.translateM(mModelMatrix, 0, 0.0f, 4.0f, -7.0f);
Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 0.0f, 0.0f, 1.0f);
drawCube();
Matrix.setIdentityM(mModelMatrix, 0);
Matrix.translateM(mModelMatrix, 0, 0.0f, -4.0f, -7.0f);
drawCube();
Matrix.setIdentityM(mModelMatrix, 0);
Matrix.translateM(mModelMatrix, 0, 0.0f, 0.0f, -5.0f);
Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 1.0f, 1.0f, 0.0f);
drawCube();
// Draw a point to indicate the light.
GLES20.glUseProgram(mPointProgramHandle);
drawLight();
}
示例14: onDrawFrame
import android.opengl.Matrix; //導入方法依賴的package包/類
@Override
public void onDrawFrame(GL10 glUnused) {
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
// Set our per-vertex lighting program.
GLES20.glUseProgram(mProgramHandle);
// Set program handles for cube drawing.
mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_MVPMatrix");
mMVMatrixHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_MVMatrix");
mLightPosHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_LightPos");
mTextureUniformHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_Texture");
mPositionHandle = GLES20.glGetAttribLocation(mProgramHandle, "a_Position");
mNormalHandle = GLES20.glGetAttribLocation(mProgramHandle, "a_Normal");
mTextureCoordinateHandle = GLES20.glGetAttribLocation(mProgramHandle, "a_TexCoordinate");
// Calculate position of the light. Push into the distance.
Matrix.setIdentityM(mLightModelMatrix, 0);
Matrix.translateM(mLightModelMatrix, 0, 0.0f, 0.0f, -1.0f);
Matrix.multiplyMV(mLightPosInWorldSpace, 0, mLightModelMatrix, 0, mLightPosInModelSpace, 0);
Matrix.multiplyMV(mLightPosInEyeSpace, 0, mViewMatrix, 0, mLightPosInWorldSpace, 0);
// Draw a cube.
// Translate the cube into the screen.
Matrix.setIdentityM(mModelMatrix, 0);
Matrix.translateM(mModelMatrix, 0, 0.0f, 0.0f, -3.5f);
// Set a matrix that contains the current rotation.
Matrix.setIdentityM(mCurrentRotation, 0);
Matrix.rotateM(mCurrentRotation, 0, mDeltaX, 0.0f, 1.0f, 0.0f);
Matrix.rotateM(mCurrentRotation, 0, mDeltaY, 1.0f, 0.0f, 0.0f);
mDeltaX = 0.0f;
mDeltaY = 0.0f;
// Multiply the current rotation by the accumulated rotation, and then set the accumulated rotation to the result.
Matrix.multiplyMM(mTemporaryMatrix, 0, mCurrentRotation, 0, mAccumulatedRotation, 0);
System.arraycopy(mTemporaryMatrix, 0, mAccumulatedRotation, 0, 16);
// Rotate the cube taking the overall rotation into account.
Matrix.multiplyMM(mTemporaryMatrix, 0, mModelMatrix, 0, mAccumulatedRotation, 0);
System.arraycopy(mTemporaryMatrix, 0, mModelMatrix, 0, 16);
// This multiplies the view matrix by the model matrix, and stores
// the result in the MVP matrix
// (which currently contains model * view).
Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mModelMatrix, 0);
// Pass in the modelview matrix.
GLES20.glUniformMatrix4fv(mMVMatrixHandle, 1, false, mMVPMatrix, 0);
// This multiplies the modelview matrix by the projection matrix,
// and stores the result in the MVP matrix
// (which now contains model * view * projection).
Matrix.multiplyMM(mTemporaryMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);
System.arraycopy(mTemporaryMatrix, 0, mMVPMatrix, 0, 16);
// Pass in the combined matrix.
GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);
// Pass in the light position in eye space.
GLES20.glUniform3f(mLightPosHandle, mLightPosInEyeSpace[0], mLightPosInEyeSpace[1], mLightPosInEyeSpace[2]);
// Pass in the texture information
// Set the active texture unit to texture unit 0.
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
// Bind the texture to this unit.
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mAndroidDataHandle);
// Tell the texture uniform sampler to use this texture in the
// shader by binding to texture unit 0.
GLES20.glUniform1i(mTextureUniformHandle, 0);
if (mCubes != null) {
mCubes.render();
}
}
示例15: onDrawFrame
import android.opengl.Matrix; //導入方法依賴的package包/類
@Override
public void onDrawFrame(GL10 glUnused)
{
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
// Do a complete rotation every 10 seconds.
long time = SystemClock.uptimeMillis() % 10000L;
float angleInDegrees = (360.0f / 10000.0f) * ((int) time);
// Set our per-vertex lighting program.
GLES20.glUseProgram(mProgramHandle);
// Set program handles for cube drawing.
mMVPMatrixHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_MVPMatrix");
mMVMatrixHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_MVMatrix");
mLightPosHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_LightPos");
mTextureUniformHandle = GLES20.glGetUniformLocation(mProgramHandle, "u_Texture");
mPositionHandle = GLES20.glGetAttribLocation(mProgramHandle, "a_Position");
mColorHandle = GLES20.glGetAttribLocation(mProgramHandle, "a_Color");
mNormalHandle = GLES20.glGetAttribLocation(mProgramHandle, "a_Normal");
mTextureCoordinateHandle = GLES20.glGetAttribLocation(mProgramHandle, "a_TexCoordinate");
// Set the active texture unit to texture unit 0.
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
// Bind the texture to this unit.
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataHandle);
// Tell the texture uniform sampler to use this texture in the shader by binding to texture unit 0.
GLES20.glUniform1i(mTextureUniformHandle, 0);
// Calculate position of the light. Rotate and then push into the distance.
Matrix.setIdentityM(mLightModelMatrix, 0);
Matrix.translateM(mLightModelMatrix, 0, 0.0f, 0.0f, -5.0f);
Matrix.rotateM(mLightModelMatrix, 0, angleInDegrees, 0.0f, 1.0f, 0.0f);
Matrix.translateM(mLightModelMatrix, 0, 0.0f, 0.0f, 2.0f);
Matrix.multiplyMV(mLightPosInWorldSpace, 0, mLightModelMatrix, 0, mLightPosInModelSpace, 0);
Matrix.multiplyMV(mLightPosInEyeSpace, 0, mViewMatrix, 0, mLightPosInWorldSpace, 0);
// Draw some cubes.
Matrix.setIdentityM(mModelMatrix, 0);
Matrix.translateM(mModelMatrix, 0, 4.0f, 0.0f, -7.0f);
Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 1.0f, 0.0f, 0.0f);
drawCube();
Matrix.setIdentityM(mModelMatrix, 0);
Matrix.translateM(mModelMatrix, 0, -4.0f, 0.0f, -7.0f);
Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 0.0f, 1.0f, 0.0f);
drawCube();
Matrix.setIdentityM(mModelMatrix, 0);
Matrix.translateM(mModelMatrix, 0, 0.0f, 4.0f, -7.0f);
Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 0.0f, 0.0f, 1.0f);
drawCube();
Matrix.setIdentityM(mModelMatrix, 0);
Matrix.translateM(mModelMatrix, 0, 0.0f, -4.0f, -7.0f);
drawCube();
Matrix.setIdentityM(mModelMatrix, 0);
Matrix.translateM(mModelMatrix, 0, 0.0f, 0.0f, -5.0f);
Matrix.rotateM(mModelMatrix, 0, angleInDegrees, 1.0f, 1.0f, 0.0f);
drawCube();
// Draw a point to indicate the light.
GLES20.glUseProgram(mPointProgramHandle);
drawLight();
}