use new way to define interface funcs in BMap

This commit is contained in:
yyc12345 2023-10-08 15:03:44 +08:00
parent 754a281655
commit 79516d7963
4 changed files with 289 additions and 177 deletions

View File

@ -41,7 +41,6 @@ _Ty CheckGeneralObject(BMap::BMFile* possible_bmfile, LibCmo::CK2::CK_ID possibl
} }
#define CheckCKObject(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CKObject*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_OBJECT) #define CheckCKObject(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CKObject*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_OBJECT)
//#define CheckCKBeObject(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CKBeObject*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_BEOBJECT)
#define CheckCKGroup(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CKGroup*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_GROUP) #define CheckCKGroup(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CKGroup*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_GROUP)
#define CheckCK3dObject(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CK3dObject*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_3DOBJECT) #define CheckCK3dObject(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CK3dObject*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_3DOBJECT)
#define CheckCKMesh(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CKMesh*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_MESH) #define CheckCKMesh(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CKMesh*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_MESH)
@ -50,7 +49,11 @@ _Ty CheckGeneralObject(BMap::BMFile* possible_bmfile, LibCmo::CK2::CK_ID possibl
#pragma endregion #pragma endregion
void BMInit() { #pragma region Module Init & Dispose
bool BMInit() {
if (CheckInited()) return false;
// register IronPad // register IronPad
IronPad::IronPadRegister(); IronPad::IronPadRegister();
// and startup CK environment // and startup CK environment
@ -58,9 +61,13 @@ void BMInit() {
// set init // set init
g_IsInited = true; g_IsInited = true;
return true;
} }
void BMDispose() { bool BMDispose() {
if (!CheckInited()) return false;
// free all existed file reader / writer // free all existed file reader / writer
for (auto ptr : g_AllBMFiles) { for (auto ptr : g_AllBMFiles) {
delete ptr; delete ptr;
@ -79,42 +86,62 @@ void BMDispose() {
LibCmo::CK2::CKShutdown(); LibCmo::CK2::CKShutdown();
// unregister iron pad // unregister iron pad
IronPad::IronPadUnregister(); IronPad::IronPadUnregister();
return true;
} }
#pragma endregion
#pragma region BMFile #pragma region BMFile
BMap::BMFile* BMFile_Load(LibCmo::CKSTRING file_name, LibCmo::CKSTRING temp_folder, LibCmo::CKSTRING texture_folder, LibCmo::CKDWORD encoding_count, LibCmo::CKSTRING encodings[]) { bool BMFile_Load(
if (!CheckInited()) return nullptr; BMPARAM_IN(LibCmo::CKSTRING, file_name),
BMPARAM_IN(LibCmo::CKSTRING, temp_folder),
BMPARAM_IN(LibCmo::CKSTRING, texture_folder),
BMPARAM_IN(LibCmo::CKDWORD, encoding_count),
BMPARAM_IN(LibCmo::CKSTRING*, encodings),
BMPARAM_OUT(BMap::BMFile*, out_file)) {
if (!CheckInited()) return false;
// create a now one and try to load data. // create a now one and try to load data.
std::unique_ptr<BMap::BMFile> file(new BMap::BMFile(temp_folder, texture_folder, encoding_count, encodings, false)); std::unique_ptr<BMap::BMFile> file(new BMap::BMFile(temp_folder, texture_folder, encoding_count, encodings, false));
if (file->IsFreezed()) return nullptr; if (file->IsFreezed()) return false;
if (!file->Load(file_name)) return nullptr; if (!file->Load(file_name)) return false;
// add into list and return // add into list and return
g_AllBMFiles.emplace(file.get()); g_AllBMFiles.emplace(file.get());
return file.release(); BMPARAM_OUT_ASSIGN(out_file, file.release());
return true;
} }
BMap::BMFile* BMFile_Create(LibCmo::CKSTRING temp_folder, LibCmo::CKSTRING texture_folder, LibCmo::CKDWORD encoding_count, LibCmo::CKSTRING encodings[]) { bool BMFile_Create(
if (!CheckInited()) return nullptr; BMPARAM_IN(LibCmo::CKSTRING, temp_folder),
BMPARAM_IN(LibCmo::CKSTRING, texture_folder),
BMPARAM_IN(LibCmo::CKDWORD, encoding_count),
BMPARAM_IN(LibCmo::CKSTRING*, encodings),
BMPARAM_OUT(BMap::BMFile*, out_file)) {
if (!CheckInited()) return false;
// create a now one // create a now one
std::unique_ptr<BMap::BMFile> file(new BMap::BMFile(temp_folder, texture_folder, encoding_count, encodings, false)); std::unique_ptr<BMap::BMFile> file(new BMap::BMFile(temp_folder, texture_folder, encoding_count, encodings, false));
if (file->IsFreezed()) return nullptr; if (file->IsFreezed()) return false;
// add into list and return if success // add into list and return if success
g_AllBMFiles.emplace(file.get()); g_AllBMFiles.emplace(file.get());
return file.release(); BMPARAM_OUT_ASSIGN(out_file, file.release());
return true;
} }
bool BMFile_Save(BMap::BMFile* map_file, LibCmo::CKSTRING file_name, LibCmo::CKINT compreess_level) { bool BMFile_Save(
BMPARAM_IN(BMap::BMFile*, map_file),
BMPARAM_IN(LibCmo::CKSTRING, file_name),
BMPARAM_IN(LibCmo::CKINT, compreess_level)) {
if (!CheckBMFile(map_file)) return false; if (!CheckBMFile(map_file)) return false;
return map_file->Save(file_name, compreess_level); return map_file->Save(file_name, compreess_level);
} }
bool BMFile_Free(BMap::BMFile* map_file) { bool BMFile_Free(BMPARAM_IN(BMap::BMFile*, map_file)) {
if (!CheckBMFile(map_file)) return false; if (!CheckBMFile(map_file)) return false;
g_AllBMFiles.erase(map_file); g_AllBMFiles.erase(map_file);
@ -122,81 +149,97 @@ bool BMFile_Free(BMap::BMFile* map_file) {
return true; return true;
} }
LibCmo::CKDWORD BMFile_GetGroupCount(BMap::BMFile* bmfile) { bool BMFile_GetGroupCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count)) {
if (!CheckBMFile(bmfile)) return 0; if (!CheckBMFile(bmfile)) return false;
return bmfile->GetGroupCount(); BMPARAM_OUT_ASSIGN(out_count, bmfile->GetGroupCount());
return true;
} }
LibCmo::CK2::CK_ID BMFile_GetGroup(BMap::BMFile* bmfile, LibCmo::CKDWORD idx) { bool BMFile_GetGroup(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id)) {
if (!CheckBMFile(bmfile)) return 0; if (!CheckBMFile(bmfile)) return false;
return bmfile->GetGroup(idx); BMPARAM_OUT_ASSIGN(out_id, bmfile->GetGroup(idx));
return true;
} }
LibCmo::CK2::CK_ID BMFile_CreateGroup(BMap::BMFile* bmfile) { bool BMFile_CreateGroup(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id)) {
if (!CheckBMFile(bmfile)) return 0; if (!CheckBMFile(bmfile)) return false;
return bmfile->CreateGroup(); BMPARAM_OUT_ASSIGN(out_id, bmfile->CreateGroup());
return true;
} }
LibCmo::CKDWORD BMFile_Get3dObjectCount(BMap::BMFile* bmfile) { bool BMFile_Get3dObjectCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count)) {
if (!CheckBMFile(bmfile)) return 0; if (!CheckBMFile(bmfile)) return false;
return bmfile->Get3dObjectCount(); BMPARAM_OUT_ASSIGN(out_count, bmfile->Get3dObjectCount());
return true;
} }
LibCmo::CK2::CK_ID BMFile_Get3dObject(BMap::BMFile* bmfile, LibCmo::CKDWORD idx) { bool BMFile_Get3dObject(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id)) {
if (!CheckBMFile(bmfile)) return 0; if (!CheckBMFile(bmfile)) return false;
return bmfile->Get3dObject(idx); BMPARAM_OUT_ASSIGN(out_id, bmfile->Get3dObject(idx));
return true;
} }
LibCmo::CK2::CK_ID BMFile_Create3dObject(BMap::BMFile* bmfile) { bool BMFile_Create3dObject(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id)) {
if (!CheckBMFile(bmfile)) return 0; if (!CheckBMFile(bmfile)) return false;
return bmfile->Create3dObject(); BMPARAM_OUT_ASSIGN(out_id, bmfile->Create3dObject());
return true;
} }
LibCmo::CKDWORD BMFile_GetMeshCount(BMap::BMFile* bmfile) { bool BMFile_GetMeshCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count)) {
if (!CheckBMFile(bmfile)) return 0; if (!CheckBMFile(bmfile)) return false;
return bmfile->GetMeshCount(); BMPARAM_OUT_ASSIGN(out_count, bmfile->GetMeshCount());
return true;
} }
LibCmo::CK2::CK_ID BMFile_GetMesh(BMap::BMFile* bmfile, LibCmo::CKDWORD idx) { bool BMFile_GetMesh(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id)) {
if (!CheckBMFile(bmfile)) return 0; if (!CheckBMFile(bmfile)) return false;
return bmfile->GetMesh(idx); BMPARAM_OUT_ASSIGN(out_id, bmfile->GetMesh(idx));
return true;
} }
LibCmo::CK2::CK_ID BMFile_CreateMesh(BMap::BMFile* bmfile) { bool BMFile_CreateMesh(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id)) {
if (!CheckBMFile(bmfile)) return 0; if (!CheckBMFile(bmfile)) return false;
return bmfile->CreateMesh(); BMPARAM_OUT_ASSIGN(out_id, bmfile->CreateMesh());
return true;
} }
LibCmo::CKDWORD BMFile_GetMaterialCount(BMap::BMFile* bmfile) { bool BMFile_GetMaterialCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count)) {
if (!CheckBMFile(bmfile)) return 0; if (!CheckBMFile(bmfile)) return false;
return bmfile->GetMaterialCount(); BMPARAM_OUT_ASSIGN(out_count, bmfile->GetMaterialCount());
return true;
} }
LibCmo::CK2::CK_ID BMFile_GetMaterial(BMap::BMFile* bmfile, LibCmo::CKDWORD idx) { bool BMFile_GetMaterial(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id)) {
if (!CheckBMFile(bmfile)) return 0; if (!CheckBMFile(bmfile)) return false;
return bmfile->GetMaterial(idx); BMPARAM_OUT_ASSIGN(out_id, bmfile->GetMaterial(idx));
return true;
} }
LibCmo::CK2::CK_ID BMFile_CreateMaterial(BMap::BMFile* bmfile) { bool BMFile_CreateMaterial(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id)) {
if (!CheckBMFile(bmfile)) return 0; if (!CheckBMFile(bmfile)) return false;
return bmfile->CreateMaterial(); BMPARAM_OUT_ASSIGN(out_id, bmfile->CreateMaterial());
return true;
} }
LibCmo::CKDWORD BMFile_GetTextureCount(BMap::BMFile* bmfile) { bool BMFile_GetTextureCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count)) {
if (!CheckBMFile(bmfile)) return 0; if (!CheckBMFile(bmfile)) return false;
return bmfile->GetTextureCount(); BMPARAM_OUT_ASSIGN(out_count, bmfile->GetTextureCount());
return true;
} }
LibCmo::CK2::CK_ID BMFile_GetTexture(BMap::BMFile* bmfile, LibCmo::CKDWORD idx) { bool BMFile_GetTexture(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id)) {
if (!CheckBMFile(bmfile)) return 0; if (!CheckBMFile(bmfile)) return false;
return bmfile->GetTexture(idx); BMPARAM_OUT_ASSIGN(out_id, bmfile->GetTexture(idx));
return true;
} }
LibCmo::CK2::CK_ID BMFile_CreateTexture(BMap::BMFile* bmfile) { bool BMFile_CreateTexture(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id)) {
if (!CheckBMFile(bmfile)) return 0; if (!CheckBMFile(bmfile)) return false;
return bmfile->CreateTexture(); BMPARAM_OUT_ASSIGN(out_id, bmfile->CreateTexture());
return true;
} }
#pragma endregion #pragma endregion
#pragma region BMMeshTransition #pragma region BMMeshTransition
BMap::BMMeshTransition* BMMeshTrans_New() { bool BMMeshTrans_New(BMPARAM_OUT(BMap::BMMeshTransition*, out_trans)) {
if (!CheckInited()) return nullptr; if (!CheckInited()) return false;
// create new one, insert and return. // create new one, insert and return.
auto meshtrans = new BMap::BMMeshTransition(); auto meshtrans = new BMap::BMMeshTransition();
g_AllBMMeshTrans.emplace(meshtrans); g_AllBMMeshTrans.emplace(meshtrans);
return meshtrans; BMPARAM_OUT_ASSIGN(out_trans, meshtrans);
return true;
} }
bool BMMeshTrans_Delete(BMap::BMMeshTransition* trans) { bool BMMeshTrans_Delete(BMPARAM_IN(BMap::BMMeshTransition*, trans)) {
if (!CheckBMMeshTrans(trans)) return false; if (!CheckBMMeshTrans(trans)) return false;
g_AllBMMeshTrans.erase(trans); g_AllBMMeshTrans.erase(trans);
@ -204,59 +247,67 @@ bool BMMeshTrans_Delete(BMap::BMMeshTransition* trans) {
return true; return true;
} }
bool BMMeshTrans_PrepareVertexCount(BMap::BMMeshTransition* trans, LibCmo::CKDWORD count) { bool BMMeshTrans_PrepareVertexCount(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CKDWORD, count)) {
if (!CheckBMMeshTrans(trans)) return false; if (!CheckBMMeshTrans(trans)) return false;
return trans->PrepareVertexCount(count); return trans->PrepareVertexCount(count);
} }
LibCmo::VxMath::VxVector3* BMMeshTrans_PrepareVertex(BMap::BMMeshTransition* trans) { bool BMMeshTrans_PrepareVertex(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::VxMath::VxVector3*, out_mem)) {
if (!CheckBMMeshTrans(trans)) return nullptr; if (!CheckBMMeshTrans(trans)) return false;
return trans->PrepareVertex(); BMPARAM_OUT_ASSIGN(out_mem, trans->PrepareVertex());
return BMPARAM_OUT_VAL(out_mem) != nullptr;
} }
bool BMMeshTrans_PrepareNormalCount(BMap::BMMeshTransition* trans, LibCmo::CKDWORD count) { bool BMMeshTrans_PrepareNormalCount(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CKDWORD, count)) {
if (!CheckBMMeshTrans(trans)) return false; if (!CheckBMMeshTrans(trans)) return false;
return trans->PrepareNormalCount(count); return trans->PrepareNormalCount(count);
} }
LibCmo::VxMath::VxVector3* BMMeshTrans_PrepareNormal(BMap::BMMeshTransition* trans) { bool BMMeshTrans_PrepareNormal(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::VxMath::VxVector3*, out_mem)) {
if (!CheckBMMeshTrans(trans)) return nullptr; if (!CheckBMMeshTrans(trans)) return false;
return trans->PrepareNormal(); BMPARAM_OUT_ASSIGN(out_mem, trans->PrepareNormal());
return BMPARAM_OUT_VAL(out_mem) != nullptr;
} }
bool BMMeshTrans_PrepareUVCount(BMap::BMMeshTransition* trans, LibCmo::CKDWORD count) { bool BMMeshTrans_PrepareUVCount(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CKDWORD, count)) {
if (!CheckBMMeshTrans(trans)) return false; if (!CheckBMMeshTrans(trans)) return false;
return trans->PrepareUVCount(count); return trans->PrepareUVCount(count);
} }
LibCmo::VxMath::VxVector2* BMMeshTrans_PrepareUV(BMap::BMMeshTransition* trans) { bool BMMeshTrans_PrepareUV(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::VxMath::VxVector2*, out_mem)) {
if (!CheckBMMeshTrans(trans)) return nullptr; if (!CheckBMMeshTrans(trans)) return false;
return trans->PrepareUV(); BMPARAM_OUT_ASSIGN(out_mem, trans->PrepareUV());
return BMPARAM_OUT_VAL(out_mem) != nullptr;
} }
bool BMMeshTrans_PrepareMtlSlotCount(BMap::BMMeshTransition* trans, LibCmo::CKDWORD count) { bool BMMeshTrans_PrepareMtlSlotCount(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CKDWORD, count)) {
if (!CheckBMMeshTrans(trans)) return false; if (!CheckBMMeshTrans(trans)) return false;
return trans->PrepareMtlSlotCount(count); return trans->PrepareMtlSlotCount(count);
} }
LibCmo::CK2::CK_ID* BMMeshTrans_PrepareMtlSlot(BMap::BMMeshTransition* trans) { bool BMMeshTrans_PrepareMtlSlot(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::CK2::CK_ID*, out_mem)) {
if (!CheckBMMeshTrans(trans)) return nullptr; if (!CheckBMMeshTrans(trans)) return false;
return trans->PrepareMtlSlot(); BMPARAM_OUT_ASSIGN(out_mem, trans->PrepareMtlSlot());
return BMPARAM_OUT_VAL(out_mem) != nullptr;
} }
bool BMMeshTrans_PrepareFaceCount(BMap::BMMeshTransition* trans, LibCmo::CKDWORD count) { bool BMMeshTrans_PrepareFaceCount(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CKDWORD, count)) {
if (!CheckBMMeshTrans(trans)) return false; if (!CheckBMMeshTrans(trans)) return false;
return trans->PrepareFaceCount(count); return trans->PrepareFaceCount(count);
} }
LibCmo::CKDWORD* BMMeshTrans_PrepareFaceVertexIndices(BMap::BMMeshTransition* trans) { bool BMMeshTrans_PrepareFaceVertexIndices(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::CKDWORD*, out_mem)) {
if (!CheckBMMeshTrans(trans)) return nullptr; if (!CheckBMMeshTrans(trans)) return false;
return trans->PrepareFaceVertexIndices(); BMPARAM_OUT_ASSIGN(out_mem, trans->PrepareFaceVertexIndices());
return BMPARAM_OUT_VAL(out_mem) != nullptr;
} }
LibCmo::CKDWORD* BMMeshTrans_PrepareFaceNormalIndices(BMap::BMMeshTransition* trans) { bool BMMeshTrans_PrepareFaceNormalIndices(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::CKDWORD*, out_mem)) {
if (!CheckBMMeshTrans(trans)) return nullptr; if (!CheckBMMeshTrans(trans)) return false;
return trans->PrepareFaceNormalIndices(); BMPARAM_OUT_ASSIGN(out_mem, trans->PrepareFaceNormalIndices());
return BMPARAM_OUT_VAL(out_mem) != nullptr;
} }
LibCmo::CKDWORD* BMMeshTrans_PrepareFaceUVIndices(BMap::BMMeshTransition* trans) { bool BMMeshTrans_PrepareFaceUVIndices(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::CKDWORD*, out_mem)) {
if (!CheckBMMeshTrans(trans)) return nullptr; if (!CheckBMMeshTrans(trans)) return false;
return trans->PrepareFaceUVIndices(); BMPARAM_OUT_ASSIGN(out_mem, trans->PrepareFaceUVIndices());
return BMPARAM_OUT_VAL(out_mem) != nullptr;
} }
LibCmo::CKDWORD* BMMeshTrans_PrepareFaceMtlSlot(BMap::BMMeshTransition* trans) { bool BMMeshTrans_PrepareFaceMtlSlot(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::CKDWORD*, out_mem)) {
if (!CheckBMMeshTrans(trans)) return nullptr; if (!CheckBMMeshTrans(trans)) return false;
return trans->PrepareFaceMtlSlot(); BMPARAM_OUT_ASSIGN(out_mem, trans->PrepareFaceMtlSlot());
return BMPARAM_OUT_VAL(out_mem) != nullptr;
} }
bool BMMeshTrans_Parse(BMap::BMMeshTransition* trans, LibCmo::CK2::ObjImpls::CKMesh* write_into_mesh) { bool BMMeshTrans_Parse(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CK2::ObjImpls::CKMesh*, write_into_mesh)) {
if (!CheckBMMeshTrans(trans)) return false; if (!CheckBMMeshTrans(trans)) return false;
return trans->Parse(write_into_mesh); return trans->Parse(write_into_mesh);
} }
@ -265,15 +316,18 @@ bool BMMeshTrans_Parse(BMap::BMMeshTransition* trans, LibCmo::CK2::ObjImpls::CKM
#pragma region CKObject #pragma region CKObject
LibCmo::CKSTRING BMObject_GetName(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid) { bool BMObject_GetName(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKSTRING, out_name)) {
auto obj = CheckCKObject(bmfile, objid);
if (obj == nullptr) return nullptr;
return obj->GetName();
}
bool BMObject_SetName(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid, LibCmo::CKSTRING name) {
auto obj = CheckCKObject(bmfile, objid); auto obj = CheckCKObject(bmfile, objid);
if (obj == nullptr) return false; if (obj == nullptr) return false;
BMPARAM_OUT_ASSIGN(out_name, obj->GetName());
return true;
}
bool BMObject_SetName(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKSTRING name)) {
auto obj = CheckCKObject(bmfile, objid);
if (obj == nullptr) return false;
obj->SetName(name); obj->SetName(name);
return true; return true;
} }
@ -282,7 +336,7 @@ bool BMObject_SetName(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid, LibCmo::CK
#pragma region CKGroup #pragma region CKGroup
bool BMGroup_AddObject(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid, LibCmo::CK2::CK_ID memberid) { bool BMGroup_AddObject(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_ID memberid)) {
auto obj = CheckCKGroup(bmfile, objid); auto obj = CheckCKGroup(bmfile, objid);
auto memberobj = CheckCK3dObject(bmfile, memberid); auto memberobj = CheckCK3dObject(bmfile, memberid);
if (obj == nullptr || memberobj == nullptr) return false; if (obj == nullptr || memberobj == nullptr) return false;
@ -290,17 +344,20 @@ bool BMGroup_AddObject(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid, LibCmo::C
return obj->AddObject(memberobj) == LibCmo::CK2::CKERROR::CKERR_OK; return obj->AddObject(memberobj) == LibCmo::CK2::CKERROR::CKERR_OK;
} }
LibCmo::CKDWORD BMGroup_GetObjectCount(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid) { bool BMGroup_GetObjectCount(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKDWORD, out_count)) {
auto obj = CheckCKGroup(bmfile, objid); auto obj = CheckCKGroup(bmfile, objid);
if (obj == nullptr) return false; if (obj == nullptr) return false;
return obj->GetObjectCount();
BMPARAM_OUT_ASSIGN(out_count, obj->GetObjectCount());
return true;
} }
LibCmo::CK2::CK_ID BMGroup_GetObject(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid, LibCmo::CKDWORD pos) { bool BMGroup_GetObject(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKDWORD pos), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_objid)) {
auto obj = CheckCKGroup(bmfile, objid); auto obj = CheckCKGroup(bmfile, objid);
if (obj == nullptr) return 0; if (obj == nullptr) return false;
return SafeGetID(obj->GetObject(pos)); BMPARAM_OUT_ASSIGN(out_objid, SafeGetID(obj->GetObject(pos)));
return true;
} }
#pragma endregion #pragma endregion
@ -319,7 +376,7 @@ LibCmo::CK2::CK_ID BMGroup_GetObject(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID ob
#pragma region CK3dObject #pragma region CK3dObject
CStyleVxMatrix BM3dEntity_GetWorldMatrix(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid) { CStyleVxMatrix BM3dEntity_GetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid)) {
CStyleVxMatrix result; CStyleVxMatrix result;
auto obj = CheckCK3dObject(bmfile, objid); auto obj = CheckCK3dObject(bmfile, objid);
if (obj == nullptr) { if (obj == nullptr) {
@ -331,7 +388,7 @@ CStyleVxMatrix BM3dEntity_GetWorldMatrix(BMap::BMFile* bmfile, LibCmo::CK2::CK_I
return result; return result;
} }
bool BM3dEntity_SetWorldMatrix(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid, CStyleVxMatrix mat) { bool BM3dEntity_SetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid), CStyleVxMatrix mat) {
auto obj = CheckCK3dObject(bmfile, objid); auto obj = CheckCK3dObject(bmfile, objid);
if (obj == nullptr) return false; if (obj == nullptr) return false;
@ -341,14 +398,14 @@ bool BM3dEntity_SetWorldMatrix(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid, C
return true; return true;
} }
LibCmo::CK2::CK_ID BM3dEntity_GetCurrentMesh(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid) { LibCmo::CK2::CK_ID BM3dEntity_GetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid)) {
auto obj = CheckCK3dObject(bmfile, objid); auto obj = CheckCK3dObject(bmfile, objid);
if (obj == nullptr) return 0; if (obj == nullptr) return 0;
return SafeGetID(obj->GetCurrentMesh()); return SafeGetID(obj->GetCurrentMesh());
} }
bool BM3dEntity_SetCurrentMesh(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid, LibCmo::CK2::CK_ID meshid) { bool BM3dEntity_SetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), LibCmo::CK2::CK_ID meshid) {
auto obj = CheckCK3dObject(bmfile, objid); auto obj = CheckCK3dObject(bmfile, objid);
auto meshobj = CheckCKMesh(bmfile, meshid); auto meshobj = CheckCKMesh(bmfile, meshid);
if (obj == nullptr || meshobj == nullptr) return false; if (obj == nullptr || meshobj == nullptr) return false;
@ -357,14 +414,14 @@ bool BM3dEntity_SetCurrentMesh(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid, L
return true; return true;
} }
bool BM3dEntity_GetVisibility(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid) { bool BM3dEntity_GetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid)) {
auto obj = CheckCK3dObject(bmfile, objid); auto obj = CheckCK3dObject(bmfile, objid);
if (obj == nullptr) return false; if (obj == nullptr) return false;
return obj->IsVisible(); return obj->IsVisible();
} }
bool BM3dEntity_SetVisibility(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid, bool is_visible) { bool BM3dEntity_SetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), bool is_visible) {
auto obj = CheckCK3dObject(bmfile, objid); auto obj = CheckCK3dObject(bmfile, objid);
if (obj == nullptr) return false; if (obj == nullptr) return false;

View File

@ -3,100 +3,155 @@
#include "BMap.hpp" #include "BMap.hpp"
#include <algorithm> #include <algorithm>
/* /**
Design Note: @note
# Design Note:
## Function Declaration
All exported interface functions will always return a bool to indicate whether current operations is successful.
The layout of interface functions' parameters is Essential Param -> Input Param -> Out Param.
A example is in there: `LIBCMO_EXPORT bool BMSomeFunc(BMPARAM_OBJECT_DECL, BMPARAM_IN(LibCmo::CK2::CK_ID, someobj), BMPARAM_OUT(LibCmo::CKSTRING, out_name))`
First param is `BMPARAM_OBJECT_DECL`. It is essential param for this function. In this exmaple, it is the combination of BMFile* and CK_ID. If your provide invalid value for them, the function will failed immediately.
Second param is `BMPARAM_IN(LibCmo::CK2::CK_ID, someobj)`. It declare this function accept a Object ID for underlying function calling.
Last param is `BMPARAM_OUT(LibCmo::CKSTRING, out_name)`. It is the return value of this function. Only will be filled when this function success.
Input Param and Out Param can be multiple. No count limit.
## CK_ID Interface.
We use CK_ID as CKObject visitor to ensure the visiting is safe.
We choose CK_ID because checking a valid CK_ID is more easy and cost lower performance than checking a valid CKObject*.
Another reason is that CKObject* relate to class inheritance and need cast. Use CK_ID can leyt them get safe cast in C++, not in other binding languages.
Each CK_ID also should be used with its corresponding BMFile*, because each BMfile* will create a unique CKContext*. CK_ID between different BMFile* is not shared.
+ We use raw pointer for BMFile and BMMeshTransition + We use raw pointer for BMFile and BMMeshTransition
- These 2 class do no involve class inheritance so we can safely pass them to this DLL. - These 2 class do no involve class inheritance so we can safely pass them to this DLL.
- These 2 class is not a part of CK core. It is more easy to check them validation. It is enough checking them in a std::set. - These 2 class is not a part of CK core. It is more easy to check them validation. It is enough checking them in a std::set.
+ We use CK_ID as CKObject visitor to ensure the visiting is safe.
- We choose CK_ID because checking a valid CK_ID is more easy and cost lower performance than checking a valid CKObject*.
- Another reason is that CKObject* relate to class inheritance and need cast. Use CK_ID can leyt them get safe cast in C++, not in other binding languages.
- Each CK_ID also should be used with its corresponding BMFile*, because each BMfile* will create a unique CKContext*. CK_ID between different BMFile* is not shared.
*/ */
// some macro to help export function define. // ===== Interface Used Macro =====
#define BMPARAM_FILE_DECL BMap::BMFile* bmfile /** The first param used by BMFile function family */
#define BMPARAM_MESHTRANS_DECL BMap::BMMeshTransition* trans #define BMPARAM_FILE_DECL(_bmfile) BMap::BMFile* _bmfile
#define BMPARAM_OBJECT_DECL BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid /** The first param used by BMMeshTrans function family */
#define BMPARAM_MESHTRANS_DECL(_trans) BMap::BMMeshTransition* _trans
/** The first param used by BMObject, BMGroup, BM3dObject, BMMesh, BMMaterial and BMTexture function family */
#define BMPARAM_OBJECT_DECL(_bmfile, _objid) BMap::BMFile* _bmfile, LibCmo::CK2::CK_ID _objid
/** Declare an input parameter */
#define BMPARAM_IN(_t, _name) _t _name #define BMPARAM_IN(_t, _name) _t _name
/**
Declare an output parameter.
A pointer will be added automatically for caller receive it.
See BMPARAM_OUT_ASSIGN and BMPARAM_OUT_VAL to know how to use output param in function body.
@remark
There is an example:
```
bool some_interface_func(BMPARAM_OUT(Type_t, param_name)) {
BMPARAM_OUT_ASSIGN(param_name, some_value); // assign to out param.
return BMPARAM_OUT_VAL(param_name) != other_value; // use out param value.
}
@see BMPARAM_OUT_ASSIGN, BMPARAM_OUT_VAL
```
*/
#define BMPARAM_OUT(_t, _name) _t* _name #define BMPARAM_OUT(_t, _name) _t* _name
/** Assign value for out param in function body. */
#define BMPARAM_OUT_ASSIGN(_name, _val) (*(_name)) = (_val)
/** Visit value for out param in function body. */
#define BMPARAM_OUT_VAL(_name) (*(_name))
#pragma region Init / Dispose #pragma region Init / Dispose
LIBCMO_EXPORT void BMInit(); LIBCMO_EXPORT bool BMInit();
LIBCMO_EXPORT void BMDispose(); LIBCMO_EXPORT bool BMDispose();
#pragma endregion #pragma endregion
#pragma region BMFile #pragma region BMFile
LIBCMO_EXPORT BMap::BMFile* BMFile_Load(LibCmo::CKSTRING file_name, LibCmo::CKSTRING temp_folder, LibCmo::CKSTRING texture_folder, LibCmo::CKDWORD encoding_count, LibCmo::CKSTRING encodings[]); LIBCMO_EXPORT bool BMFile_Load(
LIBCMO_EXPORT BMap::BMFile* BMFile_Create(LibCmo::CKSTRING temp_folder, LibCmo::CKSTRING texture_folder, LibCmo::CKDWORD encoding_count, LibCmo::CKSTRING encodings[]); BMPARAM_IN(LibCmo::CKSTRING, file_name),
LIBCMO_EXPORT bool BMFile_Save(BMap::BMFile* map_file, LibCmo::CKSTRING file_name, LibCmo::CKINT compreess_level); BMPARAM_IN(LibCmo::CKSTRING, temp_folder),
LIBCMO_EXPORT bool BMFile_Free(BMap::BMFile* map_file); BMPARAM_IN(LibCmo::CKSTRING, texture_folder),
BMPARAM_IN(LibCmo::CKDWORD, encoding_count),
BMPARAM_IN(LibCmo::CKSTRING*, encodings),
BMPARAM_OUT(BMap::BMFile*, out_file)
);
LIBCMO_EXPORT bool BMFile_Create(
BMPARAM_IN(LibCmo::CKSTRING, temp_folder),
BMPARAM_IN(LibCmo::CKSTRING, texture_folder),
BMPARAM_IN(LibCmo::CKDWORD, encoding_count),
BMPARAM_IN(LibCmo::CKSTRING*, encodings),
BMPARAM_OUT(BMap::BMFile*, out_file)
);
LIBCMO_EXPORT bool BMFile_Save(
BMPARAM_IN(BMap::BMFile*, map_file),
BMPARAM_IN(LibCmo::CKSTRING, file_name),
BMPARAM_IN(LibCmo::CKINT, compreess_level)
);
LIBCMO_EXPORT bool BMFile_Free(
BMPARAM_IN(BMap::BMFile*, map_file)
);
LIBCMO_EXPORT LibCmo::CKDWORD BMFile_GetGroupCount(BMap::BMFile* bmfile); LIBCMO_EXPORT bool BMFile_GetGroupCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
LIBCMO_EXPORT LibCmo::CK2::CK_ID BMFile_GetGroup(BMap::BMFile* bmfile, LibCmo::CKDWORD idx); LIBCMO_EXPORT bool BMFile_GetGroup(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
LIBCMO_EXPORT LibCmo::CK2::CK_ID BMFile_CreateGroup(BMap::BMFile* bmfile); LIBCMO_EXPORT bool BMFile_CreateGroup(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
LIBCMO_EXPORT LibCmo::CKDWORD BMFile_Get3dObjectCount(BMap::BMFile* bmfile); LIBCMO_EXPORT bool BMFile_Get3dObjectCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
LIBCMO_EXPORT LibCmo::CK2::CK_ID BMFile_Get3dObject(BMap::BMFile* bmfile, LibCmo::CKDWORD idx); LIBCMO_EXPORT bool BMFile_Get3dObject(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
LIBCMO_EXPORT LibCmo::CK2::CK_ID BMFile_Create3dObject(BMap::BMFile* bmfile); LIBCMO_EXPORT bool BMFile_Create3dObject(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
LIBCMO_EXPORT LibCmo::CKDWORD BMFile_GetMeshCount(BMap::BMFile* bmfile); LIBCMO_EXPORT bool BMFile_GetMeshCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
LIBCMO_EXPORT LibCmo::CK2::CK_ID BMFile_GetMesh(BMap::BMFile* bmfile, LibCmo::CKDWORD idx); LIBCMO_EXPORT bool BMFile_GetMesh(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
LIBCMO_EXPORT LibCmo::CK2::CK_ID BMFile_CreateMesh(BMap::BMFile* bmfile); LIBCMO_EXPORT bool BMFile_CreateMesh(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
LIBCMO_EXPORT LibCmo::CKDWORD BMFile_GetMaterialCount(BMap::BMFile* bmfile); LIBCMO_EXPORT bool BMFile_GetMaterialCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
LIBCMO_EXPORT LibCmo::CK2::CK_ID BMFile_GetMaterial(BMap::BMFile* bmfile, LibCmo::CKDWORD idx); LIBCMO_EXPORT bool BMFile_GetMaterial(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
LIBCMO_EXPORT LibCmo::CK2::CK_ID BMFile_CreateMaterial(BMap::BMFile* bmfile); LIBCMO_EXPORT bool BMFile_CreateMaterial(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
LIBCMO_EXPORT LibCmo::CKDWORD BMFile_GetTextureCount(BMap::BMFile* bmfile); LIBCMO_EXPORT bool BMFile_GetTextureCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
LIBCMO_EXPORT LibCmo::CK2::CK_ID BMFile_GetTexture(BMap::BMFile* bmfile, LibCmo::CKDWORD idx); LIBCMO_EXPORT bool BMFile_GetTexture(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
LIBCMO_EXPORT LibCmo::CK2::CK_ID BMFile_CreateTexture(BMap::BMFile* bmfile); LIBCMO_EXPORT bool BMFile_CreateTexture(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
#pragma endregion #pragma endregion
#pragma region BMMeshTransition #pragma region BMMeshTransition
LIBCMO_EXPORT BMap::BMMeshTransition* BMMeshTrans_New(); LIBCMO_EXPORT bool BMMeshTrans_New(BMPARAM_OUT(BMap::BMMeshTransition*, out_trans));
LIBCMO_EXPORT bool BMMeshTrans_Delete(BMap::BMMeshTransition* trans); LIBCMO_EXPORT bool BMMeshTrans_Delete(BMPARAM_IN(BMap::BMMeshTransition*, trans));
LIBCMO_EXPORT bool BMMeshTrans_PrepareVertexCount(BMap::BMMeshTransition* trans, LibCmo::CKDWORD count); LIBCMO_EXPORT bool BMMeshTrans_PrepareVertexCount(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CKDWORD, count));
LIBCMO_EXPORT LibCmo::VxMath::VxVector3* BMMeshTrans_PrepareVertex(BMap::BMMeshTransition* trans); LIBCMO_EXPORT bool BMMeshTrans_PrepareVertex(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::VxMath::VxVector3*, out_mem));
LIBCMO_EXPORT bool BMMeshTrans_PrepareNormalCount(BMap::BMMeshTransition* trans, LibCmo::CKDWORD count); LIBCMO_EXPORT bool BMMeshTrans_PrepareNormalCount(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CKDWORD, count));
LIBCMO_EXPORT LibCmo::VxMath::VxVector3* BMMeshTrans_PrepareNormal(BMap::BMMeshTransition* trans); LIBCMO_EXPORT bool BMMeshTrans_PrepareNormal(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::VxMath::VxVector3*, out_mem));
LIBCMO_EXPORT bool BMMeshTrans_PrepareUVCount(BMap::BMMeshTransition* trans, LibCmo::CKDWORD count); LIBCMO_EXPORT bool BMMeshTrans_PrepareUVCount(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CKDWORD, count));
LIBCMO_EXPORT LibCmo::VxMath::VxVector2* BMMeshTrans_PrepareUV(BMap::BMMeshTransition* trans); LIBCMO_EXPORT bool BMMeshTrans_PrepareUV(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::VxMath::VxVector2*, out_mem));
LIBCMO_EXPORT bool BMMeshTrans_PrepareMtlSlotCount(BMap::BMMeshTransition* trans, LibCmo::CKDWORD count); LIBCMO_EXPORT bool BMMeshTrans_PrepareMtlSlotCount(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CKDWORD, count));
LIBCMO_EXPORT LibCmo::CK2::CK_ID* BMMeshTrans_PrepareMtlSlot(BMap::BMMeshTransition* trans); LIBCMO_EXPORT bool BMMeshTrans_PrepareMtlSlot(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::CK2::CK_ID*, out_mem));
LIBCMO_EXPORT bool BMMeshTrans_PrepareFaceCount(BMap::BMMeshTransition* trans, LibCmo::CKDWORD count); LIBCMO_EXPORT bool BMMeshTrans_PrepareFaceCount(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CKDWORD, count));
LIBCMO_EXPORT LibCmo::CKDWORD* BMMeshTrans_PrepareFaceVertexIndices(BMap::BMMeshTransition* trans); LIBCMO_EXPORT bool BMMeshTrans_PrepareFaceVertexIndices(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::CKDWORD*, out_mem));
LIBCMO_EXPORT LibCmo::CKDWORD* BMMeshTrans_PrepareFaceNormalIndices(BMap::BMMeshTransition* trans); LIBCMO_EXPORT bool BMMeshTrans_PrepareFaceNormalIndices(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::CKDWORD*, out_mem));
LIBCMO_EXPORT LibCmo::CKDWORD* BMMeshTrans_PrepareFaceUVIndices(BMap::BMMeshTransition* trans); LIBCMO_EXPORT bool BMMeshTrans_PrepareFaceUVIndices(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::CKDWORD*, out_mem));
LIBCMO_EXPORT LibCmo::CKDWORD* BMMeshTrans_PrepareFaceMtlSlot(BMap::BMMeshTransition* trans); LIBCMO_EXPORT bool BMMeshTrans_PrepareFaceMtlSlot(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_OUT(LibCmo::CKDWORD*, out_mem));
LIBCMO_EXPORT bool BMMeshTrans_Parse(BMap::BMMeshTransition* trans, LibCmo::CK2::ObjImpls::CKMesh* write_into_mesh); LIBCMO_EXPORT bool BMMeshTrans_Parse(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(LibCmo::CK2::ObjImpls::CKMesh*, write_into_mesh));
#pragma endregion #pragma endregion
#pragma region CKObject #pragma region CKObject
LIBCMO_EXPORT LibCmo::CKSTRING BMObject_GetName(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid); LIBCMO_EXPORT bool BMObject_GetName(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKSTRING, out_name));
LIBCMO_EXPORT bool BMObject_SetName(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid, LibCmo::CKSTRING name); LIBCMO_EXPORT bool BMObject_SetName(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKSTRING name));
#pragma endregion #pragma endregion
#pragma region CKGroup #pragma region CKGroup
LIBCMO_EXPORT bool BMGroup_AddObject(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid, LibCmo::CK2::CK_ID memberid); LIBCMO_EXPORT bool BMGroup_AddObject(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_ID memberid));
LIBCMO_EXPORT LibCmo::CKDWORD BMGroup_GetObjectCount(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid); LIBCMO_EXPORT bool BMGroup_GetObjectCount(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
LIBCMO_EXPORT LibCmo::CK2::CK_ID BMGroup_GetObject(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid, LibCmo::CKDWORD pos); LIBCMO_EXPORT bool BMGroup_GetObject(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKDWORD pos), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_objid));
#pragma endregion #pragma endregion
#pragma region CKTexture #pragma region CKTexture
LIBCMO_EXPORT bool BMTexture_PrepareSlotCount(); LIBCMO_EXPORT LibCmo::CKSTRING BMTexture_GetFileName();
LIBCMO_EXPORT LibCmo::CKSTRING BMTexture_GetSlotFileName();
LIBCMO_EXPORT bool BMTexture_LoadImage(LibCmo::CKSTRING filename); LIBCMO_EXPORT bool BMTexture_LoadImage(LibCmo::CKSTRING filename);
LIBCMO_EXPORT bool BMTexture_SaveImage(LibCmo::CKSTRING filename); LIBCMO_EXPORT bool BMTexture_SaveImage(LibCmo::CKSTRING filename);
LIBCMO_EXPORT LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS BMTexture_GetSaveOptions(); LIBCMO_EXPORT LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS BMTexture_GetSaveOptions();
@ -125,11 +180,11 @@ struct CStyleVxMatrix {
} }
}; };
LIBCMO_EXPORT CStyleVxMatrix BM3dEntity_GetWorldMatrix(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid); LIBCMO_EXPORT CStyleVxMatrix BM3dEntity_GetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid));
LIBCMO_EXPORT bool BM3dEntity_SetWorldMatrix(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid, CStyleVxMatrix mat); LIBCMO_EXPORT bool BM3dEntity_SetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid), CStyleVxMatrix mat);
LIBCMO_EXPORT LibCmo::CK2::CK_ID BM3dEntity_GetCurrentMesh(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid); LIBCMO_EXPORT LibCmo::CK2::CK_ID BM3dEntity_GetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid));
LIBCMO_EXPORT bool BM3dEntity_SetCurrentMesh(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid, LibCmo::CK2::CK_ID meshid); LIBCMO_EXPORT bool BM3dEntity_SetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), LibCmo::CK2::CK_ID meshid);
LIBCMO_EXPORT bool BM3dEntity_GetVisibility(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid); LIBCMO_EXPORT bool BM3dEntity_GetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid));
LIBCMO_EXPORT bool BM3dEntity_SetVisibility(BMap::BMFile* bmfile, LibCmo::CK2::CK_ID objid, bool is_visible); LIBCMO_EXPORT bool BM3dEntity_SetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), bool is_visible);
#pragma endregion #pragma endregion

View File

@ -228,7 +228,7 @@ namespace BMap {
#pragma region BMfile #pragma region BMfile
BMFile::BMFile(LibCmo::CKSTRING temp_folder, LibCmo::CKSTRING texture_folder, LibCmo::CKDWORD encoding_count, LibCmo::CKSTRING encodings[], bool is_reader) : BMFile::BMFile(LibCmo::CKSTRING temp_folder, LibCmo::CKSTRING texture_folder, LibCmo::CKDWORD encoding_count, LibCmo::CKSTRING* encodings, bool is_reader) :
m_IsReader(is_reader), m_IsFreezed(false) { m_IsReader(is_reader), m_IsFreezed(false) {
m_Context = new LibCmo::CK2::CKContext(); m_Context = new LibCmo::CK2::CKContext();
// set temp folder and texture folder // set temp folder and texture folder

View File

@ -75,7 +75,7 @@ namespace BMap {
class BMFile { class BMFile {
public: public:
BMFile(LibCmo::CKSTRING temp_folder, LibCmo::CKSTRING texture_folder, LibCmo::CKDWORD encoding_count, LibCmo::CKSTRING encodings[], bool is_reader); BMFile(LibCmo::CKSTRING temp_folder, LibCmo::CKSTRING texture_folder, LibCmo::CKDWORD encoding_count, LibCmo::CKSTRING* encodings, bool is_reader);
~BMFile(); ~BMFile();
LIBCMO_DISABLE_COPY_MOVE(BMFile); LIBCMO_DISABLE_COPY_MOVE(BMFile);