Commit b377cf79 authored by Adrien Boucaud's avatar Adrien Boucaud

Add glTF reader and importer

parent 43fd2271
......@@ -8,6 +8,8 @@ set(classes
vtkFLUENTReader
vtkGAMBITReader
vtkGaussianCubeReader
vtkGLTFDocumentLoader
vtkGLTFReader
vtkHoudiniPolyDataWriter
vtkIVWriter
vtkMCubesReader
......@@ -27,5 +29,11 @@ set(classes
vtkWindBladeReader
vtkXYZMolReader)
set(private_classes
vtkGLTFDocumentLoaderInternals
vtkGLTFUtils)
vtk_module_add_module(VTK::IOGeometry
CLASSES ${classes})
CLASSES ${classes}
PRIVATE_CLASSES ${private_classes}
)
......@@ -46,6 +46,34 @@ vtk_add_test_cxx(vtkIOGeometryCxxTests tests
TestAVSucdReaderBinary,TestAVSucdReader.cxx DATA{${_vtk_build_TEST_INPUT_DATA_DIRECTORY}/Data/cellsnd.bin.inp}
)
vtk_add_test_cxx(vtkIOGeometryCxxTests tests
TestGLTFReaderGeometry,TestGLTFReaderGeometry.cxx DATA{../Data/glTF/Triangle/Triangle.gltf,simpleTriangle.bin}
)
vtk_add_test_cxx(vtkIOGeometryCxxTests tests
TestGLTFReaderEmbeddedGeometry,TestGLTFReaderGeometry.cxx DATA{../Data/glTF/Triangle/EmbeddedTriangle.gltf}
)
vtk_add_test_cxx(vtkIOGeometryCxxTests tests
TestGLTFReaderGLBGeometry,TestGLTFReaderGeometry.cxx DATA{../Data/glTF/Triangle/Triangle.glb}
)
vtk_add_test_cxx(vtkIOGeometryCxxTests tests
TestGLTFReaderAnimation,TestGLTFReaderAnimation.cxx 200 DATA{../Data/glTF/BoxAnimated/BoxAnimated.gltf,BoxAnimated0.bin}
)
vtk_add_test_cxx(vtkIOGeometryCxxTests tests
TestGLTFReaderMorphing,TestGLTFReaderAnimation.cxx 200 DATA{../Data/glTF/AnimatedMorphCube/AnimatedMorphCube.gltf,AnimatedMorphCube.bin}
)
vtk_add_test_cxx(vtkIOGeometryCxxTests tests
TestGLTFReaderSkinning,TestGLTFReaderAnimation.cxx 200 DATA{../Data/glTF/SimpleSkin/SimpleSkin.gltf}
)
vtk_add_test_cxx(vtkIOGeometryCxxTests tests
TestGLTFReaderMultipleAnimations,TestGLTFReaderAnimation.cxx 75 DATA{../Data/glTF/InterpolationTest/InterpolationTest.gltf,interpolation.bin,InterpolationTest_data.bin}
)
if(enable_large_data_tests)
vtk_add_test_cxx(vtkIOGeometryCxxTests large_data_tests
TestWindBladeReader.cxx
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestGLTFReaderAnimation.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include <vtkActor.h>
#include <vtkCamera.h>
#include <vtkCompositePolyDataMapper.h>
#include <vtkGLTFReader.h>
#include <vtkInformation.h>
#include <vtkMultiBlockDataSet.h>
#include <vtkRegressionTestImage.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkSmartPointer.h>
#include <vtkStreamingDemandDrivenPipeline.h>
int TestGLTFReaderAnimation(int argc, char* argv[])
{
if (argc <= 2)
{
std::cout << "Usage: " << argv[0] << "<step> <gltf file>" << std::endl;
return EXIT_FAILURE;
}
const int step = std::atoi(argv[1]);
vtkNew<vtkGLTFReader> reader;
reader->SetFileName(argv[2]);
reader->SetFrameRate(60);
reader->UpdateInformation();
vtkInformation* readerInfo = reader->GetOutputInformation(0);
int nbSteps = readerInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
if (nbSteps < step)
{
std::cerr << "Invalid number of steps for input argument: " << step << std::endl;
return EXIT_FAILURE;
}
reader->ApplyDeformationsToGeometryOn();
for (unsigned int i = 0; i < reader->GetNumberOfAnimations(); i++)
{
reader->EnableAnimation(i);
}
readerInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP(), step);
reader->Update();
vtkNew<vtkCompositePolyDataMapper> mapper;
mapper->SetInputConnection(reader->GetOutputPort());
vtkNew<vtkActor> actor;
actor->SetMapper(mapper);
vtkNew<vtkRenderer> renderer;
renderer->AddActor(actor);
renderer->SetBackground(.0, .0, .2);
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->AddRenderer(renderer);
vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
renderWindowInteractor->SetRenderWindow(renderWindow);
renderWindow->Render();
renderer->GetActiveCamera()->Azimuth(30);
renderer->GetActiveCamera()->Elevation(30);
renderer->GetActiveCamera()->SetClippingRange(0.1, 1000);
int retVal = vtkRegressionTestImage(renderWindow);
if (retVal == vtkRegressionTester::DO_INTERACTOR)
{
renderWindowInteractor->Start();
}
return !retVal;
}
/*=========================================================================
Program: Visualization Toolkit
Module: TestGLTFReaderGeometry.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include <vtkActor.h>
#include <vtkCompositePolyDataMapper.h>
#include <vtkGLTFReader.h>
#include <vtkMultiBlockDataSet.h>
#include <vtkRegressionTestImage.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkSmartPointer.h>
int TestGLTFReaderGeometry(int argc, char* argv[])
{
if (argc <= 1)
{
std::cout << "Usage: " << argv[0] << " <gltf file>" << std::endl;
return EXIT_FAILURE;
}
vtkNew<vtkGLTFReader> reader;
reader->SetFileName(argv[1]);
reader->Update();
vtkNew<vtkCompositePolyDataMapper> mapper;
mapper->SetInputConnection(reader->GetOutputPort());
vtkNew<vtkActor> actor;
actor->SetMapper(mapper);
vtkNew<vtkRenderer> renderer;
renderer->AddActor(actor);
renderer->SetBackground(.0, .0, .2);
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->AddRenderer(renderer);
vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
renderWindowInteractor->SetRenderWindow(renderWindow);
renderWindow->Render();
int retVal = vtkRegressionTestImage(renderWindow);
if (retVal == vtkRegressionTester::DO_INTERACTOR)
{
renderWindowInteractor->Start();
}
return !retVal;
}
12c066c99a6806ce4aa22822062b14a6acc57f11445ce637c5db4bb78079f809a646a755b4cfb20e19f841401188340f4080421f4d935228c0e876b717f2268e
70e39296411dea3b911a4197518d1f01030f4dfa2409343adfab84a4b5f34eb3b742a60882d350879542a344232392225d70bee7f4ed4dcd0dc48c2b12b86eca
70e39296411dea3b911a4197518d1f01030f4dfa2409343adfab84a4b5f34eb3b742a60882d350879542a344232392225d70bee7f4ed4dcd0dc48c2b12b86eca
70e39296411dea3b911a4197518d1f01030f4dfa2409343adfab84a4b5f34eb3b742a60882d350879542a344232392225d70bee7f4ed4dcd0dc48c2b12b86eca
39e958dea4e17b5d1a6269aad4fe1bb1047328bf2aeb6d59c618953952c73a2ab62285d32aa7bcf77c7c4899e8070e64c384a0d28a46c009e19e59542badab00
f37aa616f1ff74b9587b0c220c820180f426b29f7f758942e74a41d529313f76f796d9df8458f15cc136b52b0d5109a78f9a63c352f8a87b1df81447ee3d777f
6cbf0716d2f6130e8ee79e5d3127041db1f58b3abe348ec4de4a97b117a597ad4cab6e3629384a08fbf5f2e9b606be1fc2a25cff41e508e93bbbddb827bc1404
6b48c622ab554faab7f8b9501d59f8db01aeb18092e7e26949f5814288d7b6082968f5f9c6baa63f82996a59e069e94f7db9abcec2735c78dc3882debe6ecd14
8e8c3d10e53f987349e76cd48552683dfc92cf5895198b8d42da373efad9bb0934a31d713e5d16833d3fcb6a8ab290ef2d91a070fa368193ae85b79635eebf67
e7fc69c0865820ca423853266ba8c9050c0329c2c2d4339ce24c2b311f073053142ae8c6bb4aaff6994244024e7e0d49b6e3d06023de6edc3db873b77670004d
26742d13bb5851e03f4bc36fe9d45c3460a6a5c96764b88194d53a9ec247b822c3a5e51cdeb0691c2191a26c4ac2aa8cd00643f8854e5cad4113c8aadcc93a19
6c950c4de089591568fb7e308472d92b6beef87949b42bbd9cde9ec6f991603cb770c6ea1a9a72f2186cbc6f8ff028ed1524784e6ff1fdbf2f1ed547464162e2
adeb7713af55b54eda9a041a9d8469fcb07993733a89e4596eb65111efa2005040e95f1a8b0637216b1a028425801a0dded1970e8274d6a5fd6b4a8a9fa2e318
a750230193262ee62e80966cca1a9cba433a6bc411942bad36deef27d48e471808fe0cab46a476d4f7d31c0f087695de62265b2a4b603967d733206c20dacdc1
14d5d5315da46e2256155977ce3622b4dd7218fbf536818ffb23b64ad6db53cb3542ad174d1b208753e11877e31d14fc15a87de5be40a8c157fb3d5417b38e33
c880f8ec6ae33f33f8c767153b79408cb71cd0d439963a15f3d5c43377d2cbb7c69ec2435e8744dc0255aefb335b36c84d2c23633b424ea46686632ea36b319a
c6b7560dcda724f8a594f93fdea6698e89082d7bfaf7a6509cfc37faec6299c6e3d674ffe41a04f2f7ac4608c15f0f87d58be74cb587554eccfa571bbcd5fc1d
fdc5e3408bace50d4f226a8da6d8e0d24922bd2943a3f3afdd46ec8c1a8ecb67b335776bd39f14ff52e3f81301f6f8e824d6b65f109cc377ab890349faf511de
287530df3da6fa9266531b67797c4ab93daa349e775d506b630094d851b2948124f8e2557b5ee4ecac8d66185f46297e9deb9872636ef17f6d05d8682f290fc3
ad7a6176194ebca306c65511d540e2ad196ddf8e4c5960aaf7649ef09228410259e60f46fa2c8d0d2599d68c452a72bc1fd11a5b7e0edda158bb7d26b0022c92
74224a29bdfe76abc8ed8caa3b244c2581fa16215c4a6111c1fd6480cb5591735eac654d732c7104aced2b6f825e8972bf6ab4850ad1354cc7e2f2e5f4df36eb
......@@ -17,7 +17,12 @@ PRIVATE_DEPENDS
VTK::CommonMisc
VTK::CommonSystem
VTK::CommonTransforms
VTK::FiltersGeneral
VTK::FiltersHybrid
VTK::ImagingCore
VTK::IOImage
VTK::RenderingCore
VTK::jsoncpp
VTK::vtksys
VTK::zlib
TEST_DEPENDS
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*=========================================================================
Program: Visualization Toolkit
Module: vtkGLTFDocumentLoader.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkGLTFDocumentLoaderInternals
* @brief Internal class for vtkGLTFDocumentLoader
*
* This class provides json-related methods for vtkGLTFDocumentLoader
*/
#ifndef vtkGLTFDocumentLoaderInternals_h
#define vtkGLTFDocumentLoaderInternals_h
#include "vtkGLTFDocumentLoader.h" // For vtkGLTFDocumentLoader
#include "vtk_jsoncpp_fwd.h" // For Json forward declaration
#include <string> // For string
class vtkGLTFDocumentLoaderInternals
{
public:
vtkGLTFDocumentLoaderInternals();
/**
* Reset internal Model struct, and serialize glTF metadata (all json information) into it.
* To load buffers, use LoadModelData
*/
bool LoadModelMetaDataFromFile(std::string& FileName);
vtkGLTFDocumentLoader* Self;
/**
* Reads the model's buffer metadata, then uses it to load all buffers into the model.
*/
bool LoadBuffers(bool firstBufferIsGLB);
static const unsigned short GL_POINTS = 0x0000;
static const unsigned short GL_LINES = 0x0001;
static const unsigned short GL_LINE_LOOP = 0x0002;
static const unsigned short GL_LINE_STRIP = 0x0003;
static const unsigned short GL_TRIANGLES = 0x0004;
static const unsigned short GL_TRIANGLE_STRIP = 0x0005;
static const unsigned short GL_TRIANGLE_FAN = 0x0006;
private:
/**
* Reads a Json value describing a glTF buffer object, then uses this information to load the
* corresponding binary buffer into an std::vector<char> array.
* Needs to know the .glTF file's location in order to interpret relative paths.
*/
bool LoadBuffer(
const Json::Value& root, std::vector<char>& buffer, const std::string& glTFFileName);
/**
* Load a glTF file and parse it into a Json value. File extension can be either .gltf
* or .glb. In case of a binary glTF file, only the Json part will be read.
*/
bool LoadFileMetaData(const std::string& fileName, Json::Value& gltfRoot);
/**
* Populate a Skin struct with data from a Json variable describing the object.
* This method only loads metadata from the json file, it does not load the bind matrices from the
* buffer.
*/
bool LoadSkin(const Json::Value& root, vtkGLTFDocumentLoader::Skin& skin);
/**
* Populate a BufferView struct with data from a Json variable describing the object.
*/
bool LoadBufferView(const Json::Value& root, vtkGLTFDocumentLoader::BufferView& bufferView);
/**
* Populate a Sparse struct with data from a Json variable describing the object.
*/
bool LoadSparse(const Json::Value& root, vtkGLTFDocumentLoader::Accessor::Sparse& sparse);
/**
* Sets an Accessor's min and max fields with values from a Json variable.
*/
bool LoadAccessorBounds(const Json::Value& root, vtkGLTFDocumentLoader::Accessor& accessor);
/**
* Populate a Camera struct with data from a Json variable describing the object.
*/
bool LoadCamera(const Json::Value& root, vtkGLTFDocumentLoader::Camera& camera);
/**
* Populate an Accessor struct with data from a Json variable describing the object.
*/
bool LoadAccessor(const Json::Value& root, vtkGLTFDocumentLoader::Accessor& accessor);
/**
* Populate a Primitive struct with data from a Json variable describing the object.
* This method only loads integer indices to accessors, it does not extract any value from a
* buffer.
*/
bool LoadPrimitive(const Json::Value& root, vtkGLTFDocumentLoader::Primitive& primitive);
/**
* Populate a Mesh struture with data from a Json variable describing the object.
*/
bool LoadMesh(const Json::Value& root, vtkGLTFDocumentLoader::Mesh& mesh);
/**
* Populate a TextureInfo struct with data from a Json variable describing the object.
*/
bool LoadTextureInfo(const Json::Value& root, vtkGLTFDocumentLoader::TextureInfo& textureInfo);
/**
* Populate a Material struct with data from a Json variable describing the object.
*/
bool LoadMaterial(const Json::Value& root, vtkGLTFDocumentLoader::Material& material);
/**
* Populate an Animation struct with data from a Json variable describing the object.
* This function only loads indices to the keyframe accessors, not the data they contain.
*/
bool LoadAnimation(const Json::Value& root, vtkGLTFDocumentLoader::Animation& animation);
/**
* Populate a Scene struct with data from a Json variable describing the object.
* Does not check for node's existence.
*/
bool LoadScene(const Json::Value& root, vtkGLTFDocumentLoader::Scene& scene);
/**
* Populate a Node struct with data from a Json variable describing the object.
* Does not check for the node's children's existence.
*/
bool LoadNode(const Json::Value& root, vtkGLTFDocumentLoader::Node& node);
/**
* Populate an Image struct with data from a Json variable describing the object.
* This loads a glTF object, not an actual image file.
*/
bool LoadImage(const Json::Value& root, vtkGLTFDocumentLoader::Image& image);
/**
* Populate a Texture struct with data from a Json variable describing the object.
* This loads a glTF object from a Json value, no files are loaded by this function.
* Discounting the 'name' field, glTF texture objects contain two indices: one to an image
* object (the object that references to an actual image file), and one to a sampler
* object (which specifies filter and wrapping options for a texture).
*/
bool LoadTexture(const Json::Value& root, vtkGLTFDocumentLoader::Texture& texture);
/**
* Populate a Sampler struct with data from a Json variable describing the object.
*/
bool LoadSampler(const Json::Value& root, vtkGLTFDocumentLoader::Sampler& sampler);
/**
* Associates an accessor type string to the corresponding enum value.
*/
vtkGLTFDocumentLoader::AccessorType AccessorTypeStringToEnum(std::string typeName);
/**
* Associate a material's alphaMode string to the corresponding enum value.
*/
vtkGLTFDocumentLoader::Material::AlphaModeType MaterialAlphaModeStringToEnum(
std::string alphaModeString);
};
#endif
// VTK-HeaderTest-Exclude: vtkGLTFDocumentLoaderInternals.h
This diff is collapsed.
/*=========================================================================
Program: Visualization Toolkit
Module: vtkGLTFReader.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkGLTFReader
* @brief Read a GLTF file.
*
* vtkGLTFReader is a source object that reads a glTF file.
*
* The GL Transmission Format (glTF) is an API-neutral runtime asset delivery format.
* A glTF asset is represented by:
* - A JSON-formatted file (.gltf) containing a full scene description: node hierarchy, materials,
* cameras, as well as descriptor information for meshes, animations, and other constructs
* - Binary files (.bin) containing geometry and animation data, and other buffer-based data
* - Image files (.jpg, .png) for textures
*
* This reader currently outputs a vtkMultiBlockDataSet containing geometry information
* for the current selected scene, with animations, skins and morph targets applied, unless
* configured not to (see ApplyDeformationsToGeometry).
*
* It is possible to get information about available scenes and animations by using the
* corresponding accessors.
* To use animations, first call SetFramerate with a non-zero value,
* then use EnableAnimation or DisableAnimation to configure which animations you would like to
* apply to the geometry.
* Finally, use UPDATE_TIME_STEPS to choose which frame to apply.
* If ApplyDeformationsToGeometry is set to true, the reader will apply the deformations, otherwise,
* animation transformation information will be saved to the dataset's FieldData.
*
* Materials are currently not supported in this reader. If you would like to display materials,
* please try using vtkGLTFImporter.
*
* This reader only supports assets that use the 2.x version of the glTF specification.
*
* For the full glTF specification, see:
* https://github.com/KhronosGroup/glTF/tree/master/specification/2.0
*
* Note: array sizes should not exceed INT_MAX
*/
#ifndef vtkGLTFReader_h
#define vtkGLTFReader_h
#include "vtkIOGeometryModule.h" // For export macro
#include "vtkMultiBlockDataSetAlgorithm.h"
#include "vtkSmartPointer.h" // For SmartPointer
#include <string> // For std::string
#include <vector> // For std::vector
class vtkGLTFDocumentLoader;
class vtkFieldData;
class vtkImageData;
class VTKIOGEOMETRY_EXPORT vtkGLTFReader : public vtkMultiBlockDataSetAlgorithm
{
public:
static vtkGLTFReader* New();
vtkTypeMacro(vtkGLTFReader, vtkMultiBlockDataSetAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent) override;
//@{
/**
* Materials are not directly applied to this reader's output.
* Use GetGLTFTexture to access a specific texture's image data, and the indices present in the
* output dataset's field data to create vtkTextures and apply them to the geometry.
*/
struct GLTFTexture
{
vtkSmartPointer<vtkImageData> Image;
unsigned short MinFilterValue;
unsigned short MaxFilterValue;
unsigned short WrapSValue;
unsigned short WrapTValue;
};
size_t GetNumberOfTextures();
GLTFTexture GetGLTFTexture(unsigned int textureIndex);
//@}
//@{
/**
* Set/Get the name of the file from which to read points.
*/
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
//@}
//@{
/**
* The model's skinning transforms are computed and added to the different vtkPolyData objects'
* field data.
* If this flag is set to true, the reader will apply those skinning transforms to the model's
* geometry.
*/
vtkSetMacro(ApplyDeformationsToGeometry, bool);
vtkGetMacro(ApplyDeformationsToGeometry, bool);
vtkBooleanMacro(ApplyDeformationsToGeometry, bool);
//@}
//@{
/**
* glTF models can contain multiple animations, with various names and duration. glTF does not
* specify however any runtime behavior (order of playing, auto-start, loops, mapping of
* timelines, etc), which is why no animation is enabled by default.
* These accessors expose metadata information about a model's available animations.
*/
vtkGetMacro(NumberOfAnimations, size_t);
std::string GetAnimationName(unsigned int animationIndex);
float GetAnimationDuration(unsigned int animationIndex);
//@}
//@{
/**
* Enable/Disable an animation. The reader will apply all enabled animations to the model's
* transformations, at the specified time step. Use UPDATE_TIME_STEP to select which frame should
* be applied.
*/
void EnableAnimation(unsigned int animationIndex);
void DisableAnimation(unsigned int animationIndex);
bool IsAnimationEnabled(unsigned int animationIndex);
//@}
//@{
/**
* glTF models can contain multiple scene descriptions.
* These accessors expose metadata information about a model's available scenes.
*/
std::string GetSceneName(unsigned int sceneIndex);
vtkGetMacro(NumberOfScenes, size_t);
//@}
//@{
/**
* Get/Set the scene to be used by the reader
*/
vtkGetMacro(CurrentScene, unsigned int);
vtkSetMacro(CurrentScene, unsigned int);
//@}
//@{
/**
* Get/Set the rate at which animations will be sampled:
* the glTF format does not have the concept of static timesteps.
* TimeSteps are generated, during the REQUEST_INFORMATION pass,
* as linearly interpolated time values between 0s and the animations' maximum durations,
* sampled at the specified frame rate.
* Use the TIME_STEPS information key to obtain integer indices to each of these steps.
*/
vtkGetMacro(FrameRate, unsigned int);
vtkSetMacro(FrameRate, unsigned int);
//@}
protected:
vtkGLTFReader();
~vtkGLTFReader() override;
vtkSmartPointer<vtkGLTFDocumentLoader> Loader;
vtkSmartPointer<vtkMultiBlockDataSet> OutputDataSet;
std::vector<GLTFTexture> Textures;
/**
* Create and store GLTFTexture struct for each image present in the model.
*/
void StoreTextureData();
char* FileName;
unsigned int CurrentScene;
unsigned int FrameRate;
size_t NumberOfAnimations;
size_t NumberOfScenes;
std::vector<bool> AnimationEnabledStates;
bool IsModelLoaded;
bool IsMetaDataLoaded;
bool ApplyDeformationsToGeometry;
int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
private:
vtkGLTFReader(const vtkGLTFReader&) = delete;
void operator=(const vtkGLTFReader&) = delete;
};
#endif
This diff is collapsed.
/*=========================================================================
Program: Visualization Toolkit
Module: vtkGLTFUtils.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @brief Helper functions for glTF parsing and validation.
*
* vtkGLTFUtils is a helper namespace that contains various functions to help
* with the parsing and validation of JSON-formatted glTF files.
* More specifically, these functions add existence and type verifications
* before extracting Json values.
* Another function helps check the document's version against supported glTF versions
*/
#ifndef vtkGLTFUtils_h
#define vtkGLTFUtils_h
#include "vtk_jsoncpp_fwd.h" // For Json forward declaration
#include <string> // For string
#include <vector> // For vector
namespace vtkGLTFUtils
{
using ChunkInfoType = std::pair<std::string, uint32_t>;
// Binary glTF constants
const uint32_t GLBWordSize = 4;
const uint32_t GLBHeaderSize = 12;
const uint32_t GLBChunkHeaderSize = 8;
const uint32_t GLBVersion = 2;
/**