Updated Loading of .shmodel files and updated original models #303
|
@ -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();
|
||||||
|
|
|
@ -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);
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -23,19 +23,44 @@ namespace SHADE
|
||||||
reinterpret_cast<char*>(&asset.header),
|
reinterpret_cast<char*>(&asset.header),
|
||||||
sizeof(asset.header)
|
sizeof(asset.header)
|
||||||
);
|
);
|
||||||
|
|
||||||
asset.meshHeaders.resize(asset.header.meshCount);
|
|
||||||
asset.animHeaders.resize(asset.header.animCount);
|
|
||||||
|
|
||||||
file.read(
|
|
||||||
reinterpret_cast<char*>(asset.meshHeaders.data()),
|
|
||||||
sizeof(asset.header.meshCount) * sizeof(SHMeshDataHeader)
|
|
||||||
);
|
|
||||||
|
|
||||||
file.read(
|
if (asset.header.meshCount > 0)
|
||||||
reinterpret_cast<char*>(asset.animHeaders.data()),
|
{
|
||||||
sizeof(asset.header.animCount) * sizeof(SHAnimDataHeader)
|
asset.meshHeaders.resize(asset.header.meshCount);
|
||||||
);
|
file.read(
|
||||||
|
reinterpret_cast<char*>(asset.meshHeaders.data()),
|
||||||
|
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*>(&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)
|
void SHModelLoader::ReadData(FileReference file, SHModelAsset& asset)
|
||||||
|
@ -208,7 +233,8 @@ 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);
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Reference in New Issue