Пример #1
0
        public void drawCubeGL(int eye)
        {
            Matrix4 vp = new Matrix4();

            if (eye == 0)
            {
                //watch out the matrix order since we already tranpose the matraix when we create the glMatrix(column-major)
                vp = glViewMatrix * glProjectionMatrix;
            }
            else
            {
                vp = glViewMatrix_R * glProjectionMatrix_R;
            }

            marker_cube_m.draw(ref marker_cube_g, ref glModelMatrix, ref vp);
        }
Пример #2
0
        public void drawController(int eye)
        {
            //testing drawing at the controller position, mEyeProjLeft * mEyePosLeft * mScene.mHMDPose * mControllerPose;
            // find the pose of the controllers
            Matrix4 glControllerPose = new Matrix4();

            /*
             * for (uint nDevice = OpenVR.k_unTrackedDeviceIndex_Hmd + 1; nDevice < OpenVR.k_unMaxTrackedDeviceCount; ++nDevice)
             * {
             *  if (!mHMD.IsTrackedDeviceConnected(nDevice))
             *      continue;
             *
             *  if (mHMD.GetTrackedDeviceClass(nDevice) != ETrackedDeviceClass.Controller)
             *      continue;
             *
             *  if (!mScene.mTrackedDevices[nDevice].bPoseIsValid)
             *      continue;
             *
             *
             *  Matrix4 mControllerPose = mScene.mDevicePose[nDevice];
             *  Matrix4.Transpose(ref mControllerPose, out glControllerPose);
             *
             * }
             */
            Matrix4 mControllerPose = mScene.leftControllerNode.transform;

            Matrix4.Transpose(ref mControllerPose, out glControllerPose);

            Matrix4 vp = new Matrix4();

            if (eye == 0)
            {
                //it's already transposed (column-major) so the order is v * p
                //vp = glViewMatrix_L * glProjectionMatrix;
                getOVRVPMatrix(0, ref vp);
            }
            else
            {
                //it's already transposed (column-major) so the order is v * p
                vp = glViewMatrix_R * glProjectionMatrix_R;
                getOVRVPMatrix(1, ref vp);
            }

            GL.Enable(EnableCap.DepthTest);
            // glControllerPose pass as model since model matrix is identity matrix
            controller_cube_m.draw(ref controller_cube_g, ref glControllerPose, ref vp);
        }