------------------------------------------------------------------------------
| 455 | |
| 456 | //------------------------------------------------------------------------------ |
| 457 | void ApplyTransformToCamera(vtkSmartPointer<vtkCamera> cam, vtkSmartPointer<vtkMatrix4x4> transform) |
| 458 | { |
| 459 | if (!cam || !transform) |
| 460 | { |
| 461 | return; |
| 462 | } |
| 463 | |
| 464 | // At identity, camera position is origin, +y up, -z view direction |
| 465 | double position[3] = { 0.0, 0.0, 0.0 }; |
| 466 | double viewUp[3] = { 0.0, 1.0, 0.0 }; |
| 467 | double focus[3] = { 0.0, 0.0, -1.0 }; |
| 468 | |
| 469 | vtkNew<vtkTransform> t; |
| 470 | t->SetMatrix(transform); |
| 471 | |
| 472 | t->TransformPoint(position, position); |
| 473 | t->TransformVector(viewUp, viewUp); |
| 474 | t->TransformVector(focus, focus); |
| 475 | |
| 476 | focus[0] += position[0]; |
| 477 | focus[1] += position[1]; |
| 478 | focus[2] += position[2]; |
| 479 | |
| 480 | cam->SetPosition(position); |
| 481 | cam->SetFocalPoint(focus); |
| 482 | cam->SetViewUp(viewUp); |
| 483 | } |
| 484 | } |
| 485 | |
| 486 | //------------------------------------------------------------------------------ |
no test coverage detected