vtkOpenVRCamera.h 2.69 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/*=========================================================================

  Program:   Visualization Toolkit

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
14 15 16 17 18 19 20
/**
 * @class   vtkOpenVRCamera
 * @brief   OpenVR camera
 *
 * vtkOpenVRCamera is a concrete implementation of the abstract class
 * vtkCamera.  vtkOpenVRCamera interfaces to the OpenVR rendering library.
*/
21 22 23 24 25 26 27 28 29 30

#ifndef vtkOpenVRCamera_h
#define vtkOpenVRCamera_h

#include "vtkRenderingOpenVRModule.h" // For export macro
#include "vtkOpenGLCamera.h"
#include "vtkNew.h" // ivars
#include "vtkTransform.h" // ivars

class vtkOpenVRRenderer;
Ken Martin's avatar
Ken Martin committed
31
class vtkOpenVRRenderWindow;
32 33 34 35 36 37 38 39
class vtkMatrix3x3;
class vtkMatrix4x4;

class VTKRENDERINGOPENVR_EXPORT vtkOpenVRCamera : public vtkOpenGLCamera
{
public:
  static vtkOpenVRCamera *New();
  vtkTypeMacro(vtkOpenVRCamera, vtkOpenGLCamera);
40
  void PrintSelf(ostream& os, vtkIndent indent) override;
41

42 43 44
  /**
   * Implement base class method.
   */
45 46 47 48 49
  virtual void Render(vtkRenderer *ren);

  virtual void GetKeyMatrices(vtkRenderer *ren, vtkMatrix4x4 *&WCVCMatrix,
    vtkMatrix3x3 *&normalMatrix, vtkMatrix4x4 *&VCDCMatrix, vtkMatrix4x4 *&WCDCMatrix);

50 51 52 53
  /**
   * Provides a matrix to go from absolute OpenVR tracking coordinates
   * to device coordinates. Used for rendering devices.
   */
54 55
  virtual void GetTrackingToDCMatrix(vtkMatrix4x4 *&TCDCMatrix);

Ken Martin's avatar
Ken Martin committed
56 57 58
  // apply the left or right eye pose to the camera
  // position and focal point.  Factor is typically
  // 1.0 to add or -1.0 to subtract
Ken Martin's avatar
Ken Martin committed
59
  void ApplyEyePose(vtkOpenVRRenderWindow *, bool left, double factor);
Ken Martin's avatar
Ken Martin committed
60

61 62 63 64
  // Get the OpenVR Physical Space to World coordinate matrix
  vtkTransform *GetPhysicalToWorldTransform() {
    return this->PoseTransform.Get(); }

65 66 67 68 69 70 71 72 73
protected:
  vtkOpenVRCamera();
  ~vtkOpenVRCamera();

  // gets the pose and projections for the left and right eves from
  // the openvr library
  void GetHMDEyePoses(vtkRenderer *);
  void GetHMDEyeProjections(vtkRenderer *);

Ken Martin's avatar
Ken Martin committed
74 75
  double LeftEyePose[3];
  double RightEyePose[3];
76 77 78 79 80 81
  vtkMatrix4x4 *LeftEyeProjection;
  vtkMatrix4x4 *RightEyeProjection;

  vtkMatrix4x4 *LeftEyeTCDCMatrix;
  vtkMatrix4x4 *RightEyeTCDCMatrix;

82
  // used to translate the
83 84 85 86
  // View to the HMD space
  vtkNew<vtkTransform> PoseTransform;

private:
87 88
  vtkOpenVRCamera(const vtkOpenVRCamera&) = delete;
  void operator=(const vtkOpenVRCamera&) = delete;
89 90 91
};

#endif