------------------------------------------------------------------------------
| 58 | |
| 59 | //------------------------------------------------------------------------------ |
| 60 | void vtkVRHMDCamera::GetKeyMatrices(vtkRenderer* ren, vtkMatrix4x4*& wcvc, vtkMatrix3x3*& normMat, |
| 61 | vtkMatrix4x4*& vcdc, vtkMatrix4x4*& wcdc) |
| 62 | { |
| 63 | if (ren->GetSelector()) |
| 64 | { |
| 65 | this->Superclass::GetKeyMatrices(ren, wcvc, normMat, vcdc, wcdc); |
| 66 | return; |
| 67 | } |
| 68 | |
| 69 | // has the camera changed? |
| 70 | if (ren != this->LastRenderer || this->MTime > this->KeyMatrixTime || |
| 71 | ren->GetMTime() > this->KeyMatrixTime) |
| 72 | { |
| 73 | vtkVRRenderWindow* win = vtkVRRenderWindow::SafeDownCast(ren->GetRenderWindow()); |
| 74 | |
| 75 | // on left eye render we compute the NormalMatrix, this should be fairly |
| 76 | // accurate for both eyes. |
| 77 | if (this->LeftEye) |
| 78 | { |
| 79 | this->UpdateWorldToEyeMatrices(ren); |
| 80 | this->UpdateEyeToProjectionMatrices(ren); |
| 81 | |
| 82 | vtkMatrix4x4* w2v = this->GetModelViewTransformMatrix(); |
| 83 | this->WCVCMatrix->DeepCopy(w2v); |
| 84 | |
| 85 | // only compute normal matrix once |
| 86 | for (int i = 0; i < 3; ++i) |
| 87 | { |
| 88 | for (int j = 0; j < 3; ++j) |
| 89 | { |
| 90 | this->NormalMatrix->SetElement(i, j, w2v->GetElement(i, j)); |
| 91 | } |
| 92 | } |
| 93 | this->NormalMatrix->Invert(); |
| 94 | } |
| 95 | |
| 96 | if (this->LeftEye) |
| 97 | { |
| 98 | this->SetCameraFromWorldToDeviceMatrix(this->WorldToLeftEyeMatrix, win->GetPhysicalScale()); |
| 99 | this->ModelViewTransform->SetMatrix(this->WorldToLeftEyeMatrix); |
| 100 | this->WCVCMatrix->DeepCopy(this->WorldToLeftEyeMatrix); |
| 101 | this->WCVCMatrix->Transpose(); |
| 102 | |
| 103 | vtkMatrix4x4::Multiply4x4( |
| 104 | this->LeftEyeToProjectionMatrix, this->WorldToLeftEyeMatrix, this->WCDCMatrix); |
| 105 | this->WCDCMatrix->Transpose(); |
| 106 | |
| 107 | vtkMatrix4x4::Multiply4x4(this->LeftEyeToProjectionMatrix, this->PhysicalToLeftEyeMatrix, |
| 108 | this->PhysicalToProjectionMatrixForLeftEye); |
| 109 | |
| 110 | this->VCDCMatrix->DeepCopy(this->LeftEyeToProjectionMatrix); |
| 111 | this->VCDCMatrix->Transpose(); |
| 112 | } |
| 113 | else |
| 114 | { |
| 115 | this->SetCameraFromWorldToDeviceMatrix(this->WorldToRightEyeMatrix, win->GetPhysicalScale()); |
| 116 | this->ModelViewTransform->SetMatrix(this->WorldToRightEyeMatrix); |
| 117 | this->WCVCMatrix->DeepCopy(this->WorldToRightEyeMatrix); |
no test coverage detected