WIP Commit, Node and Joint indexing
This commit is contained in:
parent
6c396469d4
commit
816c16324c
|
@ -132,19 +132,19 @@ namespace SHADE
|
||||||
void SHAnimatorComponent::updatePoseWithClip(int closestFrameIndex, float poseTime, Handle<SHRigNode> node, const SHMatrix& parentMatrix)
|
void SHAnimatorComponent::updatePoseWithClip(int closestFrameIndex, float poseTime, Handle<SHRigNode> node, const SHMatrix& parentMatrix)
|
||||||
{
|
{
|
||||||
// Check if there is a channel for this node
|
// Check if there is a channel for this node
|
||||||
const int BONE_IDX = rig->GetNodeIndex(node);
|
|
||||||
SHMatrix transformMatrix = node->TransformMatrix;
|
SHMatrix transformMatrix = node->TransformMatrix;
|
||||||
const auto& CHANNELS = currClip->GetChannels();
|
//const int BONE_IDX = rig->GetNodeIndex(node);
|
||||||
if (BONE_IDX < CHANNELS.size())
|
//const auto& CHANNELS = currClip->GetChannels();
|
||||||
{
|
//if (BONE_IDX < CHANNELS.size())
|
||||||
const auto& CHANNEL = CHANNELS[BONE_IDX];
|
//{
|
||||||
transformMatrix = SHMatrix::Transform
|
// const auto& CHANNEL = CHANNELS[BONE_IDX];
|
||||||
(
|
// transformMatrix = SHMatrix::Transform
|
||||||
getInterpolatedValue(CHANNEL.PositionKeyFrames, closestFrameIndex, poseTime),
|
// (
|
||||||
getInterpolatedValue(CHANNEL.RotationKeyFrames, closestFrameIndex, poseTime),
|
// getInterpolatedValue(CHANNEL.PositionKeyFrames, closestFrameIndex, poseTime),
|
||||||
getInterpolatedValue(CHANNEL.ScaleKeyFrames, closestFrameIndex, poseTime)
|
// getInterpolatedValue(CHANNEL.RotationKeyFrames, closestFrameIndex, poseTime),
|
||||||
);
|
// getInterpolatedValue(CHANNEL.ScaleKeyFrames, closestFrameIndex, poseTime)
|
||||||
}
|
// );
|
||||||
|
//}
|
||||||
|
|
||||||
// Apply parent's transformation
|
// Apply parent's transformation
|
||||||
transformMatrix = transformMatrix * parentMatrix;
|
transformMatrix = transformMatrix * parentMatrix;
|
||||||
|
|
|
@ -120,8 +120,10 @@ namespace SHADE
|
||||||
|
|
||||||
// Fill the node with data
|
// Fill the node with data
|
||||||
const auto& NODE_DATA = asset.nodeDataCollection.at(sourceNode->idRef);
|
const auto& NODE_DATA = asset.nodeDataCollection.at(sourceNode->idRef);
|
||||||
newNode->OffsetMatrix = SHMatrix::Transpose(NODE_DATA.inverseBindMatrix);
|
//newNode->OffsetMatrix = SHMatrix::Transpose(NODE_DATA.inverseBindMatrix);
|
||||||
newNode->TransformMatrix = SHMatrix::Transpose(NODE_DATA.transform);
|
//newNode->TransformMatrix = SHMatrix::Transpose(NODE_DATA.transform);
|
||||||
|
newNode->OffsetMatrix = NODE_DATA.inverseBindMatrix;
|
||||||
|
newNode->TransformMatrix = NODE_DATA.transform;
|
||||||
|
|
||||||
// Populate maps
|
// Populate maps
|
||||||
if (!NODE_DATA.name.empty())
|
if (!NODE_DATA.name.empty())
|
||||||
|
|
|
@ -108,6 +108,8 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
mesh->BoneCount = asset.rig.nodeDataCollection.size();
|
mesh->BoneCount = asset.rig.nodeDataCollection.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//BuildTransformMatrices(asset.rig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,6 +140,26 @@ namespace SHADE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SHModelLoader::BuildTransformMatrices(SHRigAsset& rig)
|
||||||
|
{
|
||||||
|
std::queue<SHRigNodeAsset const*> nodeQueue;
|
||||||
|
nodeQueue.push(rig.root);
|
||||||
|
|
||||||
|
while(!nodeQueue.empty())
|
||||||
|
{
|
||||||
|
auto& current = nodeQueue.front();
|
||||||
|
nodeQueue.pop();
|
||||||
|
auto& parentData {rig.nodeDataCollection[current->idRef]};
|
||||||
|
|
||||||
|
for (auto const& child: current->children)
|
||||||
|
{
|
||||||
|
nodeQueue.push(child);
|
||||||
|
auto& childData {rig.nodeDataCollection[child->idRef]};
|
||||||
|
childData.transform = childData.transform * parentData.transform;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SHModelLoader::ReadRigHeader(FileReference file, SHRigDataHeader& header)
|
void SHModelLoader::ReadRigHeader(FileReference file, SHRigDataHeader& header)
|
||||||
{
|
{
|
||||||
file.read(
|
file.read(
|
||||||
|
@ -174,7 +196,7 @@ namespace SHADE
|
||||||
reinterpret_cast<char*>(&node.inverseBindMatrix),
|
reinterpret_cast<char*>(&node.inverseBindMatrix),
|
||||||
sizeof(SHMatrix)
|
sizeof(SHMatrix)
|
||||||
);
|
);
|
||||||
node.inverseBindMatrix = SHMatrix::Transpose(node.inverseBindMatrix);
|
node.inverseBindMatrix = node.inverseBindMatrix;
|
||||||
|
|
||||||
NodeDataFlag flag;
|
NodeDataFlag flag;
|
||||||
file.get(reinterpret_cast<char&>(flag));
|
file.get(reinterpret_cast<char&>(flag));
|
||||||
|
@ -214,20 +236,21 @@ namespace SHADE
|
||||||
translation = GetVec3FromVector(carrier);
|
translation = GetVec3FromVector(carrier);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (flag & NODE_DATA_MATRIX)
|
if (flag & NODE_DATA_MATRIX)
|
||||||
//{
|
{
|
||||||
// carrier.resize(NODE_COMPONENT_COUNT_MATRIX);
|
carrier.resize(NODE_COMPONENT_COUNT_MATRIX);
|
||||||
// file.read(
|
file.read(
|
||||||
// reinterpret_cast<char*>(carrier.data()),
|
reinterpret_cast<char*>(carrier.data()),
|
||||||
// sizeof(double) * NODE_COMPONENT_COUNT_MATRIX
|
sizeof(double) * NODE_COMPONENT_COUNT_MATRIX
|
||||||
// );
|
);
|
||||||
// matrix = GetMatrixFromVector(carrier);
|
matrix = GetMatrixFromVector(carrier);
|
||||||
//}
|
}
|
||||||
|
|
||||||
//matrix *= SHMatrix::Transform(translation, rotation, scale);
|
//matrix *= SHMatrix::Transform(translation, rotation, scale);
|
||||||
matrix *= SHMatrix::Translate(translation) * SHMatrix::Rotate(rotation) * SHMatrix::Scale(scale);
|
matrix *= SHMatrix::Translate(translation) * SHMatrix::Rotate(rotation) * SHMatrix::Scale(scale);
|
||||||
//result = SHMatrix::Transpose(result);
|
|
||||||
node.transform = matrix;
|
node.transform = matrix;
|
||||||
|
//node.transform = SHMatrix::Inverse(node.inverseBindMatrix);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,8 @@ namespace SHADE
|
||||||
void ReadAnimData(FileReference file, std::vector<SHAnimDataHeader> const& headers, std::vector<SHAnimAsset*>& anims);
|
void ReadAnimData(FileReference file, std::vector<SHAnimDataHeader> const& headers, std::vector<SHAnimAsset*>& anims);
|
||||||
void ReadAnimNode(FileReference file, uint32_t frameCount, SHAnimNode& data);
|
void ReadAnimNode(FileReference file, uint32_t frameCount, SHAnimNode& data);
|
||||||
|
|
||||||
|
void BuildTransformMatrices(SHRigAsset& rig);
|
||||||
|
|
||||||
void ReadHeaders(FileReference file, SHModelAsset& asset);
|
void ReadHeaders(FileReference file, SHModelAsset& asset);
|
||||||
void ReadData(FileReference file, SHModelAsset& asset);
|
void ReadData(FileReference file, SHModelAsset& asset);
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -107,7 +107,6 @@ constexpr std::string_view EXTENSIONS[] = {
|
||||||
"dummy",
|
"dummy",
|
||||||
SCRIPT_EXTENSION,
|
SCRIPT_EXTENSION,
|
||||||
FONT_EXTENSION,
|
FONT_EXTENSION,
|
||||||
AUDIO_WAV_EXTENSION,
|
|
||||||
AUDIO_BANK_EXTENSION
|
AUDIO_BANK_EXTENSION
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -162,6 +162,7 @@ namespace SHADE
|
||||||
{
|
{
|
||||||
assetCollection.emplace(asset.id, asset);
|
assetCollection.emplace(asset.id, asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file.name == asset.name)
|
if (file.name == asset.name)
|
||||||
{
|
{
|
||||||
AssetPath path{ file.path };
|
AssetPath path{ file.path };
|
||||||
|
|
Loading…
Reference in New Issue