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

Method SetViewTransformMatrix

Rendering/External/vtkExternalOpenGLCamera.cxx:26–66  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

24
25//------------------------------------------------------------------------------
26void vtkExternalOpenGLCamera::SetViewTransformMatrix(const double elements[16])
27{
28 if (!elements)
29 {
30 return;
31 }
32 // Transpose the matrix to undo the transpose that VTK does internally
33 vtkMatrix4x4* matrix = vtkMatrix4x4::New();
34 matrix->DeepCopy(elements);
35 matrix->Transpose();
36 this->ViewTransform->SetMatrix(matrix);
37 this->ModelViewTransform->SetMatrix(matrix);
38 this->UserProvidedViewTransform = true;
39
40 // Synchronize camera viewUp
41 matrix->Invert();
42 double viewUp[4] = { 0.0, 1.0, 0.0, 0.0 }, newViewUp[4];
43 matrix->MultiplyPoint(viewUp, newViewUp);
44 vtkMath::Normalize(newViewUp);
45 this->SetViewUp(newViewUp);
46
47 // Synchronize camera position
48 double position[4] = { 0.0, 0.0, 0.0, 1.0 }, newPosition[4];
49 matrix->MultiplyPoint(position, newPosition);
50
51 if (newPosition[3] != 0.0)
52 {
53 newPosition[0] /= newPosition[3];
54 newPosition[1] /= newPosition[3];
55 newPosition[2] /= newPosition[3];
56 newPosition[3] = 1.0;
57 }
58 this->SetPosition(newPosition);
59
60 // Synchronize focal point
61 double focalPoint[4] = { 0.0, 0.0, -1.0, 1.0 }, newFocalPoint[4];
62 matrix->MultiplyPoint(focalPoint, newFocalPoint);
63 this->SetFocalPoint(newFocalPoint);
64
65 matrix->Delete();
66}
67
68//------------------------------------------------------------------------------
69void vtkExternalOpenGLCamera::SetProjectionTransformMatrix(const double elements[16])

Callers 1

Calls 11

SetViewUpMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
NormalizeFunction · 0.50
DeepCopyMethod · 0.45
TransposeMethod · 0.45
SetMatrixMethod · 0.45
InvertMethod · 0.45
MultiplyPointMethod · 0.45
SetPositionMethod · 0.45
SetFocalPointMethod · 0.45

Tested by

no test coverage detected