finish material

This commit is contained in:
yyc12345 2023-09-14 22:08:40 +08:00
parent 3faea2bbec
commit 248b7e7385
2 changed files with 40 additions and 0 deletions

View File

@ -18,6 +18,7 @@
#include "ObjImpls/CK3dEntity.hpp"
#include "ObjImpls/CK3dObject.hpp"
#include "ObjImpls/CKTexture.hpp"
#include "ObjImpls/CKMaterial.hpp"
namespace LibCmo::CK2 {
@ -272,6 +273,7 @@ CKClassRegister(cid, parentCid, \
EasyClassReg(ObjImpls::CK3dEntity, CK_CLASSID::CKCID_3DENTITY, CK_CLASSID::CKCID_RENDEROBJECT, "3D Entity");
EasyClassReg(ObjImpls::CK3dObject, CK_CLASSID::CKCID_3DOBJECT, CK_CLASSID::CKCID_3DENTITY, "3D Object");
EasyClassReg(ObjImpls::CKTexture, CK_CLASSID::CKCID_TEXTURE, CK_CLASSID::CKCID_BEOBJECT, "Texture");
EasyClassReg(ObjImpls::CKMaterial, CK_CLASSID::CKCID_MATERIAL, CK_CLASSID::CKCID_BEOBJECT, "Material");
#undef EasyClassReg

View File

@ -122,6 +122,44 @@ namespace LibCmo::CK2::ObjImpls {
}
}
// extra texture data
if (chunk->SeekIdentifier(CK_STATESAVEFLAGS_MATERIAL::CK_STATESAVE_MATDATA2)) {
// read 3 extra texture
CK_ID objid;
CKObject* tex = nullptr;
for (size_t i = 1; i < 4; ++i) {
chunk->ReadObjectID(objid);
tex = m_Context->GetObject(objid);
if (tex != nullptr && tex->GetClassID() == CK_CLASSID::CKCID_TEXTURE) {
m_Textures[i] = static_cast<CKTexture*>(tex);
}
}
}
// single effect
if (chunk->SeekIdentifier(CK_STATESAVEFLAGS_MATERIAL::CK_STATESAVE_MATDATA3)) {
CKDWORD data;
chunk->ReadStruct(data);
m_Effect = static_cast<VxMath::VX_EFFECT>(data);
}
// effect with parameter
if (chunk->SeekIdentifier(CK_STATESAVEFLAGS_MATERIAL::CK_STATESAVE_MATDATA5)) {
// MARK: i do not support CKParameter anymore.
// so we downgrade it into single effect type.
// hope this convertion will not break anything.
// drop parameter id.
CK_ID paramid;
chunk->ReadObjectID(paramid);
// read effect self
CKDWORD data;
chunk->ReadStruct(data);
m_Effect = static_cast<VxMath::VX_EFFECT>(data);
}
return true;
}