예제 #1
0
        private void Init(Context context)
        {
            SetEGLContextClientVersion(2);
            PreserveEGLContextOnPause = true;

            IWindowManager windowManager = (IWindowManager)context.GetSystemService(Context.WindowService).JavaCast <IWindowManager>();

            mHeadTracker = new HeadTracker(context);
            mHmd         = new HeadMountedDisplay(windowManager.DefaultDisplay);
        }
예제 #2
0
        public bool equals(Object other)
        {
            if (other == null)
            {
                return(false);
            }
            if (other == this)
            {
                return(true);
            }
            if (!(other is HeadMountedDisplay))
            {
                return(false);
            }
            HeadMountedDisplay o = (HeadMountedDisplay)other;

            return((mScreen.equals(o.mScreen)) && (mCardboard.equals(o.mCardboard)));
        }
예제 #3
0
        public void onProjectionChanged(HeadMountedDisplay hmd, EyeParams leftEye, EyeParams rightEye, float zNear, float zFar)
        {
            mHmd         = new HeadMountedDisplay(hmd);
            mLeftEyeFov  = new FieldOfView(leftEye.getFov());
            mRightEyeFov = new FieldOfView(rightEye.getFov());

            ScreenParams          screen = mHmd.getScreen();
            CardboardDeviceParams cdp    = mHmd.getCardboard();

            if (mProgramHolder == null)
            {
                mProgramHolder = createProgramHolder();
            }

            EyeViewport leftEyeViewport  = initViewportForEye(leftEye, 0.0F);
            EyeViewport rightEyeViewport = initViewportForEye(rightEye, leftEyeViewport.width);

            leftEye.getFov().toPerspectiveMatrix(zNear, zFar, leftEye.getTransform().GetPerspective(), 0);

            rightEye.getFov().toPerspectiveMatrix(zNear, zFar, rightEye.getTransform().GetPerspective(), 0);

            float textureWidthM   = leftEyeViewport.width + rightEyeViewport.width;
            float textureHeightM  = Math.Max(leftEyeViewport.height, rightEyeViewport.height);
            float xPxPerM         = screen.getWidth() / screen.getWidthMeters();
            float yPxPerM         = screen.getHeight() / screen.getHeightMeters();
            int   textureWidthPx  = Math.Round(textureWidthM * xPxPerM);
            int   textureHeightPx = Math.Round(textureHeightM * yPxPerM);

            float xEyeOffsetMScreen = screen.getWidthMeters() / 2.0F - cdp.getInterpupillaryDistance() / 2.0F;
            float yEyeOffsetMScreen = cdp.getVerticalDistanceToLensCenter() - screen.getBorderSizeMeters();

            mLeftEyeDistortionMesh = createDistortionMesh(leftEye, leftEyeViewport, textureWidthM, textureHeightM, xEyeOffsetMScreen, yEyeOffsetMScreen);

            xEyeOffsetMScreen       = screen.getWidthMeters() - xEyeOffsetMScreen;
            mRightEyeDistortionMesh = createDistortionMesh(rightEye, rightEyeViewport, textureWidthM, textureHeightM, xEyeOffsetMScreen, yEyeOffsetMScreen);

            setupRenderTextureAndRenderbuffer(textureWidthPx, textureHeightPx);
        }
예제 #4
0
            public RendererHelper(CardboardView view, CardboardView.Renderer renderer)
            {
                mView          = view;
                mRenderer      = renderer;
                mHmd           = new HeadMountedDisplay(mView.mHmd);
                mHeadTransform = new HeadTransform();
                mMonocular     = new EyeParams(EyeParams.Eye.MONOCULAR);
                mLeftEye       = new EyeParams(EyeParams.Eye.LEFT);
                mRightEye      = new EyeParams(EyeParams.Eye.RIGHT);
                UpdateFieldOfView(mLeftEye.getFov(), mRightEye.getFov());
                mView.mDistortionRenderer = new DistortionRenderer();

                mLeftEyeTranslate  = new float[16];
                mRightEyeTranslate = new float[16];

                mVRMode = mView.mVRMode;
                mDistortionCorrectionEnabled = mView.mDistortionCorrectionEnabled;
                mDistortionCorrectionScale   = mView.mDistortionCorrectionScale;
                mZNear = mView.mZNear;
                mZFar  = mView.mZFar;

                mProjectionChanged = true;
            }
예제 #5
0
 public HeadMountedDisplay(HeadMountedDisplay hmd)
 {
     mScreen    = new ScreenParams(hmd.mScreen);
     mCardboard = new CardboardDeviceParams(hmd.mCardboard);
 }