VTK  9.2.6
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_nlohmannjson.h>
28 #include VTK_NLOHMANN_JSON(json.hpp)
29 
30 #include <string> // For string
31 #include <vector> // For vector
32 
34 {
35 public:
37 
43  bool LoadModelMetaDataFromFile(std::string& FileName, std::vector<std::string>& usedExtensions);
45 
49  bool LoadBuffers(bool firstBufferIsGLB);
50 
51  static const unsigned short GL_POINTS = 0x0000;
52  static const unsigned short GL_LINES = 0x0001;
53  static const unsigned short GL_LINE_LOOP = 0x0002;
54  static const unsigned short GL_LINE_STRIP = 0x0003;
55  static const unsigned short GL_TRIANGLES = 0x0004;
56  static const unsigned short GL_TRIANGLE_STRIP = 0x0005;
57  static const unsigned short GL_TRIANGLE_FAN = 0x0006;
58 
59 private:
63  bool LoadNodeExtensions(
64  const nlohmann::json& root, vtkGLTFDocumentLoader::Node::Extensions& nodeExtensions);
65 
69  bool LoadExtensions(const nlohmann::json& root, vtkGLTFDocumentLoader::Extensions& extensions);
70 
76  bool LoadBuffer(
77  const nlohmann::json& root, std::vector<char>& buffer, const std::string& glTFFileName);
78 
83  bool LoadFileMetaData(const std::string& fileName, nlohmann::json& gltfRoot);
84 
90  bool LoadSkin(const nlohmann::json& root, vtkGLTFDocumentLoader::Skin& skin);
91 
95  bool LoadBufferView(const nlohmann::json& root, vtkGLTFDocumentLoader::BufferView& bufferView);
96 
100  bool LoadSparse(const nlohmann::json& root, vtkGLTFDocumentLoader::Accessor::Sparse& sparse);
101 
105  bool LoadAccessorBounds(const nlohmann::json& root, vtkGLTFDocumentLoader::Accessor& accessor);
106 
110  bool LoadCamera(const nlohmann::json& root, vtkGLTFDocumentLoader::Camera& camera);
111 
115  bool LoadAccessor(const nlohmann::json& root, vtkGLTFDocumentLoader::Accessor& accessor);
116 
122  bool LoadPrimitive(const nlohmann::json& root, vtkGLTFDocumentLoader::Primitive& primitive);
123 
127  bool LoadMesh(const nlohmann::json& root, vtkGLTFDocumentLoader::Mesh& mesh);
128 
132  bool LoadTextureInfo(const nlohmann::json& root, vtkGLTFDocumentLoader::TextureInfo& textureInfo);
133 
137  bool LoadMaterial(const nlohmann::json& root, vtkGLTFDocumentLoader::Material& material);
138 
143  bool LoadAnimation(const nlohmann::json& root, vtkGLTFDocumentLoader::Animation& animation);
144 
149  bool LoadScene(const nlohmann::json& root, vtkGLTFDocumentLoader::Scene& scene);
150 
155  bool LoadNode(const nlohmann::json& root, vtkGLTFDocumentLoader::Node& node);
156 
161  bool LoadImage(const nlohmann::json& root, vtkGLTFDocumentLoader::Image& image);
162 
170  bool LoadTexture(const nlohmann::json& root, vtkGLTFDocumentLoader::Texture& texture);
171 
175  bool LoadSampler(const nlohmann::json& root, vtkGLTFDocumentLoader::Sampler& sampler);
176 
180  vtkGLTFDocumentLoader::AccessorType AccessorTypeStringToEnum(std::string typeName);
181 
185  vtkGLTFDocumentLoader::Material::AlphaModeType MaterialAlphaModeStringToEnum(
186  std::string alphaModeString);
187 
192  bool LoadKHRLightsPunctualNodeExtension(const nlohmann::json& root,
194 
199  bool LoadKHRLightsPunctualExtension(
200  const nlohmann::json& root, vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual& lights);
201 
205  bool LoadKHRLightsPunctualExtensionLight(
206  const nlohmann::json& root, vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light& light);
207 };
208 
209 #endif
210 
211 // VTK-HeaderTest-Exclude: vtkGLTFDocumentLoaderInternals.h
Internal class for vtkGLTFDocumentLoader.
bool LoadBuffers(bool firstBufferIsGLB)
Reads the model's buffer metadata, then uses it to load all buffers into the model.
bool LoadModelMetaDataFromFile(std::string &FileName, std::vector< std::string > &usedExtensions)
Reset internal Model struct, and serialize glTF metadata (all json information) into it.
static const unsigned short GL_TRIANGLE_FAN
static const unsigned short GL_TRIANGLE_STRIP
Deserialize a GLTF model file.
AccessorType
Defines an accessor's type.
@ image
Definition: vtkX3D.h:380
@ string
Definition: vtkX3D.h:496
This struct describes an accessor.sparse glTF object.
This struct describes an accessor glTF object.
This struct describes a glTF animation object.
This struct describes a glTF bufferView object.
This struct describes a glTF camera object.
This struct contains extension metadata.
This struct describes a glTF image object.
This struct describes a glTF material object.
This struct describes a glTF mesh object.
This struct describes a glTF node object.
This struct describes a glTF primitive object.
This struct describes a glTF sampler object.
This struct describes a glTF scene object.
This struct describes a glTF asset.
This struct describes a glTF textureInfo object, mostly used in material descriptions They contain tw...
This struct describes a glTF texture object.