From d003b28b2e786698051d2fe5039fafd88d2bc088 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Sun, 8 Oct 2023 21:09:28 +0800 Subject: [PATCH] add material interface functions --- BMap/BMExports.cpp | 285 +++++++++++++++++++++++++++++++++++++++++++++ BMap/BMExports.hpp | 4 +- 2 files changed, 287 insertions(+), 2 deletions(-) diff --git a/BMap/BMExports.cpp b/BMap/BMExports.cpp index e27f6cf..3d00410 100644 --- a/BMap/BMExports.cpp +++ b/BMap/BMExports.cpp @@ -429,6 +429,291 @@ bool BMTexture_SetVideoFormat(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(Lib #pragma region CKMaterial +bool BMMaterial_GetDiffuse(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxColor, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetDiffuse()); + return true; +} +bool BMMaterial_SetDiffuse(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxColor, col)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetDiffuse(col); + return true; +} +bool BMMaterial_GetAmbient(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxColor, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetAmbient()); + return true; +} +bool BMMaterial_SetAmbient(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxColor, col)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetAmbient(col); + return true; +} +bool BMMaterial_GetSpecular(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxColor, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetSpecular()); + return true; +} +bool BMMaterial_SetSpecular(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxColor, col)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetSpecular(col); + return true; +} +bool BMMaterial_GetEmissive(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxColor, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetEmissive()); + return true; +} +bool BMMaterial_SetEmissive(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxColor, col)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetEmissive(col); + return true; +} +bool BMMaterial_GetSpecularPower(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKFLOAT, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetSpecularPower()); + return true; +} +bool BMMaterial_SetSpecularPower(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKFLOAT, val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetSpecularPower(val); + return true; +} + +bool BMMaterial_GetTexture(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_texid)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + + BMPARAM_OUT_ASSIGN(out_texid, SafeGetID(obj->GetTexture(0))); + return true; +} +bool BMMaterial_SetTexture(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_ID, texid)) { + auto obj = CheckCKMaterial(bmfile, objid); + auto texobj = CheckCKTexture(bmfile, texid); + if (obj == nullptr /*|| texobj == nullptr*/) return false; // allow nullptr assign + + obj->SetTexture(texobj, 0); + return true; +} +bool BMMaterial_GetTextureBorderColor(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKDWORD, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetTextureBorderColor()); + return true; +} +bool BMMaterial_SetTextureBorderColor(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKDWORD, val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetTextureBorderColor(val); + return true; +} + +bool BMMaterial_GetTextureBlendMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXTEXTURE_BLENDMODE, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetTextureBlendMode()); + return true; +} +bool BMMaterial_SetTextureBlendMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXTEXTURE_BLENDMODE, val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetTextureBlendMode(val); + return true; +} +bool BMMaterial_GetTextureMinMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXTEXTURE_FILTERMODE, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetTextureMinMode()); + return true; +} +bool BMMaterial_SetTextureMinMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXTEXTURE_FILTERMODE, val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetTextureMinMode(val); + return true; +} +bool BMMaterial_GetTextureMagMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXTEXTURE_FILTERMODE, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetTextureMagMode()); + return true; +} +bool BMMaterial_SetTextureMagMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXTEXTURE_FILTERMODE, val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetTextureMagMode(val); + return true; +} +bool BMMaterial_GetTextureAddressMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXTEXTURE_ADDRESSMODE, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetTextureAddressMode()); + return true; +} +bool BMMaterial_SetTextureAddressMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXTEXTURE_ADDRESSMODE, val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetTextureAddressMode(val); + return true; +} + +bool BMMaterial_GetSourceBlend(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXBLEND_MODE, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetSourceBlend()); + return true; +} +bool BMMaterial_SetSourceBlend(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXBLEND_MODE, val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetSourceBlend(val); + return true; +} +bool BMMaterial_GetDestBlend(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXBLEND_MODE, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetDestBlend()); + return true; +} +bool BMMaterial_SetDestBlend(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXBLEND_MODE, val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetDestBlend(val); + return true; +} +bool BMMaterial_GetFillMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXFILL_MODE, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetFillMode()); + return true; +} +bool BMMaterial_SetFillMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXFILL_MODE, val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetFillMode(val); + return true; +} +bool BMMaterial_GetShadeMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXSHADE_MODE, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetShadeMode()); + return true; +} +bool BMMaterial_SetShadeMode(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXSHADE_MODE, val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetShadeMode(val); + return true; +} + +bool BMMaterial_GetAlphaTestEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetAlphaTestEnabled()); + return true; +} +bool BMMaterial_SetAlphaTestEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, enabled)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetAlphaTestEnabled(enabled); + return true; +} +bool BMMaterial_GetAlphaBlendEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetAlphaBlendEnabled()); + return true; +} +bool BMMaterial_SetAlphaBlendEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, enabled)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetAlphaBlendEnabled(enabled); + return true; +} +bool BMMaterial_GetPerspectiveCorrectionEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetPerspectiveCorrectionEnabled()); + return true; +} +bool BMMaterial_SetPerspectiveCorrectionEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, enabled)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetPerspectiveCorrectionEnabled(enabled); + return true; +} +bool BMMaterial_GetZWriteEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetZWriteEnabled()); + return true; +} +bool BMMaterial_SetZWriteEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, enabled)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetZWriteEnabled(enabled); + return true; +} +bool BMMaterial_GetTwoSidedEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetTwoSidedEnabled()); + return true; +} +bool BMMaterial_SetTwoSidedEnabled(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, enabled)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetTwoSidedEnabled(enabled); + return true; +} + +bool BMMaterial_GetAlphaRef(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKBYTE, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetAlphaRef()); + return true; +} +bool BMMaterial_SetAlphaRef(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKBYTE, val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetAlphaRef(val); + return true; +} +bool BMMaterial_GetAlphaFunc(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXCMPFUNC, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetAlphaFunc()); + return true; +} +bool BMMaterial_SetAlphaFunc(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXCMPFUNC, val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetAlphaFunc(val); + return true; +} +bool BMMaterial_GetZFunc(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXCMPFUNC, out_val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + BMPARAM_OUT_ASSIGN(out_val, obj->GetZFunc()); + return true; +} +bool BMMaterial_SetZFunc(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXCMPFUNC, val)) { + auto obj = CheckCKMaterial(bmfile, objid); + if (obj == nullptr) return false; + obj->SetZFunc(val); + return true; +} + #pragma endregion #pragma region CKMesh diff --git a/BMap/BMExports.hpp b/BMap/BMExports.hpp index 8d10650..8cadc72 100644 --- a/BMap/BMExports.hpp +++ b/BMap/BMExports.hpp @@ -174,8 +174,8 @@ LIBCMO_EXPORT bool BMMaterial_SetEmissive(BMPARAM_OBJECT_DECL(bmfile, objid), BM LIBCMO_EXPORT bool BMMaterial_GetSpecularPower(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKFLOAT, out_val)); LIBCMO_EXPORT bool BMMaterial_SetSpecularPower(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKFLOAT, val)); -LIBCMO_EXPORT bool BMMaterial_GetTexture(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_tex)); -LIBCMO_EXPORT bool BMMaterial_SetTexture(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_ID, tex)); +LIBCMO_EXPORT bool BMMaterial_GetTexture(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_texid)); +LIBCMO_EXPORT bool BMMaterial_SetTexture(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_ID, texid)); LIBCMO_EXPORT bool BMMaterial_GetTextureBorderColor(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKDWORD, out_val)); LIBCMO_EXPORT bool BMMaterial_SetTextureBorderColor(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKDWORD, val));