MCPcopy Create free account
hub / github.com/Kitware/VTK / GetKeyMatrices

Method GetKeyMatrices

Rendering/VR/vtkVRHMDCamera.cxx:60–139  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

58
59//------------------------------------------------------------------------------
60void 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);

Callers 6

ProjectTetrahedraMethod · 0.45
RenderMultipleInputsMethod · 0.45
RenderSingleInputMethod · 0.45
ProjectBoundsMethod · 0.45
RenderOpaqueGeometryMethod · 0.45

Calls 14

GetPhysicalScaleMethod · 0.80
GetSelectorMethod · 0.45
GetMTimeMethod · 0.45
GetRenderWindowMethod · 0.45
DeepCopyMethod · 0.45
SetElementMethod · 0.45
InvertMethod · 0.45
SetMatrixMethod · 0.45

Tested by

no test coverage detected