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 */ /* 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 // Construct the node
auto newNode = nodeStore.Create(); auto newNode = nodeStore.Create();

View File

@ -27,7 +27,7 @@ namespace SHADE
/* Forward Declarations */ /* Forward Declarations */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
struct SHRigAsset; struct SHRigAsset;
struct RigNode; struct SHRigNode;
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
/* Type Definitions */ /* Type Definitions */
@ -99,6 +99,6 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------*/
/* Helper Functions */ /* 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) sizeof(asset.header)
); );
if (asset.header.meshCount > 0)
{
asset.meshHeaders.resize(asset.header.meshCount); asset.meshHeaders.resize(asset.header.meshCount);
asset.animHeaders.resize(asset.header.animCount);
file.read( file.read(
reinterpret_cast<char*>(asset.meshHeaders.data()), reinterpret_cast<char*>(asset.meshHeaders.data()),
sizeof(asset.header.meshCount) * sizeof(SHMeshDataHeader) 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( file.read(
reinterpret_cast<char*>(asset.animHeaders.data()), reinterpret_cast<char*>(&animHeader.animNodeCount),
sizeof(asset.header.animCount) * sizeof(SHAnimDataHeader) 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) void SHModelLoader::ReadData(FileReference file, SHModelAsset& asset)
@ -209,6 +234,7 @@ namespace SHADE
auto const& header = headers[i]; auto const& header = headers[i];
auto& animAsset = *new SHAnimAsset; auto& animAsset = *new SHAnimAsset;
animAsset.name.resize(header.charCount);
file.read( file.read(
animAsset.name.data(), animAsset.name.data(),
header.charCount header.charCount
@ -242,11 +268,9 @@ namespace SHADE
if (!file.is_open()) if (!file.is_open())
{ {
SHLOG_ERROR("[Model Loader] Unable to open SHModel File: {}", path.string()); SHLOG_ERROR("[Model Loader] Unable to open SHModel File: {}", path.string());
return; return nullptr;
} }
file.seekg(0);
ReadHeaders(file, *result); ReadHeaders(file, *result);
ReadData(file, *result); ReadData(file, *result);

View File

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