------------------------------------------------------------------------------
| 1362 | |
| 1363 | //------------------------------------------------------------------------------ |
| 1364 | void vtkGLTFDocumentLoader::Node::UpdateTransform() |
| 1365 | { |
| 1366 | this->Transform->Identity(); |
| 1367 | |
| 1368 | if (this->TRSLoaded) |
| 1369 | { |
| 1370 | std::vector<float> rotationValues = this->InitialRotation; |
| 1371 | std::vector<float> scale = this->InitialScale; |
| 1372 | std::vector<float> translation = this->InitialTranslation; |
| 1373 | |
| 1374 | if (!this->Translation.empty()) |
| 1375 | { |
| 1376 | translation = this->Translation; |
| 1377 | } |
| 1378 | if (!this->Rotation.empty()) |
| 1379 | { |
| 1380 | rotationValues = this->Rotation; |
| 1381 | } |
| 1382 | if (!this->Scale.empty()) |
| 1383 | { |
| 1384 | scale = this->Scale; |
| 1385 | } |
| 1386 | // Rotate quaternions to match vtk's representation |
| 1387 | std::rotate( |
| 1388 | std::begin(rotationValues), std::begin(rotationValues) + 3, std::end(rotationValues)); |
| 1389 | // Initialize quaternion |
| 1390 | vtkQuaternion<float> rotation; |
| 1391 | rotation.Normalize(); |
| 1392 | rotation.Set(rotationValues.data()); |
| 1393 | |
| 1394 | float rotationMatrix[3][3]; |
| 1395 | rotation.ToMatrix3x3(rotationMatrix); |
| 1396 | |
| 1397 | // Apply transformations |
| 1398 | for (int i = 0; i < 3; i++) |
| 1399 | { |
| 1400 | for (int j = 0; j < 3; j++) |
| 1401 | { |
| 1402 | this->Transform->SetElement(i, j, scale[j] * rotationMatrix[i][j]); |
| 1403 | } |
| 1404 | this->Transform->SetElement(i, 3, translation[i]); |
| 1405 | } |
| 1406 | } |
| 1407 | else |
| 1408 | { |
| 1409 | this->Transform->DeepCopy(this->Matrix); |
| 1410 | } |
| 1411 | } |
| 1412 | |
| 1413 | //------------------------------------------------------------------------------ |
| 1414 | void vtkGLTFDocumentLoader::Animation::Sampler::GetInterpolatedData(float timeValue, |