add feature
- add exmaple cmake configure command in README. - change BMap::Save interface to support compression and texture save opt switches. - update PyBMap due to the change of BMap.
This commit is contained in:
parent
6296261532
commit
92346dc81e
|
@ -137,10 +137,12 @@ bool BMFile_Create(
|
||||||
bool BMFile_Save(
|
bool BMFile_Save(
|
||||||
BMPARAM_IN(BMap::BMFile*, map_file),
|
BMPARAM_IN(BMap::BMFile*, map_file),
|
||||||
BMPARAM_IN(LibCmo::CKSTRING, file_name),
|
BMPARAM_IN(LibCmo::CKSTRING, file_name),
|
||||||
|
BMPARAM_IN(LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS, texture_save_opt),
|
||||||
|
BMPARAM_IN(bool, use_compress),
|
||||||
BMPARAM_IN(LibCmo::CKINT, compreess_level)) {
|
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, texture_save_opt, use_compress, compreess_level);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BMFile_Free(BMPARAM_IN(BMap::BMFile*, map_file)) {
|
bool BMFile_Free(BMPARAM_IN(BMap::BMFile*, map_file)) {
|
||||||
|
|
|
@ -90,6 +90,8 @@ LIBCMO_EXPORT bool BMFile_Create(
|
||||||
LIBCMO_EXPORT bool BMFile_Save(
|
LIBCMO_EXPORT bool BMFile_Save(
|
||||||
BMPARAM_IN(BMap::BMFile*, map_file),
|
BMPARAM_IN(BMap::BMFile*, map_file),
|
||||||
BMPARAM_IN(LibCmo::CKSTRING, file_name),
|
BMPARAM_IN(LibCmo::CKSTRING, file_name),
|
||||||
|
BMPARAM_IN(LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS, texture_save_opt),
|
||||||
|
BMPARAM_IN(bool, use_compress),
|
||||||
BMPARAM_IN(LibCmo::CKINT, compreess_level)
|
BMPARAM_IN(LibCmo::CKINT, compreess_level)
|
||||||
);
|
);
|
||||||
LIBCMO_EXPORT bool BMFile_Free(
|
LIBCMO_EXPORT bool BMFile_Free(
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace BMap {
|
||||||
m_ProcVertexs(), m_ProcFaces(), m_ProcDupRemover() {}
|
m_ProcVertexs(), m_ProcFaces(), m_ProcDupRemover() {}
|
||||||
|
|
||||||
BMMeshTransition::~BMMeshTransition() {}
|
BMMeshTransition::~BMMeshTransition() {}
|
||||||
|
|
||||||
bool BMMeshTransition::PrepareVertexCount(LibCmo::CKDWORD count) {
|
bool BMMeshTransition::PrepareVertexCount(LibCmo::CKDWORD count) {
|
||||||
if (m_IsParsed) return false;
|
if (m_IsParsed) return false;
|
||||||
m_Vertexs.resize(count);
|
m_Vertexs.resize(count);
|
||||||
|
@ -240,7 +240,7 @@ namespace BMap {
|
||||||
if (raw_callback != nullptr) {
|
if (raw_callback != nullptr) {
|
||||||
m_Context->SetOutputCallback([raw_callback](LibCmo::CKSTRING strl) -> void {
|
m_Context->SetOutputCallback([raw_callback](LibCmo::CKSTRING strl) -> void {
|
||||||
raw_callback(strl);
|
raw_callback(strl);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// set temp folder and texture folder
|
// set temp folder and texture folder
|
||||||
|
@ -268,7 +268,7 @@ namespace BMap {
|
||||||
|
|
||||||
bool BMFile::Load(LibCmo::CKSTRING filename) {
|
bool BMFile::Load(LibCmo::CKSTRING filename) {
|
||||||
if (!CanExecLoad()) return false;
|
if (!CanExecLoad()) return false;
|
||||||
|
|
||||||
// create temp ckfile and load
|
// create temp ckfile and load
|
||||||
LibCmo::CK2::CKFileReader reader(m_Context);
|
LibCmo::CK2::CKFileReader reader(m_Context);
|
||||||
LibCmo::CK2::CKERROR err = reader.DeepLoad(filename);
|
LibCmo::CK2::CKERROR err = reader.DeepLoad(filename);
|
||||||
|
@ -312,7 +312,7 @@ namespace BMap {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BMFile::Save(LibCmo::CKSTRING filename, LibCmo::CKINT compress_level) {
|
bool BMFile::Save(LibCmo::CKSTRING filename, LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS texture_save_opt, bool use_compress, LibCmo::CKINT compress_level) {
|
||||||
if (!CanExecSave()) return false;
|
if (!CanExecSave()) return false;
|
||||||
|
|
||||||
// create temp writer
|
// create temp writer
|
||||||
|
@ -335,8 +335,15 @@ namespace BMap {
|
||||||
writer.AddSavedObject(m_Context->GetObject(id));
|
writer.AddSavedObject(m_Context->GetObject(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set global texture save mode
|
||||||
|
m_Context->SetGlobalImagesSaveOptions(texture_save_opt);
|
||||||
// set compress level
|
// set compress level
|
||||||
m_Context->SetCompressionLevel(compress_level);
|
if (use_compress) {
|
||||||
|
m_Context->SetFileWriteMode(LibCmo::CK2::CK_FILE_WRITEMODE::CKFILE_WHOLECOMPRESSED);
|
||||||
|
m_Context->SetCompressionLevel(compress_level);
|
||||||
|
} else {
|
||||||
|
m_Context->SetFileWriteMode(LibCmo::CK2::CK_FILE_WRITEMODE::CKFILE_UNCOMPRESSED);
|
||||||
|
}
|
||||||
|
|
||||||
// save to file and detect error
|
// save to file and detect error
|
||||||
LibCmo::CK2::CKERROR err = writer.Save(filename);
|
LibCmo::CK2::CKERROR err = writer.Save(filename);
|
||||||
|
|
|
@ -70,7 +70,7 @@ namespace BMap {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool Load(LibCmo::CKSTRING filename);
|
bool Load(LibCmo::CKSTRING filename);
|
||||||
bool Save(LibCmo::CKSTRING filename, LibCmo::CKINT compress_level);
|
bool Save(LibCmo::CKSTRING filename, LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS texture_save_opt, bool use_compress, LibCmo::CKINT compress_level);
|
||||||
|
|
||||||
LibCmo::CK2::ObjImpls::CKObject* GetObjectPtr(LibCmo::CK2::CK_ID objid) {
|
LibCmo::CK2::ObjImpls::CKObject* GetObjectPtr(LibCmo::CK2::CK_ID objid) {
|
||||||
return m_Context->GetObject(objid);;
|
return m_Context->GetObject(objid);;
|
||||||
|
|
|
@ -135,9 +135,11 @@ BMFile_Create = _create_bmap_func('BMFile_Create', [bm_CKSTRING, bm_CKSTRING, bm
|
||||||
## BMFile_Save
|
## BMFile_Save
|
||||||
# @param map_file[in] Type: BMap::BMFile*.
|
# @param map_file[in] Type: BMap::BMFile*.
|
||||||
# @param file_name[in] Type: LibCmo::CKSTRING.
|
# @param file_name[in] Type: LibCmo::CKSTRING.
|
||||||
|
# @param texture_save_opt[in] Type: LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS.
|
||||||
|
# @param use_compress[in] Type: bool.
|
||||||
# @param compreess_level[in] Type: LibCmo::CKINT.
|
# @param compreess_level[in] Type: LibCmo::CKINT.
|
||||||
# @return True if no error, otherwise False.
|
# @return True if no error, otherwise False.
|
||||||
BMFile_Save = _create_bmap_func('BMFile_Save', [bm_void_p, bm_CKSTRING, bm_CKINT])
|
BMFile_Save = _create_bmap_func('BMFile_Save', [bm_void_p, bm_CKSTRING, bm_enum, bm_bool, bm_CKINT])
|
||||||
## BMFile_Free
|
## BMFile_Free
|
||||||
# @param map_file[in] Type: BMap::BMFile*.
|
# @param map_file[in] Type: BMap::BMFile*.
|
||||||
# @return True if no error, otherwise False.
|
# @return True if no error, otherwise False.
|
||||||
|
|
|
@ -713,12 +713,14 @@ class BMFileWriter(_AbstractPointer):
|
||||||
def __exit__(self, exc_type, exc_value, traceback):
|
def __exit__(self, exc_type, exc_value, traceback):
|
||||||
self.dispose()
|
self.dispose()
|
||||||
|
|
||||||
def save(self, file_name_: str, compress_level_: int) -> None:
|
def save(self, file_name_: str, texture_save_opt_: virtools_types.CK_TEXTURE_SAVEOPTIONS, use_compress_: bool, compress_level_: int) -> None:
|
||||||
# create param
|
# create param
|
||||||
file_name: bmap.bm_CKSTRING = bmap.bm_CKSTRING(file_name_.encode(g_BMapEncoding))
|
file_name: bmap.bm_CKSTRING = bmap.bm_CKSTRING(file_name_.encode(g_BMapEncoding))
|
||||||
|
texture_save_opt: bmap.bm_enum = bmap.bm_enum(texture_save_opt_.value)
|
||||||
|
use_compress: bmap.bm_bool = bmap.bm_bool(use_compress_)
|
||||||
compress_level: bmap.bm_CKINT = bmap.bm_CKINT(compress_level_)
|
compress_level: bmap.bm_CKINT = bmap.bm_CKINT(compress_level_)
|
||||||
# exec
|
# exec
|
||||||
bmap.BMFile_Save(self._get_pointer(), file_name, compress_level)
|
bmap.BMFile_Save(self._get_pointer(), file_name, texture_save_opt, use_compress, compress_level)
|
||||||
|
|
||||||
def dispose(self) -> None:
|
def dispose(self) -> None:
|
||||||
if self._is_valid():
|
if self._is_valid():
|
||||||
|
|
|
@ -73,4 +73,5 @@ This project require:
|
||||||
* iconv (non-Windows system required)
|
* iconv (non-Windows system required)
|
||||||
|
|
||||||
It can be compiled on Windows via sln file. You should set up `LibRef.props` when using sln file to build this project on Windows.
|
It can be compiled on Windows via sln file. You should set up `LibRef.props` when using sln file to build this project on Windows.
|
||||||
You also can use CMake file to compile this project on Linux or anything else platform. However CMake may not be updated in time because I develop this project on Windows frequently.
|
You also can use CMake file to compile this project on Linux or anything else platform. However CMake may not be updated in time because I develop this project on Windows frequently.
|
||||||
|
You may need use this command to configure CMake: `cmake .. -DSTB_IMAGE_PATH="/path/to/stb-image" -DCMAKE_BUILD_TYPE=Release`
|
||||||
|
|
Loading…
Reference in New Issue
Block a user