mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-21 00:25:44 +00:00
chore: move materialIndex to XModelObject
This commit is contained in:
parent
1bc1c12244
commit
0a65c93aa5
@ -9,6 +9,7 @@
|
||||
struct XModelObject
|
||||
{
|
||||
std::string name;
|
||||
int materialIndex;
|
||||
};
|
||||
|
||||
struct XModelBone
|
||||
@ -52,7 +53,6 @@ struct XModelFace
|
||||
{
|
||||
int vertexIndex[3];
|
||||
int objectIndex;
|
||||
int materialIndex;
|
||||
};
|
||||
|
||||
struct XModelMaterial
|
||||
|
@ -312,14 +312,16 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void AddXModelObjects(AbstractXModelWriter& writer, const XModel* model, const unsigned lod)
|
||||
void AddXModelObjects(AbstractXModelWriter& writer, const XModel* model, const unsigned lod, const DistinctMapper<Material*>& materialMapper)
|
||||
{
|
||||
const auto surfCount = model->lodInfo[lod].numsurfs;
|
||||
const auto baseSurfaceIndex = model->lodInfo[lod].surfIndex;
|
||||
|
||||
for (auto surfIndex = 0u; surfIndex < surfCount; surfIndex++)
|
||||
{
|
||||
XModelObject object;
|
||||
object.name = "surf" + std::to_string(surfIndex);
|
||||
object.materialIndex = static_cast<int>(materialMapper.GetDistinctPositionByInputPosition(surfIndex + baseSurfaceIndex));
|
||||
|
||||
writer.AddObject(std::move(object));
|
||||
}
|
||||
@ -506,11 +508,10 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void AddXModelFaces(AbstractXModelWriter& writer, const DistinctMapper<Material*>& materialMapper, const XModel* model, const unsigned lod)
|
||||
void AddXModelFaces(AbstractXModelWriter& writer, const XModel* model, const unsigned lod)
|
||||
{
|
||||
const auto* surfs = &model->surfs[model->lodInfo[lod].surfIndex];
|
||||
const auto surfCount = model->lodInfo[lod].numsurfs;
|
||||
const auto baseSurfIndex = model->lodInfo[lod].surfIndex;
|
||||
|
||||
for (auto surfIndex = 0u; surfIndex < surfCount; surfIndex++)
|
||||
{
|
||||
@ -524,7 +525,6 @@ namespace
|
||||
face.vertexIndex[1] = tri[1] + surface.baseVertIndex;
|
||||
face.vertexIndex[2] = tri[2] + surface.baseVertIndex;
|
||||
face.objectIndex = static_cast<int>(surfIndex);
|
||||
face.materialIndex = static_cast<int>(materialMapper.GetDistinctPositionByInputPosition(surfIndex + baseSurfIndex));
|
||||
writer.AddFace(face);
|
||||
}
|
||||
}
|
||||
@ -538,10 +538,10 @@ namespace
|
||||
|
||||
AddXModelBones(context, writer, model);
|
||||
AddXModelMaterials(writer, materialMapper, model);
|
||||
AddXModelObjects(writer, model, lod);
|
||||
AddXModelObjects(writer, model, lod, materialMapper);
|
||||
AddXModelVertices(writer, model, lod);
|
||||
AddXModelVertexBoneWeights(writer, model, lod, boneWeightCollection);
|
||||
AddXModelFaces(writer, materialMapper, model, lod);
|
||||
AddXModelFaces(writer, model, lod);
|
||||
}
|
||||
|
||||
void DumpXModelExportLod(const AssetDumpingContext& context, const XAssetInfo<XModel>* asset, const unsigned lod)
|
||||
|
@ -318,12 +318,16 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void AddXModelObjects(AbstractXModelWriter& writer, const XModelSurfs* modelSurfs)
|
||||
void AddXModelObjects(AbstractXModelWriter& writer,
|
||||
const XModelSurfs* modelSurfs,
|
||||
const DistinctMapper<Material*>& materialMapper,
|
||||
const int baseSurfaceIndex)
|
||||
{
|
||||
for (auto surfIndex = 0u; surfIndex < modelSurfs->numsurfs; surfIndex++)
|
||||
{
|
||||
XModelObject object;
|
||||
object.name = "surf" + std::to_string(surfIndex);
|
||||
object.materialIndex = static_cast<int>(materialMapper.GetDistinctPositionByInputPosition(surfIndex + baseSurfaceIndex));
|
||||
|
||||
writer.AddObject(std::move(object));
|
||||
}
|
||||
@ -501,8 +505,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AddXModelFaces(AbstractXModelWriter& writer, const DistinctMapper<Material*>& materialMapper, const XModelSurfs* modelSurfs, const int baseSurfaceIndex)
|
||||
void AddXModelFaces(AbstractXModelWriter& writer, const XModelSurfs* modelSurfs)
|
||||
{
|
||||
for (auto surfIndex = 0u; surfIndex < modelSurfs->numsurfs; surfIndex++)
|
||||
{
|
||||
@ -516,7 +519,6 @@ namespace
|
||||
face.vertexIndex[1] = tri[1] + surface.baseVertIndex;
|
||||
face.vertexIndex[2] = tri[2] + surface.baseVertIndex;
|
||||
face.objectIndex = static_cast<int>(surfIndex);
|
||||
face.materialIndex = static_cast<int>(materialMapper.GetDistinctPositionByInputPosition(surfIndex + baseSurfaceIndex));
|
||||
writer.AddFace(face);
|
||||
}
|
||||
}
|
||||
@ -532,10 +534,10 @@ namespace
|
||||
|
||||
AddXModelBones(context, writer, model);
|
||||
AddXModelMaterials(writer, materialMapper, model);
|
||||
AddXModelObjects(writer, modelSurfs);
|
||||
AddXModelObjects(writer, modelSurfs, materialMapper, model->lodInfo[lod].surfIndex);
|
||||
AddXModelVertices(writer, modelSurfs);
|
||||
AddXModelVertexBoneWeights(writer, modelSurfs, boneWeightCollection);
|
||||
AddXModelFaces(writer, materialMapper, modelSurfs, model->lodInfo[lod].surfIndex);
|
||||
AddXModelFaces(writer, modelSurfs);
|
||||
}
|
||||
|
||||
void DumpXModelExportLod(const AssetDumpingContext& context, const XAssetInfo<XModel>* asset, const unsigned lod)
|
||||
|
@ -317,12 +317,16 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void AddXModelObjects(AbstractXModelWriter& writer, const XModelSurfs* modelSurfs)
|
||||
void AddXModelObjects(AbstractXModelWriter& writer,
|
||||
const XModelSurfs* modelSurfs,
|
||||
const DistinctMapper<Material*>& materialMapper,
|
||||
const int baseSurfaceIndex)
|
||||
{
|
||||
for (auto surfIndex = 0u; surfIndex < modelSurfs->numsurfs; surfIndex++)
|
||||
{
|
||||
XModelObject object;
|
||||
object.name = "surf" + std::to_string(surfIndex);
|
||||
object.materialIndex = static_cast<int>(materialMapper.GetDistinctPositionByInputPosition(surfIndex + baseSurfaceIndex));
|
||||
|
||||
writer.AddObject(std::move(object));
|
||||
}
|
||||
@ -500,8 +504,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AddXModelFaces(AbstractXModelWriter& writer, const DistinctMapper<Material*>& materialMapper, const XModelSurfs* modelSurfs, const int baseSurfaceIndex)
|
||||
void AddXModelFaces(AbstractXModelWriter& writer, const XModelSurfs* modelSurfs)
|
||||
{
|
||||
for (auto surfIndex = 0u; surfIndex < modelSurfs->numsurfs; surfIndex++)
|
||||
{
|
||||
@ -515,7 +518,6 @@ namespace
|
||||
face.vertexIndex[1] = tri[1] + surface.baseVertIndex;
|
||||
face.vertexIndex[2] = tri[2] + surface.baseVertIndex;
|
||||
face.objectIndex = static_cast<int>(surfIndex);
|
||||
face.materialIndex = static_cast<int>(materialMapper.GetDistinctPositionByInputPosition(surfIndex + baseSurfaceIndex));
|
||||
writer.AddFace(face);
|
||||
}
|
||||
}
|
||||
@ -531,10 +533,10 @@ namespace
|
||||
|
||||
AddXModelBones(context, writer, model);
|
||||
AddXModelMaterials(writer, materialMapper, model);
|
||||
AddXModelObjects(writer, modelSurfs);
|
||||
AddXModelObjects(writer, modelSurfs, materialMapper, model->lodInfo[lod].surfIndex);
|
||||
AddXModelVertices(writer, modelSurfs);
|
||||
AddXModelVertexBoneWeights(writer, modelSurfs, boneWeightCollection);
|
||||
AddXModelFaces(writer, materialMapper, modelSurfs, model->lodInfo[lod].surfIndex);
|
||||
AddXModelFaces(writer, modelSurfs);
|
||||
}
|
||||
|
||||
void DumpXModelExportLod(const AssetDumpingContext& context, const XAssetInfo<XModel>* asset, const unsigned lod)
|
||||
|
@ -312,14 +312,16 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void AddXModelObjects(AbstractXModelWriter& writer, const XModel* model, const unsigned lod)
|
||||
void AddXModelObjects(AbstractXModelWriter& writer, const XModel* model, const unsigned lod, const DistinctMapper<Material*>& materialMapper)
|
||||
{
|
||||
const auto surfCount = model->lodInfo[lod].numsurfs;
|
||||
const auto baseSurfaceIndex = model->lodInfo[lod].surfIndex;
|
||||
|
||||
for (auto surfIndex = 0u; surfIndex < surfCount; surfIndex++)
|
||||
{
|
||||
XModelObject object;
|
||||
object.name = "surf" + std::to_string(surfIndex);
|
||||
object.materialIndex = static_cast<int>(materialMapper.GetDistinctPositionByInputPosition(surfIndex + baseSurfaceIndex));
|
||||
|
||||
writer.AddObject(std::move(object));
|
||||
}
|
||||
@ -506,11 +508,10 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void AddXModelFaces(AbstractXModelWriter& writer, const DistinctMapper<Material*>& materialMapper, const XModel* model, const unsigned lod)
|
||||
void AddXModelFaces(AbstractXModelWriter& writer, const XModel* model, const unsigned lod)
|
||||
{
|
||||
const auto* surfs = &model->surfs[model->lodInfo[lod].surfIndex];
|
||||
const auto surfCount = model->lodInfo[lod].numsurfs;
|
||||
const auto baseSurfIndex = model->lodInfo[lod].surfIndex;
|
||||
|
||||
for (auto surfIndex = 0u; surfIndex < surfCount; surfIndex++)
|
||||
{
|
||||
@ -524,7 +525,6 @@ namespace
|
||||
face.vertexIndex[1] = tri[1] + surface.baseVertIndex;
|
||||
face.vertexIndex[2] = tri[2] + surface.baseVertIndex;
|
||||
face.objectIndex = static_cast<int>(surfIndex);
|
||||
face.materialIndex = static_cast<int>(materialMapper.GetDistinctPositionByInputPosition(surfIndex + baseSurfIndex));
|
||||
writer.AddFace(face);
|
||||
}
|
||||
}
|
||||
@ -538,10 +538,10 @@ namespace
|
||||
|
||||
AddXModelBones(context, writer, model);
|
||||
AddXModelMaterials(writer, materialMapper, model);
|
||||
AddXModelObjects(writer, model, lod);
|
||||
AddXModelObjects(writer, model, lod, materialMapper);
|
||||
AddXModelVertices(writer, model, lod);
|
||||
AddXModelVertexBoneWeights(writer, model, lod, boneWeightCollection);
|
||||
AddXModelFaces(writer, materialMapper, model, lod);
|
||||
AddXModelFaces(writer, model, lod);
|
||||
}
|
||||
|
||||
void DumpXModelExportLod(const AssetDumpingContext& context, const XAssetInfo<XModel>* asset, const unsigned lod)
|
||||
|
@ -324,14 +324,16 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void AddXModelObjects(AbstractXModelWriter& writer, const XModel* model, const unsigned lod)
|
||||
void AddXModelObjects(AbstractXModelWriter& writer, const XModel* model, const unsigned lod, const DistinctMapper<Material*>& materialMapper)
|
||||
{
|
||||
const auto surfCount = model->lodInfo[lod].numsurfs;
|
||||
const auto baseSurfaceIndex = model->lodInfo[lod].surfIndex;
|
||||
|
||||
for (auto surfIndex = 0u; surfIndex < surfCount; surfIndex++)
|
||||
{
|
||||
XModelObject object;
|
||||
object.name = "surf" + std::to_string(surfIndex);
|
||||
object.materialIndex = static_cast<int>(materialMapper.GetDistinctPositionByInputPosition(surfIndex + baseSurfaceIndex));
|
||||
|
||||
writer.AddObject(std::move(object));
|
||||
}
|
||||
@ -527,11 +529,10 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
void AddXModelFaces(AbstractXModelWriter& writer, const DistinctMapper<Material*>& materialMapper, const XModel* model, const unsigned lod)
|
||||
void AddXModelFaces(AbstractXModelWriter& writer, const XModel* model, const unsigned lod)
|
||||
{
|
||||
const auto* surfs = &model->surfs[model->lodInfo[lod].surfIndex];
|
||||
const auto surfCount = model->lodInfo[lod].numsurfs;
|
||||
const auto baseSurfIndex = model->lodInfo[lod].surfIndex;
|
||||
|
||||
if (!surfs)
|
||||
return;
|
||||
@ -548,7 +549,6 @@ namespace
|
||||
face.vertexIndex[1] = tri[1] + surface.baseVertIndex;
|
||||
face.vertexIndex[2] = tri[2] + surface.baseVertIndex;
|
||||
face.objectIndex = static_cast<int>(surfIndex);
|
||||
face.materialIndex = static_cast<int>(materialMapper.GetDistinctPositionByInputPosition(surfIndex + baseSurfIndex));
|
||||
writer.AddFace(face);
|
||||
}
|
||||
}
|
||||
@ -562,10 +562,10 @@ namespace
|
||||
|
||||
AddXModelBones(context, writer, model);
|
||||
AddXModelMaterials(writer, materialMapper, model);
|
||||
AddXModelObjects(writer, model, lod);
|
||||
AddXModelObjects(writer, model, lod, materialMapper);
|
||||
AddXModelVertices(writer, model, lod);
|
||||
AddXModelVertexBoneWeights(writer, model, lod, boneWeightCollection);
|
||||
AddXModelFaces(writer, materialMapper, model, lod);
|
||||
AddXModelFaces(writer, model, lod);
|
||||
}
|
||||
|
||||
void DumpXModelExportLod(const AssetDumpingContext& context, const XAssetInfo<XModel>* asset, const unsigned lod)
|
||||
|
@ -140,7 +140,7 @@ class XModelExportWriter6 final : public XModelExportWriterBase
|
||||
const XModelVertex& v1 = m_vertices[face.vertexIndex[1]];
|
||||
const XModelVertex& v2 = m_vertices[face.vertexIndex[2]];
|
||||
|
||||
stream << "TRI " << face.objectIndex << " " << face.materialIndex << " 0 0\n";
|
||||
stream << "TRI " << face.objectIndex << " " << m_objects[face.objectIndex].materialIndex << " 0 0\n";
|
||||
WriteFaceVertex(stream, distinctPositions[0], v0);
|
||||
WriteFaceVertex(stream, distinctPositions[1], v1);
|
||||
WriteFaceVertex(stream, distinctPositions[2], v2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user