VTK  9.7.1
vtkWebGPUCamera.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
3 #ifndef vtkWebGPUCamera_h
4 #define vtkWebGPUCamera_h
5 
6 #include "vtkCamera.h"
7 
8 #include "vtkMatrix4x4.h" // for ivar
9 #include "vtkNew.h" // for ivar
10 #include "vtkRenderingWebGPUModule.h" // for export macro
11 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
12 
13 VTK_ABI_NAMESPACE_BEGIN
14 class vtkActor;
15 class vtkMatrix3x3;
17 
18 class VTKRENDERINGWEBGPU_EXPORT VTK_MARSHALAUTO vtkWebGPUCamera : public vtkCamera
19 {
20 public:
21  static vtkWebGPUCamera* New();
23  static vtkOverrideAttribute* CreateOverrideAttributes();
24  vtkTypeMacro(vtkWebGPUCamera, vtkCamera);
25  void PrintSelf(ostream& os, vtkIndent indent) override;
26 
27  void CacheSceneTransforms(vtkRenderer* renderer);
28  inline void* GetCachedSceneTransforms() { return &(this->CachedSceneTransforms); }
29  static std::size_t GetCacheSizeBytes() { return sizeof(SceneTransforms); }
30 
37  void Render(vtkRenderer* renderer) override;
38 
43  void UpdateViewport(vtkRenderer* renderer) override;
44 
45 protected:
47  ~vtkWebGPUCamera() override;
48 
49 private:
50  vtkWebGPUCamera(const vtkWebGPUCamera&) = delete;
51  void operator=(const vtkWebGPUCamera&) = delete;
52 
53  std::tuple<int, int, int, int> ComputeYInvertedViewport(vtkRenderer* renderer);
54 
55  vtkTimeStamp KeyMatrixTime;
56  vtkRenderer* LastRenderer = nullptr;
57  vtkNew<vtkMatrix3x3> NormalMatrix;
58 
59  // Pack uniforms as needed.
60  struct SceneTransforms
61  {
62  // Viewport dimensions
63  vtkTypeFloat32 Viewport[4];
64  // World -> Camera space
65  vtkTypeFloat32 ViewMatrix[4][4] = {};
66  // Camera space -> Clipped space
67  vtkTypeFloat32 ProjectionMatrix[4][4] = {};
68  // Normal matrix Inverted and transposed ViewMatrix
69  vtkTypeFloat32 NormalMatrix[3][4] = {};
70  // Clipped space -> Camera space
71  vtkTypeFloat32 InvertedProjectionMatrix[4][4] = {};
72  // Custom flags used to encode various integer/boolean properties.
73  vtkTypeUInt32 Flags = 0;
74  };
75  SceneTransforms CachedSceneTransforms;
76 };
77 
78 #define vtkWebGPUCamera_OVERRIDE_ATTRIBUTES vtkWebGPUCamera::CreateOverrideAttributes()
79 VTK_ABI_NAMESPACE_END
80 #endif
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Attribute for vtkObjectFactory overrides.
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:41
record modification and/or execution time
Definition: vtkTimeStamp.h:24
abstract specification for renderers
Definition: vtkRenderer.h:63
static std::size_t GetCacheSizeBytes()
virtual void UpdateViewport(vtkRenderer *ren)
Update the viewport.
Definition: vtkCamera.h:685
a simple class to control print indentation
Definition: vtkIndent.h:28
a virtual camera for 3D rendering
Definition: vtkCamera.h:41
virtual void Render(vtkRenderer *)
This method causes the camera to set up whatever is required for viewing the scene.
Definition: vtkCamera.h:616
#define VTK_NEWINSTANCE
void * GetCachedSceneTransforms()
#define VTK_MARSHALAUTO
represent and manipulate 3x3 transformation matrices
Definition: vtkMatrix3x3.h:26
static vtkCamera * New()
Construct camera instance with its focal point at the origin, and position=(0,0,1).