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
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
66 class vtkFieldData;
68 class vtkImageData;
69 class vtkStringArray;
70 
71 class VTKIOGEOMETRY_EXPORT vtkGLTFReader : public vtkMultiBlockDataSetAlgorithm
72 {
73 public:
74  static vtkGLTFReader* New();
76  void PrintSelf(ostream& os, vtkIndent indent) override;
77 
79 
84  struct GLTFTexture
85  {
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 
208 
210 
211  std::vector<GLTFTexture> Textures;
212 
216  void StoreTextureData();
217 
218  char* FileName = nullptr;
220  vtkMTimeType LastStreamTimeStamp = 0;
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 
234 
237 
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
Read a GLTF file.
Definition: vtkGLTFReader.h:71
Abstract class used for custom streams.
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
vtkSmartPointer< vtkGLTFDocumentLoader > Loader
a vtkAbstractArray subclass for strings
Materials are not directly applied to this reader's output.
Definition: vtkGLTFReader.h:84
int vtkIdType
Definition: vtkType.h:315
Superclass for algorithms that produce only vtkMultiBlockDataSet as output.
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
vtkSmartPointer< vtkURILoader > URILoader
static vtkMultiBlockDataSetAlgorithm * New()
vtkSmartPointer< vtkMultiBlockDataSet > OutputDataSet
vtkSmartPointer< vtkStringArray > SceneNames
vtkSmartPointer< vtkDataArraySelection > AnimationSelection
a simple class to control print indentation
Definition: vtkIndent.h:28
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
Store on/off settings for data arrays, etc.
vtkSmartPointer< vtkImageData > Image
Definition: vtkGLTFReader.h:86
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
unsigned short MinFilterValue
Definition: vtkGLTFReader.h:87
vtkSmartPointer< vtkDataArraySelection > PreviousAnimationSelection
Helper class for readers and importer that need to load more than one resource.
Definition: vtkURILoader.h:99
std::vector< GLTFTexture > Textures
Deserialize a GLTF model file.
Store zero or more vtkInformation instances.
unsigned short MaxFilterValue
Definition: vtkGLTFReader.h:88
represent and manipulate fields of data
Definition: vtkFieldData.h:51
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
vtkSmartPointer< vtkResourceStream > Stream