VTK  9.3.0
vtkGLTFDocumentLoaderInternals.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 
11 #ifndef vtkGLTFDocumentLoaderInternals_h
12 #define vtkGLTFDocumentLoaderInternals_h
13 
14 #include "vtkGLTFDocumentLoader.h" // For vtkGLTFDocumentLoader
15 #include <vtk_nlohmannjson.h>
16 #include VTK_NLOHMANN_JSON(json.hpp)
17 
18 #include <string> // For string
19 #include <vector> // For vector
20 
21 VTK_ABI_NAMESPACE_BEGIN
22 
24 {
25 public:
27 
33  bool LoadModelMetaData(std::vector<std::string>& extensionsUsedByLoader);
34 
38  bool LoadBuffers(bool firstBufferIsGLB);
39 
41 
42  static const unsigned short GL_POINTS = 0x0000;
43  static const unsigned short GL_LINES = 0x0001;
44  static const unsigned short GL_LINE_LOOP = 0x0002;
45  static const unsigned short GL_LINE_STRIP = 0x0003;
46  static const unsigned short GL_TRIANGLES = 0x0004;
47  static const unsigned short GL_TRIANGLE_STRIP = 0x0005;
48  static const unsigned short GL_TRIANGLE_FAN = 0x0006;
49 
50 private:
54  bool LoadNodeExtensions(
55  const nlohmann::json& root, vtkGLTFDocumentLoader::Node::Extensions& nodeExtensions);
56 
60  bool LoadExtensions(const nlohmann::json& root, vtkGLTFDocumentLoader::Extensions& extensions);
61 
67  bool LoadBuffer(const nlohmann::json& root, std::vector<char>& buffer);
68 
73  bool LoadFileMetaData(nlohmann::json& gltfRoot);
74 
80  bool LoadSkin(const nlohmann::json& root, vtkGLTFDocumentLoader::Skin& skin);
81 
85  bool LoadBufferView(const nlohmann::json& root, vtkGLTFDocumentLoader::BufferView& bufferView);
86 
90  bool LoadSparse(const nlohmann::json& root, vtkGLTFDocumentLoader::Accessor::Sparse& sparse);
91 
95  bool LoadAccessorBounds(const nlohmann::json& root, vtkGLTFDocumentLoader::Accessor& accessor);
96 
100  bool LoadCamera(const nlohmann::json& root, vtkGLTFDocumentLoader::Camera& camera);
101 
105  bool LoadAccessor(const nlohmann::json& root, vtkGLTFDocumentLoader::Accessor& accessor);
106 
112  bool LoadPrimitive(const nlohmann::json& root, vtkGLTFDocumentLoader::Primitive& primitive);
113 
117  bool LoadMesh(const nlohmann::json& root, vtkGLTFDocumentLoader::Mesh& mesh);
118 
122  bool LoadTextureInfo(const nlohmann::json& root, vtkGLTFDocumentLoader::TextureInfo& textureInfo);
123 
127  bool LoadMaterial(const nlohmann::json& root, vtkGLTFDocumentLoader::Material& material);
128 
133  bool LoadAnimation(const nlohmann::json& root, vtkGLTFDocumentLoader::Animation& animation);
134 
139  bool LoadScene(const nlohmann::json& root, vtkGLTFDocumentLoader::Scene& scene);
140 
145  bool LoadNode(const nlohmann::json& root, vtkGLTFDocumentLoader::Node& node);
146 
151  bool LoadImage(const nlohmann::json& root, vtkGLTFDocumentLoader::Image& image);
152 
160  bool LoadTexture(const nlohmann::json& root, vtkGLTFDocumentLoader::Texture& texture);
161 
165  bool LoadSampler(const nlohmann::json& root, vtkGLTFDocumentLoader::Sampler& sampler);
166 
170  vtkGLTFDocumentLoader::AccessorType AccessorTypeStringToEnum(std::string typeName);
171 
175  vtkGLTFDocumentLoader::Material::AlphaModeType MaterialAlphaModeStringToEnum(
176  std::string alphaModeString);
177 
182  bool LoadKHRLightsPunctualNodeExtension(const nlohmann::json& root,
184 
189  bool LoadKHRLightsPunctualExtension(
190  const nlohmann::json& root, vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual& lights);
191 
195  bool LoadKHRLightsPunctualExtensionLight(
196  const nlohmann::json& root, vtkGLTFDocumentLoader::Extensions::KHRLightsPunctual::Light& light);
197 };
198 
199 VTK_ABI_NAMESPACE_END
200 #endif
201 
202 // 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.
static const unsigned short GL_TRIANGLE_FAN
static const unsigned short GL_TRIANGLE_STRIP
bool LoadModelMetaData(std::vector< std::string > &extensionsUsedByLoader)
Reset internal Model struct, and serialize glTF metadata (all json information) into it.
Deserialize a GLTF model file.
AccessorType
Defines an accessor's type.
@ image
Definition: vtkX3D.h:374
@ string
Definition: vtkX3D.h:490
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.