VTK  9.0.1
vtkGLTFDocumentLoaderInternals.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 
23 #ifndef vtkGLTFDocumentLoaderInternals_h
24 #define vtkGLTFDocumentLoaderInternals_h
25 
26 #include "vtkGLTFDocumentLoader.h" // For vtkGLTFDocumentLoader
27 #include "vtk_jsoncpp_fwd.h" // For Json forward declaration
28 
29 #include <string> // For string
30 #include <vector> // For vector
31 
33 {
34 public:
36 
42  bool LoadModelMetaDataFromFile(std::string& FileName, std::vector<std::string>& usedExtensions);
44 
48  bool LoadBuffers(bool firstBufferIsGLB);
49 
50  static const unsigned short GL_POINTS = 0x0000;
51  static const unsigned short GL_LINES = 0x0001;
52  static const unsigned short GL_LINE_LOOP = 0x0002;
53  static const unsigned short GL_LINE_STRIP = 0x0003;
54  static const unsigned short GL_TRIANGLES = 0x0004;
55  static const unsigned short GL_TRIANGLE_STRIP = 0x0005;
56  static const unsigned short GL_TRIANGLE_FAN = 0x0006;
57 
58 private:
62  bool LoadNodeExtensions(
63  const Json::Value& root, vtkGLTFDocumentLoader::Node::Extensions& nodeExtensions);
64 
68  bool LoadExtensions(const Json::Value& root, vtkGLTFDocumentLoader::Extensions& extensions);
69 
75  bool LoadBuffer(
76  const Json::Value& root, std::vector<char>& buffer, const std::string& glTFFileName);
77 
82  bool LoadFileMetaData(const std::string& fileName, Json::Value& gltfRoot);
83 
89  bool LoadSkin(const Json::Value& root, vtkGLTFDocumentLoader::Skin& skin);
90 
94  bool LoadBufferView(const Json::Value& root, vtkGLTFDocumentLoader::BufferView& bufferView);
95 
99  bool LoadSparse(const Json::Value& root, vtkGLTFDocumentLoader::Accessor::Sparse& sparse);
100 
104  bool LoadAccessorBounds(const Json::Value& root, vtkGLTFDocumentLoader::Accessor& accessor);
105 
109  bool LoadCamera(const Json::Value& root, vtkGLTFDocumentLoader::Camera& camera);
110 
114  bool LoadAccessor(const Json::Value& root, vtkGLTFDocumentLoader::Accessor& accessor);
115 
121  bool LoadPrimitive(const Json::Value& root, vtkGLTFDocumentLoader::Primitive& primitive);
122 
126  bool LoadMesh(const Json::Value& root, vtkGLTFDocumentLoader::Mesh& mesh);
127 
131  bool LoadTextureInfo(const Json::Value& root, vtkGLTFDocumentLoader::TextureInfo& textureInfo);
132 
136  bool LoadMaterial(const Json::Value& root, vtkGLTFDocumentLoader::Material& material);
137 
142  bool LoadAnimation(const Json::Value& root, vtkGLTFDocumentLoader::Animation& animation);
143 
148  bool LoadScene(const Json::Value& root, vtkGLTFDocumentLoader::Scene& scene);
149 
154  bool LoadNode(const Json::Value& root, vtkGLTFDocumentLoader::Node& node);
155 
160  bool LoadImage(const Json::Value& root, vtkGLTFDocumentLoader::Image& image);
161 
169  bool LoadTexture(const Json::Value& root, vtkGLTFDocumentLoader::Texture& texture);
170 
174  bool LoadSampler(const Json::Value& root, vtkGLTFDocumentLoader::Sampler& sampler);
175 
179  vtkGLTFDocumentLoader::AccessorType AccessorTypeStringToEnum(std::string typeName);
180 
184  vtkGLTFDocumentLoader::Material::AlphaModeType MaterialAlphaModeStringToEnum(
185  std::string alphaModeString);
186 
191  bool LoadKHRLightsPunctualNodeExtension(const Json::Value& root,
193 
198  bool LoadKHRLightsPunctualExtension(
199  const Json::Value& root, vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual& lights);
200 
204  bool LoadKHRLightsPunctualExtensionLight(
205  const Json::Value& root, vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light& light);
206 };
207 
208 #endif
209 
210 // VTK-HeaderTest-Exclude: vtkGLTFDocumentLoaderInternals.h
vtkGLTFDocumentLoader::Material::AlphaModeType
AlphaModeType
Definition: vtkGLTFDocumentLoader.h:297
vtkGLTFDocumentLoader::Animation
This struct describes a glTF animation object.
Definition: vtkGLTFDocumentLoader.h:401
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual
Definition: vtkGLTFDocumentLoader.h:475
vtkGLTFDocumentLoader::Skin
This struct describes a glTF asset.
Definition: vtkGLTFDocumentLoader.h:386
vtkGLTFDocumentLoaderInternals::LoadBuffers
bool LoadBuffers(bool firstBufferIsGLB)
Reads the model's buffer metadata, then uses it to load all buffers into the model.
vtkGLTFDocumentLoader::Scene
This struct describes a glTF scene object.
Definition: vtkGLTFDocumentLoader.h:375
vtkGLTFDocumentLoaderInternals::GL_LINE_LOOP
static const unsigned short GL_LINE_LOOP
Definition: vtkGLTFDocumentLoaderInternals.h:52
vtkGLTFDocumentLoaderInternals::GL_TRIANGLE_FAN
static const unsigned short GL_TRIANGLE_FAN
Definition: vtkGLTFDocumentLoaderInternals.h:56
vtkX3D::image
@ image
Definition: vtkX3D.h:380
vtkGLTFDocumentLoader::TextureInfo
This struct describes a glTF textureInfo object, mostly used in material descriptions They contain tw...
Definition: vtkGLTFDocumentLoader.h:268
vtkGLTFDocumentLoaderInternals::LoadModelMetaDataFromFile
bool LoadModelMetaDataFromFile(std::string &FileName, std::vector< std::string > &usedExtensions)
Reset internal Model struct, and serialize glTF metadata (all json information) into it.
vtkGLTFDocumentLoaderInternals::Self
vtkGLTFDocumentLoader * Self
Definition: vtkGLTFDocumentLoaderInternals.h:43
vtkGLTFDocumentLoader::Extensions
This struct contains extension metadata.
Definition: vtkGLTFDocumentLoader.h:472
vtkGLTFDocumentLoaderInternals::vtkGLTFDocumentLoaderInternals
vtkGLTFDocumentLoaderInternals()=default
vtkGLTFDocumentLoaderInternals::GL_TRIANGLES
static const unsigned short GL_TRIANGLES
Definition: vtkGLTFDocumentLoaderInternals.h:54
vtkGLTFDocumentLoaderInternals::GL_LINES
static const unsigned short GL_LINES
Definition: vtkGLTFDocumentLoaderInternals.h:51
vtkGLTFDocumentLoaderInternals::GL_TRIANGLE_STRIP
static const unsigned short GL_TRIANGLE_STRIP
Definition: vtkGLTFDocumentLoaderInternals.h:55
vtkGLTFDocumentLoader::Texture
This struct describes a glTF texture object.
Definition: vtkGLTFDocumentLoader.h:335
vtkGLTFDocumentLoaderInternals::GL_POINTS
static const unsigned short GL_POINTS
Definition: vtkGLTFDocumentLoaderInternals.h:50
vtkGLTFDocumentLoader.h
vtkGLTFDocumentLoader::Material
This struct describes a glTF material object.
Definition: vtkGLTFDocumentLoader.h:295
vtkGLTFDocumentLoader::Accessor
This struct describes an accessor glTF object.
Definition: vtkGLTFDocumentLoader.h:137
vtkGLTFDocumentLoader::Node::Extensions
Definition: vtkGLTFDocumentLoader.h:236
vtkGLTFDocumentLoader::BufferView
This struct describes a glTF bufferView object.
Definition: vtkGLTFDocumentLoader.h:121
vtkGLTFDocumentLoaderInternals
Internal class for vtkGLTFDocumentLoader.
Definition: vtkGLTFDocumentLoaderInternals.h:32
vtkGLTFDocumentLoader::Node::Extensions::KHRLightsPunctual
Definition: vtkGLTFDocumentLoader.h:239
vtkGLTFDocumentLoader::Image
This struct describes a glTF image object.
Definition: vtkGLTFDocumentLoader.h:278
vtkGLTFDocumentLoaderInternals::GL_LINE_STRIP
static const unsigned short GL_LINE_STRIP
Definition: vtkGLTFDocumentLoaderInternals.h:53
vtkGLTFDocumentLoader::Accessor::Sparse
This struct describes an accessor.sparse glTF object.
Definition: vtkGLTFDocumentLoader.h:143
vtkX3D::string
@ string
Definition: vtkX3D.h:496
vtkGLTFDocumentLoader::AccessorType
AccessorType
Defines an accessor's type.
Definition: vtkGLTFDocumentLoader.h:82
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:451
vtkGLTFDocumentLoader
Deserialize a GLTF model file.
Definition: vtkGLTFDocumentLoader.h:62
vtkGLTFDocumentLoader::Mesh
This struct describes a glTF mesh object.
Definition: vtkGLTFDocumentLoader.h:256
vtkGLTFDocumentLoader::Sampler
This struct describes a glTF sampler object.
Definition: vtkGLTFDocumentLoader.h:346
vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light
Definition: vtkGLTFDocumentLoader.h:477
vtkGLTFDocumentLoader::Primitive
This struct describes a glTF primitive object.
Definition: vtkGLTFDocumentLoader.h:187