Skip to content
Snippets Groups Projects
Commit 45adbcbe authored by Sankhesh Jhaveri's avatar Sankhesh Jhaveri :speech_balloon:
Browse files

GLTF loader can now selectively toggle loading of certain data

Model images, keyframes and skin matrices can now be toggled.
parent 0bb51e1c
No related branches found
No related tags found
No related merge requests found
......@@ -729,6 +729,11 @@ bool vtkGLTFDocumentLoader::ExtractPrimitiveAttributes(Primitive& primitive)
//------------------------------------------------------------------------------
bool vtkGLTFDocumentLoader::LoadAnimationData()
{
if (!this->LoadAnimation)
{
// Skip loading animation key frames
return true;
}
AccessorLoadingWorker worker;
worker.Accessors = &(this->InternalModel->Accessors);
worker.BufferViews = &(this->InternalModel->BufferViews);
......@@ -801,6 +806,11 @@ bool vtkGLTFDocumentLoader::LoadAnimationData()
//------------------------------------------------------------------------------
bool vtkGLTFDocumentLoader::LoadImageData()
{
if (!this->LoadImages)
{
// Skip loading model images
return true;
}
vtkNew<vtkImageReader2Factory> factory;
size_t numberOfMeshes = this->InternalModel->Meshes.size();
size_t numberOfImages = this->InternalModel->Images.size();
......@@ -918,6 +928,11 @@ bool vtkGLTFDocumentLoader::LoadImageData()
//------------------------------------------------------------------------------
bool vtkGLTFDocumentLoader::LoadSkinMatrixData()
{
if (!this->LoadSkinMatrix)
{
// Skip loading the skin bind matrces
return true;
}
AccessorLoadingWorker worker;
worker.Accessors = &(this->InternalModel->Accessors);
worker.BufferViews = &(this->InternalModel->BufferViews);
......
......@@ -615,6 +615,39 @@ public:
vtkGetMacro(GLBStart, vtkTypeInt64);
///@}
///@{
/**
* Set/Get whether to load animation keyframes from buffers
*
* Defaults to true
*/
vtkSetMacro(LoadAnimation, bool);
vtkGetMacro(LoadAnimation, bool);
vtkBooleanMacro(LoadAnimation, bool);
///@}
///@{
/**
* Set/Get whether to load images from filesystem and bufferView, if available
*
* Defaults to true
*/
vtkSetMacro(LoadImages, bool);
vtkGetMacro(LoadImages, bool);
vtkBooleanMacro(LoadImages, bool);
///@}
///@{
/**
* Set/Get whether to load inverse bind matrices from buffers into model's Skin structs
*
* Defaults to true
*/
vtkSetMacro(LoadSkinMatrix, bool);
vtkGetMacro(LoadSkinMatrix, bool);
vtkBooleanMacro(LoadSkinMatrix, bool);
///@}
protected:
vtkGLTFDocumentLoader() = default;
~vtkGLTFDocumentLoader() override = default;
......@@ -675,6 +708,13 @@ private:
static const std::vector<std::string> SupportedExtensions;
std::vector<std::string> UsedExtensions;
vtkTypeInt64 GLBStart = 0;
/**
* Selectively load model data
*/
bool LoadAnimation = true;
bool LoadImages = true;
bool LoadSkinMatrix = true;
};
VTK_ABI_NAMESPACE_END
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment