VTK  9.0.1
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 
37 #ifndef vtkGLTFDocumentLoader_h
38 #define vtkGLTFDocumentLoader_h
39 
40 #include "vtkIOGeometryModule.h" // For export macro
41 #include "vtkObject.h"
42 #include "vtkSmartPointer.h" // For SmartPointer
43 
44 #include <map> // For std::map
45 #include <memory> // For std::shared_ptr
46 #include <string> // For std::string
47 #include <vector> // For std::vector
48 
49 class vtkCellArray;
50 class vtkDataArray;
51 class vtkFloatArray;
52 class vtkImageData;
53 class vtkMatrix4x4;
54 class vtkPoints;
55 class vtkPolyData;
56 class vtkTransform;
58 
59 class VTKIOGEOMETRY_EXPORT vtkGLTFDocumentLoader : public vtkObject
60 {
61 public:
64  void PrintSelf(ostream& os, vtkIndent indent) override;
65 
69  enum class Target : unsigned short
70  {
71  ARRAY_BUFFER = 34962,
72  ELEMENT_ARRAY_BUFFER = 34963
73  };
74 
79  enum class AccessorType : unsigned char
80  {
81  SCALAR,
82  VEC2,
83  VEC3,
84  VEC4,
85  MAT2,
86  MAT3,
87  MAT4,
88  INVALID
89  };
90 
95  enum class ComponentType : unsigned short
96  {
97  BYTE = 5120,
98  UNSIGNED_BYTE = 5121,
99  SHORT = 5122,
100  UNSIGNED_SHORT = 5123,
101  UNSIGNED_INT = 5125,
102  FLOAT = 5126
103  };
104 
105  /* The following structs help deserialize a glTF document, representing each object. As such,
106  * their members mostly match with the specification. Default values and boundaries are set
107  * according to the specification.
108  * Most of these structs contain a name property, which is optional, and, while being loaded, is
109  * not currently exploited by the loader.
110  * They are mostly root-level properties, and once created, are stored into vectors in the Model
111  * structure.
112  */
113 
118  struct BufferView
119  {
120  int Buffer;
124  int Target;
126  };
127 
134  struct Accessor
135  {
140  struct Sparse
141  {
142  int Count;
148  };
153  int Count;
154  unsigned int NumberOfComponents;
156  std::vector<double> Max;
157  std::vector<double> Min;
158  bool IsSparse;
161  };
162 
169  struct MorphTarget
170  {
171  // accessor indices from the .gltf file, the map's keys correspond to attribute names
172  std::map<std::string, int> AttributeIndices;
173  // attribute values
174  std::map<std::string, vtkSmartPointer<vtkFloatArray> > AttributeValues;
175  };
176 
184  struct Primitive
185  {
186  // accessor indices from the .glTF file, the map's keys correspond to attribute names
187  std::map<std::string, int> AttributeIndices;
190 
191  // attribute values from buffer data
192  std::map<std::string, vtkSmartPointer<vtkDataArray> > AttributeValues;
193 
195 
196  std::vector<MorphTarget> Targets;
197 
198  int Material;
199  int Mode;
200  int CellSize; // 1, 2 or 3, depending on draw mode
201  };
202 
209  struct Node
210  {
211  std::vector<int> Children;
212  int Camera;
213  int Mesh;
214  int Skin;
215 
218 
219  bool TRSLoaded;
220 
222 
223  std::vector<float> InitialRotation;
224  std::vector<float> InitialTranslation;
225  std::vector<float> InitialScale;
226  std::vector<float> InitialWeights;
227  std::vector<float> Rotation;
228  std::vector<float> Translation;
229  std::vector<float> Scale;
230  std::vector<float> Weights;
231 
232  // Object-specific extension metadata
233  struct Extensions
234  {
235  // KHR_lights_punctual extension
237  {
238  int Light = -1;
239  };
241  };
243 
245 
247  };
248 
253  struct Mesh
254  {
255  std::vector<struct Primitive> Primitives;
256  std::vector<float> Weights;
258  };
259 
265  struct TextureInfo
266  {
267  int Index = -1;
268  int TexCoord;
269  };
270 
275  struct Image
276  {
280 
282 
284  };
285 
292  struct Material
293  {
294  enum class AlphaModeType : unsigned char
295  {
296  OPAQUE,
297  MASK,
298  BLEND
299  };
300 
302  {
304  std::vector<double> BaseColorFactor;
305 
309  };
310 
312 
318  std::vector<double> EmissiveFactor;
319 
321  double AlphaCutoff;
322 
324 
326  };
327 
332  struct Texture
333  {
334  int Sampler;
335  int Source;
337  };
338 
343  struct Sampler
344  {
345  enum FilterType : unsigned short
346  {
347  NEAREST = 9728,
348  LINEAR = 9729,
349  NEAREST_MIPMAP_NEAREST = 9984,
350  LINEAR_MIPMAP_NEAREST = 9985,
351  NEAREST_MIPMAP_LINEAR = 9986,
352  LINEAR_MIPMAP_LINEAR = 9987
353  };
354  enum WrapType : unsigned short
355  {
356  CLAMP_TO_EDGE = 33071,
357  MIRRORED_REPEAT = 33648,
358  REPEAT = 10497
359  };
365  };
366 
372  struct Scene
373  {
374  std::vector<unsigned int> Nodes;
376  };
377 
383  struct Skin
384  {
385  std::vector<vtkSmartPointer<vtkMatrix4x4> > InverseBindMatrices;
386  std::vector<int> Joints;
388  int Skeleton;
390  };
391 
398  struct Animation
399  {
400  struct Sampler
401  {
402  enum class InterpolationMode : unsigned char
403  {
404  LINEAR,
405  STEP,
406  CUBICSPLINE
407  };
409  unsigned int Input;
410  unsigned int Output;
412 
415 
419  void GetInterpolatedData(float t, size_t numberOfComponents, std::vector<float>* output,
420  bool forceStep = false, bool isRotation = false) const;
421  };
422 
423  struct Channel
424  {
425  enum class PathType : unsigned char
426  {
427  ROTATION,
428  TRANSLATION,
429  SCALE,
430  WEIGHTS
431  };
432  int Sampler;
435  };
436 
437  float Duration; // In seconds
438  std::vector<Animation::Channel> Channels;
439  std::vector<Animation::Sampler> Samplers;
441  };
442 
448  struct Camera
449  {
450  // common properties
451  double Znear;
452  double Zfar;
453  bool IsPerspective; // if not, camera mode is orthographic
454  // perspective
455  double Xmag;
456  double Ymag;
457  // orthographic
458  double Yfov;
459  double AspectRatio;
461  };
462 
469  struct Extensions
470  {
471  // KHR_lights_punctual extension
473  {
474  struct Light
475  {
476  enum class LightType : unsigned char
477  {
478  DIRECTIONAL,
479  POINT,
480  SPOT
481  };
483 
484  std::vector<double> Color;
485  double Intensity;
486  double Range;
487 
488  // Type-specific parameters
491 
493  };
494  std::vector<Light> Lights;
495  };
497  };
498 
502  struct Model
503  {
504  std::vector<Accessor> Accessors;
505  std::vector<Animation> Animations;
506  std::vector<std::vector<char> > Buffers;
507  std::vector<BufferView> BufferViews;
508  std::vector<Camera> Cameras;
509  std::vector<Image> Images;
510  std::vector<Material> Materials;
511  std::vector<Mesh> Meshes;
512  std::vector<Node> Nodes;
513  std::vector<Sampler> Samplers;
514  std::vector<Scene> Scenes;
515  std::vector<Skin> Skins;
516  std::vector<Texture> Textures;
517 
519 
523  };
524 
529  bool ApplyAnimation(float t, int animationId, bool forceStep = false);
530 
534  void ResetAnimation(int animationId);
535 
540  bool LoadFileBuffer(const std::string& fileName, std::vector<char>& glbBuffer);
541 
547 
551  bool LoadModelData(const std::vector<char>& glbBuffer);
552 
557 
561  std::shared_ptr<Model> GetInternalModel();
562 
567 
571  const std::vector<std::string>& GetSupportedExtensions();
572 
576  const std::vector<std::string>& GetUsedExtensions();
577 
578 protected:
580  ~vtkGLTFDocumentLoader() override = default;
581 
582 private:
583  struct AccessorLoadingWorker;
584 
585  struct SparseAccessorLoadingWorker;
586 
587  template <typename Type>
588  struct BufferDataExtractionWorker;
589 
591  void operator=(const vtkGLTFDocumentLoader&) = delete;
592 
596  bool LoadSkinMatrixData();
597 
602  bool ExtractPrimitiveAttributes(Primitive& primitive);
603 
610  bool ExtractPrimitiveAccessorData(Primitive& primitive);
611 
616  bool BuildPolyDataFromPrimitive(Primitive& primitive);
617 
621  bool LoadAnimationData();
622 
626  bool LoadImageData();
627 
634  void BuildGlobalTransforms(unsigned int nodeIndex, vtkSmartPointer<vtkTransform> parentTransform);
635 
636  std::shared_ptr<Model> InternalModel;
637 
638  static const std::vector<std::string> SupportedExtensions;
639  std::vector<std::string> UsedExtensions;
640 };
641 
642 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:34
vtkGLTFDocumentLoader::Primitive::Material
int Material
Definition: vtkGLTFDocumentLoader.h:198
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:492
vtkGLTFDocumentLoader::Node::InitialScale
std::vector< float > InitialScale
Definition: vtkGLTFDocumentLoader.h:225
vtkGLTFDocumentLoader::Node::Translation
std::vector< float > Translation
Definition: vtkGLTFDocumentLoader.h:228
vtkGLTFDocumentLoader::Model::Images
std::vector< Image > Images
Definition: vtkGLTFDocumentLoader.h:509
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Lights
std::vector< Light > Lights
Definition: vtkGLTFDocumentLoader.h:494
vtkGLTFDocumentLoader::Scene::Nodes
std::vector< unsigned int > Nodes
Definition: vtkGLTFDocumentLoader.h:374
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light::Type
LightType Type
Definition: vtkGLTFDocumentLoader.h:482
vtkGLTFDocumentLoader::Node::ExtensionMetaData
Node::Extensions ExtensionMetaData
Definition: vtkGLTFDocumentLoader.h:242
vtkGLTFDocumentLoader::Model::Animations
std::vector< Animation > Animations
Definition: vtkGLTFDocumentLoader.h:505
vtkGLTFDocumentLoader::Model::Textures
std::vector< Texture > Textures
Definition: vtkGLTFDocumentLoader.h:516
vtkGLTFDocumentLoader::Animation::Sampler::InputData
vtkSmartPointer< vtkFloatArray > InputData
Definition: vtkGLTFDocumentLoader.h:413
vtkGLTFDocumentLoader::Node::Transform
vtkSmartPointer< vtkTransform > Transform
Definition: vtkGLTFDocumentLoader.h:216
vtkGLTFDocumentLoader::Material::AlphaModeType
AlphaModeType
Definition: vtkGLTFDocumentLoader.h:295
vtkGLTFDocumentLoader::Animation
This struct describes a glTF animation object.
Definition: vtkGLTFDocumentLoader.h:399
vtkGLTFDocumentLoader::Image::MimeType
std::string MimeType
Definition: vtkGLTFDocumentLoader.h:278
vtkGLTFDocumentLoader::Node::GlobalTransform
vtkSmartPointer< vtkTransform > GlobalTransform
Definition: vtkGLTFDocumentLoader.h:217
vtkGLTFDocumentLoader::Sampler::FilterType
FilterType
Definition: vtkGLTFDocumentLoader.h:346
vtkGLTFDocumentLoader::Animation::Channel::TargetPath
PathType TargetPath
Definition: vtkGLTFDocumentLoader.h:434
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual
Definition: vtkGLTFDocumentLoader.h:473
vtkGLTFDocumentLoader::Mesh::Weights
std::vector< float > Weights
Definition: vtkGLTFDocumentLoader.h:256
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:451
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:152
vtkGLTFDocumentLoader::Skin
This struct describes a glTF asset.
Definition: vtkGLTFDocumentLoader.h:384
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light::SpotInnerConeAngle
double SpotInnerConeAngle
Definition: vtkGLTFDocumentLoader.h:489
vtkX3D::type
@ type
Definition: vtkX3D.h:522
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light::Color
std::vector< double > Color
Definition: vtkGLTFDocumentLoader.h:484
vtkGLTFDocumentLoader::Animation::Samplers
std::vector< Animation::Sampler > Samplers
Definition: vtkGLTFDocumentLoader.h:439
vtkUnsignedShortArray
dynamic, self-adjusting array of unsigned short
Definition: vtkUnsignedShortArray.h:40
vtkGLTFDocumentLoader::Animation::Sampler::Interpolation
InterpolationMode Interpolation
Definition: vtkGLTFDocumentLoader.h:408
vtkFloatArray
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:36
vtkGLTFDocumentLoader::Scene
This struct describes a glTF scene object.
Definition: vtkGLTFDocumentLoader.h:373
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:362
vtkGLTFDocumentLoader::Model::Cameras
std::vector< Camera > Cameras
Definition: vtkGLTFDocumentLoader.h:508
vtkGLTFDocumentLoader::Sampler::WrapT
WrapType WrapT
Definition: vtkGLTFDocumentLoader.h:363
vtkGLTFDocumentLoader::Animation::Channels
std::vector< Animation::Channel > Channels
Definition: vtkGLTFDocumentLoader.h:438
vtkGLTFDocumentLoader::Camera::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:460
vtkGLTFDocumentLoader::Camera::Xmag
double Xmag
Definition: vtkGLTFDocumentLoader.h:455
vtkGLTFDocumentLoader::Node::Matrix
vtkSmartPointer< vtkMatrix4x4 > Matrix
Definition: vtkGLTFDocumentLoader.h:221
vtkGLTFDocumentLoader::TextureInfo
This struct describes a glTF textureInfo object, mostly used in material descriptions They contain tw...
Definition: vtkGLTFDocumentLoader.h:266
vtkGLTFDocumentLoader::Node::UpdateTransform
void UpdateTransform()
vtkGLTFDocumentLoader::Node::InitialTranslation
std::vector< float > InitialTranslation
Definition: vtkGLTFDocumentLoader.h:224
vtkGLTFDocumentLoader::TextureInfo::TexCoord
int TexCoord
Definition: vtkGLTFDocumentLoader.h:268
vtkGLTFDocumentLoader::Primitive::Geometry
vtkSmartPointer< vtkPolyData > Geometry
Definition: vtkGLTFDocumentLoader.h:194
vtkGLTFDocumentLoader::Material::OcclusionTexture
TextureInfo OcclusionTexture
Definition: vtkGLTFDocumentLoader.h:315
vtkGLTFDocumentLoader::Node::Mesh
int Mesh
Definition: vtkGLTFDocumentLoader.h:213
vtkSmartPointer< vtkCellArray >
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:54
vtkGLTFDocumentLoader::Model::Scenes
std::vector< Scene > Scenes
Definition: vtkGLTFDocumentLoader.h:514
vtkGLTFDocumentLoader::Primitive::Targets
std::vector< MorphTarget > Targets
Definition: vtkGLTFDocumentLoader.h:196
vtkGLTFDocumentLoader::Camera::Ymag
double Ymag
Definition: vtkGLTFDocumentLoader.h:456
vtkGLTFDocumentLoader::Animation::Channel::Sampler
int Sampler
Definition: vtkGLTFDocumentLoader.h:432
vtkGLTFDocumentLoader::Animation::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:440
vtkGLTFDocumentLoader::vtkGLTFDocumentLoader
vtkGLTFDocumentLoader()=default
vtkGLTFDocumentLoader::Texture::Source
int Source
Definition: vtkGLTFDocumentLoader.h:335
vtkGLTFDocumentLoader::Skin::Joints
std::vector< int > Joints
Definition: vtkGLTFDocumentLoader.h:386
vtkGLTFDocumentLoader::Image::Uri
std::string Uri
Definition: vtkGLTFDocumentLoader.h:279
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
vtkGLTFDocumentLoader::Image::ImageData
vtkSmartPointer< vtkImageData > ImageData
Definition: vtkGLTFDocumentLoader.h:281
vtkGLTFDocumentLoader::Material::EmissiveTexture
TextureInfo EmissiveTexture
Definition: vtkGLTFDocumentLoader.h:317
vtkGLTFDocumentLoader::Model::Buffers
std::vector< std::vector< char > > Buffers
Definition: vtkGLTFDocumentLoader.h:506
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:55
vtkGLTFDocumentLoader::Texture::Sampler
int Sampler
Definition: vtkGLTFDocumentLoader.h:334
vtkGLTFDocumentLoader::Primitive::Indices
vtkSmartPointer< vtkCellArray > Indices
Definition: vtkGLTFDocumentLoader.h:189
vtkGLTFDocumentLoader::Model::Materials
std::vector< Material > Materials
Definition: vtkGLTFDocumentLoader.h:510
vtkGLTFDocumentLoader::Extensions
This struct contains extension metadata.
Definition: vtkGLTFDocumentLoader.h:470
vtkGLTFDocumentLoader::Animation::Channel
Definition: vtkGLTFDocumentLoader.h:424
vtkGLTFDocumentLoader::Accessor::NumberOfComponents
unsigned int NumberOfComponents
Definition: vtkGLTFDocumentLoader.h:154
vtkGLTFDocumentLoader::BufferView::Target
int Target
Definition: vtkGLTFDocumentLoader.h:124
vtkGLTFDocumentLoader::Node::InitialWeights
std::vector< float > InitialWeights
Definition: vtkGLTFDocumentLoader.h:226
vtkGLTFDocumentLoader::Material::OcclusionTextureStrength
double OcclusionTextureStrength
Definition: vtkGLTFDocumentLoader.h:316
vtkGLTFDocumentLoader::LoadModelData
bool LoadModelData(const std::vector< char > &glbBuffer)
Load buffer data into the internal Model.
vtkGLTFDocumentLoader::Camera::Zfar
double Zfar
Definition: vtkGLTFDocumentLoader.h:452
vtkGLTFDocumentLoader::Node::Children
std::vector< int > Children
Definition: vtkGLTFDocumentLoader.h:211
vtkGLTFDocumentLoader::Mesh::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:257
vtkGLTFDocumentLoader::Model
This struct contains all data from a gltf asset.
Definition: vtkGLTFDocumentLoader.h:503
vtkGLTFDocumentLoader::GetSupportedExtensions
const std::vector< std::string > & GetSupportedExtensions()
Get the list of extensions that are supported by this loader.
vtkGLTFDocumentLoader::Sampler::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:364
vtkGLTFDocumentLoader::Material::PbrMetallicRoughness::MetallicFactor
float MetallicFactor
Definition: vtkGLTFDocumentLoader.h:307
vtkGLTFDocumentLoader::Texture::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:336
vtkGLTFDocumentLoader::Primitive::AttributeIndices
std::map< std::string, int > AttributeIndices
Definition: vtkGLTFDocumentLoader.h:187
vtkGLTFDocumentLoader::Node::Rotation
std::vector< float > Rotation
Definition: vtkGLTFDocumentLoader.h:227
vtkGLTFDocumentLoader::Model::DefaultScene
int DefaultScene
Definition: vtkGLTFDocumentLoader.h:521
vtkGLTFDocumentLoader::Primitive::AttributeValues
std::map< std::string, vtkSmartPointer< vtkDataArray > > AttributeValues
Definition: vtkGLTFDocumentLoader.h:192
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light::LightType
LightType
Definition: vtkGLTFDocumentLoader.h:477
vtkGLTFDocumentLoader::Model::BufferMetaData
std::string BufferMetaData
Definition: vtkGLTFDocumentLoader.h:520
vtkGLTFDocumentLoader::Material::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:325
vtkGLTFDocumentLoader::Animation::Duration
float Duration
Definition: vtkGLTFDocumentLoader.h:437
vtkGLTFDocumentLoader::Model::FileName
std::string FileName
Definition: vtkGLTFDocumentLoader.h:522
vtkGLTFDocumentLoader::Accessor::Sparse::Count
int Count
Definition: vtkGLTFDocumentLoader.h:142
vtkGLTFDocumentLoader::Material::PbrMetallicRoughness::BaseColorTexture
TextureInfo BaseColorTexture
Definition: vtkGLTFDocumentLoader.h:303
vtkGLTFDocumentLoader::Target
Target
Define an openGL draw target.
Definition: vtkGLTFDocumentLoader.h:70
vtkGLTFDocumentLoader::Model::BufferViews
std::vector< BufferView > BufferViews
Definition: vtkGLTFDocumentLoader.h:507
vtkGLTFDocumentLoader::Node::Extensions::KHRLightsPunctualMetaData
Node::Extensions::KHRLightsPunctual KHRLightsPunctualMetaData
Definition: vtkGLTFDocumentLoader.h:240
vtkGLTFDocumentLoader::GetInternalModel
std::shared_ptr< Model > GetInternalModel()
Get the internal Model.
vtkGLTFDocumentLoader::Accessor::ComponentTypeValue
ComponentType ComponentTypeValue
Definition: vtkGLTFDocumentLoader.h:151
vtkGLTFDocumentLoader::Accessor::ByteOffset
int ByteOffset
Definition: vtkGLTFDocumentLoader.h:150
vtkGLTFDocumentLoader::Node::Camera
int Camera
Definition: vtkGLTFDocumentLoader.h:212
vtkGLTFDocumentLoader::Animation::Sampler::Input
unsigned int Input
Definition: vtkGLTFDocumentLoader.h:409
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light::Intensity
double Intensity
Definition: vtkGLTFDocumentLoader.h:485
vtkGLTFDocumentLoader::Texture
This struct describes a glTF texture object.
Definition: vtkGLTFDocumentLoader.h:333
vtkGLTFDocumentLoader::Image::BufferView
int BufferView
Definition: vtkGLTFDocumentLoader.h:277
vtkGLTFDocumentLoader::Material::AlphaCutoff
double AlphaCutoff
Definition: vtkGLTFDocumentLoader.h:321
vtkGLTFDocumentLoader::Material
This struct describes a glTF material object.
Definition: vtkGLTFDocumentLoader.h:293
vtkGLTFDocumentLoader::Node::InitialRotation
std::vector< float > InitialRotation
Definition: vtkGLTFDocumentLoader.h:223
vtkGLTFDocumentLoader::Mesh::Primitives
std::vector< struct Primitive > Primitives
Definition: vtkGLTFDocumentLoader.h:255
vtkGLTFDocumentLoader::Model::Accessors
std::vector< Accessor > Accessors
Definition: vtkGLTFDocumentLoader.h:504
vtkGLTFDocumentLoader::Node::Scale
std::vector< float > Scale
Definition: vtkGLTFDocumentLoader.h:229
vtkGLTFDocumentLoader::Animation::Sampler::OutputData
vtkSmartPointer< vtkFloatArray > OutputData
Definition: vtkGLTFDocumentLoader.h:414
vtkGLTFDocumentLoader::Animation::Sampler::NumberOfComponents
int NumberOfComponents
Definition: vtkGLTFDocumentLoader.h:411
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:42
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:34
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:36
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:180
vtkGLTFDocumentLoader::Accessor
This struct describes an accessor glTF object.
Definition: vtkGLTFDocumentLoader.h:135
vtkGLTFDocumentLoader::MorphTarget::AttributeIndices
std::map< std::string, int > AttributeIndices
Definition: vtkGLTFDocumentLoader.h:172
vtkGLTFDocumentLoader::Node::Extensions
Definition: vtkGLTFDocumentLoader.h:234
vtkSmartPointer.h
vtkGLTFDocumentLoader::Primitive::CellSize
int CellSize
Definition: vtkGLTFDocumentLoader.h:200
vtkGLTFDocumentLoader::BufferView
This struct describes a glTF bufferView object.
Definition: vtkGLTFDocumentLoader.h:119
vtkGLTFDocumentLoader::Material::DoubleSided
bool DoubleSided
Definition: vtkGLTFDocumentLoader.h:323
vtkGLTFDocumentLoader::Node::Extensions::KHRLightsPunctual
Definition: vtkGLTFDocumentLoader.h:237
vtkGLTFDocumentLoader::Model::Skins
std::vector< Skin > Skins
Definition: vtkGLTFDocumentLoader.h:515
vtkGLTFDocumentLoader::Model::Meshes
std::vector< Mesh > Meshes
Definition: vtkGLTFDocumentLoader.h:511
vtkGLTFDocumentLoader::Image
This struct describes a glTF image object.
Definition: vtkGLTFDocumentLoader.h:276
vtkGLTFDocumentLoader::MorphTarget
This struct describes a glTF Morph Target object.
Definition: vtkGLTFDocumentLoader.h:170
vtkGLTFDocumentLoader::Accessor::Min
std::vector< double > Min
Definition: vtkGLTFDocumentLoader.h:157
vtkGLTFDocumentLoader::BufferView::ByteOffset
int ByteOffset
Definition: vtkGLTFDocumentLoader.h:121
vtkGLTFDocumentLoader::Camera::Yfov
double Yfov
Definition: vtkGLTFDocumentLoader.h:458
vtkGLTFDocumentLoader::Accessor::Sparse::ValuesBufferView
int ValuesBufferView
Definition: vtkGLTFDocumentLoader.h:146
vtkGLTFDocumentLoader::Accessor::Sparse::ValuesByteOffset
int ValuesByteOffset
Definition: vtkGLTFDocumentLoader.h:147
vtkGLTFDocumentLoader::Material::PbrMetallicRoughness::MetallicRoughnessTexture
TextureInfo MetallicRoughnessTexture
Definition: vtkGLTFDocumentLoader.h:306
vtkObject.h
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light::SpotOuterConeAngle
double SpotOuterConeAngle
Definition: vtkGLTFDocumentLoader.h:490
vtkGLTFDocumentLoader::Accessor::Sparse
This struct describes an accessor.sparse glTF object.
Definition: vtkGLTFDocumentLoader.h:141
vtkGLTFDocumentLoader::Accessor::Sparse::IndicesComponentType
ComponentType IndicesComponentType
Definition: vtkGLTFDocumentLoader.h:145
vtkGLTFDocumentLoader::Skin::Skeleton
int Skeleton
Definition: vtkGLTFDocumentLoader.h:388
vtkGLTFDocumentLoader::MorphTarget::AttributeValues
std::map< std::string, vtkSmartPointer< vtkFloatArray > > AttributeValues
Definition: vtkGLTFDocumentLoader.h:174
vtkGLTFDocumentLoader::Accessor::IsSparse
bool IsSparse
Definition: vtkGLTFDocumentLoader.h:158
vtkX3D::string
@ string
Definition: vtkX3D.h:496
vtkGLTFDocumentLoader::Model::ExtensionMetaData
Extensions ExtensionMetaData
Definition: vtkGLTFDocumentLoader.h:518
vtkGLTFDocumentLoader::Material::PbrMetallicRoughness::RoughnessFactor
float RoughnessFactor
Definition: vtkGLTFDocumentLoader.h:308
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:80
vtkGLTFDocumentLoader::Node::Weights
std::vector< float > Weights
Definition: vtkGLTFDocumentLoader.h:230
vtkGLTFDocumentLoader::Accessor::SparseObject
Sparse SparseObject
Definition: vtkGLTFDocumentLoader.h:159
vtkGLTFDocumentLoader::Node
This struct describes a glTF node object.
Definition: vtkGLTFDocumentLoader.h:210
vtkGLTFDocumentLoader::Camera
This struct describes a glTF camera object.
Definition: vtkGLTFDocumentLoader.h:449
vtkGLTFDocumentLoader::Material::PbrMetallicRoughness
PbrMetallicRoughness PbrMetallicRoughness
Definition: vtkGLTFDocumentLoader.h:311
vtkGLTFDocumentLoader::Material::PbrMetallicRoughness
Definition: vtkGLTFDocumentLoader.h:302
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:355
vtkGLTFDocumentLoader
Deserialize a GLTF model file.
Definition: vtkGLTFDocumentLoader.h:60
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light::Range
double Range
Definition: vtkGLTFDocumentLoader.h:486
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctualMetaData
KHRLightsPunctual KHRLightsPunctualMetaData
Definition: vtkGLTFDocumentLoader.h:496
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:254
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
vtkGLTFDocumentLoader::BufferView::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:125
vtkGLTFDocumentLoader::Sampler
This struct describes a glTF sampler object.
Definition: vtkGLTFDocumentLoader.h:344
vtkGLTFDocumentLoader::Camera::AspectRatio
double AspectRatio
Definition: vtkGLTFDocumentLoader.h:459
vtkGLTFDocumentLoader::Camera::IsPerspective
bool IsPerspective
Definition: vtkGLTFDocumentLoader.h:453
vtkGLTFDocumentLoader::Primitive::Mode
int Mode
Definition: vtkGLTFDocumentLoader.h:199
vtkGLTFDocumentLoader::Material::NormalTexture
TextureInfo NormalTexture
Definition: vtkGLTFDocumentLoader.h:313
vtkGLTFDocumentLoader::Node::Skin
int Skin
Definition: vtkGLTFDocumentLoader.h:214
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light
Definition: vtkGLTFDocumentLoader.h:475
vtkGLTFDocumentLoader::Material::AlphaMode
AlphaModeType AlphaMode
Definition: vtkGLTFDocumentLoader.h:320
vtkGLTFDocumentLoader::Image::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:283
vtkGLTFDocumentLoader::BufferView::ByteLength
int ByteLength
Definition: vtkGLTFDocumentLoader.h:122
vtkGLTFDocumentLoader::Accessor::Type
AccessorType Type
Definition: vtkGLTFDocumentLoader.h:155
vtkGLTFDocumentLoader::Model::Nodes
std::vector< Node > Nodes
Definition: vtkGLTFDocumentLoader.h:512
vtkGLTFDocumentLoader::Primitive
This struct describes a glTF primitive object.
Definition: vtkGLTFDocumentLoader.h:185
vtkGLTFDocumentLoader::ComponentType
ComponentType
Define a type for different data components.
Definition: vtkGLTFDocumentLoader.h:96
vtkGLTFDocumentLoader::Animation::Channel::PathType
PathType
Definition: vtkGLTFDocumentLoader.h:426
vtkGLTFDocumentLoader::Accessor::Max
std::vector< double > Max
Definition: vtkGLTFDocumentLoader.h:156
vtkGLTFDocumentLoader::BufferView::ByteStride
int ByteStride
Definition: vtkGLTFDocumentLoader.h:123
vtkGLTFDocumentLoader::Accessor::Sparse::IndicesBufferView
int IndicesBufferView
Definition: vtkGLTFDocumentLoader.h:143
vtkGLTFDocumentLoader::Accessor::Count
int Count
Definition: vtkGLTFDocumentLoader.h:153
vtkGLTFDocumentLoader::Material::EmissiveFactor
std::vector< double > EmissiveFactor
Definition: vtkGLTFDocumentLoader.h:318
vtkGLTFDocumentLoader::LoadFileBuffer
bool LoadFileBuffer(const std::string &fileName, std::vector< char > &glbBuffer)
Load the binary part of a binary glTF (.glb) file.
vtkGLTFDocumentLoader::Model::Samplers
std::vector< Sampler > Samplers
Definition: vtkGLTFDocumentLoader.h:513
vtkGLTFDocumentLoader::Node::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:244
vtkGLTFDocumentLoader::Skin::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:389
vtkGLTFDocumentLoader::BufferView::Buffer
int Buffer
Definition: vtkGLTFDocumentLoader.h:120
vtkGLTFDocumentLoader::Skin::InverseBindMatricesAccessorId
int InverseBindMatricesAccessorId
Definition: vtkGLTFDocumentLoader.h:387
vtkGLTFDocumentLoader::Primitive::IndicesId
int IndicesId
Definition: vtkGLTFDocumentLoader.h:188
vtkGLTFDocumentLoader::Accessor::Sparse::IndicesByteOffset
int IndicesByteOffset
Definition: vtkGLTFDocumentLoader.h:144
vtkGLTFDocumentLoader::Animation::Sampler::Output
unsigned int Output
Definition: vtkGLTFDocumentLoader.h:410
vtkGLTFDocumentLoader::Material::PbrMetallicRoughness::BaseColorFactor
std::vector< double > BaseColorFactor
Definition: vtkGLTFDocumentLoader.h:304
vtkGLTFDocumentLoader::Skin::InverseBindMatrices
std::vector< vtkSmartPointer< vtkMatrix4x4 > > InverseBindMatrices
Definition: vtkGLTFDocumentLoader.h:385
vtkGLTFDocumentLoader::Sampler::MinFilter
FilterType MinFilter
Definition: vtkGLTFDocumentLoader.h:361
vtkGLTFDocumentLoader::Animation::Sampler
Definition: vtkGLTFDocumentLoader.h:401
vtkGLTFDocumentLoader::Node::TRSLoaded
bool TRSLoaded
Definition: vtkGLTFDocumentLoader.h:219
vtkGLTFDocumentLoader::Animation::Channel::TargetNode
int TargetNode
Definition: vtkGLTFDocumentLoader.h:433
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:149
vtkGLTFDocumentLoader::Scene::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:375
vtkGLTFDocumentLoader::Material::NormalTextureScale
double NormalTextureScale
Definition: vtkGLTFDocumentLoader.h:314
vtkGLTFDocumentLoader::Accessor::Name
std::string Name
Definition: vtkGLTFDocumentLoader.h:160
vtkGLTFDocumentLoader::Sampler::MagFilter
FilterType MagFilter
Definition: vtkGLTFDocumentLoader.h:360
vtkGLTFDocumentLoader::Animation::Sampler::InterpolationMode
InterpolationMode
Definition: vtkGLTFDocumentLoader.h:403
vtkGLTFDocumentLoader::LoadModelMetaDataFromFile
bool LoadModelMetaDataFromFile(std::string FileName)
Reset internal Model struct, and serialize glTF metadata (all json information) into it.