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

Function ApplyTransformToCamera

IO/Import/vtkGLTFImporter.cxx:457–483  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

455
456//------------------------------------------------------------------------------
457void 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//------------------------------------------------------------------------------

Callers 1

ImportCamerasMethod · 0.85

Calls 6

TransformVectorMethod · 0.80
SetViewUpMethod · 0.80
SetMatrixMethod · 0.45
TransformPointMethod · 0.45
SetPositionMethod · 0.45
SetFocalPointMethod · 0.45

Tested by

no test coverage detected