Skip to content

Commit

Permalink
Fix scene node indices
Browse files Browse the repository at this point in the history
I thought it was all nodes but it appears it only wants/needs root nodes, no child nodes.
  • Loading branch information
burninrubber0 committed Feb 24, 2023
1 parent 3ad75b3 commit 0830e31
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ void Converter::convertTriggersToGLTF()
convertLandmark(triggerData->getLandmark(i), model->nodes[i + landmarkNodeIndex], i);
currentNodeCount++;
landmarkChildCount += triggerData->getLandmark(i).getStartingGridCount();
model->scenes[0].nodes.push_back(landmarkNodeIndex + i + landmarkChildCount - triggerData->getLandmark(i).getStartingGridCount());
}
int blackspotNodeIndex = currentNodeCount;
for (int i = 0; i < triggerData->getBlackspotCount(); ++i)
Expand All @@ -275,6 +276,7 @@ void Converter::convertTriggersToGLTF()
model->nodes.back().mesh = 0;
convertBlackspot(triggerData->getBlackspot(i), model->nodes[blackspotNodeIndex + i], i);
currentNodeCount++;
model->scenes[0].nodes.push_back(blackspotNodeIndex + i);
}
int vfxBoxRegionNodeIndex = currentNodeCount;
for (int i = 0; i < triggerData->getVfxBoxRegionCount(); ++i)
Expand All @@ -283,6 +285,7 @@ void Converter::convertTriggersToGLTF()
model->nodes.back().mesh = 0;
convertVfxBoxRegion(triggerData->getVfxBoxRegion(i), model->nodes[vfxBoxRegionNodeIndex + i], i);
currentNodeCount++;
model->scenes[0].nodes.push_back(vfxBoxRegionNodeIndex + i);
}

// Nodes with GenericRegion arrays
Expand All @@ -302,6 +305,7 @@ void Converter::convertTriggersToGLTF()
convertSignatureStunt(triggerData->getSignatureStunt(i), model->nodes[signatureStuntNodeIndex + i + signatureStuntChildCount], i);
currentNodeCount++;
signatureStuntChildCount += triggerData->getSignatureStunt(i).getStuntElementCount();
model->scenes[0].nodes.push_back(signatureStuntNodeIndex + i + signatureStuntChildCount - triggerData->getSignatureStunt(i).getStuntElementCount());
}
int killzoneNodeIndex = currentNodeCount;
int killzoneChildCount = 0;
Expand All @@ -319,6 +323,7 @@ void Converter::convertTriggersToGLTF()
convertKillzone(triggerData->getKillzone(i), model->nodes[killzoneNodeIndex + i + killzoneChildCount], i);
currentNodeCount++;
killzoneChildCount += triggerData->getKillzone(i).getTriggerCount();
model->scenes[0].nodes.push_back(killzoneNodeIndex + i + killzoneChildCount - triggerData->getKillzone(i).getTriggerCount());
}

// Remaining GenericRegion nodes
Expand All @@ -331,6 +336,7 @@ void Converter::convertTriggersToGLTF()
model->nodes.push_back(Node());
model->nodes.back().mesh = 0;
convertGenericRegion(triggerData->getGenericRegion(i), model->nodes[genericRegionNodeIndex + currentGenericRegionNode], i);
model->scenes[0].nodes.push_back(genericRegionNodeIndex + currentGenericRegionNode);
currentGenericRegionNode++;
currentNodeCount++;
}
Expand All @@ -346,6 +352,7 @@ void Converter::convertTriggersToGLTF()
model->nodes.push_back(Node());
model->nodes.back().mesh = 0;
convertTriggerRegion(triggerData->getTriggerRegion(i), model->nodes[triggerRegionNodeIndex + currentTriggerRegionNode], i);
model->scenes[0].nodes.push_back(triggerRegionNodeIndex + currentTriggerRegionNode);
currentTriggerRegionNode++;
currentNodeCount++;
}
Expand All @@ -359,6 +366,7 @@ void Converter::convertTriggersToGLTF()
model->nodes.back().mesh = 0;
convertRoamingLocation(triggerData->getRoamingLocation(i), model->nodes[roamingLocationNodeIndex + i], i);
currentNodeCount++;
model->scenes[0].nodes.push_back(roamingLocationNodeIndex + i);
}
int spawnLocationNodeIndex = currentNodeCount;
for (int i = 0; i < triggerData->getSpawnLocationCount(); ++i)
Expand All @@ -367,12 +375,9 @@ void Converter::convertTriggersToGLTF()
model->nodes.back().mesh = 0;
convertSpawnLocation(triggerData->getSpawnLocation(i), model->nodes[spawnLocationNodeIndex + i], i);
currentNodeCount++;
model->scenes[0].nodes.push_back(spawnLocationNodeIndex + i);
}

// Add node indices to scene
for (int i = 0; i < currentNodeCount; ++i)
model->scenes[0].nodes.push_back(i);

// Set up asset
model->asset.version = "2.0";
model->asset.generator = "tinygltf";
Expand Down

0 comments on commit 0830e31

Please sign in to comment.