本文整理汇总了Java中com.google.vr.sdk.base.Eye.getType方法的典型用法代码示例。如果您正苦于以下问题:Java Eye.getType方法的具体用法?Java Eye.getType怎么用?Java Eye.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.vr.sdk.base.Eye
的用法示例。
在下文中一共展示了Eye.getType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDrawEye
import com.google.vr.sdk.base.Eye; //导入方法依赖的package包/类
@Override
public void onDrawEye(Eye eye) {
GLES20.glDisable(GLES20.GL_DEPTH_TEST);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
// TODO: Do something with the head and/or eye transform (e.g. pan the photo around)
// For now, just reset the view matrix, so that the photo is in the center at all times.
Matrix.setIdentityM(view, 0);
float[] perspective = eye.getPerspective(Z_NEAR, Z_FAR);
if (eye.getType() == 1) {
Matrix.multiplyMM(modelView, 0, view, 0, rectLeftEye.getModelMatrix(), 0);
Matrix.multiplyMM(modelViewProjection, 0, perspective, 0, modelView, 0);
rectLeftEye.draw(modelViewProjection);
} else {
Matrix.multiplyMM(modelView, 0, view, 0, rectRightEye.getModelMatrix(), 0);
Matrix.multiplyMM(modelViewProjection, 0, perspective, 0, modelView, 0);
rectRightEye.draw(modelViewProjection);
}
}
示例2: render
import com.google.vr.sdk.base.Eye; //导入方法依赖的package包/类
public void render(Scene scene, Eye eye, Renderer3d renderer3d) {
// Allow concurrence separating matices
if (eye.getType() == Eye.Type.LEFT) {
MatrixUtils.copyMatrix(eye.getPerspective(scene.camera.getNear(), scene.camera.getFar()), leftProjectionMatrix);
MatrixUtils.multiply(eye.getEyeView(), scene.camera.viewMatrix, leftViewMatrix);
renderer3d.render(scene, leftProjectionMatrix, leftViewMatrix);
} else {
MatrixUtils.copyMatrix(eye.getPerspective(scene.camera.getNear(), scene.camera.getFar()), rightProjectionMatrix);
MatrixUtils.multiply(eye.getEyeView(), scene.camera.viewMatrix, rightViewMatrix);
renderer3d.render(scene, rightProjectionMatrix, rightViewMatrix);
}
}
示例3: onDrawEye
import com.google.vr.sdk.base.Eye; //导入方法依赖的package包/类
@Override
public void onDrawEye(Eye eye) {
Viewport curView = eye.getViewport();
Viewport initViewport = new Viewport();
initViewport.setViewport(curView.x, curView.y, curView.width, curView.height);
FieldOfView curFov = eye.getFov();
FieldOfView initFov = new FieldOfView(curFov.getLeft(), curFov.getRight(), curFov.getBottom(), curFov.getTop());
// Change to camera resolution for scene render
eye.getViewport().setViewport(0, 0, mPreviewSize.getWidth(), mPreviewSize.getHeight());
eye.getFov().setAngles((float)mFov.x / 2.0f, (float)mFov.x / 2.0f, (float)mFov.y / 2.0f, (float)mFov.y / 2.0f);
eye.getViewport().setGLViewport();
eye.getViewport().setGLScissor();
eye.setProjectionChanged();
// Apply the eye transformation to the camera.
float[] viewMat = new float[16];
Matrix.multiplyMM(viewMat, 0, eye.getEyeView(), 0, mCamera, 0);
// Get the perspective matrix for 3D objects rendering
// Create FOV identical to physical
float[] perspective = new float[16];
perspective = eye.getPerspective(Z_NEAR, Z_FAR);
//Matrix.perspectiveM(perspective, 0, (float)mFov.y, (float)mPreviewSize.getWidth() / (float)mPreviewSize.getHeight(), Z_NEAR, Z_FAR);
// FieldOfView physFov = new FieldOfView((float)mFov.x, (float)mFov.x, (float)mFov.y, (float)mFov.y);
// physFov.toPerspectiveMatrix(Z_NEAR, Z_FAR, perspective, 0);
// First draw object scene texture through frame buffer
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFboIdObjects);
if (eye.getType() == Eye.Type.LEFT) {
GLES20.glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
} else {
GLES20.glClearColor(0.0f, 0.0f, 1.0f, 0.0f);
}
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
GLES20.glEnable(GLES20.GL_DEPTH_TEST);
//GLES20.glViewport(0, 0, mPreviewSize.getWidth(), mPreviewSize.getHeight());
//GLES20.glViewport(0, 0, 100, 100);
drawObjects(viewMat, perspective);
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, DEFAULT_FBO_ID);
// Change back to initial res
eye.getViewport().setViewport(initViewport.x, initViewport.y, initViewport.width, initViewport.height);
eye.getFov().setAngles(initFov.getLeft(), initFov.getRight(), initFov.getBottom(), initFov.getTop());
eye.getViewport().setGLViewport();
eye.getViewport().setGLScissor();
eye.setProjectionChanged();
// Recalculate the perspective matrix for vr view
perspective = eye.getPerspective(Z_NEAR, Z_FAR);
// Matrix.perspectiveM(perspective, 0, eye.getFov().getTop(), (float)eye.getViewport().width / (float)eye.getViewport().height, Z_NEAR, Z_FAR);
// Now draw actual screen for cardboard viewer
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);
GLES20.glEnable(GLES20.GL_DEPTH_TEST);
//eye.getViewport().setGLViewport();
screenRenderer.draw(viewMat, perspective);
}