VTK  9.1.0
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
70class vtkFieldData;
72class vtkImageData;
73class vtkStringArray;
74
75class VTKIOGEOMETRY_EXPORT vtkGLTFReader : public vtkMultiBlockDataSetAlgorithm
76{
77public:
78 static vtkGLTFReader* New();
80 void PrintSelf(ostream& os, vtkIndent indent) override;
81
83
89 {
91 unsigned short MinFilterValue;
92 unsigned short MaxFilterValue;
93 unsigned short WrapSValue;
94 unsigned short WrapTValue;
95 };
96
100
102
108
110
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
181
186
187protected:
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
234private:
235 vtkGLTFReader(const vtkGLTFReader&) = delete;
236 void operator=(const vtkGLTFReader&) = delete;
237};
238
239#endif
Store on/off settings for data arrays for a vtkSource.
represent and manipulate fields of data
Definition: vtkFieldData.h:164
Deserialize a GLTF model file.
Read a GLTF file.
Definition: vtkGLTFReader.h:76
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...
vtkDataArraySelection * GetAnimationSelection()
Get the vtkDataArraySelection object to enable/disable animations.
vtkSmartPointer< vtkStringArray > SceneNames
std::string GetSceneName(vtkIdType sceneIndex)
glTF models can contain multiple scene descriptions.
void CreateAnimationSelection()
Fill the AnimationSelection vtkDataArraySelection with animation names.
vtkStringArray * GetAllSceneNames()
Get a list all scenes names as a vtkStringArray, with duplicate names numbered and empty names replac...
vtkSmartPointer< vtkMultiBlockDataSet > OutputDataSet
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void EnableAnimation(vtkIdType animationIndex)
Enable/Disable an animation.
vtkIdType GetNumberOfTextures()
bool IsAnimationEnabled(vtkIdType animationIndex)
Enable/Disable an animation.
vtkGetFilePathMacro(FileName)
Set/Get the name of the file from which to read points.
static vtkGLTFReader * New()
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:157
a simple class to control print indentation
Definition: vtkIndent.h:113
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
Superclass for algorithms that produce only vtkMultiBlockDataSet as output.
Hold a reference to a vtkObjectBase instance.
a vtkAbstractArray subclass for strings
Materials are not directly applied to this reader's output.
Definition: vtkGLTFReader.h:89
unsigned short MinFilterValue
Definition: vtkGLTFReader.h:91
unsigned short MaxFilterValue
Definition: vtkGLTFReader.h:92
vtkSmartPointer< vtkImageData > Image
Definition: vtkGLTFReader.h:90
int vtkIdType
Definition: vtkType.h:332