VTK  9.0.20200808
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
vtkGLTFReader::AnimationSelection
vtkSmartPointer< vtkDataArraySelection > AnimationSelection
Definition: vtkGLTFReader.h:217
vtkIdType
int vtkIdType
Definition: vtkType.h:330
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
vtkSmartPointer< vtkImageData >
vtkMultiBlockDataSetAlgorithm::New
static vtkMultiBlockDataSetAlgorithm * New()
vtkGLTFReader::SceneNames
vtkSmartPointer< vtkStringArray > SceneNames
Definition: vtkGLTFReader.h:214
vtkFieldData
represent and manipulate fields of data
Definition: vtkFieldData.h:53
vtkMultiBlockDataSetAlgorithm::RequestData
virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
Definition: vtkMultiBlockDataSetAlgorithm.h:89
vtkDataArraySelection
Store on/off settings for data arrays for a vtkSource.
Definition: vtkDataArraySelection.h:34
vtkGLTFReader::GLTFTexture::WrapTValue
unsigned short WrapTValue
Definition: vtkGLTFReader.h:94
vtkGLTFReader::GLTFTexture::MinFilterValue
unsigned short MinFilterValue
Definition: vtkGLTFReader.h:91
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:41
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkSmartPointer.h
vtkMultiBlockDataSetAlgorithm.h
vtkGLTFReader::OutputDataSet
vtkSmartPointer< vtkMultiBlockDataSet > OutputDataSet
Definition: vtkGLTFReader.h:193
vtkMultiBlockDataSetAlgorithm::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:73
vtkX3D::string
Definition: vtkX3D.h:496
vtkGLTFReader::GLTFTexture::Image
vtkSmartPointer< vtkImageData > Image
Definition: vtkGLTFReader.h:90
vtkGLTFDocumentLoader
Deserialize a GLTF model file.
Definition: vtkGLTFDocumentLoader.h:62
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:36
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:88
vtkGLTFReader::Textures
std::vector< GLTFTexture > Textures
Definition: vtkGLTFReader.h:195
vtkMultiBlockDataSetAlgorithm::RequestInformation
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *)
This is called by the superclass.
Definition: vtkMultiBlockDataSetAlgorithm.h:80
vtkGLTFReader::GLTFTexture::WrapSValue
unsigned short WrapSValue
Definition: vtkGLTFReader.h:93
vtkGLTFReader
Read a GLTF file.
Definition: vtkGLTFReader.h:75
vtkMultiBlockDataSetAlgorithm
Superclass for algorithms that produce only vtkMultiBlockDataSet as output.
Definition: vtkMultiBlockDataSetAlgorithm.h:32