------------------------------------------------------------------------------
| 1004 | |
| 1005 | //------------------------------------------------------------------------------ |
| 1006 | bool vtkGLTFDocumentLoader::LoadModelData(const std::vector<char>& glbBuffer) |
| 1007 | { |
| 1008 | vtkGLTFDocumentLoaderInternals impl; |
| 1009 | impl.Self = this; |
| 1010 | |
| 1011 | if (this->InternalModel == nullptr) |
| 1012 | { |
| 1013 | vtkErrorMacro("Error loading model data: metadata was not loaded"); |
| 1014 | return false; |
| 1015 | } |
| 1016 | |
| 1017 | // Push optional glB buffer |
| 1018 | if (!glbBuffer.empty()) |
| 1019 | { |
| 1020 | this->InternalModel->Buffers.push_back(glbBuffer); |
| 1021 | } |
| 1022 | |
| 1023 | if (!impl.LoadBuffers(!glbBuffer.empty())) |
| 1024 | { |
| 1025 | return false; |
| 1026 | } |
| 1027 | |
| 1028 | this->PrepareData(); |
| 1029 | |
| 1030 | // Read primitive attributes from buffers |
| 1031 | size_t numberOfMeshes = this->InternalModel->Meshes.size(); |
| 1032 | size_t numberOfImages = this->InternalModel->Images.size(); |
| 1033 | for (size_t i = 0; i < numberOfMeshes; i++) |
| 1034 | { |
| 1035 | for (Primitive& primitive : this->InternalModel->Meshes[i].Primitives) |
| 1036 | { |
| 1037 | if (!this->ExtractPrimitiveAccessorData(primitive)) |
| 1038 | { |
| 1039 | return false; |
| 1040 | } |
| 1041 | } |
| 1042 | double progress = (i + 1) / static_cast<double>(numberOfMeshes + numberOfImages); |
| 1043 | this->InvokeEvent(vtkCommand::ProgressEvent, static_cast<void*>(&progress)); |
| 1044 | } |
| 1045 | // Read additional buffer data |
| 1046 | if (!this->LoadAnimationData()) |
| 1047 | { |
| 1048 | return false; |
| 1049 | } |
| 1050 | if (!this->LoadImageData()) |
| 1051 | { |
| 1052 | return false; |
| 1053 | } |
| 1054 | return this->LoadSkinMatrixData(); |
| 1055 | } |
| 1056 | |
| 1057 | /** vtk object building and animation operations **/ |
| 1058 | //------------------------------------------------------------------------------ |
no test coverage detected