Updated Loading of .shmodel files and updated original models #303

Merged
XiaoQiDigipen merged 9 commits from Model-Loader-Update into SP3-17-animation-system 2023-01-08 12:40:01 +08:00
4 changed files with 45 additions and 21 deletions
Showing only changes of commit 73a1aaa480 - Show all commits

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,