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 
100 
102 
105  vtkSetStringMacro(FileName);
106  vtkGetStringMacro(FileName);
108 
110 
117  vtkGetMacro(ApplyDeformationsToGeometry, bool);
118  vtkBooleanMacro(ApplyDeformationsToGeometry, bool);
120 
122 
128  vtkGetMacro(NumberOfAnimations, vtkIdType);
130  float GetAnimationDuration(vtkIdType animationIndex);
132 
134 
139  void EnableAnimation(vtkIdType animationIndex);
140  void DisableAnimation(vtkIdType animationIndex);
141  bool IsAnimationEnabled(vtkIdType animationIndex);
143 
145 
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 
181 
186 
187 protected:
189  ~vtkGLTFReader() override;
190 
192 
194 
195  std::vector<GLTFTexture> Textures;
196 
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 
227 
233 
234 private:
235  vtkGLTFReader(const vtkGLTFReader&) = delete;
236  void operator=(const vtkGLTFReader&) = delete;
237 };
238 
239 #endif
vtkGLTFReader::IsAnimationEnabled
bool IsAnimationEnabled(vtkIdType animationIndex)
vtkGLTFReader::AnimationSelection
vtkSmartPointer< vtkDataArraySelection > AnimationSelection
Definition: vtkGLTFReader.h:217
vtkGLTFReader::GetSceneName
std::string GetSceneName(vtkIdType sceneIndex)
glTF models can contain multiple scene descriptions.
vtkIdType
int vtkIdType
Definition: vtkType.h:338
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:36
vtkSmartPointer< vtkImageData >
vtkGLTFReader::SetScene
void SetScene(const std::string &scene)
vtkGLTFReader::SceneNames
vtkSmartPointer< vtkStringArray > SceneNames
Definition: vtkGLTFReader.h:214
vtkFieldData
represent and manipulate fields of data
Definition: vtkFieldData.h:54
vtkGLTFReader::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkDataArraySelection
Store on/off settings for data arrays for a vtkSource.
Definition: vtkDataArraySelection.h:35
vtkGLTFReader::GLTFTexture::WrapTValue
unsigned short WrapTValue
Definition: vtkGLTFReader.h:94
vtkGLTFReader::GetAllSceneNames
vtkStringArray * GetAllSceneNames()
Get a list all scenes names as a vtkStringArray, with duplicate names numbered and empty names replac...
vtkGLTFReader::RequestInformation
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkGLTFReader::GetAnimationDuration
float GetAnimationDuration(vtkIdType animationIndex)
vtkGLTFReader::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkGLTFReader::GLTFTexture::MinFilterValue
unsigned short MinFilterValue
Definition: vtkGLTFReader.h:91
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:34
vtkSmartPointer.h
vtkMultiBlockDataSetAlgorithm.h
vtkGLTFReader::OutputDataSet
vtkSmartPointer< vtkMultiBlockDataSet > OutputDataSet
Definition: vtkGLTFReader.h:193
vtkGLTFReader::GetNumberOfTextures
vtkIdType GetNumberOfTextures()
vtkGLTFReader::SetApplyDeformationsToGeometry
void SetApplyDeformationsToGeometry(bool flag)
The model's skinning transforms are computed and added to the different vtkPolyData objects' field da...
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:65
vtkX3D::string
@ string
Definition: vtkX3D.h:496
vtkGLTFReader::StoreTextureData
void StoreTextureData()
Create and store GLTFTexture struct for each image present in the model.
vtkGLTFReader::GLTFTexture::Image
vtkSmartPointer< vtkImageData > Image
Definition: vtkGLTFReader.h:90
vtkGLTFReader::New
static vtkGLTFReader * New()
vtkGLTFDocumentLoader
Deserialize a GLTF model file.
Definition: vtkGLTFDocumentLoader.h:60
vtkGLTFReader::CreateAnimationSelection
void CreateAnimationSelection()
Fill the AnimationSelection vtkDataArraySelection with animation names.
vtkGLTFReader::Loader
vtkSmartPointer< vtkGLTFDocumentLoader > Loader
Definition: vtkGLTFReader.h:191
vtkGLTFReader::PreviousAnimationSelection
vtkSmartPointer< vtkDataArraySelection > PreviousAnimationSelection
Definition: vtkGLTFReader.h:216
vtkStringArray
a vtkAbstractArray subclass for strings
Definition: vtkStringArray.h:37
vtkGLTFReader::GLTFTexture::MaxFilterValue
unsigned short MaxFilterValue
Definition: vtkGLTFReader.h:92
vtkGLTFReader::GLTFTexture
Materials are not directly applied to this reader's output.
Definition: vtkGLTFReader.h:89
vtkGLTFReader::GetAnimationSelection
vtkDataArraySelection * GetAnimationSelection()
Get the vtkDataArraySelection object to enable/disable animations.
vtkGLTFReader::CreateSceneNamesArray
void CreateSceneNamesArray()
Create the SceneNames array, generate unique identifiers for each scene based on their glTF name,...
vtkGLTFReader::Textures
std::vector< GLTFTexture > Textures
Definition: vtkGLTFReader.h:195
vtkGLTFReader::vtkGLTFReader
vtkGLTFReader()
vtkGLTFReader::GetAnimationName
std::string GetAnimationName(vtkIdType animationIndex)
vtkGLTFReader::GLTFTexture::WrapSValue
unsigned short WrapSValue
Definition: vtkGLTFReader.h:93
vtkGLTFReader::~vtkGLTFReader
~vtkGLTFReader() override
vtkGLTFReader
Read a GLTF file.
Definition: vtkGLTFReader.h:76
vtkGLTFReader::GetGLTFTexture
GLTFTexture GetGLTFTexture(vtkIdType textureIndex)
vtkGLTFReader::DisableAnimation
void DisableAnimation(vtkIdType animationIndex)
vtkGLTFReader::EnableAnimation
void EnableAnimation(vtkIdType animationIndex)
Enable/Disable an animation.
vtkMultiBlockDataSetAlgorithm
Superclass for algorithms that produce only vtkMultiBlockDataSet as output.
Definition: vtkMultiBlockDataSetAlgorithm.h:33