VTK: IO/Geometry/vtkGLTFReader.h Source File

| VTK 9.3.1

vtkGLTFReader.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
52 #ifndef vtkGLTFReader_h
53 #define vtkGLTFReader_h
54
55 #include "vtkIOGeometryModule.h" // For export macro
56 #include "vtkMultiBlockDataSetAlgorithm.h"
57 #include "vtkResourceStream.h" // For vtkResourceStream
58 #include "vtkSmartPointer.h" // For vtkSmartPointer
59 #include "vtkURILoader.h" // For vtkURILoader
60
61 #include <string> // For std::string
62 #include <vector> // For std::vector
63
64 VTK_ABI_NAMESPACE_BEGIN
65 class vtkDataArraySelection;
66 class vtkFieldData;
67 class vtkGLTFDocumentLoader;
68 class vtkImageData;
69 class vtkStringArray;
70
71 class VTKIOGEOMETRY_EXPORT vtkGLTFReader : public vtkMultiBlockDataSetAlgorithm
72 {
73 public:
74 static vtkGLTFReader* New();
75 vtkTypeMacro(vtkGLTFReader, vtkMultiBlockDataSetAlgorithm);
76 void PrintSelf(ostream& os, vtkIndent indent) override;
77
79
84 struct GLTFTexture
85 {
86 vtkSmartPointer<vtkImageData> Image;
87 unsigned short MinFilterValue;
88 unsigned short MaxFilterValue;
89 unsigned short WrapSValue;
90 unsigned short WrapTValue;
91 };
92
93 vtkIdType GetNumberOfTextures();
94 GLTFTexture GetGLTFTexture(vtkIdType textureIndex);
96
98
101 vtkSetFilePathMacro(FileName);
102 vtkGetFilePathMacro(FileName);
104
106
110 vtkSetSmartPointerMacro(Stream, vtkResourceStream);
111 vtkGetSmartPointerMacro(Stream, vtkResourceStream);
113
115
120 vtkSetSmartPointerMacro(URILoader, vtkURILoader);
121 vtkGetSmartPointerMacro(URILoader, vtkURILoader);
123
125
131 void SetApplyDeformationsToGeometry(bool flag);
132 vtkGetMacro(ApplyDeformationsToGeometry, bool);
133 vtkBooleanMacro(ApplyDeformationsToGeometry, bool);
135
137
143 vtkGetMacro(NumberOfAnimations, vtkIdType);
144 std::string GetAnimationName(vtkIdType animationIndex);
145 float GetAnimationDuration(vtkIdType animationIndex);
147
149
154 void EnableAnimation(vtkIdType animationIndex);
155 void DisableAnimation(vtkIdType animationIndex);
156 bool IsAnimationEnabled(vtkIdType animationIndex);
158
160
164 std::string GetSceneName(vtkIdType sceneIndex);
165 vtkGetMacro(NumberOfScenes, vtkIdType);
167
169
172 vtkGetMacro(CurrentScene, vtkIdType);
173 vtkSetMacro(CurrentScene, vtkIdType);
174 void SetScene(const std::string& scene);
176
178
187 vtkGetMacro(FrameRate, unsigned int);
188 vtkSetMacro(FrameRate, unsigned int);
190
196 vtkStringArray* GetAllSceneNames();
197
201 vtkDataArraySelection* GetAnimationSelection();
202
203 protected:
204 vtkGLTFReader();
205 ~vtkGLTFReader() override;
206
207 vtkSmartPointer<vtkGLTFDocumentLoader> Loader;
208
209 vtkSmartPointer<vtkMultiBlockDataSet> OutputDataSet;
210
211 std::vector<GLTFTexture> Textures;
212
216 void StoreTextureData();
217
218 char* FileName = nullptr;
219 vtkSmartPointer<vtkResourceStream> Stream;
220 vtkMTimeType LastStreamTimeStamp = 0;
221 vtkSmartPointer<vtkURILoader> URILoader;
222
223 vtkIdType CurrentScene = 0;
224 unsigned int FrameRate = 60;
225 vtkIdType NumberOfAnimations = 0;
226 vtkIdType NumberOfScenes = 0;
227
228 bool IsModelLoaded = false;
229 bool IsMetaDataLoaded = false;
230
231 bool ApplyDeformationsToGeometry = true;
232
233 vtkSmartPointer<vtkStringArray> SceneNames;
234
235 vtkSmartPointer<vtkDataArraySelection> PreviousAnimationSelection;
236 vtkSmartPointer<vtkDataArraySelection> AnimationSelection;
237
238 int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
239 int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
240
245 void CreateSceneNamesArray();
246
251 void CreateAnimationSelection();
252
253 private:
254 vtkGLTFReader(const vtkGLTFReader&) = delete;
255 void operator=(const vtkGLTFReader&) = delete;
256 };
257
258 VTK_ABI_NAMESPACE_END
259 #endif
vtkDataArraySelection
Store on/off settings for data arrays, etc.
Definition: vtkDataArraySelection.h:37
vtkFieldData
represent and manipulate fields of data
Definition: vtkFieldData.h:61
vtkGLTFDocumentLoader
Deserialize a GLTF model file.
Definition: vtkGLTFDocumentLoader.h:53
vtkGLTFReader
Read a GLTF file.
Definition: vtkGLTFReader.h:72
vtkGLTFReader::Loader
vtkSmartPointer< vtkGLTFDocumentLoader > Loader
Definition: vtkGLTFReader.h:207
vtkGLTFReader::DisableAnimation
void DisableAnimation(vtkIdType animationIndex)
Enable/Disable an animation.
vtkGLTFReader::~vtkGLTFReader
~vtkGLTFReader() override
vtkGLTFReader::vtkSetFilePathMacro
vtkSetFilePathMacro(FileName)
Set/Get the name of the file from which to read points.
vtkGLTFReader::vtkGLTFReader
vtkGLTFReader()
vtkGLTFReader::GetAnimationName
std::string GetAnimationName(vtkIdType animationIndex)
glTF models can contain multiple animations, with various names and duration.
vtkGLTFReader::vtkGetSmartPointerMacro
vtkGetSmartPointerMacro(URILoader, vtkURILoader)
Set/Get the URI loader to use when reading from a Stream.
vtkGLTFReader::Textures
std::vector< GLTFTexture > Textures
Definition: vtkGLTFReader.h:211
vtkGLTFReader::Stream
vtkSmartPointer< vtkResourceStream > Stream
Definition: vtkGLTFReader.h:219
vtkGLTFReader::StoreTextureData
void StoreTextureData()
Create and store GLTFTexture struct for each image present in the model.
vtkGLTFReader::SetScene
void SetScene(const std::string &scene)
Get/Set the scene to be used by the reader.
vtkGLTFReader::CreateSceneNamesArray
void CreateSceneNamesArray()
Create the SceneNames array, generate unique identifiers for each scene based on their glTF name,...
vtkGLTFReader::GetGLTFTexture
GLTFTexture GetGLTFTexture(vtkIdType textureIndex)
vtkGLTFReader::AnimationSelection
vtkSmartPointer< vtkDataArraySelection > AnimationSelection
Definition: vtkGLTFReader.h:236
vtkGLTFReader::GetAnimationDuration
float GetAnimationDuration(vtkIdType animationIndex)
glTF models can contain multiple animations, with various names and duration.
vtkGLTFReader::RequestInformation
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkGLTFReader::SetApplyDeformationsToGeometry
void SetApplyDeformationsToGeometry(bool flag)
The model's skinning transforms are computed and added to the different vtkPolyData objects' field da...
vtkGLTFReader::SceneNames
vtkSmartPointer< vtkStringArray > SceneNames
Definition: vtkGLTFReader.h:233
vtkGLTFReader::GetSceneName
std::string GetSceneName(vtkIdType sceneIndex)
glTF models can contain multiple scene descriptions.
vtkGLTFReader::CreateAnimationSelection
void CreateAnimationSelection()
Fill the AnimationSelection vtkDataArraySelection with animation names.
vtkGLTFReader::vtkSetSmartPointerMacro
vtkSetSmartPointerMacro(Stream, vtkResourceStream)
Set/Get the stream from which to read the glTF.
vtkGLTFReader::OutputDataSet
vtkSmartPointer< vtkMultiBlockDataSet > OutputDataSet
Definition: vtkGLTFReader.h:209
vtkGLTFReader::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkGLTFReader::URILoader
vtkSmartPointer< vtkURILoader > URILoader
Definition: vtkGLTFReader.h:221
vtkGLTFReader::New
static vtkGLTFReader * New()
vtkGLTFReader::EnableAnimation
void EnableAnimation(vtkIdType animationIndex)
Enable/Disable an animation.
vtkGLTFReader::vtkSetSmartPointerMacro
vtkSetSmartPointerMacro(URILoader, vtkURILoader)
Set/Get the URI loader to use when reading from a Stream.
vtkGLTFReader::GetNumberOfTextures
vtkIdType GetNumberOfTextures()
vtkGLTFReader::IsAnimationEnabled
bool IsAnimationEnabled(vtkIdType animationIndex)
Enable/Disable an animation.
vtkGLTFReader::GetAnimationSelection
vtkDataArraySelection * GetAnimationSelection()
Get the vtkDataArraySelection object to enable/disable animations.
vtkGLTFReader::vtkGetFilePathMacro
vtkGetFilePathMacro(FileName)
Set/Get the name of the file from which to read points.
vtkGLTFReader::GetAllSceneNames
vtkStringArray * GetAllSceneNames()
Get a list all scenes names as a vtkStringArray, with duplicate names numbered and empty names replac...
vtkGLTFReader::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkGLTFReader::vtkGetSmartPointerMacro
vtkGetSmartPointerMacro(Stream, vtkResourceStream)
Set/Get the stream from which to read the glTF.
vtkGLTFReader::PreviousAnimationSelection
vtkSmartPointer< vtkDataArraySelection > PreviousAnimationSelection
Definition: vtkGLTFReader.h:235
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:52
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:40
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:72
vtkMultiBlockDataSetAlgorithm
Superclass for algorithms that produce only vtkMultiBlockDataSet as output.
Definition: vtkMultiBlockDataSetAlgorithm.h:25
vtkResourceStream
Abstract class used for custom streams.
Definition: vtkResourceStream.h:31
vtkSmartPointer< vtkImageData >
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:41
vtkURILoader
Helper class for readers and importer that need to load more than one resource.
Definition: vtkURILoader.h:100
vtkX3D::string
@ string
Definition: vtkX3D.h:490
vtkGLTFReader::GLTFTexture
Materials are not directly applied to this reader's output.
Definition: vtkGLTFReader.h:85
vtkGLTFReader::GLTFTexture::WrapSValue
unsigned short WrapSValue
Definition: vtkGLTFReader.h:89
vtkGLTFReader::GLTFTexture::MinFilterValue
unsigned short MinFilterValue
Definition: vtkGLTFReader.h:87
vtkGLTFReader::GLTFTexture::MaxFilterValue
unsigned short MaxFilterValue
Definition: vtkGLTFReader.h:88
vtkGLTFReader::GLTFTexture::Image
vtkSmartPointer< vtkImageData > Image
Definition: vtkGLTFReader.h:86
vtkGLTFReader::GLTFTexture::WrapTValue
unsigned short WrapTValue
Definition: vtkGLTFReader.h:90
vtkMultiBlockDataSetAlgorithm.h
vtkResourceStream.h
vtkSmartPointer.h
vtkIdType
int vtkIdType
Definition: vtkType.h:315
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
vtkURILoader.h