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


Java Matrix类代码示例

本文整理汇总了Java中android.opengl.Matrix的典型用法代码示例。如果您正苦于以下问题:Java Matrix类的具体用法?Java Matrix怎么用?Java Matrix使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Matrix类属于android.opengl包,在下文中一共展示了Matrix类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onDrawFrame

import android.opengl.Matrix; //导入依赖的package包/类
@Override
public void onDrawFrame(GL10 unused) {
    angle = ((float) SystemClock.elapsedRealtime() - startTime) * 0.02f;
    GLES20.glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);

    if (scene != null) {
        Matrix.setLookAtM(mViewMatrix, 0,
                0, 0, -4,
                0f, 0f, 0f,
                0f, 1.0f, 0.0f);

        Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mViewMatrix, 0);
        Matrix.rotateM(mMVPMatrix, 0, angle, 0.8f, 2.f, 1.f);

        GLES20.glUseProgram(shaderProgram);

        int mMVPMatrixHandle = GLES20.glGetUniformLocation(shaderProgram, "uMVPMatrix");
        GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);

        scene.render(shaderProgram, "vPosition", "aColor");
    }
}
 
开发者ID:PacktPublishing,项目名称:Building-Android-UIs-with-Custom-Views,代码行数:24,代码来源:GLDrawer.java

示例2: gluLookAt

import android.opengl.Matrix; //导入依赖的package包/类
public static void gluLookAt(float[] m,
                             float eyeX,float eyeY,float eyeZ,
                             float focusX,float focusY,float focusZ,
                             float upX,float upY,float upZ) {
    float[] lookAtM=new float[16];
    float[] resultM=new float[16];
    Matrix.setLookAtM(lookAtM,0,
            eyeX,eyeY,eyeZ,focusX,focusY,focusZ,upX,upY,upZ);
    Matrix.multiplyMM(resultM,0,m,0,lookAtM,0);
    System.arraycopy(resultM,0,m,0,16);
}
 
开发者ID:jphacks,项目名称:TK_1701,代码行数:12,代码来源:GLES.java

示例3: initViewMatrix

import android.opengl.Matrix; //导入依赖的package包/类
private void initViewMatrix() {
    // Position the eye in front of the origin
    final float eyeX = 0.0f;
    final float eyeY = 0.0f;
    final float eyeZ = 0f;

    // We are looking toward the distance.
    final float lookX = 0.0f;
    final float lookY = 0.0f;
    final float lookZ = -5.0f;

    // Set our up vector.
    // This is where our head would be pointing
    // were we holding the camera.
    final float upX = 0.0f;
    final float upY = 1.0f;
    final float upZ = 0.0f;

    // Set the view matrix.
    // This matrix can be said to represent the camera position,
    Matrix.setLookAtM(mViewMatrix, 0,
            eyeX, eyeY, eyeZ,
            lookX, lookY, lookZ,
            upX, upY, upZ);
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:26,代码来源:Cube.java

示例4: drawLight

import android.opengl.Matrix; //导入依赖的package包/类
/**
 * Draws a point representing the position of the light.
 */
private void drawLight()
{
	final int pointMVPMatrixHandle = GLES20.glGetUniformLocation(mPointProgramHandle, "u_MVPMatrix");
       final int pointPositionHandle = GLES20.glGetAttribLocation(mPointProgramHandle, "a_Position");
       
	// Pass in the position.
	GLES20.glVertexAttrib3f(pointPositionHandle, mLightPosInModelSpace[0], mLightPosInModelSpace[1], mLightPosInModelSpace[2]);

	// Since we are not using a buffer object, disable vertex arrays for this attribute.
       GLES20.glDisableVertexAttribArray(pointPositionHandle);  
	
	// Pass in the transformation matrix.
	Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mLightModelMatrix, 0);
	Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);
	GLES20.glUniformMatrix4fv(pointMVPMatrixHandle, 1, false, mMVPMatrix, 0);
	
	// Draw the point.
	GLES20.glDrawArrays(GLES20.GL_POINTS, 0, 1);
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:23,代码来源:LessonFourRenderer.java

示例5: onSurfaceChanged

import android.opengl.Matrix; //导入依赖的package包/类
@Override
public void onSurfaceChanged(GL10 glUnused, int width, int height) {
    // Set the OpenGL viewport to the same size as the surface.
    GLES20.glViewport(0, 0, width, height);

    // Create a new perspective projection matrix. The height will stay the same
    // while the width will vary as per aspect ratio.
    final float ratio = (float) width / height;
    final float left = -ratio;
    final float right = ratio;
    final float bottom = -1.0f;
    final float top = 1.0f;
    final float near = 1.0f;
    final float far = 10.0f;

    Matrix.frustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far);
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:18,代码来源:LessonOneRenderer.java

示例6: _drawBox

import android.opengl.Matrix; //导入依赖的package包/类
private void _drawBox(float x, float y, float sx, float sy, float r, float g, float b, float a, int tex){
    // scale and translate
  	float[] m = new float[16];
  	Matrix.setIdentityM(m, 0);
  	Matrix.scaleM(m, 0, 2.0f*sx, 2.0f*sy, 1.0f);
  	m[3] += (1.0-2.0*x);
  	m[7] += (1.0/_ratio-2.0*y);
  	//Log.v(TAG,"RATIO IS "+_ratio);
  	float[] m2 = new float[16];      	
  	Matrix.multiplyMM(m2, 0, m, 0, mMVPMatrix, 0);
  	if (tex == -1)
  		mSquare.draw(m2, r, g, b, a);
  	else
  		mSquareTex.draw(m2,r,g,b,a,tex);
    checkGlError("draw");
}
 
开发者ID:efroemling,项目名称:bombsquad-remote-android,代码行数:17,代码来源:GLRenderer.java

示例7: draw

import android.opengl.Matrix; //导入依赖的package包/类
public final void draw(final int tex_id, final float[] tex_matrix, final float[] mvp_matrix) {
		synchronized (mSync) {
			if (mRequestRelease) return;
			mTexId = tex_id;
			if ((tex_matrix != null) && (tex_matrix.length >= 16)) {
				System.arraycopy(tex_matrix, 0, mMatrix, 0, 16);
			} else {
				Matrix.setIdentityM(mMatrix, 0);
			}
			if ((mvp_matrix != null) && (mvp_matrix.length >= 16)) {
				System.arraycopy(mvp_matrix, 0, mMatrix, 16, 16);
			} else {
				Matrix.setIdentityM(mMatrix, 16);
			}
			mRequestDraw++;
			mSync.notifyAll();
/*			try {
				mSync.wait();
			} catch (final InterruptedException e) {
			} */
		}
	}
 
开发者ID:FacePlusPlus,项目名称:MegviiFacepp-Android-SDK,代码行数:23,代码来源:RenderHandler.java

示例8: drawLight

import android.opengl.Matrix; //导入依赖的package包/类
/**
 * Draws a point representing the position of the light.
 */
private void drawLight()
{
	final int pointMVPMatrixHandle = GLES20.glGetUniformLocation(mPointProgramHandle, "u_MVPMatrix");
       final int pointPositionHandle = GLES20.glGetAttribLocation(mPointProgramHandle, "a_Position");

	// Pass in the position.
	GLES20.glVertexAttrib3f(pointPositionHandle, mLightPosInModelSpace[0], mLightPosInModelSpace[1], mLightPosInModelSpace[2]);

	// Since we are not using a buffer object, disable vertex arrays for this attribute.
       GLES20.glDisableVertexAttribArray(pointPositionHandle);

	// Pass in the transformation matrix.
	Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mLightModelMatrix, 0);
	Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);
	GLES20.glUniformMatrix4fv(pointMVPMatrixHandle, 1, false, mMVPMatrix, 0);

	// Draw the point.
	GLES20.glDrawArrays(GLES20.GL_POINTS, 0, 1);
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:23,代码来源:LessonTwoRenderer.java

示例9: recomputeMatrix

import android.opengl.Matrix; //导入依赖的package包/类
/**
 * Re-computes mModelViewMatrix, based on the current values for rotation, scale, and
 * translation.
 */
private void recomputeMatrix() {
    float[] modelView = mModelViewMatrix;

    Matrix.setIdentityM(modelView, 0);
    Matrix.translateM(modelView, 0, mPosX, mPosY, 0.0f);
    if (mAngle != 0.0f) {
        Matrix.rotateM(modelView, 0, mAngle, 0.0f, 0.0f, 1.0f);
    }
    Matrix.scaleM(modelView, 0, mScaleX, mScaleY, 1.0f);
    mMatrixReady = true;
}
 
开发者ID:AndyZhu1991,项目名称:grafika,代码行数:16,代码来源:Sprite2d.java

示例10: testGetTranslationMatrix

import android.opengl.Matrix; //导入依赖的package包/类
@Test
public void testGetTranslationMatrix() throws Exception {
    Bitmap3DString o = new Bitmap3DString(font, string);
    o.setPositionX(2.0f);

    PowerMockito.doAnswer(new Answer<Object>() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            float[] matrix = (float[])invocation.getArguments()[0];

            for(int counter = 0; counter < matrix.length; counter++) {
                matrix[counter] = 2.0f;
            }
            return null;
        }
    }).when(Matrix.class, "translateM", o.translationMatrix, 0, o.getPositionX(), o.getPositionY(), o.getPositionZ());

    float[] expected = { 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f, 2.0f };
    assertArrayEquals(expected, o.getTranslationMatrix(), 0);
}
 
开发者ID:snada,项目名称:BitmapFontLoader,代码行数:21,代码来源:Bitmap3DStringTest.java

示例11: drawLight

import android.opengl.Matrix; //导入依赖的package包/类
/**
 * Draws a point representing the position of the light.
 */
private void drawLight() {
    final int pointMVPMatrixHandle = GLES20.glGetUniformLocation(mPointProgramHandle, "u_MVPMatrix");
    final int pointPositionHandle = GLES20.glGetAttribLocation(mPointProgramHandle, "a_Position");

    // Pass in the position.
    GLES20.glVertexAttrib3f(pointPositionHandle, mLightPosInModelSpace[0], mLightPosInModelSpace[1], mLightPosInModelSpace[2]);

    // Since we are not using a buffer object, disable vertex arrays for this attribute.
    GLES20.glDisableVertexAttribArray(pointPositionHandle);

    // Pass in the transformation matrix.
    Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mLightModelMatrix, 0);
    Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);
    GLES20.glUniformMatrix4fv(pointMVPMatrixHandle, 1, false, mMVPMatrix, 0);

    // Draw the point.
    GLES20.glDrawArrays(GLES20.GL_POINTS, 0, 1);
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:22,代码来源:Cube.java

示例12: onSurfaceChanged

import android.opengl.Matrix; //导入依赖的package包/类
@Override
public void onSurfaceChanged(GL10 glUnused, int width, int height) {
	// Set the OpenGL viewport to the same size as the surface.
	GLES20.glViewport(0, 0, width, height);

	// Create a new perspective projection matrix. The height will stay the
	// same while the width will vary as per aspect ratio.
	final float ratio = (float) width / height;
	final float left = -ratio;
	final float right = ratio;
	final float bottom = -1.0f;
	final float top = 1.0f;
	final float near = 1.0f;
	final float far = 1000.0f;

	Matrix.frustumM(projectionMatrix, 0, left, right, bottom, top, near, far);
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:18,代码来源:LessonEightRenderer.java

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

示例14: onSurfaceChanged

import android.opengl.Matrix; //导入依赖的package包/类
@Override
public void onSurfaceChanged(GL10 glUnused, int width, int height) {
	// Set the OpenGL viewport to the same size as the surface.
	GLES20.glViewport(0, 0, width, height);

	// Create a new perspective projection matrix. The height will stay the
	// same
	// while the width will vary as per aspect ratio.
	final float ratio = (float) width / height;
	final float left = -ratio;
	final float right = ratio;
	final float bottom = -1.0f;
	final float top = 1.0f;
	final float near = 1.0f;
	final float far = 10.0f;
	
	Matrix.frustumM(mProjectionMatrix, 0, left, right, bottom, top, near, far);
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:19,代码来源:GLLayer.java

示例15: drawLight

import android.opengl.Matrix; //导入依赖的package包/类
/**
 * Draws a point representing the position of the light.
 */
private void drawLight()
{
	final int pointMVPMatrixHandle = GLES20.glGetUniformLocation(mPointProgramHandle, "u_MVPMatrix");
       final int pointPositionHandle = GLES20.glGetAttribLocation(mPointProgramHandle, "a_Position");
       
	// Pass in the position.
	GLES20.glVertexAttrib3f(pointPositionHandle, mLightPosInModelSpace[0], mLightPosInModelSpace[1], mLightPosInModelSpace[2]);

	// Since we are not using a buffer object, disable vertex arrays for this attribute.
       GLES20.glDisableVertexAttribArray(pointPositionHandle);  
	
	// Pass in the transformation matrix.
	Matrix.multiplyMM(mMVPMatrix, 0, mViewMatrix, 0, mLightModelMatrix, 0);
	Matrix.multiplyMM(mTemporaryMatrix, 0, mProjectionMatrix, 0, mMVPMatrix, 0);
	System.arraycopy(mTemporaryMatrix, 0, mMVPMatrix, 0, 16);
	GLES20.glUniformMatrix4fv(pointMVPMatrixHandle, 1, false, mMVPMatrix, 0);
	
	// Draw the point.
	GLES20.glDrawArrays(GLES20.GL_POINTS, 0, 1);
}
 
开发者ID:biezhihua,项目名称:Android_OpenGL_Demo,代码行数:24,代码来源:LessonSixRenderer.java


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