【发布时间】:2016-04-05 00:46:44
【问题描述】:
我正在使用 Oculus rift SDK 创建一个 360° 图像播放器。 场景由一个立方体组成,摄像机位于立方体的中心,可以围绕偏航、俯仰和滚动进行旋转。
我使用 openGL 绘制了对象,并考虑了每个立方体面的 2D 纹理以创建 360° 效果。 我想找到原始纹理中某个瞬间实际显示在 Oculus 视口上的部分。
到目前为止,我的方法是尝试使用欧拉角找到视口的某个重要点(即中心点和角)的近似像素位置,以便识别原始纹理中的某些区域。
考虑到使用欧拉角的所有问题,这似乎不是最聪明的方法。
有没有更好的方法来完成它?
编辑
我做了一个可以在渲染循环中运行的小例子:
//Keep the Orientation from Oculus (Point 1)
OVR::Matrix4f rotation = Matrix4f(hmdState.HeadPose.ThePose);
//Find the vector respect to a certain point in the viewport, in this case the center (Point 2)
FovPort fov_viewport = FovPort::CreateFromRadians(hmdDesc.CameraFrustumHFovInRadians, hmdDesc.CameraFrustumVFovInRadians);
Vector2f temp2f = fov_viewport.TanAngleToRendertargetNDC(Vector2f(0.0,0.0));// this values are the tangent in the center
Vector3f vector_view = Vector3f(temp2f.x, temp2f.y, -1.0);// just add the third component , where is oriented
vector_view.Normalize();
//Apply the rotation (Point 3)
Vector3f final_vect = rotation.Transform(vector_view);//seems the right operation.
//An example to check if we are looking at the front face (Partial point 4)
if (abs(final_vect.z) > abs(final_vect.x) && abs(final_vect.z) > abs(final_vect.y) && final_vect.z <0){
system("pause");
}
- 是否应该考虑整个视口,还是应该为每只眼睛考虑?
- 如何指示视口相对于中心的不同点?我不太明白哪些值应该是 TanAngleToRendertargetNDC() 的输入。
【问题讨论】: