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