VTK  9.7.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 class vtkTexture;
71 class vtkGLTFTexture;
72 
73 class VTKIOGEOMETRY_EXPORT vtkGLTFReader : public vtkMultiBlockDataSetAlgorithm
74 {
75 public:
76  static vtkGLTFReader* New();
78  void PrintSelf(ostream& os, vtkIndent indent) override;
79 
81 
87  vtkIdType GetNumberOfTextures();
88  vtkSmartPointer<vtkGLTFTexture> GetTexture(vtkIdType textureIndex);
90 
92 
95  vtkSetFilePathMacro(FileName);
96  vtkGetFilePathMacro(FileName);
98 
100 
104  vtkSetSmartPointerMacro(Stream, vtkResourceStream);
105  vtkGetSmartPointerMacro(Stream, vtkResourceStream);
107 
109 
114  vtkSetMacro(GLBStart, vtkTypeInt64);
115  vtkGetMacro(GLBStart, vtkTypeInt64);
117 
119 
124  vtkSetSmartPointerMacro(URILoader, vtkURILoader);
125  vtkGetSmartPointerMacro(URILoader, vtkURILoader);
127 
129 
135  void SetApplyDeformationsToGeometry(bool flag);
136  vtkGetMacro(ApplyDeformationsToGeometry, bool);
137  vtkBooleanMacro(ApplyDeformationsToGeometry, bool);
139 
141 
147  vtkGetMacro(NumberOfAnimations, vtkIdType);
148  std::string GetAnimationName(vtkIdType animationIndex);
149  float GetAnimationDuration(vtkIdType animationIndex);
151 
153 
158  void EnableAnimation(vtkIdType animationIndex);
159  void DisableAnimation(vtkIdType animationIndex);
160  bool IsAnimationEnabled(vtkIdType animationIndex);
162 
164 
168  std::string GetSceneName(vtkIdType sceneIndex);
169  vtkGetMacro(NumberOfScenes, vtkIdType);
171 
173 
176  vtkGetMacro(CurrentScene, vtkIdType);
177  vtkSetMacro(CurrentScene, vtkIdType);
178  void SetScene(const std::string& scene);
180 
182 
191  vtkGetMacro(FrameRate, unsigned int);
192  vtkSetMacro(FrameRate, unsigned int);
194 
196 
203  vtkSetMacro(OutputPointsPrecision, int);
204  vtkGetMacro(OutputPointsPrecision, int);
206 
212  vtkStringArray* GetAllSceneNames();
213 
217  vtkDataArraySelection* GetAnimationSelection();
218 
219 protected:
220  vtkGLTFReader();
221  ~vtkGLTFReader() override;
222 
224 
226 
227  std::vector<vtkSmartPointer<vtkGLTFTexture>> Textures;
228 
232  void StoreTextureData();
233 
238  virtual void InitializeLoader();
239 
240  char* FileName = nullptr;
242  vtkTypeInt64 GLBStart = 0;
243  vtkMTimeType LastStreamTimeStamp = 0;
245 
246  vtkIdType CurrentScene = 0;
247  unsigned int FrameRate = 60;
248  vtkIdType NumberOfAnimations = 0;
249  vtkIdType NumberOfScenes = 0;
250 
251  bool IsModelLoaded = false;
252  bool IsMetaDataLoaded = false;
253 
254  bool ApplyDeformationsToGeometry = true;
255  int OutputPointsPrecision = vtkAlgorithm::SINGLE_PRECISION;
256 
258 
261 
264 
269  void CreateSceneNamesArray();
270 
275  void CreateAnimationSelection();
276 
277 private:
278  vtkGLTFReader(const vtkGLTFReader&) = delete;
279  void operator=(const vtkGLTFReader&) = delete;
280 };
281 
282 VTK_ABI_NAMESPACE_END
283 #endif
Read a GLTF file.
Definition: vtkGLTFReader.h:73
std::vector< vtkSmartPointer< vtkGLTFTexture > > Textures
Abstract class used for custom streams.
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
vtkSmartPointer< vtkGLTFDocumentLoader > Loader
a vtkAbstractArray subclass for strings
Hold a reference to a vtkObjectBase instance.
Definition: vtkMeta.h:23
int vtkIdType
Definition: vtkType.h:363
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:45
Store on/off settings for data arrays, etc.
handles properties associated with a texture map
Definition: vtkTexture.h:58
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSmartPointer< vtkDataArraySelection > PreviousAnimationSelection
Helper class for readers and importer that need to load more than one resource.
Definition: vtkURILoader.h:99
Deserialize a GLTF model file.
Store zero or more vtkInformation instances.
Represents and manipulates a collection of data arrays.
Definition: vtkFieldData.h:51
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
vtkSmartPointer< vtkResourceStream > Stream