VTK  9.1.0
vtkGLTFDocumentLoader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkGLTFDocumentLoader.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 
40 #ifndef vtkGLTFDocumentLoader_h
41 #define vtkGLTFDocumentLoader_h
42 
43 #include "vtkIOGeometryModule.h" // For export macro
44 #include "vtkObject.h"
45 #include "vtkSmartPointer.h" // For SmartPointer
46 
47 #include <map> // For std::map
48 #include <memory> // For std::shared_ptr
49 #include <string> // For std::string
50 #include <vector> // For std::vector
51 
52 class vtkCellArray;
53 class vtkDataArray;
54 class vtkFloatArray;
55 class vtkImageData;
56 class vtkMatrix4x4;
57 class vtkPoints;
58 class vtkPolyData;
60 
61 class VTKIOGEOMETRY_EXPORT vtkGLTFDocumentLoader : public vtkObject
62 {
63 public:
66  void PrintSelf(ostream& os, vtkIndent indent) override;
67 
71  enum class Target : unsigned short
72  {
73  ARRAY_BUFFER = 34962,
74  ELEMENT_ARRAY_BUFFER = 34963
75  };
76 
81  enum class AccessorType : unsigned char
82  {
83  SCALAR,
84  VEC2,
85  VEC3,
86  VEC4,
87  MAT2,
88  MAT3,
89  MAT4,
90  INVALID
91  };
92 
97  enum class ComponentType : unsigned short
98  {
99  BYTE = 5120,
100  UNSIGNED_BYTE = 5121,
101  SHORT = 5122,
102  UNSIGNED_SHORT = 5123,
103  UNSIGNED_INT = 5125,
104  FLOAT = 5126
105  };
106 
107  /* The following structs help deserialize a glTF document, representing each object. As such,
108  * their members mostly match with the specification. Default values and boundaries are set
109  * according to the specification.
110  * Most of these structs contain a name property, which is optional, and, while being loaded, is
111  * not currently exploited by the loader.
112  * They are mostly root-level properties, and once created, are stored into vectors in the Model
113  * structure.
114  */
115 
120  struct BufferView
121  {
122  int Buffer;
126  int Target;
128  };
129 
136  struct Accessor
137  {
142  struct Sparse
143  {
144  int Count;
150  };
155  int Count;
156  unsigned int NumberOfComponents;
158  std::vector<double> Max;
159  std::vector<double> Min;
160  bool IsSparse;
163  };
164 
171  struct MorphTarget
172  {
173  // accessor indices from the .gltf file, the map's keys correspond to attribute names
174  std::map<std::string, int> AttributeIndices;
175  // attribute values
176  std::map<std::string, vtkSmartPointer<vtkFloatArray>> AttributeValues;
177  };
178 
186  struct Primitive
187  {
188  // accessor indices from the .glTF file, the map's keys correspond to attribute names
189  std::map<std::string, int> AttributeIndices;
192 
193  // attribute values from buffer data
194  std::map<std::string, vtkSmartPointer<vtkDataArray>> AttributeValues;
195 
197 
198  std::vector<MorphTarget> Targets;
199 
200  int Material;
201  int Mode;
202  int CellSize; // 1, 2 or 3, depending on draw mode
203  };
204 
211  struct Node
212  {
213  std::vector<int> Children;
214  int Camera;
215  int Mesh;
216  int Skin;
217 
220 
221  bool TRSLoaded;
222 
224 
225  std::vector<float> InitialRotation;
226  std::vector<float> InitialTranslation;
227  std::vector<float> InitialScale;
228  std::vector<float> InitialWeights;
229  std::vector<float> Rotation;
230  std::vector<float> Translation;
231  std::vector<float> Scale;
232  std::vector<float> Weights;
233 
234  // Object-specific extension metadata
235  struct Extensions
236  {
237  // KHR_lights_punctual extension
239  {
240  int Light = -1;
241  };
243  };
245 
247 
249  };
250 
255  struct Mesh
256  {
257  std::vector<struct Primitive> Primitives;
258  std::vector<float> Weights;
260  };
261 
267  struct TextureInfo
268  {
269  int Index = -1;
270  int TexCoord;
271  };
272 
277  struct Image
278  {
282 
284 
286  };
287 
294  struct Material
295  {
296  enum class AlphaModeType : unsigned char
297  {
298  OPAQUE,
299  MASK,
300  BLEND
301  };
302 
304  {
306  std::vector<double> BaseColorFactor;
307 
311  };
312 
314 
320  std::vector<double> EmissiveFactor;
321 
323  double AlphaCutoff;
324 
326 
328 
329  // extension KHR_materials_unlit
330  bool Unlit;
331  };
332 
337  struct Texture
338  {
339  int Sampler;
340  int Source;
342  };
343 
348  struct Sampler
349  {
350  enum FilterType : unsigned short
351  {
352  NEAREST = 9728,
353  LINEAR = 9729,
354  NEAREST_MIPMAP_NEAREST = 9984,
355  LINEAR_MIPMAP_NEAREST = 9985,
356  NEAREST_MIPMAP_LINEAR = 9986,
357  LINEAR_MIPMAP_LINEAR = 9987
358  };
359  enum WrapType : unsigned short
360  {
361  CLAMP_TO_EDGE = 33071,
362  MIRRORED_REPEAT = 33648,
363  REPEAT = 10497
364  };
370  };
371 
377  struct Scene
378  {
379  std::vector<unsigned int> Nodes;
381  };
382 
388  struct Skin
389  {
390  std::vector<vtkSmartPointer<vtkMatrix4x4>> InverseBindMatrices;
391  std::vector<int> Joints;
393  int Skeleton;
395  };
396 
403  struct Animation
404  {
405  struct Sampler
406  {
407  enum class InterpolationMode : unsigned char
408  {
409  LINEAR,
410  STEP,
411  CUBICSPLINE
412  };
414  unsigned int Input;
415  unsigned int Output;
417 
420 
424  void GetInterpolatedData(float t, size_t numberOfComponents, std::vector<float>* output,
425  bool forceStep = false, bool isRotation = false) const;
426  };
427 
428  struct Channel
429  {
430  enum class PathType : unsigned char
431  {
432  ROTATION,
433  TRANSLATION,
434  SCALE,
435  WEIGHTS
436  };
437  int Sampler;
440  };
441 
442  float Duration; // In seconds
443  std::vector<Animation::Channel> Channels;
444  std::vector<Animation::Sampler> Samplers;
446  };
447 
453  struct Camera
454  {
455  // common properties
456  double Znear;
457  double Zfar;
458  bool IsPerspective; // if not, camera mode is orthographic
459  // perspective
460  double Xmag;
461  double Ymag;
462  // orthographic
463  double Yfov;
464  double AspectRatio;
466  };
467 
474  struct Extensions
475  {
476  // KHR_lights_punctual extension
478  {
479  struct Light
480  {
481  enum class LightType : unsigned char
482  {
483  DIRECTIONAL,
484  POINT,
485  SPOT
486  };
488 
489  std::vector<double> Color;
490  double Intensity;
491  double Range;
492 
493  // Type-specific parameters
496 
498  };
499  std::vector<Light> Lights;
500  };
502  };
503 
507  struct Model
508  {
509  std::vector<Accessor> Accessors;
510  std::vector<Animation> Animations;
511  std::vector<std::vector<char>> Buffers;
512  std::vector<BufferView> BufferViews;
513  std::vector<Camera> Cameras;
514  std::vector<Image> Images;
515  std::vector<Material> Materials;
516  std::vector<Mesh> Meshes;
517  std::vector<Node> Nodes;
518  std::vector<Sampler> Samplers;
519  std::vector<Scene> Scenes;
520  std::vector<Skin> Skins;
521  std::vector<Texture> Textures;
522 
524 
528  };
529 
534  bool ApplyAnimation(float t, int animationId, bool forceStep = false);
535 
539  void ResetAnimation(int animationId);
540 
545  bool LoadFileBuffer(VTK_FILEPATH const std::string& fileName, std::vector<char>& glbBuffer);
546 
552 
556  bool LoadModelData(const std::vector<char>& glbBuffer);
557 
562 
566  std::shared_ptr<Model> GetInternalModel();
567 
572 
576  const std::vector<std::string>& GetSupportedExtensions();
577 
581  const std::vector<std::string>& GetUsedExtensions();
582 
589  void BuildGlobalTransforms(unsigned int nodeIndex, vtkSmartPointer<vtkMatrix4x4> parentTransform);
590 
595 
599  static void ComputeJointMatrices(const Model& model, const Skin& skin, Node& node,
601 
602 protected:
604  ~vtkGLTFDocumentLoader() override = default;
605 
606 private:
607  struct AccessorLoadingWorker;
608 
609  struct SparseAccessorLoadingWorker;
610 
611  template <typename Type>
612  struct BufferDataExtractionWorker;
613 
615  void operator=(const vtkGLTFDocumentLoader&) = delete;
616 
620  bool LoadSkinMatrixData();
621 
626  bool ExtractPrimitiveAttributes(Primitive& primitive);
627 
634  bool ExtractPrimitiveAccessorData(Primitive& primitive);
635 
640  bool BuildPolyDataFromPrimitive(Primitive& primitive);
641 
645  bool LoadAnimationData();
646 
650  bool LoadImageData();
651 
652  std::shared_ptr<Model> InternalModel;
653 
654  static const std::vector<std::string> SupportedExtensions;
655  std::vector<std::string> UsedExtensions;
656 };
657 
658 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:143
vtkGLTFDocumentLoader::Primitive::Material
int Material
Definition: vtkGLTFDocumentLoader.h:200
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:497
vtkGLTFDocumentLoader::Node::InitialScale
std::vector< float > InitialScale
Definition: vtkGLTFDocumentLoader.h:227
vtkGLTFDocumentLoader::ComputeJointMatrices
static void ComputeJointMatrices(const Model &model, const Skin &skin, Node &node, std::vector< vtkSmartPointer< vtkMatrix4x4 >> &jointMats)
Compute all joint matrices of the skin of a specific node.
vtkGLTFDocumentLoader::Node::Translation
std::vector< float > Translation
Definition: vtkGLTFDocumentLoader.h:230
vtkGLTFDocumentLoader::Model::Images
std::vector< Image > Images
Definition: vtkGLTFDocumentLoader.h:514
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Lights
std::vector< Light > Lights
Definition: vtkGLTFDocumentLoader.h:499
vtkGLTFDocumentLoader::Scene::Nodes
std::vector< unsigned int > Nodes
Definition: vtkGLTFDocumentLoader.h:379
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light::Type
LightType Type
Definition: vtkGLTFDocumentLoader.h:487
vtkGLTFDocumentLoader::Node::ExtensionMetaData
Node::Extensions ExtensionMetaData
Definition: vtkGLTFDocumentLoader.h:244
vtkGLTFDocumentLoader::Model::Animations
std::vector< Animation > Animations
Definition: vtkGLTFDocumentLoader.h:510
vtkX3D::vector
@ vector
Definition: vtkX3D.h:243
vtkGLTFDocumentLoader::Model::Textures
std::vector< Texture > Textures
Definition: vtkGLTFDocumentLoader.h:521
vtkGLTFDocumentLoader::Animation::Sampler::InputData
vtkSmartPointer< vtkFloatArray > InputData
Definition: vtkGLTFDocumentLoader.h:418
vtkGLTFDocumentLoader::Material::AlphaModeType
AlphaModeType
Definition: vtkGLTFDocumentLoader.h:297
vtkGLTFDocumentLoader::Animation
This struct describes a glTF animation object.
Definition: vtkGLTFDocumentLoader.h:404
vtkGLTFDocumentLoader::Image::MimeType
std::string MimeType
Definition: vtkGLTFDocumentLoader.h:280
vtkGLTFDocumentLoader::Sampler::FilterType
FilterType
Definition: vtkGLTFDocumentLoader.h:351
vtkGLTFDocumentLoader::Animation::Channel::TargetPath
PathType TargetPath
Definition: vtkGLTFDocumentLoader.h:439
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual
Definition: vtkGLTFDocumentLoader.h:478
vtkGLTFDocumentLoader::Node::GlobalTransform
vtkSmartPointer< vtkMatrix4x4 > GlobalTransform
Definition: vtkGLTFDocumentLoader.h:219
vtkGLTFDocumentLoader::Mesh::Weights
std::vector< float > Weights
Definition: vtkGLTFDocumentLoader.h:258
vtkGLTFDocumentLoader::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkGLTFDocumentLoader::Camera::Znear
double Znear
Definition: vtkGLTFDocumentLoader.h:456
vtkGLTFDocumentLoader::GetNumberOfComponentsForType
static unsigned int GetNumberOfComponentsForType(vtkGLTFDocumentLoader::AccessorType type)
Returns the number of components for a given accessor type.
vtkGLTFDocumentLoader::Accessor::Normalized
bool Normalized
Definition: vtkGLTFDocumentLoader.h:154
vtkGLTFDocumentLoader::Skin
This struct describes a glTF asset.
Definition: vtkGLTFDocumentLoader.h:389
VTK_FILEPATH
#define VTK_FILEPATH
Definition: vtkWrappingHints.h:46
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light::SpotInnerConeAngle
double SpotInnerConeAngle
Definition: vtkGLTFDocumentLoader.h:494
vtkX3D::type
@ type
Definition: vtkX3D.h:522
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light::Color
std::vector< double > Color
Definition: vtkGLTFDocumentLoader.h:489
vtkGLTFDocumentLoader::Animation::Samplers
std::vector< Animation::Sampler > Samplers
Definition: vtkGLTFDocumentLoader.h:444
vtkUnsignedShortArray
dynamic, self-adjusting array of unsigned short
Definition: vtkUnsignedShortArray.h:40
vtkGLTFDocumentLoader::Animation::Sampler::Interpolation
InterpolationMode Interpolation
Definition: vtkGLTFDocumentLoader.h:413
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:145
vtkGLTFDocumentLoader::Scene
This struct describes a glTF scene object.
Definition: vtkGLTFDocumentLoader.h:378
vtkGLTFDocumentLoader::ResetAnimation
void ResetAnimation(int animationId)
Restore the transforms that were modified by an animation to their initial state.
vtkGLTFDocumentLoader::Sampler::WrapS
WrapType WrapS
Definition: vtkGLTFDocumentLoader.h:367
vtkGLTFDocumentLoader::Model::Cameras
std::vector< Camera > Cameras
Definition: vtkGLTFDocumentLoader.h:513
vtkGLTFDocumentLoader::Sampler::WrapT
WrapType WrapT
Definition: vtkGLTFDocumentLoader.h:368
vtkGLTFDocumentLoader::Animation::Channels
std::vector< Animation::Channel > Channels
Definition: vtkGLTFDocumentLoader.h:443
vtkGLTFDocumentLoader::Camera::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:465
vtkGLTFDocumentLoader::Camera::Xmag
double Xmag
Definition: vtkGLTFDocumentLoader.h:460
vtkGLTFDocumentLoader::Node::Matrix
vtkSmartPointer< vtkMatrix4x4 > Matrix
Definition: vtkGLTFDocumentLoader.h:223
vtkGLTFDocumentLoader::TextureInfo
This struct describes a glTF textureInfo object, mostly used in material descriptions They contain tw...
Definition: vtkGLTFDocumentLoader.h:268
vtkGLTFDocumentLoader::Material::Unlit
bool Unlit
Definition: vtkGLTFDocumentLoader.h:330
vtkGLTFDocumentLoader::Node::UpdateTransform
void UpdateTransform()
vtkGLTFDocumentLoader::Node::InitialTranslation
std::vector< float > InitialTranslation
Definition: vtkGLTFDocumentLoader.h:226
vtkGLTFDocumentLoader::TextureInfo::TexCoord
int TexCoord
Definition: vtkGLTFDocumentLoader.h:270
vtkGLTFDocumentLoader::Primitive::Geometry
vtkSmartPointer< vtkPolyData > Geometry
Definition: vtkGLTFDocumentLoader.h:196
vtkGLTFDocumentLoader::Material::OcclusionTexture
TextureInfo OcclusionTexture
Definition: vtkGLTFDocumentLoader.h:317
vtkGLTFDocumentLoader::Node::Mesh
int Mesh
Definition: vtkGLTFDocumentLoader.h:215
vtkSmartPointer< vtkCellArray >
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:82
vtkGLTFDocumentLoader::Model::Scenes
std::vector< Scene > Scenes
Definition: vtkGLTFDocumentLoader.h:519
vtkGLTFDocumentLoader::Primitive::Targets
std::vector< MorphTarget > Targets
Definition: vtkGLTFDocumentLoader.h:198
vtkGLTFDocumentLoader::Camera::Ymag
double Ymag
Definition: vtkGLTFDocumentLoader.h:461
vtkGLTFDocumentLoader::Animation::Channel::Sampler
int Sampler
Definition: vtkGLTFDocumentLoader.h:437
vtkGLTFDocumentLoader::Animation::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:445
vtkGLTFDocumentLoader::vtkGLTFDocumentLoader
vtkGLTFDocumentLoader()=default
vtkGLTFDocumentLoader::Texture::Source
int Source
Definition: vtkGLTFDocumentLoader.h:340
vtkGLTFDocumentLoader::Skin::Joints
std::vector< int > Joints
Definition: vtkGLTFDocumentLoader.h:391
vtkGLTFDocumentLoader::Image::Uri
std::string Uri
Definition: vtkGLTFDocumentLoader.h:281
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
vtkGLTFDocumentLoader::Image::ImageData
vtkSmartPointer< vtkImageData > ImageData
Definition: vtkGLTFDocumentLoader.h:283
vtkGLTFDocumentLoader::Material::EmissiveTexture
TextureInfo EmissiveTexture
Definition: vtkGLTFDocumentLoader.h:319
vtkGLTFDocumentLoader::Model::Buffers
std::vector< std::vector< char > > Buffers
Definition: vtkGLTFDocumentLoader.h:511
vtkGLTFDocumentLoader::Texture::Sampler
int Sampler
Definition: vtkGLTFDocumentLoader.h:339
vtkGLTFDocumentLoader::Primitive::Indices
vtkSmartPointer< vtkCellArray > Indices
Definition: vtkGLTFDocumentLoader.h:191
vtkGLTFDocumentLoader::Model::Materials
std::vector< Material > Materials
Definition: vtkGLTFDocumentLoader.h:515
vtkGLTFDocumentLoader::Extensions
This struct contains extension metadata.
Definition: vtkGLTFDocumentLoader.h:475
vtkGLTFDocumentLoader::Animation::Channel
Definition: vtkGLTFDocumentLoader.h:429
vtkGLTFDocumentLoader::Accessor::NumberOfComponents
unsigned int NumberOfComponents
Definition: vtkGLTFDocumentLoader.h:156
vtkGLTFDocumentLoader::BufferView::Target
int Target
Definition: vtkGLTFDocumentLoader.h:126
vtkGLTFDocumentLoader::Node::InitialWeights
std::vector< float > InitialWeights
Definition: vtkGLTFDocumentLoader.h:228
vtkGLTFDocumentLoader::Material::OcclusionTextureStrength
double OcclusionTextureStrength
Definition: vtkGLTFDocumentLoader.h:318
vtkGLTFDocumentLoader::LoadModelData
bool LoadModelData(const std::vector< char > &glbBuffer)
Load buffer data into the internal Model.
vtkGLTFDocumentLoader::Camera::Zfar
double Zfar
Definition: vtkGLTFDocumentLoader.h:457
vtkGLTFDocumentLoader::Node::Children
std::vector< int > Children
Definition: vtkGLTFDocumentLoader.h:213
vtkGLTFDocumentLoader::Mesh::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:259
vtkGLTFDocumentLoader::Model
This struct contains all data from a gltf asset.
Definition: vtkGLTFDocumentLoader.h:508
vtkGLTFDocumentLoader::GetSupportedExtensions
const std::vector< std::string > & GetSupportedExtensions()
Get the list of extensions that are supported by this loader.
vtkGLTFDocumentLoader::Node::Transform
vtkSmartPointer< vtkMatrix4x4 > Transform
Definition: vtkGLTFDocumentLoader.h:218
vtkGLTFDocumentLoader::Sampler::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:369
vtkGLTFDocumentLoader::Material::PbrMetallicRoughness::MetallicFactor
float MetallicFactor
Definition: vtkGLTFDocumentLoader.h:309
vtkGLTFDocumentLoader::Texture::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:341
vtkGLTFDocumentLoader::Primitive::AttributeIndices
std::map< std::string, int > AttributeIndices
Definition: vtkGLTFDocumentLoader.h:189
vtkGLTFDocumentLoader::Node::Rotation
std::vector< float > Rotation
Definition: vtkGLTFDocumentLoader.h:229
vtkGLTFDocumentLoader::Model::DefaultScene
int DefaultScene
Definition: vtkGLTFDocumentLoader.h:526
vtkGLTFDocumentLoader::Primitive::AttributeValues
std::map< std::string, vtkSmartPointer< vtkDataArray > > AttributeValues
Definition: vtkGLTFDocumentLoader.h:194
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light::LightType
LightType
Definition: vtkGLTFDocumentLoader.h:482
vtkGLTFDocumentLoader::Model::BufferMetaData
std::string BufferMetaData
Definition: vtkGLTFDocumentLoader.h:525
vtkGLTFDocumentLoader::Material::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:327
vtkGLTFDocumentLoader::Animation::Duration
float Duration
Definition: vtkGLTFDocumentLoader.h:442
vtkGLTFDocumentLoader::Model::FileName
std::string FileName
Definition: vtkGLTFDocumentLoader.h:527
vtkGLTFDocumentLoader::Accessor::Sparse::Count
int Count
Definition: vtkGLTFDocumentLoader.h:144
vtkGLTFDocumentLoader::Material::PbrMetallicRoughness::BaseColorTexture
TextureInfo BaseColorTexture
Definition: vtkGLTFDocumentLoader.h:305
vtkGLTFDocumentLoader::Target
Target
Define an openGL draw target.
Definition: vtkGLTFDocumentLoader.h:72
vtkGLTFDocumentLoader::Model::BufferViews
std::vector< BufferView > BufferViews
Definition: vtkGLTFDocumentLoader.h:512
vtkGLTFDocumentLoader::Node::Extensions::KHRLightsPunctualMetaData
Node::Extensions::KHRLightsPunctual KHRLightsPunctualMetaData
Definition: vtkGLTFDocumentLoader.h:242
vtkGLTFDocumentLoader::GetInternalModel
std::shared_ptr< Model > GetInternalModel()
Get the internal Model.
vtkGLTFDocumentLoader::Accessor::ComponentTypeValue
ComponentType ComponentTypeValue
Definition: vtkGLTFDocumentLoader.h:153
vtkGLTFDocumentLoader::BuildGlobalTransforms
void BuildGlobalTransforms()
Build all global transforms.
vtkGLTFDocumentLoader::Accessor::ByteOffset
int ByteOffset
Definition: vtkGLTFDocumentLoader.h:152
vtkGLTFDocumentLoader::Node::Camera
int Camera
Definition: vtkGLTFDocumentLoader.h:214
vtkGLTFDocumentLoader::Animation::Sampler::Input
unsigned int Input
Definition: vtkGLTFDocumentLoader.h:414
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light::Intensity
double Intensity
Definition: vtkGLTFDocumentLoader.h:490
vtkGLTFDocumentLoader::Texture
This struct describes a glTF texture object.
Definition: vtkGLTFDocumentLoader.h:338
vtkGLTFDocumentLoader::Image::BufferView
int BufferView
Definition: vtkGLTFDocumentLoader.h:279
vtkGLTFDocumentLoader::Material::AlphaCutoff
double AlphaCutoff
Definition: vtkGLTFDocumentLoader.h:323
vtkGLTFDocumentLoader::Material
This struct describes a glTF material object.
Definition: vtkGLTFDocumentLoader.h:295
vtkGLTFDocumentLoader::Node::InitialRotation
std::vector< float > InitialRotation
Definition: vtkGLTFDocumentLoader.h:225
vtkGLTFDocumentLoader::Mesh::Primitives
std::vector< struct Primitive > Primitives
Definition: vtkGLTFDocumentLoader.h:257
vtkGLTFDocumentLoader::Model::Accessors
std::vector< Accessor > Accessors
Definition: vtkGLTFDocumentLoader.h:509
vtkGLTFDocumentLoader::Node::Scale
std::vector< float > Scale
Definition: vtkGLTFDocumentLoader.h:231
vtkGLTFDocumentLoader::Animation::Sampler::OutputData
vtkSmartPointer< vtkFloatArray > OutputData
Definition: vtkGLTFDocumentLoader.h:419
vtkGLTFDocumentLoader::Animation::Sampler::NumberOfComponents
int NumberOfComponents
Definition: vtkGLTFDocumentLoader.h:416
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:157
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:145
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:290
vtkGLTFDocumentLoader::Accessor
This struct describes an accessor glTF object.
Definition: vtkGLTFDocumentLoader.h:137
vtkGLTFDocumentLoader::MorphTarget::AttributeIndices
std::map< std::string, int > AttributeIndices
Definition: vtkGLTFDocumentLoader.h:174
vtkGLTFDocumentLoader::Node::Extensions
Definition: vtkGLTFDocumentLoader.h:236
vtkSmartPointer.h
vtkGLTFDocumentLoader::Primitive::CellSize
int CellSize
Definition: vtkGLTFDocumentLoader.h:202
vtkGLTFDocumentLoader::BufferView
This struct describes a glTF bufferView object.
Definition: vtkGLTFDocumentLoader.h:121
vtkGLTFDocumentLoader::Material::DoubleSided
bool DoubleSided
Definition: vtkGLTFDocumentLoader.h:325
vtkGLTFDocumentLoader::Node::Extensions::KHRLightsPunctual
Definition: vtkGLTFDocumentLoader.h:239
vtkGLTFDocumentLoader::Model::Skins
std::vector< Skin > Skins
Definition: vtkGLTFDocumentLoader.h:520
vtkGLTFDocumentLoader::Model::Meshes
std::vector< Mesh > Meshes
Definition: vtkGLTFDocumentLoader.h:516
vtkGLTFDocumentLoader::Image
This struct describes a glTF image object.
Definition: vtkGLTFDocumentLoader.h:278
vtkGLTFDocumentLoader::MorphTarget
This struct describes a glTF Morph Target object.
Definition: vtkGLTFDocumentLoader.h:172
vtkGLTFDocumentLoader::Accessor::Min
std::vector< double > Min
Definition: vtkGLTFDocumentLoader.h:159
vtkGLTFDocumentLoader::BufferView::ByteOffset
int ByteOffset
Definition: vtkGLTFDocumentLoader.h:123
vtkGLTFDocumentLoader::Camera::Yfov
double Yfov
Definition: vtkGLTFDocumentLoader.h:463
vtkGLTFDocumentLoader::Accessor::Sparse::ValuesBufferView
int ValuesBufferView
Definition: vtkGLTFDocumentLoader.h:148
vtkGLTFDocumentLoader::Accessor::Sparse::ValuesByteOffset
int ValuesByteOffset
Definition: vtkGLTFDocumentLoader.h:149
vtkGLTFDocumentLoader::Material::PbrMetallicRoughness::MetallicRoughnessTexture
TextureInfo MetallicRoughnessTexture
Definition: vtkGLTFDocumentLoader.h:308
vtkObject.h
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light::SpotOuterConeAngle
double SpotOuterConeAngle
Definition: vtkGLTFDocumentLoader.h:495
vtkGLTFDocumentLoader::Accessor::Sparse
This struct describes an accessor.sparse glTF object.
Definition: vtkGLTFDocumentLoader.h:143
vtkGLTFDocumentLoader::Accessor::Sparse::IndicesComponentType
ComponentType IndicesComponentType
Definition: vtkGLTFDocumentLoader.h:147
vtkGLTFDocumentLoader::Skin::Skeleton
int Skeleton
Definition: vtkGLTFDocumentLoader.h:393
vtkGLTFDocumentLoader::MorphTarget::AttributeValues
std::map< std::string, vtkSmartPointer< vtkFloatArray > > AttributeValues
Definition: vtkGLTFDocumentLoader.h:176
vtkGLTFDocumentLoader::Accessor::IsSparse
bool IsSparse
Definition: vtkGLTFDocumentLoader.h:160
vtkX3D::string
@ string
Definition: vtkX3D.h:496
vtkGLTFDocumentLoader::Model::ExtensionMetaData
Extensions ExtensionMetaData
Definition: vtkGLTFDocumentLoader.h:523
vtkGLTFDocumentLoader::Material::PbrMetallicRoughness::RoughnessFactor
float RoughnessFactor
Definition: vtkGLTFDocumentLoader.h:310
vtkGLTFDocumentLoader::ApplyAnimation
bool ApplyAnimation(float t, int animationId, bool forceStep=false)
Apply the specified animation, at the specified time, to the internal Model.
vtkGLTFDocumentLoader::AccessorType
AccessorType
Defines an accessor's type.
Definition: vtkGLTFDocumentLoader.h:82
vtkGLTFDocumentLoader::Node::Weights
std::vector< float > Weights
Definition: vtkGLTFDocumentLoader.h:232
vtkGLTFDocumentLoader::Accessor::SparseObject
Sparse SparseObject
Definition: vtkGLTFDocumentLoader.h:161
vtkGLTFDocumentLoader::Node
This struct describes a glTF node object.
Definition: vtkGLTFDocumentLoader.h:212
vtkGLTFDocumentLoader::Camera
This struct describes a glTF camera object.
Definition: vtkGLTFDocumentLoader.h:454
vtkGLTFDocumentLoader::Material::PbrMetallicRoughness
PbrMetallicRoughness PbrMetallicRoughness
Definition: vtkGLTFDocumentLoader.h:313
vtkGLTFDocumentLoader::Material::PbrMetallicRoughness
Definition: vtkGLTFDocumentLoader.h:304
vtkGLTFDocumentLoader::BuildModelVTKGeometry
bool BuildModelVTKGeometry()
Converts the internal Model's loaded data into more convenient vtk objects.
vtkGLTFDocumentLoader::New
static vtkGLTFDocumentLoader * New()
vtkGLTFDocumentLoader::Sampler::WrapType
WrapType
Definition: vtkGLTFDocumentLoader.h:360
vtkGLTFDocumentLoader
Deserialize a GLTF model file.
Definition: vtkGLTFDocumentLoader.h:62
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light::Range
double Range
Definition: vtkGLTFDocumentLoader.h:491
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctualMetaData
KHRLightsPunctual KHRLightsPunctualMetaData
Definition: vtkGLTFDocumentLoader.h:501
vtkGLTFDocumentLoader::GetUsedExtensions
const std::vector< std::string > & GetUsedExtensions()
Get the list of extensions that are used by the current model.
vtkGLTFDocumentLoader::Mesh
This struct describes a glTF mesh object.
Definition: vtkGLTFDocumentLoader.h:256
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:195
vtkGLTFDocumentLoader::BufferView::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:127
vtkGLTFDocumentLoader::Sampler
This struct describes a glTF sampler object.
Definition: vtkGLTFDocumentLoader.h:349
vtkGLTFDocumentLoader::Camera::AspectRatio
double AspectRatio
Definition: vtkGLTFDocumentLoader.h:464
vtkGLTFDocumentLoader::Camera::IsPerspective
bool IsPerspective
Definition: vtkGLTFDocumentLoader.h:458
vtkGLTFDocumentLoader::Primitive::Mode
int Mode
Definition: vtkGLTFDocumentLoader.h:201
vtkGLTFDocumentLoader::Material::NormalTexture
TextureInfo NormalTexture
Definition: vtkGLTFDocumentLoader.h:315
vtkGLTFDocumentLoader::Node::Skin
int Skin
Definition: vtkGLTFDocumentLoader.h:216
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light
Definition: vtkGLTFDocumentLoader.h:480
vtkGLTFDocumentLoader::Material::AlphaMode
AlphaModeType AlphaMode
Definition: vtkGLTFDocumentLoader.h:322
vtkGLTFDocumentLoader::Image::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:285
vtkGLTFDocumentLoader::BufferView::ByteLength
int ByteLength
Definition: vtkGLTFDocumentLoader.h:124
vtkGLTFDocumentLoader::Accessor::Type
AccessorType Type
Definition: vtkGLTFDocumentLoader.h:157
vtkGLTFDocumentLoader::Model::Nodes
std::vector< Node > Nodes
Definition: vtkGLTFDocumentLoader.h:517
vtkGLTFDocumentLoader::Primitive
This struct describes a glTF primitive object.
Definition: vtkGLTFDocumentLoader.h:187
vtkGLTFDocumentLoader::ComponentType
ComponentType
Define a type for different data components.
Definition: vtkGLTFDocumentLoader.h:98
vtkGLTFDocumentLoader::Animation::Channel::PathType
PathType
Definition: vtkGLTFDocumentLoader.h:431
vtkGLTFDocumentLoader::Accessor::Max
std::vector< double > Max
Definition: vtkGLTFDocumentLoader.h:158
vtkGLTFDocumentLoader::BufferView::ByteStride
int ByteStride
Definition: vtkGLTFDocumentLoader.h:125
vtkGLTFDocumentLoader::Accessor::Sparse::IndicesBufferView
int IndicesBufferView
Definition: vtkGLTFDocumentLoader.h:145
vtkGLTFDocumentLoader::Accessor::Count
int Count
Definition: vtkGLTFDocumentLoader.h:155
vtkGLTFDocumentLoader::Material::EmissiveFactor
std::vector< double > EmissiveFactor
Definition: vtkGLTFDocumentLoader.h:320
vtkGLTFDocumentLoader::Model::Samplers
std::vector< Sampler > Samplers
Definition: vtkGLTFDocumentLoader.h:518
vtkGLTFDocumentLoader::Node::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:246
vtkGLTFDocumentLoader::Skin::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:394
vtkGLTFDocumentLoader::BufferView::Buffer
int Buffer
Definition: vtkGLTFDocumentLoader.h:122
vtkGLTFDocumentLoader::BuildGlobalTransforms
void BuildGlobalTransforms(unsigned int nodeIndex, vtkSmartPointer< vtkMatrix4x4 > parentTransform)
Concatenate the current node's local transform to its parent's global transform, storing the resultin...
vtkGLTFDocumentLoader::Skin::InverseBindMatricesAccessorId
int InverseBindMatricesAccessorId
Definition: vtkGLTFDocumentLoader.h:392
vtkGLTFDocumentLoader::LoadFileBuffer
bool LoadFileBuffer(VTK_FILEPATH const std::string &fileName, std::vector< char > &glbBuffer)
Load the binary part of a binary glTF (.glb) file.
vtkGLTFDocumentLoader::Primitive::IndicesId
int IndicesId
Definition: vtkGLTFDocumentLoader.h:190
vtkGLTFDocumentLoader::Accessor::Sparse::IndicesByteOffset
int IndicesByteOffset
Definition: vtkGLTFDocumentLoader.h:146
vtkGLTFDocumentLoader::Animation::Sampler::Output
unsigned int Output
Definition: vtkGLTFDocumentLoader.h:415
vtkGLTFDocumentLoader::Material::PbrMetallicRoughness::BaseColorFactor
std::vector< double > BaseColorFactor
Definition: vtkGLTFDocumentLoader.h:306
vtkGLTFDocumentLoader::Skin::InverseBindMatrices
std::vector< vtkSmartPointer< vtkMatrix4x4 > > InverseBindMatrices
Definition: vtkGLTFDocumentLoader.h:390
vtkGLTFDocumentLoader::Sampler::MinFilter
FilterType MinFilter
Definition: vtkGLTFDocumentLoader.h:366
vtkGLTFDocumentLoader::Animation::Sampler
Definition: vtkGLTFDocumentLoader.h:406
vtkGLTFDocumentLoader::Node::TRSLoaded
bool TRSLoaded
Definition: vtkGLTFDocumentLoader.h:221
vtkGLTFDocumentLoader::Animation::Channel::TargetNode
int TargetNode
Definition: vtkGLTFDocumentLoader.h:438
vtkGLTFDocumentLoader::Animation::Sampler::GetInterpolatedData
void GetInterpolatedData(float t, size_t numberOfComponents, std::vector< float > *output, bool forceStep=false, bool isRotation=false) const
Get the interpolated animation output at time t.
vtkGLTFDocumentLoader::~vtkGLTFDocumentLoader
~vtkGLTFDocumentLoader() override=default
vtkGLTFDocumentLoader::Accessor::BufferView
int BufferView
Definition: vtkGLTFDocumentLoader.h:151
vtkGLTFDocumentLoader::Scene::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:380
vtkGLTFDocumentLoader::Material::NormalTextureScale
double NormalTextureScale
Definition: vtkGLTFDocumentLoader.h:316
vtkGLTFDocumentLoader::Accessor::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:162
vtkGLTFDocumentLoader::Sampler::MagFilter
FilterType MagFilter
Definition: vtkGLTFDocumentLoader.h:365
vtkGLTFDocumentLoader::Animation::Sampler::InterpolationMode
InterpolationMode
Definition: vtkGLTFDocumentLoader.h:408
vtkGLTFDocumentLoader::LoadModelMetaDataFromFile
bool LoadModelMetaDataFromFile(std::string FileName)
Reset internal Model struct, and serialize glTF metadata (all json information) into it.