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