------------------------------------------------------------------------------
| 24 | |
| 25 | //------------------------------------------------------------------------------ |
| 26 | void 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 | //------------------------------------------------------------------------------ |
| 69 | void vtkExternalOpenGLCamera::SetProjectionTransformMatrix(const double elements[16]) |
no test coverage detected