add CKTexture interface functions
This commit is contained in:
parent
79516d7963
commit
0d114974ff
|
@ -324,7 +324,7 @@ bool BMObject_GetName(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CK
|
|||
return true;
|
||||
}
|
||||
|
||||
bool BMObject_SetName(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKSTRING name)) {
|
||||
bool BMObject_SetName(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKSTRING, name)) {
|
||||
auto obj = CheckCKObject(bmfile, objid);
|
||||
if (obj == nullptr) return false;
|
||||
|
||||
|
@ -336,7 +336,7 @@ bool BMObject_SetName(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKS
|
|||
|
||||
#pragma region CKGroup
|
||||
|
||||
bool BMGroup_AddObject(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(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 memberobj = CheckCK3dObject(bmfile, memberid);
|
||||
if (obj == nullptr || memberobj == nullptr) return false;
|
||||
|
@ -352,7 +352,7 @@ bool BMGroup_GetObjectCount(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibC
|
|||
return true;
|
||||
}
|
||||
|
||||
bool BMGroup_GetObject(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKDWORD pos), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_objid)) {
|
||||
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);
|
||||
if (obj == nullptr) return false;
|
||||
|
||||
|
@ -364,6 +364,67 @@ bool BMGroup_GetObject(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK
|
|||
|
||||
#pragma region CKTexture
|
||||
|
||||
bool BMTexture_GetFileName(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKSTRING, out_filename)) {
|
||||
auto obj = CheckCKTexture(bmfile, objid);
|
||||
if (obj == nullptr) return false;
|
||||
|
||||
if (obj->GetUnderlyingData().GetSlotCount() == 0) return false;
|
||||
|
||||
BMPARAM_OUT_ASSIGN(out_filename, obj->GetUnderlyingData().GetSlotFileName(0));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BMTexture_LoadImage(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKSTRING, filename)) {
|
||||
auto obj = CheckCKTexture(bmfile, objid);
|
||||
if (obj == nullptr) return false;
|
||||
|
||||
// resize slot count if needed
|
||||
if (obj->GetUnderlyingData().GetSlotCount() == 0) {
|
||||
obj->GetUnderlyingData().SetSlotCount(1);
|
||||
}
|
||||
|
||||
return obj->LoadImage(filename, 0);
|
||||
}
|
||||
|
||||
bool BMTexture_SaveImage(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKSTRING, filename)) {
|
||||
auto obj = CheckCKTexture(bmfile, objid);
|
||||
if (obj == nullptr) return false;
|
||||
|
||||
return obj->GetUnderlyingData().SaveImage(filename, 0);
|
||||
}
|
||||
|
||||
bool BMTexture_GetSaveOptions(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS, out_saveopt)) {
|
||||
auto obj = CheckCKTexture(bmfile, objid);
|
||||
if (obj == nullptr) return false;
|
||||
|
||||
BMPARAM_OUT_ASSIGN(out_saveopt, obj->GetUnderlyingData().GetSaveOptions());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BMTexture_SetSaveOptions(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS, saveopt)) {
|
||||
auto obj = CheckCKTexture(bmfile, objid);
|
||||
if (obj == nullptr) return false;
|
||||
|
||||
obj->GetUnderlyingData().SetSaveOptions(saveopt);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BMTexture_GetVideoFormat(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VX_PIXELFORMAT, out_vfmt)) {
|
||||
auto obj = CheckCKTexture(bmfile, objid);
|
||||
if (obj == nullptr) return false;
|
||||
|
||||
BMPARAM_OUT_ASSIGN(out_vfmt, obj->GetVideoFormat());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BMTexture_SetVideoFormat(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VX_PIXELFORMAT, vfmt)) {
|
||||
auto obj = CheckCKTexture(bmfile, objid);
|
||||
if (obj == nullptr) return false;
|
||||
|
||||
obj->SetVideoFormat(vfmt);
|
||||
return true;
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region CKMaterial
|
||||
|
@ -376,36 +437,31 @@ bool BMGroup_GetObject(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK
|
|||
|
||||
#pragma region CK3dObject
|
||||
|
||||
CStyleVxMatrix BM3dEntity_GetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid)) {
|
||||
CStyleVxMatrix result;
|
||||
auto obj = CheckCK3dObject(bmfile, objid);
|
||||
if (obj == nullptr) {
|
||||
result.FromVxMatrix(LibCmo::VxMath::VxMatrix());
|
||||
} else {
|
||||
result.FromVxMatrix(obj->GetWorldMatrix());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool BM3dEntity_SetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid), CStyleVxMatrix mat) {
|
||||
bool BM3dEntity_GetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxMatrix, out_mat)) {
|
||||
auto obj = CheckCK3dObject(bmfile, objid);
|
||||
if (obj == nullptr) return false;
|
||||
|
||||
LibCmo::VxMath::VxMatrix cppmat;
|
||||
mat.ToVxMatrix(cppmat);
|
||||
obj->SetWorldMatrix(cppmat);
|
||||
BMPARAM_OUT_ASSIGN(out_mat, obj->GetWorldMatrix());
|
||||
return true;
|
||||
}
|
||||
|
||||
LibCmo::CK2::CK_ID BM3dEntity_GetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid)) {
|
||||
bool BM3dEntity_SetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxMatrix, mat)) {
|
||||
auto obj = CheckCK3dObject(bmfile, objid);
|
||||
if (obj == nullptr) return 0;
|
||||
if (obj == nullptr) return false;
|
||||
|
||||
return SafeGetID(obj->GetCurrentMesh());
|
||||
obj->SetWorldMatrix(mat);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BM3dEntity_SetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), LibCmo::CK2::CK_ID meshid) {
|
||||
bool BM3dEntity_GetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_meshid)) {
|
||||
auto obj = CheckCK3dObject(bmfile, objid);
|
||||
if (obj == nullptr) return false;
|
||||
|
||||
BMPARAM_OUT_ASSIGN(out_meshid, SafeGetID(obj->GetCurrentMesh()));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BM3dEntity_SetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_ID, meshid)) {
|
||||
auto obj = CheckCK3dObject(bmfile, objid);
|
||||
auto meshobj = CheckCKMesh(bmfile, meshid);
|
||||
if (obj == nullptr || meshobj == nullptr) return false;
|
||||
|
@ -414,14 +470,15 @@ bool BM3dEntity_SetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), LibCmo::CK2::
|
|||
return true;
|
||||
}
|
||||
|
||||
bool BM3dEntity_GetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid)) {
|
||||
bool BM3dEntity_GetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_isVisible)) {
|
||||
auto obj = CheckCK3dObject(bmfile, objid);
|
||||
if (obj == nullptr) return false;
|
||||
|
||||
return obj->IsVisible();
|
||||
BMPARAM_OUT_ASSIGN(out_isVisible, obj->IsVisible());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BM3dEntity_SetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), bool is_visible) {
|
||||
bool BM3dEntity_SetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, is_visible)) {
|
||||
auto obj = CheckCK3dObject(bmfile, objid);
|
||||
if (obj == nullptr) return false;
|
||||
|
||||
|
|
|
@ -9,19 +9,19 @@
|
|||
|
||||
## 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.
|
||||
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.
|
||||
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
|
||||
|
@ -41,8 +41,8 @@ Each CK_ID also should be used with its corresponding BMFile*, because each BMfi
|
|||
#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
|
||||
/**
|
||||
Declare an output parameter.
|
||||
/**
|
||||
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
|
||||
|
@ -137,25 +137,27 @@ LIBCMO_EXPORT bool BMMeshTrans_Parse(BMPARAM_MESHTRANS_DECL(trans), BMPARAM_IN(L
|
|||
#pragma region CKObject
|
||||
|
||||
LIBCMO_EXPORT bool BMObject_GetName(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKSTRING, out_name));
|
||||
LIBCMO_EXPORT bool BMObject_SetName(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKSTRING name));
|
||||
LIBCMO_EXPORT bool BMObject_SetName(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKSTRING, name));
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region CKGroup
|
||||
|
||||
LIBCMO_EXPORT bool BMGroup_AddObject(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_ID memberid));
|
||||
LIBCMO_EXPORT bool BMGroup_AddObject(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_ID, memberid));
|
||||
LIBCMO_EXPORT bool BMGroup_GetObjectCount(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
||||
LIBCMO_EXPORT bool BMGroup_GetObject(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKDWORD pos), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_objid));
|
||||
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 region CKTexture
|
||||
|
||||
LIBCMO_EXPORT LibCmo::CKSTRING BMTexture_GetFileName();
|
||||
LIBCMO_EXPORT bool BMTexture_LoadImage(LibCmo::CKSTRING filename);
|
||||
LIBCMO_EXPORT bool BMTexture_SaveImage(LibCmo::CKSTRING filename);
|
||||
LIBCMO_EXPORT LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS BMTexture_GetSaveOptions();
|
||||
LIBCMO_EXPORT bool BMTexture_SetSaveOptions(LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS saveopt);
|
||||
LIBCMO_EXPORT bool BMTexture_GetFileName(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKSTRING, out_filename));
|
||||
LIBCMO_EXPORT bool BMTexture_LoadImage(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKSTRING, filename));
|
||||
LIBCMO_EXPORT bool BMTexture_SaveImage(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKSTRING, filename));
|
||||
LIBCMO_EXPORT bool BMTexture_GetSaveOptions(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS, out_saveopt));
|
||||
LIBCMO_EXPORT bool BMTexture_SetSaveOptions(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS, saveopt));
|
||||
LIBCMO_EXPORT bool BMTexture_GetVideoFormat(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VX_PIXELFORMAT, out_vfmt));
|
||||
LIBCMO_EXPORT bool BMTexture_SetVideoFormat(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VX_PIXELFORMAT, vfmt));
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
@ -169,22 +171,11 @@ LIBCMO_EXPORT bool BMTexture_SetSaveOptions(LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS
|
|||
|
||||
#pragma region CK3dObject
|
||||
|
||||
// This struct is designed to prevent C4190 warning
|
||||
struct CStyleVxMatrix {
|
||||
LibCmo::CKBYTE placeholder[sizeof(LibCmo::VxMath::VxMatrix)];
|
||||
void FromVxMatrix(const LibCmo::VxMath::VxMatrix& mat) {
|
||||
std::memcpy(this, &mat, std::min(sizeof(LibCmo::VxMath::VxMatrix), sizeof(CStyleVxMatrix)));
|
||||
}
|
||||
void ToVxMatrix(LibCmo::VxMath::VxMatrix& mat) {
|
||||
std::memcpy(&mat, this, std::min(sizeof(LibCmo::VxMath::VxMatrix), sizeof(CStyleVxMatrix)));
|
||||
}
|
||||
};
|
||||
|
||||
LIBCMO_EXPORT CStyleVxMatrix BM3dEntity_GetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid));
|
||||
LIBCMO_EXPORT bool BM3dEntity_SetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid), CStyleVxMatrix mat);
|
||||
LIBCMO_EXPORT LibCmo::CK2::CK_ID BM3dEntity_GetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid));
|
||||
LIBCMO_EXPORT bool BM3dEntity_SetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), LibCmo::CK2::CK_ID meshid);
|
||||
LIBCMO_EXPORT bool BM3dEntity_GetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid));
|
||||
LIBCMO_EXPORT bool BM3dEntity_SetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), bool is_visible);
|
||||
LIBCMO_EXPORT bool BM3dEntity_GetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxMatrix, out_mat));
|
||||
LIBCMO_EXPORT bool BM3dEntity_SetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxMatrix, mat));
|
||||
LIBCMO_EXPORT bool BM3dEntity_GetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_meshid));
|
||||
LIBCMO_EXPORT bool BM3dEntity_SetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_ID, meshid));
|
||||
LIBCMO_EXPORT bool BM3dEntity_GetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_isVisible));
|
||||
LIBCMO_EXPORT bool BM3dEntity_SetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, is_visible));
|
||||
|
||||
#pragma endregion
|
||||
|
|
Loading…
Reference in New Issue
Block a user