VTK  9.3.1
vtkVRCamera.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
11 #ifndef vtkVRCamera_h
12 #define vtkVRCamera_h
13 
14 #include "vtkDeprecation.h" // for VTK_DEPRECATED_IN_9_2_0
15 #include "vtkNew.h" // for iavr
16 #include "vtkOpenGLCamera.h"
17 #include "vtkRenderingVRModule.h" // For export macro
18 
19 VTK_ABI_NAMESPACE_BEGIN
20 class vtkMatrix4x4;
21 class vtkVRRenderWindow;
22 
23 class VTKRENDERINGVR_EXPORT vtkVRCamera : public vtkOpenGLCamera
24 {
25 public:
26  vtkTypeMacro(vtkVRCamera, vtkOpenGLCamera);
27 
33  VTK_DEPRECATED_IN_9_2_0("use GetPhysicalToProjectionMatrix instead")
34  virtual void GetTrackingToDCMatrix(vtkMatrix4x4*& physicalToProjectionMatrix)
35  {
36  this->GetPhysicalToProjectionMatrix(physicalToProjectionMatrix);
37  };
38  virtual void GetPhysicalToProjectionMatrix(vtkMatrix4x4*& physicalToProjectionMatrix) = 0;
39 
40  // A pose in VR includes more than just the basic camera values.
41  // It includes all the properties needed to reproduce a view
42  // in physical space when requested from a different physical space
43  // This class stores those properties
44  // As the VR code is still being rearchitected this signature
45  // may change slightly through the end of 2021.
46  class Pose
47  {
48  public:
49  double Position[3];
50  double PhysicalViewUp[3];
51  double PhysicalViewDirection[3];
52  double ViewDirection[3];
53  double Translation[3];
54  double Distance;
55  double MotionFactor = 1.0;
56  };
57 
58  // Fill in a Pose object based on the current camera and physical space
59  // settings. As the VR code is still being rearchitected this signature
60  // may change slightly through the end of 2021.
61  void SetPoseFromCamera(Pose* pose, vtkVRRenderWindow* win);
62 
63  // Reproduce a pose using the current camera and render window. That is, try
64  // to make the viewer's current view look like the original saved pose.
65  // This is complicated by the fact that the viewer may now occupy a very
66  // different position and orientation in the physical space than when the
67  // pose was saved. This method accounts for this and adjusts the phjsical
68  // space to best fit the requested pose.
69  // As the VR code is still being rearchitected this signature
70  // may change slightly through the end of 2021.
71  void ApplyPoseToCamera(Pose* pose, vtkVRRenderWindow* win);
72 
73  // Set the camera's ivars based on a user provided matrix. The goal here
74  // is to make it so that the camera is consistent with the provided matrix
75  // and when the world to pose/view matrix is requested would return the
76  // same matrix as provided.
77  void SetCameraFromWorldToDeviceMatrix(vtkMatrix4x4* mat, double distance);
78  void SetCameraFromDeviceToWorldMatrix(vtkMatrix4x4* mat, double distance);
79 
80 protected:
81  vtkVRCamera();
82  ~vtkVRCamera() override;
83 
85 
86 private:
87  vtkVRCamera(const vtkVRCamera&) = delete;
88  void operator=(const vtkVRCamera&) = delete;
89 };
90 
91 VTK_ABI_NAMESPACE_END
92 #endif
93 /* VTK-HeaderTest-Exclude: vtkVRCamera.h */
VR camera.
Definition: vtkVRCamera.h:23
vtkNew< vtkMatrix4x4 > TempMatrix4x4
Definition: vtkVRCamera.h:84
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:30
#define VTK_DEPRECATED_IN_9_2_0(reason)
VR rendering window.
OpenGL camera.