VTK  9.0.1
vtkGLTFReader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkGLTFReader.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
59 #ifndef vtkGLTFReader_h
60 #define vtkGLTFReader_h
61 
62 #include "vtkIOGeometryModule.h" // For export macro
64 #include "vtkSmartPointer.h" // For SmartPointer
65 
66 #include <string> // For std::string
67 #include <vector> // For std::vector
68 
70 class vtkFieldData;
72 class vtkImageData;
73 class vtkStringArray;
74 
75 class VTKIOGEOMETRY_EXPORT vtkGLTFReader : public vtkMultiBlockDataSetAlgorithm
76 {
77 public:
78  static vtkGLTFReader* New();
80  void PrintSelf(ostream& os, vtkIndent indent) override;
81 
83 
88  struct GLTFTexture
89  {
91  unsigned short MinFilterValue;
92  unsigned short MaxFilterValue;
93  unsigned short WrapSValue;
94  unsigned short WrapTValue;
95  };
96 
97  vtkIdType GetNumberOfTextures();
98  GLTFTexture GetGLTFTexture(vtkIdType textureIndex);
100 
102 
105  vtkSetStringMacro(FileName);
106  vtkGetStringMacro(FileName);
108 
110 
116  void SetApplyDeformationsToGeometry(bool flag);
117  vtkGetMacro(ApplyDeformationsToGeometry, bool);
118  vtkBooleanMacro(ApplyDeformationsToGeometry, bool);
120 
122 
128  vtkGetMacro(NumberOfAnimations, vtkIdType);
129  std::string GetAnimationName(vtkIdType animationIndex);
130  float GetAnimationDuration(vtkIdType animationIndex);
132 
134 
139  void EnableAnimation(vtkIdType animationIndex);
140  void DisableAnimation(vtkIdType animationIndex);
141  bool IsAnimationEnabled(vtkIdType animationIndex);
143 
145 
149  std::string GetSceneName(vtkIdType sceneIndex);
150  vtkGetMacro(NumberOfScenes, vtkIdType);
152 
154 
157  vtkGetMacro(CurrentScene, vtkIdType);
158  vtkSetMacro(CurrentScene, vtkIdType);
159  void SetScene(const std::string& scene);
161 
163 
171  vtkGetMacro(FrameRate, unsigned int);
172  vtkSetMacro(FrameRate, unsigned int);
174 
180  vtkStringArray* GetAllSceneNames();
181 
185  vtkDataArraySelection* GetAnimationSelection();
186 
187 protected:
188  vtkGLTFReader();
189  ~vtkGLTFReader() override;
190 
192 
194 
195  std::vector<GLTFTexture> Textures;
196 
200  void StoreTextureData();
201 
202  char* FileName = nullptr;
203 
204  vtkIdType CurrentScene = 0;
205  unsigned int FrameRate = 60;
206  vtkIdType NumberOfAnimations = 0;
207  vtkIdType NumberOfScenes = 0;
208 
209  bool IsModelLoaded = false;
210  bool IsMetaDataLoaded = false;
211 
212  bool ApplyDeformationsToGeometry = true;
213 
215 
218 
221 
226  void CreateSceneNamesArray();
227 
232  void CreateAnimationSelection();
233 
234 private:
235  vtkGLTFReader(const vtkGLTFReader&) = delete;
236  void operator=(const vtkGLTFReader&) = delete;
237 };
238 
239 #endif
Read a GLTF file.
Definition: vtkGLTFReader.h:75
Store vtkAlgorithm input/output information.
vtkSmartPointer< vtkGLTFDocumentLoader > Loader
a vtkAbstractArray subclass for strings
Materials are not directly applied to this reader&#39;s output.
Definition: vtkGLTFReader.h:88
int vtkIdType
Definition: vtkType.h:338
Superclass for algorithms that produce only vtkMultiBlockDataSet as output.
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
static vtkMultiBlockDataSetAlgorithm * New()
vtkSmartPointer< vtkMultiBlockDataSet > OutputDataSet
vtkSmartPointer< vtkStringArray > SceneNames
vtkSmartPointer< vtkDataArraySelection > AnimationSelection
a simple class to control print indentation
Definition: vtkIndent.h:33
topologically and geometrically regular array of data
Definition: vtkImageData.h:41
Store on/off settings for data arrays for a vtkSource.
vtkSmartPointer< vtkImageData > Image
Definition: vtkGLTFReader.h:90
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:91
vtkSmartPointer< vtkDataArraySelection > PreviousAnimationSelection
std::vector< GLTFTexture > Textures
Deserialize a GLTF model file.
Store zero or more vtkInformation instances.
unsigned short MaxFilterValue
Definition: vtkGLTFReader.h:92
represent and manipulate fields of data
Definition: vtkFieldData.h:53
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.