List of usage examples for android.opengl Matrix setLookAtM
public static void setLookAtM(float[] rm, int rmOffset, float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ)
From source file:Main.java
public static float[] initViewMatrix() { float[] matrix = new float[16]; Matrix.setLookAtM(matrix, 0, 0f, 0f, 200f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); return matrix; }
From source file:com.dmitrybrant.android.cardboardmpo.MainActivity.java
@Override public void onNewFrame(HeadTransform headTransform) { Matrix.setLookAtM(camera, 0, 0.0f, 0.0f, CAMERA_Z, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); headTransform.getHeadView(headView, 0); }
From source file:com.kentdisplays.synccardboarddemo.MainActivity.java
/** * Prepares OpenGL ES before we draw a frame. * @param headTransform The head transformation in the new frame. *///www . j a v a 2 s . c o m @Override public void onNewFrame(HeadTransform headTransform) { GLES20.glUseProgram(mGlProgram); GLES20.glClearColor(0f, 0f, 0f, 1.0f); // Dark background so text shows up well mModelViewProjectionParam = GLES20.glGetUniformLocation(mGlProgram, "u_MVP"); mLightPosParam = GLES20.glGetUniformLocation(mGlProgram, "u_LightPos"); mModelViewParam = GLES20.glGetUniformLocation(mGlProgram, "u_MVMatrix"); mModelParam = GLES20.glGetUniformLocation(mGlProgram, "u_Model"); mIsFloorParam = GLES20.glGetUniformLocation(mGlProgram, "u_IsFloor"); // Build the camera matrix and apply it to the ModelView. Matrix.setLookAtM(mCamera, 0, 0.0f, 0.0f, CAMERA_Z, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); headTransform.getHeadView(mHeadView, 0); checkGLError("onReadyToDraw"); }
From source file:com.google.vrtoolkit.cardboard.samples.treasurehunt.MainActivity.java
/** * Prepares OpenGL ES before we draw a frame. * * @param headTransform The head transformation in the new frame. *//*from w w w . ja va2 s . c o m*/ @Override public void onNewFrame(HeadTransform headTransform) { // Build the Model part of the ModelView matrix. //Matrix.rotateM(modelCube, 0, TIME_DELTA, 0.5f, 0.5f, 1.0f); // Build the camera matrix and apply it to the ModelView. Matrix.setLookAtM(camera, 0, 0.0f, 0.0f, CAMERA_Z, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); headTransform.getHeadView(headView, 0); // Update the 3d audio engine with the most recent head rotation. headTransform.getQuaternion(headRotation, 0); cardboardAudioEngine.setHeadRotation(headRotation[0], headRotation[1], headRotation[2], headRotation[3]); checkGLError("onReadyToDraw"); //float[] headAngles = new float[3]; //headTransform.getEulerAngles(headAngles, 0) //float[] quat = new float[4]; //headTransform.getQuaternion(quat, 0); updateMiniCubePosition(headRotation[0], headRotation[1], headRotation[2], headRotation[3]); }
From source file:com.tumblr.cardboard.Tumblr3DActivity.java
/** * Prepares OpenGL ES before we draw a frame. * * @param headTransform The head transformation in the new frame. *///from w ww . j a v a2 s . c o m @Override public void onNewFrame(HeadTransform headTransform) { GLES20.glUseProgram(mGlProgram); mModelViewProjectionParam = GLES20.glGetUniformLocation(mGlProgram, "u_MVP"); mLightPosParam = GLES20.glGetUniformLocation(mGlProgram, "u_LightPos"); mModelViewParam = GLES20.glGetUniformLocation(mGlProgram, "u_MVMatrix"); mModelParam = GLES20.glGetUniformLocation(mGlProgram, "u_Model"); mIsFloorParam = GLES20.glGetUniformLocation(mGlProgram, "u_IsFloor"); mRectTextureUniformParam = GLES20.glGetUniformLocation(mGlProgram, "u_Texture"); // load gif updates into OpenGL synchronized (mUpdatingPhotoTextures) { while (!mUpdatingPhotoTextures.isEmpty()) { PhotoTexture texture = mUpdatingPhotoTextures.remove(); updateTexture(texture.texIndex, texture.bitmap); } } // load new photos into OpenGL synchronized (mWaitingPhotoTextures) { // load downloaded photos into OpenGL while (!mWaitingPhotoTextures.isEmpty()) { PhotoTexture texture = mWaitingPhotoTextures.remove(); loadTextureInternal(texture.texIndex, texture.bitmap, texture.recycle); if (texture.texIndex >= NUM_IMAGES_STATIC) { // First image that loads shows up in the "theater!" if (mSelectedTexIndex < 0) { mSelectedTexIndex = texture.texIndex; selectPhoto(texture.texIndex - NUM_IMAGES_STATIC); } else { // Put image in the right spot unselectPhoto(texture.texIndex - NUM_IMAGES_STATIC); } } else if (texture.texIndex == STATIC_TEXTURE_ID_REFRESH) { placePhoto(mModelRect, mImageRect, texture.texIndex, 1, 180, 30, SPHERE_RADIUS / 2); } else if (texture.texIndex == STATIC_TEXTURE_ID_PLAY) { placePhoto(mModelRect, mImageRect, texture.texIndex, 1, 210, 30, SPHERE_RADIUS / 2); } else if (texture.texIndex == STATIC_TEXTURE_ID_PAUSE) { placePhoto(mModelRect, mImageRect, texture.texIndex, 1, 150, 30, SPHERE_RADIUS / 2); } } } // Build the camera matrix and apply it to the ModelView. Matrix.setLookAtM(mCamera, 0, 0.0f, 0.0f, CAMERA_Z, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); headTransform.getHeadView(mHeadView, 0); checkGLError("onReadyToDraw"); }