@Override public void onDrawEye(Eye eye) { if (resetCameraFlag) { float[] invertedEye = new float[16]; Matrix.invertM(invertedEye, 0, eye.getEyeView(), 0); setUpCamera(); Matrix.multiplyMM(mCameraMatrix, 0, invertedEye, 0, mCameraMatrix, 0); resetCameraFlag = false; } GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT); if (lockCameraFlag) { mViewMatrix = mCameraMatrix.clone(); } else { Matrix.multiplyMM(mViewMatrix, 0, eye.getEyeView(), 0, mCameraMatrix, 0); } Matrix.multiplyMV(mLightPosInWorldSpace, 0, mLightModelMatrix, 0, mLightPosInModelSpace, 0); Matrix.multiplyMV(mLightPosInEyeSpace, 0, mViewMatrix, 0, mLightPosInWorldSpace, 0); mProjectionMatrix = eye.getPerspective(Z_NEAR, Z_FAR); GLES20.glUseProgram(mProgramHandle); currentContent.draw(eye); if (drawRedPoint) { drawTargetingPoint(); } Util.checkGLError("Error Draw Eye"); }
@Override public void onNewFrame(HeadTransform headTransform) { headTransform.getHeadView(mHeadViewMatrix, 0); headTransform.getForwardVector(mForwardVector, 0); currentContent.update(); Util.checkGLError("Error On New Frame"); }
@Override public void onCardboardTrigger() { if (lockCameraFlag) { lockCameraFlag = false; return; } for (View3D v : currentContent.getViews()) { v.performTriggerIfLookingAt(); } }
public void setCurrentContent(ViewContent content) { this.currentContent = content; content.onContentSelected(); }