VTK  9.4.20250212
vtkWebGPUActor.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 vtkWebGPUActor_h
4#define vtkWebGPUActor_h
5
6#include "vtkActor.h"
7
8#include "vtkRenderingWebGPUModule.h" // for export macro
9#include "vtk_wgpu.h" // for return
10
11VTK_ABI_NAMESPACE_BEGIN
12class vtkMatrix3x3;
15
16class VTKRENDERINGWEBGPU_EXPORT vtkWebGPUActor : public vtkActor
17{
18public:
20 vtkTypeMacro(vtkWebGPUActor, vtkActor);
21 void PrintSelf(ostream& os, vtkIndent indent) override;
22
23 void ReleaseGraphicsResources(vtkWindow* window) override;
24
25 void ShallowCopy(vtkProp* other) override;
26
27 inline const void* GetCachedActorInformation() { return &(this->CachedActorInfo); }
28 static std::size_t GetCacheSizeBytes() { return sizeof(ActorBlock); }
29
33 void Render(vtkRenderer* renderer, vtkMapper* mapper) override;
34
42
43 inline void PopulateBindgroupLayouts(std::vector<wgpu::BindGroupLayout>& layouts)
44 {
45 layouts.emplace_back(this->ActorBindGroupLayout);
46 }
47
48 virtual bool UpdateKeyMatrices();
49
51
67
68protected:
70 ~vtkWebGPUActor() override;
71
75
77
79 {
81 {
82 vtkTypeFloat32 World[4][4] = {};
83 vtkTypeFloat32 Normal[3][4] = {};
84 } Transform;
85
87 {
88 // Point size in pixels - applicable when points are visible.
89 vtkTypeFloat32 PointSize = 0;
90 // Line width in pixels - applicable when lines/edges are visible.
91 vtkTypeFloat32 LineWidth = 0;
92 // Edge width in pixels - applicable when edges are visible and UseLineWidthForEdgeThickness
93 // is false.
94 vtkTypeFloat32 EdgeWidth = 0;
95 // Custom flags used to encode various integer/boolean properties.
96 vtkTypeUInt32 Flags = 0;
97 } RenderOpts;
98
100 {
101 // Material ambient color intensity.
102 vtkTypeFloat32 AmbientIntensity = 0;
103 // Material diffuse color intensity.
104 vtkTypeFloat32 DiffuseIntensity = 1;
105 // Material specular color intensity.
106 vtkTypeFloat32 SpecularIntensity = 0;
107 // Material specular power.
108 vtkTypeFloat32 SpecularPower = 0;
109 // Opacity level
110 vtkTypeFloat32 Opacity = 0;
111 // So that `AmbientColor` starts at 16-byte boundary.
112 vtkTypeUInt32 Pad[3];
113 // Material ambient color - applicable when shading type is global.
114 vtkTypeFloat32 AmbientColor[4] = {};
115 // Material diffuse color - applicable when shading type is global.
116 vtkTypeFloat32 DiffuseColor[4] = {};
117 // Material specular color - applicable when shading type is global.
118 vtkTypeFloat32 SpecularColor[4] = {};
119 // Edge color
120 vtkTypeFloat32 EdgeColor[4] = {};
121 // Vertex color
122 vtkTypeFloat32 VertexColor[4] = {};
123 } ShadeOpts;
124 };
125
127
131
135
136 wgpu::BindGroupLayout ActorBindGroupLayout;
137 wgpu::BindGroup ActorBindGroup;
138 wgpu::Buffer ActorBuffer;
139
141 {
142 bool Value = false;
143 vtkTimeStamp TimeStamp;
144
145 public:
149 void SetValue(bool newValue);
150
154 inline bool GetValue() { return Value; }
155
159 bool IsOutdated(vtkMapper* mapper);
160 };
161
164
165private:
166 vtkWebGPUActor(const vtkWebGPUActor&) = delete;
167 void operator=(const vtkWebGPUActor&) = delete;
168};
169
170VTK_ABI_NAMESPACE_END
171#endif
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
a simple class to control print indentation
Definition vtkIndent.h:108
abstract class specifies interface to map data to graphics primitives
Definition vtkMapper.h:98
represent and manipulate 3x3 transformation matrices
Allocate and hold a VTK object.
Definition vtkNew.h:167
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:66
abstract specification for renderers
record modification and/or execution time
void SetValue(bool newValue)
Update the cached value with the new value.
bool GetValue()
Returns the cached Value.
bool IsOutdated(vtkMapper *mapper)
Returns true if the timestamp of the cached value is older than the mapper's MTime.
vtkNew< vtkTransform > NormalTransform
vtkTimeStamp ShadingOptionsBuildTimestamp
vtkTimeStamp ModelTransformsBuildTimestamp
wgpu::BindGroupLayout ActorBindGroupLayout
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
MapperBooleanCache MapperHasTranslucentPolygonalGeometry
virtual bool UpdateKeyMatrices()
vtkTypeBool HasTranslucentPolygonalGeometry() override
Does this prop have opaque/translucent polygonal geometry? These methods are overriden to skip redund...
const void * GetCachedActorInformation()
wgpu::BindGroup ActorBindGroup
MapperBooleanCache MapperHasOpaqueGeometry
~vtkWebGPUActor() override
bool CacheActorTransforms()
void Render(vtkRenderer *renderer, vtkMapper *mapper) override
Actual actor render method.
vtkNew< vtkMatrix3x3 > NormalMatrix
void ReleaseGraphicsResources(vtkWindow *window) override
Release any graphics resources that are being consumed by this actor.
void PopulateBindgroupLayouts(std::vector< wgpu::BindGroupLayout > &layouts)
wgpu::Buffer ActorBuffer
void AllocateResources(vtkWebGPUConfiguration *renderer)
bool CacheActorShadeOptions()
vtkTimeStamp RenderOptionsBuildTimestamp
bool SupportRenderBundles()
Returns true if the actor supports rendering with render bundles, false otherwise.
static vtkWebGPUActor * New()
ActorBlock CachedActorInfo
static std::size_t GetCacheSizeBytes()
vtkNew< vtkMatrix4x4 > MCWCMatrix
vtkTypeBool HasOpaqueGeometry() override
Does this prop have opaque/translucent polygonal geometry? These methods are overriden to skip redund...
void ShallowCopy(vtkProp *other) override
Shallow copy of an actor.
bool CacheActorRenderOptions()
Create a webgpu device for use in rendering and compute pipelines.
Class to create and retrieve render pipelines based on a given key.
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
int vtkTypeBool
Definition vtkABI.h:64