Updated model loading to match new model binary implementation

Changed some calls in resource to match new names and defines
This commit is contained in:
Xiao Qi 2023-01-07 21:00:11 +08:00
parent 64323f6cf8
commit 73a1aaa480
4 changed files with 45 additions and 21 deletions

View File

@ -73,7 +73,7 @@ namespace SHADE
/*-----------------------------------------------------------------------------------*/
/* Helper Functions */
/*-----------------------------------------------------------------------------------*/
Handle<SHRig::Node> SHRig::recurseCreateNode(const SHRigAsset& asset, const RigNode* sourceNode)
Handle<SHRig::Node> SHRig::recurseCreateNode(const SHRigAsset& asset, const SHRigNode* sourceNode)
{
// Construct the node
auto newNode = nodeStore.Create();

View File

@ -27,7 +27,7 @@ namespace SHADE
/* Forward Declarations */
/*-----------------------------------------------------------------------------------*/
struct SHRigAsset;
struct RigNode;
struct SHRigNode;
/*-----------------------------------------------------------------------------------*/
/* Type Definitions */
@ -99,6 +99,6 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/
/* Helper Functions */
/*---------------------------------------------------------------------------------*/
Handle<Node> recurseCreateNode(const SHRigAsset& asset, const RigNode* sourceNode);
Handle<Node> recurseCreateNode(const SHRigAsset& asset, const SHRigNode* sourceNode);
};
}

View File

@ -24,18 +24,43 @@ namespace SHADE
sizeof(asset.header)
);
asset.meshHeaders.resize(asset.header.meshCount);
asset.animHeaders.resize(asset.header.animCount);
if (asset.header.meshCount > 0)
{
asset.meshHeaders.resize(asset.header.meshCount);
file.read(
reinterpret_cast<char*>(asset.meshHeaders.data()),
asset.header.meshCount * sizeof(SHMeshDataHeader)
);
}
file.read(
reinterpret_cast<char*>(asset.meshHeaders.data()),
sizeof(asset.header.meshCount) * sizeof(SHMeshDataHeader)
);
if (asset.header.animCount > 0)
{
asset.animHeaders.resize(asset.header.animCount);
for (auto i {0}; i < asset.header.animCount; ++i)
{
auto& animHeader = asset.animHeaders[i];
file.read(
reinterpret_cast<char*>(&animHeader.charCount),
sizeof(uint32_t)
);
file.read(
reinterpret_cast<char*>(asset.animHeaders.data()),
sizeof(asset.header.animCount) * sizeof(SHAnimDataHeader)
);
file.read(
reinterpret_cast<char*>(&animHeader.animNodeCount),
sizeof(uint32_t)
);
animHeader.nodeHeaders.resize(animHeader.animNodeCount);
for (auto j {0}; j < animHeader.animNodeCount; ++j)
{
auto& nodeHeader = animHeader.nodeHeaders[j];
file.read(
reinterpret_cast<char*>(&nodeHeader),
sizeof(SHAnimNodeInfo)
);
}
}
}
}
void SHModelLoader::ReadData(FileReference file, SHModelAsset& asset)
@ -209,6 +234,7 @@ namespace SHADE
auto const& header = headers[i];
auto& animAsset = *new SHAnimAsset;
animAsset.name.resize(header.charCount);
file.read(
animAsset.name.data(),
header.charCount
@ -242,11 +268,9 @@ namespace SHADE
if (!file.is_open())
{
SHLOG_ERROR("[Model Loader] Unable to open SHModel File: {}", path.string());
return;
return nullptr;
}
file.seekg(0);
ReadHeaders(file, *result);
ReadData(file, *result);

View File

@ -437,7 +437,7 @@ namespace SHADE
return;
}
if (genMeta)
if (true)
{
GenerateNewMeta(newPath);
}
@ -610,7 +610,7 @@ namespace SHADE
for(auto const& subMesh : data->meshes)
{
SHAsset subAsset{
.name = subMesh->header.name,
.name = subMesh->name,
.id = GenerateAssetID(AssetType::MESH),
.type = AssetType::MESH,
.isSubAsset = true,