VTK  9.2.5
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 
62 #ifndef vtkGLTFReader_h
63 #define vtkGLTFReader_h
64 
65 #include "vtkIOGeometryModule.h" // For export macro
67 #include "vtkSmartPointer.h" // For SmartPointer
68 
69 #include <string> // For std::string
70 #include <vector> // For std::vector
71 
73 class vtkFieldData;
75 class vtkImageData;
76 class vtkStringArray;
77 
78 class VTKIOGEOMETRY_EXPORT vtkGLTFReader : public vtkMultiBlockDataSetAlgorithm
79 {
80 public:
81  static vtkGLTFReader* New();
83  void PrintSelf(ostream& os, vtkIndent indent) override;
84 
86 
91  struct GLTFTexture
92  {
94  unsigned short MinFilterValue;
95  unsigned short MaxFilterValue;
96  unsigned short WrapSValue;
97  unsigned short WrapTValue;
98  };
99 
103 
105 
111 
113 
120  vtkGetMacro(ApplyDeformationsToGeometry, bool);
121  vtkBooleanMacro(ApplyDeformationsToGeometry, bool);
123 
125 
131  vtkGetMacro(NumberOfAnimations, vtkIdType);
133  float GetAnimationDuration(vtkIdType animationIndex);
135 
137 
142  void EnableAnimation(vtkIdType animationIndex);
143  void DisableAnimation(vtkIdType animationIndex);
144  bool IsAnimationEnabled(vtkIdType animationIndex);
146 
148 
153  vtkGetMacro(NumberOfScenes, vtkIdType);
155 
157 
160  vtkGetMacro(CurrentScene, vtkIdType);
161  vtkSetMacro(CurrentScene, vtkIdType);
162  void SetScene(const std::string& scene);
164 
166 
174  vtkGetMacro(FrameRate, unsigned int);
175  vtkSetMacro(FrameRate, unsigned int);
177 
184 
189 
190 protected:
192  ~vtkGLTFReader() override;
193 
195 
197 
198  std::vector<GLTFTexture> Textures;
199 
204 
205  char* FileName = nullptr;
206 
207  vtkIdType CurrentScene = 0;
208  unsigned int FrameRate = 60;
209  vtkIdType NumberOfAnimations = 0;
210  vtkIdType NumberOfScenes = 0;
211 
212  bool IsModelLoaded = false;
213  bool IsMetaDataLoaded = false;
214 
215  bool ApplyDeformationsToGeometry = true;
216 
218 
221 
224 
230 
236 
237 private:
238  vtkGLTFReader(const vtkGLTFReader&) = delete;
239  void operator=(const vtkGLTFReader&) = delete;
240 };
241 
242 #endif
Store on/off settings for data arrays, etc.
represent and manipulate fields of data
Definition: vtkFieldData.h:172
Deserialize a GLTF model file.
Read a GLTF file.
Definition: vtkGLTFReader.h:79
vtkSmartPointer< vtkGLTFDocumentLoader > Loader
void DisableAnimation(vtkIdType animationIndex)
Enable/Disable an animation.
~vtkGLTFReader() override
vtkSetFilePathMacro(FileName)
Set/Get the name of the file from which to read points.
std::string GetAnimationName(vtkIdType animationIndex)
glTF models can contain multiple animations, with various names and duration.
std::vector< GLTFTexture > Textures
void StoreTextureData()
Create and store GLTFTexture struct for each image present in the model.
void SetScene(const std::string &scene)
Get/Set the scene to be used by the reader.
void CreateSceneNamesArray()
Create the SceneNames array, generate unique identifiers for each scene based on their glTF name,...
GLTFTexture GetGLTFTexture(vtkIdType textureIndex)
vtkSmartPointer< vtkDataArraySelection > AnimationSelection
float GetAnimationDuration(vtkIdType animationIndex)
glTF models can contain multiple animations, with various names and duration.
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
void SetApplyDeformationsToGeometry(bool flag)
The model's skinning transforms are computed and added to the different vtkPolyData objects' field da...
vtkSmartPointer< vtkStringArray > SceneNames
std::string GetSceneName(vtkIdType sceneIndex)
glTF models can contain multiple scene descriptions.
void CreateAnimationSelection()
Fill the AnimationSelection vtkDataArraySelection with animation names.
vtkSmartPointer< vtkMultiBlockDataSet > OutputDataSet
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkGLTFReader * New()
void EnableAnimation(vtkIdType animationIndex)
Enable/Disable an animation.
vtkIdType GetNumberOfTextures()
bool IsAnimationEnabled(vtkIdType animationIndex)
Enable/Disable an animation.
vtkDataArraySelection * GetAnimationSelection()
Get the vtkDataArraySelection object to enable/disable animations.
vtkGetFilePathMacro(FileName)
Set/Get the name of the file from which to read points.
vtkStringArray * GetAllSceneNames()
Get a list all scenes names as a vtkStringArray, with duplicate names numbered and empty names replac...
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkSmartPointer< vtkDataArraySelection > PreviousAnimationSelection
topologically and geometrically regular array of data
Definition: vtkImageData.h:163
a simple class to control print indentation
Definition: vtkIndent.h:119
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Superclass for algorithms that produce only vtkMultiBlockDataSet as output.
a vtkAbstractArray subclass for strings
@ string
Definition: vtkX3D.h:496
Materials are not directly applied to this reader's output.
Definition: vtkGLTFReader.h:92
unsigned short MinFilterValue
Definition: vtkGLTFReader.h:94
unsigned short MaxFilterValue
Definition: vtkGLTFReader.h:95
vtkSmartPointer< vtkImageData > Image
Definition: vtkGLTFReader.h:93
int vtkIdType
Definition: vtkType.h:332