Compare commits
24 Commits
v0.2.0
...
440bc63432
| Author | SHA1 | Date | |
|---|---|---|---|
| 440bc63432 | |||
| f7acb3bfa9 | |||
| 43984685bc | |||
| c2dafab217 | |||
| 34de35dd31 | |||
| ff2600c8fb | |||
| 9228f343ff | |||
| f9ab66dfc2 | |||
| af6a50c2f9 | |||
| 0bf0519c4c | |||
| c18ff8f2e3 | |||
| fe4a58e864 | |||
| eaeaf956b5 | |||
| 6bb2421e1f | |||
| ead22d13ff | |||
| aeb2e86b14 | |||
| 86b27557c9 | |||
| eef3a352d9 | |||
| b74f1b965c | |||
| c235524403 | |||
| 4bfc4782b5 | |||
| 3eeb1f6cb6 | |||
| ff5a590cf4 | |||
| d29d40448b |
19
.gitignore
vendored
19
.gitignore
vendored
@@ -1,19 +1,24 @@
|
|||||||
# -------------------- Personal --------------------
|
## ======== Personal ========
|
||||||
|
# Ignore build resources
|
||||||
|
out/
|
||||||
|
build/
|
||||||
|
install/
|
||||||
|
extern/
|
||||||
|
temp/
|
||||||
|
|
||||||
# Ignore all possible test used Virtools files
|
# Ignore all possible test used Virtools files
|
||||||
*.nmo
|
*.nmo
|
||||||
*.cmo
|
*.cmo
|
||||||
*.nms
|
*.nms
|
||||||
*.vmo
|
*.vmo
|
||||||
|
|
||||||
# Ignore temporary Visual Studio files and folders
|
# Ignore CMake generated stuff
|
||||||
temp/
|
|
||||||
out/
|
|
||||||
CMakeSettings.json
|
CMakeSettings.json
|
||||||
|
|
||||||
# -------------------- VSCode --------------------
|
## ======== VSCode ========
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
# -------------------- CMake --------------------
|
## ======== CMake ========
|
||||||
CMakeLists.txt.user
|
CMakeLists.txt.user
|
||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
CMakeFiles
|
CMakeFiles
|
||||||
@@ -26,7 +31,7 @@ compile_commands.json
|
|||||||
CTestTestfile.cmake
|
CTestTestfile.cmake
|
||||||
_deps
|
_deps
|
||||||
|
|
||||||
# -------------------- Visual Studio --------------------
|
## ======== Visual Studio ========
|
||||||
## Ignore Visual Studio temporary files, build results, and
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
## files generated by popular Visual Studio add-ons.
|
## files generated by popular Visual Studio add-ons.
|
||||||
##
|
##
|
||||||
|
|||||||
@@ -453,6 +453,28 @@ namespace BMapSharp {
|
|||||||
[DllImport(g_DllName, EntryPoint = "BMFile_CreateTexture", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
[DllImport(g_DllName, EntryPoint = "BMFile_CreateTexture", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
[return: MarshalAs(UnmanagedType.U1)]
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
internal static extern bool BMFile_CreateTexture([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [Out, MarshalAs(UnmanagedType.U4)] out uint out_id);
|
internal static extern bool BMFile_CreateTexture([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [Out, MarshalAs(UnmanagedType.U4)] out uint out_id);
|
||||||
|
/// <summary>BMFile_GetTargetLightCount</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="out_count">Type: LibCmo::CKDWORD. This is OUT parameter. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMFile_GetTargetLightCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMFile_GetTargetLightCount([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [Out, MarshalAs(UnmanagedType.U4)] out uint out_count);
|
||||||
|
/// <summary>BMFile_GetTargetLight</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="idx">Type: LibCmo::CKDWORD. </param>
|
||||||
|
/// <param name="out_id">Type: LibCmo::CK2::CK_ID. This is OUT parameter. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMFile_GetTargetLight", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMFile_GetTargetLight([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint idx, [Out, MarshalAs(UnmanagedType.U4)] out uint out_id);
|
||||||
|
/// <summary>BMFile_CreateTargetLight</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="out_id">Type: LibCmo::CK2::CK_ID. This is OUT parameter. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMFile_CreateTargetLight", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMFile_CreateTargetLight([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [Out, MarshalAs(UnmanagedType.U4)] out uint out_id);
|
||||||
/// <summary>BMMeshTrans_New</summary>
|
/// <summary>BMMeshTrans_New</summary>
|
||||||
/// <param name="out_trans">Type: BMap::BMMeshTransition*. This is OUT parameter. </param>
|
/// <param name="out_trans">Type: BMap::BMMeshTransition*. This is OUT parameter. </param>
|
||||||
/// <returns>True if no error, otherwise False.</returns>
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
@@ -1151,54 +1173,198 @@ namespace BMapSharp {
|
|||||||
[DllImport(g_DllName, EntryPoint = "BMMesh_SetMaterialSlot", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
[DllImport(g_DllName, EntryPoint = "BMMesh_SetMaterialSlot", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
[return: MarshalAs(UnmanagedType.U1)]
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
internal static extern bool BMMesh_SetMaterialSlot([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] uint index, [In, MarshalAs(UnmanagedType.U4)] uint mtlid);
|
internal static extern bool BMMesh_SetMaterialSlot([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] uint index, [In, MarshalAs(UnmanagedType.U4)] uint mtlid);
|
||||||
/// <summary>BM3dObject_GetWorldMatrix</summary>
|
/// <summary>BM3dEntity_GetWorldMatrix</summary>
|
||||||
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
/// <param name="out_mat">Type: LibCmo::VxMath::VxMatrix. This is OUT parameter. </param>
|
/// <param name="out_mat">Type: LibCmo::VxMath::VxMatrix. This is OUT parameter. </param>
|
||||||
/// <returns>True if no error, otherwise False.</returns>
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
[DllImport(g_DllName, EntryPoint = "BM3dObject_GetWorldMatrix", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
[DllImport(g_DllName, EntryPoint = "BM3dEntity_GetWorldMatrix", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
[return: MarshalAs(UnmanagedType.U1)]
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
internal static extern bool BM3dObject_GetWorldMatrix([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.Struct)] out VxMatrix out_mat);
|
internal static extern bool BM3dEntity_GetWorldMatrix([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.Struct)] out VxMatrix out_mat);
|
||||||
/// <summary>BM3dObject_SetWorldMatrix</summary>
|
/// <summary>BM3dEntity_SetWorldMatrix</summary>
|
||||||
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
/// <param name="mat">Type: LibCmo::VxMath::VxMatrix. </param>
|
/// <param name="mat">Type: LibCmo::VxMath::VxMatrix. </param>
|
||||||
/// <returns>True if no error, otherwise False.</returns>
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
[DllImport(g_DllName, EntryPoint = "BM3dObject_SetWorldMatrix", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
[DllImport(g_DllName, EntryPoint = "BM3dEntity_SetWorldMatrix", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
[return: MarshalAs(UnmanagedType.U1)]
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
internal static extern bool BM3dObject_SetWorldMatrix([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.Struct)] VxMatrix mat);
|
internal static extern bool BM3dEntity_SetWorldMatrix([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.Struct)] VxMatrix mat);
|
||||||
/// <summary>BM3dObject_GetCurrentMesh</summary>
|
/// <summary>BM3dEntity_GetCurrentMesh</summary>
|
||||||
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
/// <param name="out_meshid">Type: LibCmo::CK2::CK_ID. This is OUT parameter. </param>
|
/// <param name="out_meshid">Type: LibCmo::CK2::CK_ID. This is OUT parameter. </param>
|
||||||
/// <returns>True if no error, otherwise False.</returns>
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
[DllImport(g_DllName, EntryPoint = "BM3dObject_GetCurrentMesh", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
[DllImport(g_DllName, EntryPoint = "BM3dEntity_GetCurrentMesh", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
[return: MarshalAs(UnmanagedType.U1)]
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
internal static extern bool BM3dObject_GetCurrentMesh([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out uint out_meshid);
|
internal static extern bool BM3dEntity_GetCurrentMesh([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out uint out_meshid);
|
||||||
/// <summary>BM3dObject_SetCurrentMesh</summary>
|
/// <summary>BM3dEntity_SetCurrentMesh</summary>
|
||||||
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
/// <param name="meshid">Type: LibCmo::CK2::CK_ID. </param>
|
/// <param name="meshid">Type: LibCmo::CK2::CK_ID. </param>
|
||||||
/// <returns>True if no error, otherwise False.</returns>
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
[DllImport(g_DllName, EntryPoint = "BM3dObject_SetCurrentMesh", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
[DllImport(g_DllName, EntryPoint = "BM3dEntity_SetCurrentMesh", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
[return: MarshalAs(UnmanagedType.U1)]
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
internal static extern bool BM3dObject_SetCurrentMesh([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] uint meshid);
|
internal static extern bool BM3dEntity_SetCurrentMesh([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] uint meshid);
|
||||||
/// <summary>BM3dObject_GetVisibility</summary>
|
/// <summary>BM3dEntity_GetVisibility</summary>
|
||||||
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
/// <param name="out_isVisible">Type: bool. This is OUT parameter. </param>
|
/// <param name="out_isVisible">Type: bool. This is OUT parameter. </param>
|
||||||
/// <returns>True if no error, otherwise False.</returns>
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
[DllImport(g_DllName, EntryPoint = "BM3dObject_GetVisibility", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
[DllImport(g_DllName, EntryPoint = "BM3dEntity_GetVisibility", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
[return: MarshalAs(UnmanagedType.U1)]
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
internal static extern bool BM3dObject_GetVisibility([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U1)] out bool out_isVisible);
|
internal static extern bool BM3dEntity_GetVisibility([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U1)] out bool out_isVisible);
|
||||||
/// <summary>BM3dObject_SetVisibility</summary>
|
/// <summary>BM3dEntity_SetVisibility</summary>
|
||||||
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
/// <param name="is_visible">Type: bool. </param>
|
/// <param name="is_visible">Type: bool. </param>
|
||||||
/// <returns>True if no error, otherwise False.</returns>
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
[DllImport(g_DllName, EntryPoint = "BM3dObject_SetVisibility", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
[DllImport(g_DllName, EntryPoint = "BM3dEntity_SetVisibility", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
[return: MarshalAs(UnmanagedType.U1)]
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
internal static extern bool BM3dObject_SetVisibility([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U1)] bool is_visible);
|
internal static extern bool BM3dEntity_SetVisibility([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U1)] bool is_visible);
|
||||||
|
/// <summary>BMLight_GetType</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
|
/// <param name="out_val">Type: LibCmo::VxMath::VXLIGHT_TYPE. This is OUT parameter. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMLight_GetType", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMLight_GetType([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out VXLIGHT_TYPE out_val);
|
||||||
|
/// <summary>BMLight_SetType</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
|
/// <param name="val">Type: LibCmo::VxMath::VXLIGHT_TYPE. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMLight_SetType", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMLight_SetType([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] VXLIGHT_TYPE val);
|
||||||
|
/// <summary>BMLight_GetColor</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
|
/// <param name="out_val">Type: LibCmo::VxMath::VxColor. This is OUT parameter. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMLight_GetColor", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMLight_GetColor([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.Struct)] out VxColor out_val);
|
||||||
|
/// <summary>BMLight_SetColor</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
|
/// <param name="col">Type: LibCmo::VxMath::VxColor. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMLight_SetColor", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMLight_SetColor([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.Struct)] VxColor col);
|
||||||
|
/// <summary>BMLight_GetConstantAttenuation</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
|
/// <param name="out_val">Type: LibCmo::CKFLOAT. This is OUT parameter. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMLight_GetConstantAttenuation", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMLight_GetConstantAttenuation([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.R4)] out float out_val);
|
||||||
|
/// <summary>BMLight_SetConstantAttenuation</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
|
/// <param name="val">Type: LibCmo::CKFLOAT. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMLight_SetConstantAttenuation", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMLight_SetConstantAttenuation([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.R4)] float val);
|
||||||
|
/// <summary>BMLight_GetLinearAttenuation</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
|
/// <param name="out_val">Type: LibCmo::CKFLOAT. This is OUT parameter. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMLight_GetLinearAttenuation", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMLight_GetLinearAttenuation([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.R4)] out float out_val);
|
||||||
|
/// <summary>BMLight_SetLinearAttenuation</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
|
/// <param name="val">Type: LibCmo::CKFLOAT. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMLight_SetLinearAttenuation", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMLight_SetLinearAttenuation([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.R4)] float val);
|
||||||
|
/// <summary>BMLight_GetQuadraticAttenuation</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
|
/// <param name="out_val">Type: LibCmo::CKFLOAT. This is OUT parameter. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMLight_GetQuadraticAttenuation", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMLight_GetQuadraticAttenuation([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.R4)] out float out_val);
|
||||||
|
/// <summary>BMLight_SetQuadraticAttenuation</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
|
/// <param name="val">Type: LibCmo::CKFLOAT. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMLight_SetQuadraticAttenuation", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMLight_SetQuadraticAttenuation([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.R4)] float val);
|
||||||
|
/// <summary>BMLight_GetRange</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
|
/// <param name="out_val">Type: LibCmo::CKFLOAT. This is OUT parameter. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMLight_GetRange", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMLight_GetRange([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.R4)] out float out_val);
|
||||||
|
/// <summary>BMLight_SetRange</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
|
/// <param name="val">Type: LibCmo::CKFLOAT. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMLight_SetRange", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMLight_SetRange([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.R4)] float val);
|
||||||
|
/// <summary>BMLight_GetHotSpot</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
|
/// <param name="out_val">Type: LibCmo::CKFLOAT. This is OUT parameter. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMLight_GetHotSpot", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMLight_GetHotSpot([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.R4)] out float out_val);
|
||||||
|
/// <summary>BMLight_SetHotSpot</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
|
/// <param name="val">Type: LibCmo::CKFLOAT. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMLight_SetHotSpot", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMLight_SetHotSpot([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.R4)] float val);
|
||||||
|
/// <summary>BMLight_GetFalloff</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
|
/// <param name="out_val">Type: LibCmo::CKFLOAT. This is OUT parameter. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMLight_GetFalloff", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMLight_GetFalloff([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.R4)] out float out_val);
|
||||||
|
/// <summary>BMLight_SetFalloff</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
|
/// <param name="val">Type: LibCmo::CKFLOAT. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMLight_SetFalloff", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMLight_SetFalloff([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.R4)] float val);
|
||||||
|
/// <summary>BMLight_GetFalloffShape</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
|
/// <param name="out_val">Type: LibCmo::CKFLOAT. This is OUT parameter. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMLight_GetFalloffShape", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMLight_GetFalloffShape([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.R4)] out float out_val);
|
||||||
|
/// <summary>BMLight_SetFalloffShape</summary>
|
||||||
|
/// <param name="bmfile">Type: BMap::BMFile*. The pointer to corresponding BMFile.</param>
|
||||||
|
/// <param name="objid">Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.</param>
|
||||||
|
/// <param name="val">Type: LibCmo::CKFLOAT. </param>
|
||||||
|
/// <returns>True if no error, otherwise False.</returns>
|
||||||
|
[DllImport(g_DllName, EntryPoint = "BMLight_SetFalloffShape", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)]
|
||||||
|
[return: MarshalAs(UnmanagedType.U1)]
|
||||||
|
internal static extern bool BMLight_SetFalloffShape([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.R4)] float val);
|
||||||
|
|
||||||
// ##### GENERATED FUNCTIONS END #####
|
// ##### GENERATED FUNCTIONS END #####
|
||||||
|
|
||||||
@@ -352,7 +352,7 @@ namespace BMapSharp.BMapWrapper {
|
|||||||
BMapException.ThrowIfFailed(BMap.BMMesh_GetFaceMaterialSlotIndexs(getPointer(), getCKID(), out IntPtr out_mem));
|
BMapException.ThrowIfFailed(BMap.BMMesh_GetFaceMaterialSlotIndexs(getPointer(), getCKID(), out IntPtr out_mem));
|
||||||
Utils.ShortAssigner(out_mem, GetFaceCount(), iem);
|
Utils.ShortAssigner(out_mem, GetFaceCount(), iem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint GetMaterialSlotCount() => getGenericValue<uint>(BMap.BMMesh_GetMaterialSlotCount);
|
public uint GetMaterialSlotCount() => getGenericValue<uint>(BMap.BMMesh_GetMaterialSlotCount);
|
||||||
public void SetMaterialSlotCount(uint count) => setGenericValue<uint>(BMap.BMMesh_SetMaterialSlotCount, count);
|
public void SetMaterialSlotCount(uint count) => setGenericValue<uint>(BMap.BMMesh_SetMaterialSlotCount, count);
|
||||||
public IEnumerable<BMMaterial> GetMaterialSlots() {
|
public IEnumerable<BMMaterial> GetMaterialSlots() {
|
||||||
@@ -375,24 +375,61 @@ namespace BMapSharp.BMapWrapper {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BM3dObject : BMObject {
|
public class BM3dEntity : BMObject {
|
||||||
internal BM3dObject(IntPtr raw_pointer, uint ckid) : base(raw_pointer, ckid) { }
|
internal BM3dEntity(IntPtr raw_pointer, uint ckid) : base(raw_pointer, ckid) { }
|
||||||
|
|
||||||
public VxMatrix GetWorldMatrix() => getGenericValue<VxMatrix>(BMap.BM3dObject_GetWorldMatrix);
|
public VxMatrix GetWorldMatrix() => getGenericValue<VxMatrix>(BMap.BM3dEntity_GetWorldMatrix);
|
||||||
public void SetWorldMatrix(VxMatrix mat) => setGenericValue<VxMatrix>(BMap.BM3dObject_SetWorldMatrix, mat);
|
public void SetWorldMatrix(VxMatrix mat) => setGenericValue<VxMatrix>(BMap.BM3dEntity_SetWorldMatrix, mat);
|
||||||
|
|
||||||
public BMMesh GetCurrentMesh() {
|
public BMMesh GetCurrentMesh() {
|
||||||
BMapException.ThrowIfFailed(BMap.BM3dObject_GetCurrentMesh(getPointer(), getCKID(), out uint out_meshid));
|
BMapException.ThrowIfFailed(BMap.BM3dEntity_GetCurrentMesh(getPointer(), getCKID(), out uint out_meshid));
|
||||||
if (out_meshid == Utils.INVALID_CKID) return null;
|
if (out_meshid == Utils.INVALID_CKID) return null;
|
||||||
else return new BMMesh(getPointer(), out_meshid);
|
else return new BMMesh(getPointer(), out_meshid);
|
||||||
}
|
}
|
||||||
public void SetCurrentMesh(BMMesh mesh) {
|
public void SetCurrentMesh(BMMesh mesh) {
|
||||||
uint meshid = (mesh is null) ? Utils.INVALID_CKID : mesh.getCKID();
|
uint meshid = (mesh is null) ? Utils.INVALID_CKID : mesh.getCKID();
|
||||||
BMapException.ThrowIfFailed(BMap.BM3dObject_SetCurrentMesh(getPointer(), getCKID(), meshid));
|
BMapException.ThrowIfFailed(BMap.BM3dEntity_SetCurrentMesh(getPointer(), getCKID(), meshid));
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool GetVisibility() => getGenericValue<bool>(BMap.BM3dObject_GetVisibility);
|
public bool GetVisibility() => getGenericValue<bool>(BMap.BM3dEntity_GetVisibility);
|
||||||
public void SetVisibility(bool visb) => setGenericValue<bool>(BMap.BM3dObject_SetVisibility, visb);
|
public void SetVisibility(bool visb) => setGenericValue<bool>(BMap.BM3dEntity_SetVisibility, visb);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BM3dObject : BM3dEntity {
|
||||||
|
internal BM3dObject(IntPtr raw_pointer, uint ckid) : base(raw_pointer, ckid) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BMLight : BM3dEntity {
|
||||||
|
internal BMLight(IntPtr raw_pointer, uint ckid) : base(raw_pointer, ckid) { }
|
||||||
|
|
||||||
|
// Name `GetType` is conflict with C# base class function name.
|
||||||
|
// So we add a `Light` prefix for it.
|
||||||
|
public VXLIGHT_TYPE GetLightType() => getGenericValue<VXLIGHT_TYPE>(BMap.BMLight_GetType);
|
||||||
|
public void SetLightType(VXLIGHT_TYPE val) => setGenericValue<VXLIGHT_TYPE>(BMap.BMLight_SetType, val);
|
||||||
|
|
||||||
|
public VxColor GetColor() => getGenericValue<VxColor>(BMap.BMLight_GetColor);
|
||||||
|
public void SetColor(VxColor col) => setGenericValue<VxColor>(BMap.BMLight_SetColor, col);
|
||||||
|
|
||||||
|
public float GetConstantAttenuation() => getGenericValue<float>(BMap.BMLight_GetConstantAttenuation);
|
||||||
|
public void SetConstantAttenuation(float val) => setGenericValue<float>(BMap.BMLight_SetConstantAttenuation, val);
|
||||||
|
public float GetLinearAttenuation() => getGenericValue<float>(BMap.BMLight_GetLinearAttenuation);
|
||||||
|
public void SetLinearAttenuation(float val) => setGenericValue<float>(BMap.BMLight_SetLinearAttenuation, val);
|
||||||
|
public float GetQuadraticAttenuation() => getGenericValue<float>(BMap.BMLight_GetQuadraticAttenuation);
|
||||||
|
public void SetQuadraticAttenuation(float val) => setGenericValue<float>(BMap.BMLight_SetQuadraticAttenuation, val);
|
||||||
|
|
||||||
|
public float GetRange() => getGenericValue<float>(BMap.BMLight_GetRange);
|
||||||
|
public void SetRange(float val) => setGenericValue<float>(BMap.BMLight_SetRange, val);
|
||||||
|
|
||||||
|
public float GetHotSpot() => getGenericValue<float>(BMap.BMLight_GetHotSpot);
|
||||||
|
public void SetHotSpot(float val) => setGenericValue<float>(BMap.BMLight_SetHotSpot, val);
|
||||||
|
public float GetFalloff() => getGenericValue<float>(BMap.BMLight_GetFalloff);
|
||||||
|
public void SetFalloff(float val) => setGenericValue<float>(BMap.BMLight_SetFalloff, val);
|
||||||
|
public float GetFalloffShape() => getGenericValue<float>(BMap.BMLight_GetFalloffShape);
|
||||||
|
public void SetFalloffShape(float val) => setGenericValue<float>(BMap.BMLight_SetFalloffShape, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BMTargetLight : BMLight {
|
||||||
|
internal BMTargetLight(IntPtr raw_pointer, uint ckid) : base(raw_pointer, ckid) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BMGroup : BMObject {
|
public class BMGroup : BMObject {
|
||||||
@@ -463,6 +500,10 @@ namespace BMapSharp.BMapWrapper {
|
|||||||
getCKObjectCount(BMap.BMFile_GetGroupCount);
|
getCKObjectCount(BMap.BMFile_GetGroupCount);
|
||||||
public IEnumerable<BMGroup> GetGroups() =>
|
public IEnumerable<BMGroup> GetGroups() =>
|
||||||
getCKObjects<BMGroup>(BMap.BMFile_GetGroupCount, BMap.BMFile_GetGroup, (bmf, id) => new BMGroup(bmf, id));
|
getCKObjects<BMGroup>(BMap.BMFile_GetGroupCount, BMap.BMFile_GetGroup, (bmf, id) => new BMGroup(bmf, id));
|
||||||
|
public uint GetTargetLightCount() =>
|
||||||
|
getCKObjectCount(BMap.BMFile_GetTargetLightCount);
|
||||||
|
public IEnumerable<BMTargetLight> GetTargetLights() =>
|
||||||
|
getCKObjects<BMTargetLight>(BMap.BMFile_GetTargetLightCount, BMap.BMFile_GetTargetLight, (bmf, id) => new BMTargetLight(bmf, id));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,6 +545,7 @@ namespace BMapSharp.BMapWrapper {
|
|||||||
public BMMesh CreateMesh() => createCKObject<BMMesh>(BMap.BMFile_CreateMesh, (bmf, id) => new BMMesh(bmf, id));
|
public BMMesh CreateMesh() => createCKObject<BMMesh>(BMap.BMFile_CreateMesh, (bmf, id) => new BMMesh(bmf, id));
|
||||||
public BM3dObject Create3dObject() => createCKObject<BM3dObject>(BMap.BMFile_Create3dObject, (bmf, id) => new BM3dObject(bmf, id));
|
public BM3dObject Create3dObject() => createCKObject<BM3dObject>(BMap.BMFile_Create3dObject, (bmf, id) => new BM3dObject(bmf, id));
|
||||||
public BMGroup CreateGroup() => createCKObject<BMGroup>(BMap.BMFile_CreateGroup, (bmf, id) => new BMGroup(bmf, id));
|
public BMGroup CreateGroup() => createCKObject<BMGroup>(BMap.BMFile_CreateGroup, (bmf, id) => new BMGroup(bmf, id));
|
||||||
|
public BMTargetLight CreateTargetLight() => createCKObject<BMTargetLight>(BMap.BMFile_CreateTargetLight, (bmf, id) => new BMTargetLight(bmf, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class BMMeshTrans : AbstractPointer {
|
public sealed class BMMeshTrans : AbstractPointer {
|
||||||
@@ -226,6 +226,13 @@ namespace BMapSharp.VirtoolsTypes {
|
|||||||
_4_ARGB8888_CLUT = 31, /**< 4 bits indexed CLUT (ARGB) */
|
_4_ARGB8888_CLUT = 31, /**< 4 bits indexed CLUT (ARGB) */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum VXLIGHT_TYPE : uint {
|
||||||
|
VX_LIGHTPOINT = 1, /**< The Light is a point of light */
|
||||||
|
VX_LIGHTSPOT = 2, /**< The light is a spotlight */
|
||||||
|
VX_LIGHTDIREC = 3, /**< The light is directional light : Lights comes from an infinite point so only direction of light can be given */
|
||||||
|
// VX_LIGHTPARA = 4UL, /**< Obsolete, do not use */
|
||||||
|
}
|
||||||
|
|
||||||
public enum VXTEXTURE_BLENDMODE : uint {
|
public enum VXTEXTURE_BLENDMODE : uint {
|
||||||
VXTEXTUREBLEND_DECAL = 1, /**< Texture replace any material information */
|
VXTEXTUREBLEND_DECAL = 1, /**< Texture replace any material information */
|
||||||
VXTEXTUREBLEND_MODULATE = 2, /**< Texture and material are combine. Alpha information of the texture replace material alpha component. */
|
VXTEXTUREBLEND_MODULATE = 2, /**< Texture and material are combine. Alpha information of the texture replace material alpha component. */
|
||||||
@@ -4,6 +4,10 @@
|
|||||||
<ProjectReference Include="..\BMapSharp\BMapSharp.csproj" />
|
<ProjectReference Include="..\BMapSharp\BMapSharp.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
219
Assets/BMapBindings/BMapSharp/BMapSharpTestbench/Program.cs
Normal file
219
Assets/BMapBindings/BMapSharp/BMapSharpTestbench/Program.cs
Normal file
@@ -0,0 +1,219 @@
|
|||||||
|
using BMapSharp.BMapWrapper;
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.CommandLine;
|
||||||
|
|
||||||
|
namespace BMapSharpTestbench {
|
||||||
|
internal class Program {
|
||||||
|
|
||||||
|
static void Main(string[] args) {
|
||||||
|
// Parse arguments
|
||||||
|
var resolved_args = ResolveArguments(args);
|
||||||
|
if (resolved_args is null) {
|
||||||
|
// just silent quit
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check environment
|
||||||
|
Console.OutputEncoding = Encoding.UTF8;
|
||||||
|
if (!BMapSharp.BMapWrapper.Utils.IsBMapAvailable()) {
|
||||||
|
Console.WriteLine("Fail to initialize native BMap.");
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Waiting debugger
|
||||||
|
int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
|
||||||
|
Console.WriteLine($"C# PID is {pid}. Waiting debugger, press any key to continue...");
|
||||||
|
Console.ReadKey(true);
|
||||||
|
|
||||||
|
// Start testbench
|
||||||
|
string file_name = resolved_args.mFileName; // "LightCameraTest.nmo";
|
||||||
|
string temp_folder = resolved_args.mTempFolder; // "Temp";
|
||||||
|
string texture_folder = resolved_args.mTextureFolder; // "F:\\Ballance\\Ballance\\Textures";
|
||||||
|
string[] encodings = resolved_args.mEncodings; // ["cp1252", "gb2312"];
|
||||||
|
|
||||||
|
using (var reader = new BMapSharp.BMapWrapper.BMFileReader(file_name, temp_folder, texture_folder, encodings)) {
|
||||||
|
TestCommon(reader);
|
||||||
|
TestIEquatable(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Press any key to quit...");
|
||||||
|
Console.ReadKey(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class BMapSharpArguments {
|
||||||
|
public string mFileName;
|
||||||
|
public string mTempFolder;
|
||||||
|
public string mTextureFolder;
|
||||||
|
public string[] mEncodings;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BMapSharpArguments ResolveArguments(string[] args) {
|
||||||
|
// define arguments
|
||||||
|
var fileNameOpt = new Option<string>
|
||||||
|
("--file-path", "The path to input Virtools file.");
|
||||||
|
fileNameOpt.IsRequired = true;
|
||||||
|
var tempFolderOpt = new Option<string>
|
||||||
|
("--temp-dir", "The temp folder used by BMap.");
|
||||||
|
tempFolderOpt.IsRequired = true;
|
||||||
|
var textureFolderOpt = new Option<string>
|
||||||
|
("--texture-dir", "The texture folder containing Ballance texture resources.");
|
||||||
|
textureFolderOpt.IsRequired = true;
|
||||||
|
var encodingsOpt = new Option<IEnumerable<string>>
|
||||||
|
("--encodings", "The encodings used to parse the names stroed in input Virtools file.");
|
||||||
|
encodingsOpt.IsRequired = true;
|
||||||
|
encodingsOpt.Arity = ArgumentArity.OneOrMore;
|
||||||
|
encodingsOpt.AllowMultipleArgumentsPerToken = true;
|
||||||
|
|
||||||
|
// init root command
|
||||||
|
var rootCommand = new RootCommand("The testbench of BMapSharp.");
|
||||||
|
rootCommand.Add(fileNameOpt);
|
||||||
|
rootCommand.Add(tempFolderOpt);
|
||||||
|
rootCommand.Add(textureFolderOpt);
|
||||||
|
rootCommand.Add(encodingsOpt);
|
||||||
|
|
||||||
|
// init result container
|
||||||
|
BMapSharpArguments ret = new BMapSharpArguments();
|
||||||
|
// set handler
|
||||||
|
rootCommand.SetHandler((context) => {
|
||||||
|
ret.mFileName = context.ParseResult.GetValueForOption(fileNameOpt);
|
||||||
|
ret.mTempFolder = context.ParseResult.GetValueForOption(tempFolderOpt);
|
||||||
|
ret.mTextureFolder = context.ParseResult.GetValueForOption(textureFolderOpt);
|
||||||
|
ret.mEncodings = context.ParseResult.GetValueForOption(encodingsOpt).ToArray();
|
||||||
|
context.ExitCode = 61;
|
||||||
|
});
|
||||||
|
|
||||||
|
// execute root command and return value.
|
||||||
|
if (rootCommand.Invoke(args) != 61) return null;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void TestCommon(BMapSharp.BMapWrapper.BMFileReader reader) {
|
||||||
|
// Console.WriteLine("===== Groups =====");
|
||||||
|
// foreach (var gp in reader.GetGroups()) {
|
||||||
|
// Console.WriteLine(gp.GetName());
|
||||||
|
// foreach (var gp_item in gp.GetObjects()) {
|
||||||
|
// Console.WriteLine($"\t{gp_item.GetName()}");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Console.WriteLine("===== 3dObjects =====");
|
||||||
|
// foreach (var obj in reader.Get3dObjects()) {
|
||||||
|
// Console.WriteLine(obj.GetName());
|
||||||
|
|
||||||
|
// var current_mesh = obj.GetCurrentMesh();
|
||||||
|
// var mesh_name = current_mesh is null ? "<null>" : current_mesh.GetName();
|
||||||
|
// Console.WriteLine($"\tMesh: {mesh_name}");
|
||||||
|
// Console.WriteLine($"\tVisibility: {obj.GetVisibility()}");
|
||||||
|
// Console.WriteLine($"\tMatrix: {obj.GetWorldMatrix().ToManaged()}");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Console.WriteLine("===== Meshes =====");
|
||||||
|
// foreach (var mesh in reader.GetMeshes()) {
|
||||||
|
// Console.WriteLine(mesh.GetName());
|
||||||
|
|
||||||
|
// Console.WriteLine($"\tLit Mode: {mesh.GetLitMode()}");
|
||||||
|
// Console.WriteLine($"\tVertex Count: {mesh.GetVertexCount()}");
|
||||||
|
// Console.WriteLine($"\tFace Count: {mesh.GetFaceCount()}");
|
||||||
|
// Console.WriteLine($"\tMaterial Slot Count: {mesh.GetMaterialSlotCount()}");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Console.WriteLine("===== Materials =====");
|
||||||
|
// foreach (var mtl in reader.GetMaterials()) {
|
||||||
|
// Console.WriteLine(mtl.GetName());
|
||||||
|
|
||||||
|
// Console.WriteLine($"\tDiffuse: {mtl.GetDiffuse().ToManagedRGBA()}");
|
||||||
|
// Console.WriteLine($"\tAmbient: {mtl.GetAmbient().ToManagedRGBA()}");
|
||||||
|
// Console.WriteLine($"\tSpecular: {mtl.GetSpecular().ToManagedRGBA()}");
|
||||||
|
// Console.WriteLine($"\tEmissive: {mtl.GetEmissive().ToManagedRGBA()}");
|
||||||
|
|
||||||
|
// Console.WriteLine($"\tSpecular Power: {mtl.GetSpecularPower()}");
|
||||||
|
|
||||||
|
// Console.WriteLine($"\tTexture Border Color: {mtl.GetTextureBorderColor().ToManagedRGBA()}");
|
||||||
|
|
||||||
|
// Console.WriteLine($"\tTexture Blend Mode: {mtl.GetTextureBlendMode()}");
|
||||||
|
// Console.WriteLine($"\tTexture Min Mode: {mtl.GetTextureMinMode()}");
|
||||||
|
// Console.WriteLine($"\tTexture Mag Mode: {mtl.GetTextureMagMode()}");
|
||||||
|
// Console.WriteLine($"\tSource Blend: {mtl.GetSourceBlend()}");
|
||||||
|
// Console.WriteLine($"\tDest Blend: {mtl.GetDestBlend()}");
|
||||||
|
// Console.WriteLine($"\tFill Mode: {mtl.GetFillMode()}");
|
||||||
|
// Console.WriteLine($"\tShade Mode: {mtl.GetShadeMode()}");
|
||||||
|
|
||||||
|
// Console.WriteLine($"\tAlpha Test Enabled: {mtl.GetAlphaTestEnabled()}");
|
||||||
|
// Console.WriteLine($"\tAlpha Blend Enabled: {mtl.GetAlphaBlendEnabled()}");
|
||||||
|
// Console.WriteLine($"\tPerspective Correction Enabled: {mtl.GetPerspectiveCorrectionEnabled()}");
|
||||||
|
// Console.WriteLine($"\tZ Write Enabled: {mtl.GetZWriteEnabled()}");
|
||||||
|
// Console.WriteLine($"\tTwo Sided Enabled: {mtl.GetTwoSidedEnabled()}");
|
||||||
|
|
||||||
|
// Console.WriteLine($"\tAlpha Ref: {mtl.GetAlphaRef()}");
|
||||||
|
|
||||||
|
// Console.WriteLine($"\tAlpha Func: {mtl.GetAlphaFunc()}");
|
||||||
|
// Console.WriteLine($"\tZ Func: {mtl.GetZFunc()}");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Console.WriteLine("===== Textures =====");
|
||||||
|
// foreach (var tex in reader.GetTextures()) {
|
||||||
|
// Console.WriteLine(tex.GetName());
|
||||||
|
|
||||||
|
// Console.WriteLine($"\tFile Name: {tex.GetFileName()}");
|
||||||
|
// Console.WriteLine($"\tSave Options: {tex.GetSaveOptions()}");
|
||||||
|
// Console.WriteLine($"\tVideo Format: {tex.GetVideoFormat()}");
|
||||||
|
// }
|
||||||
|
|
||||||
|
Console.WriteLine("===== Target Lights =====");
|
||||||
|
foreach (var lit in reader.GetTargetLights()) {
|
||||||
|
Console.WriteLine(lit.GetName());
|
||||||
|
|
||||||
|
Console.WriteLine($"\tVisibility: {lit.GetVisibility()}");
|
||||||
|
Console.WriteLine($"\tMatrix: {lit.GetWorldMatrix().ToManaged()}");
|
||||||
|
|
||||||
|
Console.WriteLine($"Type: {lit.GetLightType()}");
|
||||||
|
Console.WriteLine($"Color: {lit.GetColor().ToManagedRGBA()}");
|
||||||
|
Console.WriteLine($"Constant Attenuation: {lit.GetConstantAttenuation()}");
|
||||||
|
Console.WriteLine($"Linear Attenuation: {lit.GetLinearAttenuation()}");
|
||||||
|
Console.WriteLine($"Quadratic Attenuation: {lit.GetQuadraticAttenuation()}");
|
||||||
|
Console.WriteLine($"Range: {lit.GetRange()}");
|
||||||
|
Console.WriteLine($"Hot Spot: {lit.GetHotSpot()}");
|
||||||
|
Console.WriteLine($"Falloff: {lit.GetFalloff()}");
|
||||||
|
Console.WriteLine($"Falloff Shape: {lit.GetFalloffShape()}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("===== END =====");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void TestIEquatable(BMapSharp.BMapWrapper.BMFileReader reader) {
|
||||||
|
if (reader.Get3dObjectCount() < 2u) {
|
||||||
|
Debug.Fail(
|
||||||
|
"Invalid file for test IEquatable.",
|
||||||
|
"We can not perform IEquatable test because the length of 3dObject is too short (must greater than 2). Please choose another file to perform."
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare test variables
|
||||||
|
var all_3dobjects = new List<BM3dObject>(reader.Get3dObjects());
|
||||||
|
var first_3dobj = all_3dobjects[0];
|
||||||
|
var second_3dobj = all_3dobjects[1];
|
||||||
|
all_3dobjects = new List<BM3dObject>(reader.Get3dObjects());
|
||||||
|
var first_3dobj_again = all_3dobjects[0];
|
||||||
|
Debug.Assert(!Object.ReferenceEquals(first_3dobj, first_3dobj_again));
|
||||||
|
|
||||||
|
// Hashtable test
|
||||||
|
var test_hashset = new HashSet<BM3dObject>();
|
||||||
|
Debug.Assert(test_hashset.Add(first_3dobj));
|
||||||
|
Debug.Assert(!test_hashset.Add(first_3dobj_again));
|
||||||
|
Debug.Assert(test_hashset.Add(second_3dobj));
|
||||||
|
|
||||||
|
// Dictionary test
|
||||||
|
var test_dictionary = new Dictionary<BM3dObject, string>();
|
||||||
|
Debug.Assert(test_dictionary.TryAdd(first_3dobj, first_3dobj.GetName()));
|
||||||
|
Debug.Assert(!test_dictionary.TryAdd(first_3dobj_again, first_3dobj_again.GetName()));
|
||||||
|
Debug.Assert(test_dictionary.TryAdd(second_3dobj, second_3dobj.GetName()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,3 +5,5 @@ The core of BMapSharp project is placed within `BMapSharp` subdirectory. This di
|
|||||||
The native BMap library should be placed together with managed `BMapSharp` dynamic library. I use gitignore file to filter all native binary so you need put them manually. The native BMap library must be named as `BMap.dll` (in Windows), `BMap.so` (in Linux or BSD), or `BMap.dylib` (in macOS). If you still can not load BMap or your system is not listed above, you should name it as `BMap.bin`.
|
The native BMap library should be placed together with managed `BMapSharp` dynamic library. I use gitignore file to filter all native binary so you need put them manually. The native BMap library must be named as `BMap.dll` (in Windows), `BMap.so` (in Linux or BSD), or `BMap.dylib` (in macOS). If you still can not load BMap or your system is not listed above, you should name it as `BMap.bin`.
|
||||||
|
|
||||||
The most content of `VirtoolsTypes.cs` is generated by EnumsMigration, and the most content of `BMap.cs` is generated by BMapBindings. You should watch these file changes if corresponding C++ code or structures are changed.
|
The most content of `VirtoolsTypes.cs` is generated by EnumsMigration, and the most content of `BMap.cs` is generated by BMapBindings. You should watch these file changes if corresponding C++ code or structures are changed.
|
||||||
|
|
||||||
|
Since BMap 0.3.0, testbench use command line arguments, instead of hardcode variables in code, as the arguments of BMap. It is convenient that debug BMapSharp without any modification of source code. For a brief instruction, you may need to launch BMapSharpTestbench in following command (just an example. you can modify it as you wished): `dotnet run -- --file-path "LightCameraTest.nmo" --temp-dir "Temp" --texture-dir "F:/Ballance/Ballance/Textures" --encodings cp1252 gb2312`.
|
||||||
@@ -227,6 +227,22 @@ BMFile_GetTexture = _create_bmap_func('BMFile_GetTexture', [bm_void_p, bm_CKDWOR
|
|||||||
# @param out_id[out] Type: LibCmo::CK2::CK_ID. Use ctypes.byref(data) pass it.
|
# @param out_id[out] Type: LibCmo::CK2::CK_ID. Use ctypes.byref(data) pass it.
|
||||||
# @return True if no error, otherwise False.
|
# @return True if no error, otherwise False.
|
||||||
BMFile_CreateTexture = _create_bmap_func('BMFile_CreateTexture', [bm_void_p, bm_CKID_p])
|
BMFile_CreateTexture = _create_bmap_func('BMFile_CreateTexture', [bm_void_p, bm_CKID_p])
|
||||||
|
## BMFile_GetTargetLightCount
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param out_count[out] Type: LibCmo::CKDWORD. Use ctypes.byref(data) pass it.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMFile_GetTargetLightCount = _create_bmap_func('BMFile_GetTargetLightCount', [bm_void_p, bm_CKDWORD_p])
|
||||||
|
## BMFile_GetTargetLight
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param idx[in] Type: LibCmo::CKDWORD.
|
||||||
|
# @param out_id[out] Type: LibCmo::CK2::CK_ID. Use ctypes.byref(data) pass it.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMFile_GetTargetLight = _create_bmap_func('BMFile_GetTargetLight', [bm_void_p, bm_CKDWORD, bm_CKID_p])
|
||||||
|
## BMFile_CreateTargetLight
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param out_id[out] Type: LibCmo::CK2::CK_ID. Use ctypes.byref(data) pass it.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMFile_CreateTargetLight = _create_bmap_func('BMFile_CreateTargetLight', [bm_void_p, bm_CKID_p])
|
||||||
## BMMeshTrans_New
|
## BMMeshTrans_New
|
||||||
# @param out_trans[out] Type: BMap::BMMeshTransition*. Use ctypes.byref(data) pass it.
|
# @param out_trans[out] Type: BMap::BMMeshTransition*. Use ctypes.byref(data) pass it.
|
||||||
# @return True if no error, otherwise False.
|
# @return True if no error, otherwise False.
|
||||||
@@ -747,42 +763,150 @@ BMMesh_GetMaterialSlot = _create_bmap_func('BMMesh_GetMaterialSlot', [bm_void_p,
|
|||||||
# @param mtlid[in] Type: LibCmo::CK2::CK_ID.
|
# @param mtlid[in] Type: LibCmo::CK2::CK_ID.
|
||||||
# @return True if no error, otherwise False.
|
# @return True if no error, otherwise False.
|
||||||
BMMesh_SetMaterialSlot = _create_bmap_func('BMMesh_SetMaterialSlot', [bm_void_p, bm_CKID, bm_CKDWORD, bm_CKID])
|
BMMesh_SetMaterialSlot = _create_bmap_func('BMMesh_SetMaterialSlot', [bm_void_p, bm_CKID, bm_CKDWORD, bm_CKID])
|
||||||
## BM3dObject_GetWorldMatrix
|
## BM3dEntity_GetWorldMatrix
|
||||||
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
# @param out_mat[out] Type: LibCmo::VxMath::VxMatrix. Use ctypes.byref(data) pass it.
|
# @param out_mat[out] Type: LibCmo::VxMath::VxMatrix. Use ctypes.byref(data) pass it.
|
||||||
# @return True if no error, otherwise False.
|
# @return True if no error, otherwise False.
|
||||||
BM3dObject_GetWorldMatrix = _create_bmap_func('BM3dObject_GetWorldMatrix', [bm_void_p, bm_CKID, bm_VxMatrix_p])
|
BM3dEntity_GetWorldMatrix = _create_bmap_func('BM3dEntity_GetWorldMatrix', [bm_void_p, bm_CKID, bm_VxMatrix_p])
|
||||||
## BM3dObject_SetWorldMatrix
|
## BM3dEntity_SetWorldMatrix
|
||||||
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
# @param mat[in] Type: LibCmo::VxMath::VxMatrix.
|
# @param mat[in] Type: LibCmo::VxMath::VxMatrix.
|
||||||
# @return True if no error, otherwise False.
|
# @return True if no error, otherwise False.
|
||||||
BM3dObject_SetWorldMatrix = _create_bmap_func('BM3dObject_SetWorldMatrix', [bm_void_p, bm_CKID, bm_VxMatrix])
|
BM3dEntity_SetWorldMatrix = _create_bmap_func('BM3dEntity_SetWorldMatrix', [bm_void_p, bm_CKID, bm_VxMatrix])
|
||||||
## BM3dObject_GetCurrentMesh
|
## BM3dEntity_GetCurrentMesh
|
||||||
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
# @param out_meshid[out] Type: LibCmo::CK2::CK_ID. Use ctypes.byref(data) pass it.
|
# @param out_meshid[out] Type: LibCmo::CK2::CK_ID. Use ctypes.byref(data) pass it.
|
||||||
# @return True if no error, otherwise False.
|
# @return True if no error, otherwise False.
|
||||||
BM3dObject_GetCurrentMesh = _create_bmap_func('BM3dObject_GetCurrentMesh', [bm_void_p, bm_CKID, bm_CKID_p])
|
BM3dEntity_GetCurrentMesh = _create_bmap_func('BM3dEntity_GetCurrentMesh', [bm_void_p, bm_CKID, bm_CKID_p])
|
||||||
## BM3dObject_SetCurrentMesh
|
## BM3dEntity_SetCurrentMesh
|
||||||
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
# @param meshid[in] Type: LibCmo::CK2::CK_ID.
|
# @param meshid[in] Type: LibCmo::CK2::CK_ID.
|
||||||
# @return True if no error, otherwise False.
|
# @return True if no error, otherwise False.
|
||||||
BM3dObject_SetCurrentMesh = _create_bmap_func('BM3dObject_SetCurrentMesh', [bm_void_p, bm_CKID, bm_CKID])
|
BM3dEntity_SetCurrentMesh = _create_bmap_func('BM3dEntity_SetCurrentMesh', [bm_void_p, bm_CKID, bm_CKID])
|
||||||
## BM3dObject_GetVisibility
|
## BM3dEntity_GetVisibility
|
||||||
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
# @param out_isVisible[out] Type: bool. Use ctypes.byref(data) pass it.
|
# @param out_isVisible[out] Type: bool. Use ctypes.byref(data) pass it.
|
||||||
# @return True if no error, otherwise False.
|
# @return True if no error, otherwise False.
|
||||||
BM3dObject_GetVisibility = _create_bmap_func('BM3dObject_GetVisibility', [bm_void_p, bm_CKID, bm_bool_p])
|
BM3dEntity_GetVisibility = _create_bmap_func('BM3dEntity_GetVisibility', [bm_void_p, bm_CKID, bm_bool_p])
|
||||||
## BM3dObject_SetVisibility
|
## BM3dEntity_SetVisibility
|
||||||
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
# @param is_visible[in] Type: bool.
|
# @param is_visible[in] Type: bool.
|
||||||
# @return True if no error, otherwise False.
|
# @return True if no error, otherwise False.
|
||||||
BM3dObject_SetVisibility = _create_bmap_func('BM3dObject_SetVisibility', [bm_void_p, bm_CKID, bm_bool])
|
BM3dEntity_SetVisibility = _create_bmap_func('BM3dEntity_SetVisibility', [bm_void_p, bm_CKID, bm_bool])
|
||||||
|
## BMLight_GetType
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
|
# @param out_val[out] Type: LibCmo::VxMath::VXLIGHT_TYPE. Use ctypes.byref(data) pass it.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMLight_GetType = _create_bmap_func('BMLight_GetType', [bm_void_p, bm_CKID, bm_enum_p])
|
||||||
|
## BMLight_SetType
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
|
# @param val[in] Type: LibCmo::VxMath::VXLIGHT_TYPE.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMLight_SetType = _create_bmap_func('BMLight_SetType', [bm_void_p, bm_CKID, bm_enum])
|
||||||
|
## BMLight_GetColor
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
|
# @param out_val[out] Type: LibCmo::VxMath::VxColor. Use ctypes.byref(data) pass it.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMLight_GetColor = _create_bmap_func('BMLight_GetColor', [bm_void_p, bm_CKID, bm_VxColor_p])
|
||||||
|
## BMLight_SetColor
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
|
# @param col[in] Type: LibCmo::VxMath::VxColor.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMLight_SetColor = _create_bmap_func('BMLight_SetColor', [bm_void_p, bm_CKID, bm_VxColor])
|
||||||
|
## BMLight_GetConstantAttenuation
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
|
# @param out_val[out] Type: LibCmo::CKFLOAT. Use ctypes.byref(data) pass it.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMLight_GetConstantAttenuation = _create_bmap_func('BMLight_GetConstantAttenuation', [bm_void_p, bm_CKID, bm_CKFLOAT_p])
|
||||||
|
## BMLight_SetConstantAttenuation
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
|
# @param val[in] Type: LibCmo::CKFLOAT.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMLight_SetConstantAttenuation = _create_bmap_func('BMLight_SetConstantAttenuation', [bm_void_p, bm_CKID, bm_CKFLOAT])
|
||||||
|
## BMLight_GetLinearAttenuation
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
|
# @param out_val[out] Type: LibCmo::CKFLOAT. Use ctypes.byref(data) pass it.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMLight_GetLinearAttenuation = _create_bmap_func('BMLight_GetLinearAttenuation', [bm_void_p, bm_CKID, bm_CKFLOAT_p])
|
||||||
|
## BMLight_SetLinearAttenuation
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
|
# @param val[in] Type: LibCmo::CKFLOAT.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMLight_SetLinearAttenuation = _create_bmap_func('BMLight_SetLinearAttenuation', [bm_void_p, bm_CKID, bm_CKFLOAT])
|
||||||
|
## BMLight_GetQuadraticAttenuation
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
|
# @param out_val[out] Type: LibCmo::CKFLOAT. Use ctypes.byref(data) pass it.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMLight_GetQuadraticAttenuation = _create_bmap_func('BMLight_GetQuadraticAttenuation', [bm_void_p, bm_CKID, bm_CKFLOAT_p])
|
||||||
|
## BMLight_SetQuadraticAttenuation
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
|
# @param val[in] Type: LibCmo::CKFLOAT.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMLight_SetQuadraticAttenuation = _create_bmap_func('BMLight_SetQuadraticAttenuation', [bm_void_p, bm_CKID, bm_CKFLOAT])
|
||||||
|
## BMLight_GetRange
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
|
# @param out_val[out] Type: LibCmo::CKFLOAT. Use ctypes.byref(data) pass it.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMLight_GetRange = _create_bmap_func('BMLight_GetRange', [bm_void_p, bm_CKID, bm_CKFLOAT_p])
|
||||||
|
## BMLight_SetRange
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
|
# @param val[in] Type: LibCmo::CKFLOAT.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMLight_SetRange = _create_bmap_func('BMLight_SetRange', [bm_void_p, bm_CKID, bm_CKFLOAT])
|
||||||
|
## BMLight_GetHotSpot
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
|
# @param out_val[out] Type: LibCmo::CKFLOAT. Use ctypes.byref(data) pass it.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMLight_GetHotSpot = _create_bmap_func('BMLight_GetHotSpot', [bm_void_p, bm_CKID, bm_CKFLOAT_p])
|
||||||
|
## BMLight_SetHotSpot
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
|
# @param val[in] Type: LibCmo::CKFLOAT.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMLight_SetHotSpot = _create_bmap_func('BMLight_SetHotSpot', [bm_void_p, bm_CKID, bm_CKFLOAT])
|
||||||
|
## BMLight_GetFalloff
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
|
# @param out_val[out] Type: LibCmo::CKFLOAT. Use ctypes.byref(data) pass it.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMLight_GetFalloff = _create_bmap_func('BMLight_GetFalloff', [bm_void_p, bm_CKID, bm_CKFLOAT_p])
|
||||||
|
## BMLight_SetFalloff
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
|
# @param val[in] Type: LibCmo::CKFLOAT.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMLight_SetFalloff = _create_bmap_func('BMLight_SetFalloff', [bm_void_p, bm_CKID, bm_CKFLOAT])
|
||||||
|
## BMLight_GetFalloffShape
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
|
# @param out_val[out] Type: LibCmo::CKFLOAT. Use ctypes.byref(data) pass it.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMLight_GetFalloffShape = _create_bmap_func('BMLight_GetFalloffShape', [bm_void_p, bm_CKID, bm_CKFLOAT_p])
|
||||||
|
## BMLight_SetFalloffShape
|
||||||
|
# @param bmfile[in] Type: BMap::BMFile*. The pointer to corresponding BMFile.
|
||||||
|
# @param objid[in] Type: LibCmo::CK2::CK_ID. The CKID of object you accessing.
|
||||||
|
# @param val[in] Type: LibCmo::CKFLOAT.
|
||||||
|
# @return True if no error, otherwise False.
|
||||||
|
BMLight_SetFalloffShape = _create_bmap_func('BMLight_SetFalloffShape', [bm_void_p, bm_CKID, bm_CKFLOAT])
|
||||||
|
|
||||||
##### GENERATED FUNCTIONS END #####
|
##### GENERATED FUNCTIONS END #####
|
||||||
|
|
||||||
@@ -476,10 +476,10 @@ class BMMesh(BMObject):
|
|||||||
except StopIteration:
|
except StopIteration:
|
||||||
_Utils.raise_out_of_length_exception()
|
_Utils.raise_out_of_length_exception()
|
||||||
|
|
||||||
class BM3dObject(BMObject):
|
class BM3dEntity(BMObject):
|
||||||
def get_world_matrix(self) -> virtools_types.VxMatrix:
|
def get_world_matrix(self) -> virtools_types.VxMatrix:
|
||||||
mat: bmap.bm_VxMatrix = bmap.bm_VxMatrix()
|
mat: bmap.bm_VxMatrix = bmap.bm_VxMatrix()
|
||||||
bmap.BM3dObject_GetWorldMatrix(self._get_pointer(), self._get_ckid(), ctypes.byref(mat))
|
bmap.BM3dEntity_GetWorldMatrix(self._get_pointer(), self._get_ckid(), ctypes.byref(mat))
|
||||||
# use cast & pointer to get matrix data conveniently
|
# use cast & pointer to get matrix data conveniently
|
||||||
flat: bmap.bm_CKFLOAT_p = ctypes.cast(ctypes.byref(mat), bmap.bm_CKFLOAT_p)
|
flat: bmap.bm_CKFLOAT_p = ctypes.cast(ctypes.byref(mat), bmap.bm_CKFLOAT_p)
|
||||||
ret: virtools_types.VxMatrix = virtools_types.VxMatrix()
|
ret: virtools_types.VxMatrix = virtools_types.VxMatrix()
|
||||||
@@ -489,11 +489,11 @@ class BM3dObject(BMObject):
|
|||||||
def set_world_matrix(self, mat_: virtools_types.VxMatrix) -> None:
|
def set_world_matrix(self, mat_: virtools_types.VxMatrix) -> None:
|
||||||
# star syntax expand the tuple as the argument.
|
# star syntax expand the tuple as the argument.
|
||||||
mat: bmap.bm_VxMatrix = bmap.bm_VxMatrix(*(mat_.to_const()))
|
mat: bmap.bm_VxMatrix = bmap.bm_VxMatrix(*(mat_.to_const()))
|
||||||
bmap.BM3dObject_SetWorldMatrix(self._get_pointer(), self._get_ckid(), mat)
|
bmap.BM3dEntity_SetWorldMatrix(self._get_pointer(), self._get_ckid(), mat)
|
||||||
|
|
||||||
def get_current_mesh(self) -> BMMesh | None:
|
def get_current_mesh(self) -> BMMesh | None:
|
||||||
ckid: bmap.bm_CKID = bmap.bm_CKID()
|
ckid: bmap.bm_CKID = bmap.bm_CKID()
|
||||||
bmap.BM3dObject_GetCurrentMesh(self._get_pointer(), self._get_ckid(), ctypes.byref(ckid))
|
bmap.BM3dEntity_GetCurrentMesh(self._get_pointer(), self._get_ckid(), ctypes.byref(ckid))
|
||||||
if ckid.value == g_InvalidCKID:
|
if ckid.value == g_InvalidCKID:
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
@@ -503,12 +503,60 @@ class BM3dObject(BMObject):
|
|||||||
ckid: bmap.bm_CKID = bmap.bm_CKID(g_InvalidCKID)
|
ckid: bmap.bm_CKID = bmap.bm_CKID(g_InvalidCKID)
|
||||||
if mesh is not None:
|
if mesh is not None:
|
||||||
ckid = mesh._get_ckid()
|
ckid = mesh._get_ckid()
|
||||||
bmap.BM3dObject_SetCurrentMesh(self._get_pointer(), self._get_ckid(), ckid)
|
bmap.BM3dEntity_SetCurrentMesh(self._get_pointer(), self._get_ckid(), ckid)
|
||||||
|
|
||||||
def get_visibility(self) -> bool:
|
def get_visibility(self) -> bool:
|
||||||
return self._get_bool_value(bmap.BM3dObject_GetVisibility)
|
return self._get_bool_value(bmap.BM3dEntity_GetVisibility)
|
||||||
def set_visibility(self, visb_: bool) -> None:
|
def set_visibility(self, visb_: bool) -> None:
|
||||||
self._set_bool_value(bmap.BM3dObject_SetVisibility, visb_)
|
self._set_bool_value(bmap.BM3dEntity_SetVisibility, visb_)
|
||||||
|
|
||||||
|
class BM3dObject(BM3dEntity):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class BMLight(BM3dEntity):
|
||||||
|
def get_type(self) -> virtools_types.VXLIGHT_TYPE:
|
||||||
|
return self._get_enum_value(virtools_types.VXLIGHT_TYPE, bmap.BMLight_GetType)
|
||||||
|
def set_type(self, data_: virtools_types.VXLIGHT_TYPE) -> None:
|
||||||
|
self._set_enum_value(bmap.BMLight_SetType, data_)
|
||||||
|
|
||||||
|
def get_color(self) -> virtools_types.VxColor:
|
||||||
|
return self._get_vxcolor_value(bmap.BMLight_GetColor)
|
||||||
|
def set_color(self, col: virtools_types.VxColor) -> None:
|
||||||
|
self._set_vxcolor_value(bmap.BMLight_SetColor, col)
|
||||||
|
|
||||||
|
def get_constant_attenuation(self) -> float:
|
||||||
|
return self._get_float_point_value(bmap.bm_CKFLOAT, bmap.BMLight_GetConstantAttenuation)
|
||||||
|
def set_constant_attenuation(self, val_: float) -> None:
|
||||||
|
self._set_float_point_value(bmap.bm_CKFLOAT, bmap.BMLight_SetConstantAttenuation, val_)
|
||||||
|
def get_linear_attenuation(self) -> float:
|
||||||
|
return self._get_float_point_value(bmap.bm_CKFLOAT, bmap.BMLight_GetLinearAttenuation)
|
||||||
|
def set_linear_attenuation(self, val_: float) -> None:
|
||||||
|
self._set_float_point_value(bmap.bm_CKFLOAT, bmap.BMLight_SetLinearAttenuation, val_)
|
||||||
|
def get_quadratic_attenuation(self) -> float:
|
||||||
|
return self._get_float_point_value(bmap.bm_CKFLOAT, bmap.BMLight_GetQuadraticAttenuation)
|
||||||
|
def set_quadratic_attenuation(self, val_: float) -> None:
|
||||||
|
self._set_float_point_value(bmap.bm_CKFLOAT, bmap.BMLight_SetQuadraticAttenuation, val_)
|
||||||
|
|
||||||
|
def get_range(self) -> float:
|
||||||
|
return self._get_float_point_value(bmap.bm_CKFLOAT, bmap.BMLight_GetRange)
|
||||||
|
def set_range(self, val_: float) -> None:
|
||||||
|
self._set_float_point_value(bmap.bm_CKFLOAT, bmap.BMLight_SetRange, val_)
|
||||||
|
|
||||||
|
def get_hot_spot(self) -> float:
|
||||||
|
return self._get_float_point_value(bmap.bm_CKFLOAT, bmap.BMLight_GetHotSpot)
|
||||||
|
def set_hot_spot(self, val_: float) -> None:
|
||||||
|
self._set_float_point_value(bmap.bm_CKFLOAT, bmap.BMLight_SetHotSpot, val_)
|
||||||
|
def get_falloff(self) -> float:
|
||||||
|
return self._get_float_point_value(bmap.bm_CKFLOAT, bmap.BMLight_GetFalloff)
|
||||||
|
def set_falloff(self, val_: float) -> None:
|
||||||
|
self._set_float_point_value(bmap.bm_CKFLOAT, bmap.BMLight_SetFalloff, val_)
|
||||||
|
def get_falloff_shape(self) -> float:
|
||||||
|
return self._get_float_point_value(bmap.bm_CKFLOAT, bmap.BMLight_GetFalloffShape)
|
||||||
|
def set_falloff_shape(self, val_: float) -> None:
|
||||||
|
self._set_float_point_value(bmap.bm_CKFLOAT, bmap.BMLight_SetFalloffShape, val_)
|
||||||
|
|
||||||
|
class BMTargetLight(BMLight):
|
||||||
|
pass
|
||||||
|
|
||||||
class BMGroup(BMObject):
|
class BMGroup(BMObject):
|
||||||
def add_object(self, member: BM3dObject) -> None:
|
def add_object(self, member: BM3dObject) -> None:
|
||||||
@@ -603,6 +651,10 @@ class BMFileReader(_AbstractPointer):
|
|||||||
return self.__get_ckobject_count(bmap.BMFile_GetGroupCount)
|
return self.__get_ckobject_count(bmap.BMFile_GetGroupCount)
|
||||||
def get_groups(self) -> typing.Iterator[BMGroup]:
|
def get_groups(self) -> typing.Iterator[BMGroup]:
|
||||||
return self.__get_ckobjects(BMGroup, bmap.BMFile_GetGroupCount, bmap.BMFile_GetGroup)
|
return self.__get_ckobjects(BMGroup, bmap.BMFile_GetGroupCount, bmap.BMFile_GetGroup)
|
||||||
|
def get_target_light_count(self) -> int:
|
||||||
|
return self.__get_ckobject_count(bmap.BMFile_GetTargetLightCount)
|
||||||
|
def get_target_lights(self) -> typing.Iterator[BMTargetLight]:
|
||||||
|
return self.__get_ckobjects(BMTargetLight, bmap.BMFile_GetTargetLightCount, bmap.BMFile_GetTargetLight)
|
||||||
|
|
||||||
class BMFileWriter(_AbstractPointer):
|
class BMFileWriter(_AbstractPointer):
|
||||||
def __init__(self, temp_folder_: str, texture_folder_: str, encodings_: tuple[str]):
|
def __init__(self, temp_folder_: str, texture_folder_: str, encodings_: tuple[str]):
|
||||||
@@ -663,6 +715,8 @@ class BMFileWriter(_AbstractPointer):
|
|||||||
return self.__create_ckobject(BM3dObject, bmap.BMFile_Create3dObject)
|
return self.__create_ckobject(BM3dObject, bmap.BMFile_Create3dObject)
|
||||||
def create_group(self) -> BMGroup:
|
def create_group(self) -> BMGroup:
|
||||||
return self.__create_ckobject(BMGroup, bmap.BMFile_CreateGroup)
|
return self.__create_ckobject(BMGroup, bmap.BMFile_CreateGroup)
|
||||||
|
def create_target_light(self) -> BMTargetLight:
|
||||||
|
return self.__create_ckobject(BMTargetLight, bmap.BMFile_CreateTargetLight)
|
||||||
|
|
||||||
class BMMeshTrans(_AbstractPointer):
|
class BMMeshTrans(_AbstractPointer):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -221,6 +221,15 @@ class VX_PIXELFORMAT(enum.IntEnum):
|
|||||||
_4_ABGR8888_CLUT = 30 ##< 4 bits indexed CLUT (ABGR)
|
_4_ABGR8888_CLUT = 30 ##< 4 bits indexed CLUT (ABGR)
|
||||||
_4_ARGB8888_CLUT = 31 ##< 4 bits indexed CLUT (ARGB)
|
_4_ARGB8888_CLUT = 31 ##< 4 bits indexed CLUT (ARGB)
|
||||||
|
|
||||||
|
class VXLIGHT_TYPE(enum.IntEnum):
|
||||||
|
"""!
|
||||||
|
Light type
|
||||||
|
"""
|
||||||
|
VX_LIGHTPOINT = 1 ##< The Light is a point of light
|
||||||
|
VX_LIGHTSPOT = 2 ##< The light is a spotlight
|
||||||
|
VX_LIGHTDIREC = 3 ##< The light is directional light : Lights comes from an infinite point so only direction of light can be given
|
||||||
|
#VX_LIGHTPARA = 4 ##< Obsolete, do not use
|
||||||
|
|
||||||
class VXTEXTURE_BLENDMODE(enum.IntEnum):
|
class VXTEXTURE_BLENDMODE(enum.IntEnum):
|
||||||
"""!
|
"""!
|
||||||
Blend Mode Flags
|
Blend Mode Flags
|
||||||
@@ -5,3 +5,5 @@ The real scripts are placed in sub PyBMap folder. This folder is served for test
|
|||||||
The native BMap library should be placed in sub PyBMap folder, and I have used gitignore file to filter them. The native BMap library must be named as `BMap.dll` (in Windows), `BMap.so` (in Linux or BSD), or `BMap.dylib` (in macOS). If you still can not load BMap or your system is not listed above, you should name it as `BMap.bin`.
|
The native BMap library should be placed in sub PyBMap folder, and I have used gitignore file to filter them. The native BMap library must be named as `BMap.dll` (in Windows), `BMap.so` (in Linux or BSD), or `BMap.dylib` (in macOS). If you still can not load BMap or your system is not listed above, you should name it as `BMap.bin`.
|
||||||
|
|
||||||
Please note the most content of `virtools_types.py` are generated by EnumsMigration sub-project. Additionally the most content of `bmap.py` is generated by BMapBindings. So if some structs are updated, do not forget checking these files.
|
Please note the most content of `virtools_types.py` are generated by EnumsMigration sub-project. Additionally the most content of `bmap.py` is generated by BMapBindings. So if some structs are updated, do not forget checking these files.
|
||||||
|
|
||||||
|
Since BMap 0.3.0, testbench use command line arguments, instead of hardcode variables in code, as the arguments of BMap. It is convenient that debug BMapSharp without any modification of source code. For a brief instruction, you may need to launch BMapSharpTestbench in following command (just an example. you can modify it as you wished): `py testbench.py --file-path "LightCameraTest.nmo" --temp-dir "Temp" --texture-dir "F:/Ballance/Ballance/Textures" --encodings cp1252 gb2312`.
|
||||||
178
Assets/BMapBindings/PyBMap/testbench.py
Normal file
178
Assets/BMapBindings/PyBMap/testbench.py
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
import os
|
||||||
|
import argparse
|
||||||
|
import PyBMap.bmap_wrapper as bmap
|
||||||
|
|
||||||
|
def main(file_name: str, temp_folder: str, texture_folder: str, encodings: tuple[str, ...]) -> None:
|
||||||
|
input(f'Python PID is {os.getpid()}. Waiting for debugger, press any key to continue...')
|
||||||
|
|
||||||
|
# file_name: str = 'LightCameraTest.nmo'
|
||||||
|
# temp_folder: str = 'Temp'
|
||||||
|
# texture_folder: str = 'F:\\Ballance\\Ballance\\Textures'
|
||||||
|
# encodings: tuple[str, ...] = ('cp1252', )
|
||||||
|
with bmap.BMFileReader(file_name, temp_folder, texture_folder, encodings) as reader:
|
||||||
|
test_common(reader)
|
||||||
|
test_equatable(reader)
|
||||||
|
|
||||||
|
def test_common(reader: bmap.BMFileReader):
|
||||||
|
# print('===== Groups =====')
|
||||||
|
# for gp in reader.get_groups():
|
||||||
|
# print(gp.get_name())
|
||||||
|
# for gp_item in gp.get_objects():
|
||||||
|
# print(f'\t{gp_item.get_name()}')
|
||||||
|
|
||||||
|
# print('===== 3dObjects =====')
|
||||||
|
# for obj in reader.get_3dobjects():
|
||||||
|
# print(obj.get_name())
|
||||||
|
|
||||||
|
# current_mesh = obj.get_current_mesh()
|
||||||
|
# mesh_name = '<null>' if current_mesh is None else current_mesh.get_name()
|
||||||
|
# print(f'\tMesh: {mesh_name}')
|
||||||
|
# print(f'\tVisibility: {obj.get_visibility()}')
|
||||||
|
# print(f'\tMatrix: {obj.get_world_matrix().to_const()}')
|
||||||
|
|
||||||
|
# print('===== Meshes =====')
|
||||||
|
# for mesh in reader.get_meshs():
|
||||||
|
# print(mesh.get_name())
|
||||||
|
|
||||||
|
# print(f'\tLit Mode: {mesh.get_lit_mode()}')
|
||||||
|
# print(f'\tVertex Count: {mesh.get_vertex_count()}')
|
||||||
|
# print(f'\tFace Count: {mesh.get_face_count()}')
|
||||||
|
# print(f'\tMaterial Slot Count: {mesh.get_material_slot_count()}')
|
||||||
|
|
||||||
|
# print('===== Materials =====')
|
||||||
|
# for mtl in reader.get_materials():
|
||||||
|
# print(mtl.get_name())
|
||||||
|
|
||||||
|
# print(f'\tDiffuse: {mtl.get_diffuse().to_const_rgba()}')
|
||||||
|
# print(f'\tAmbient: {mtl.get_ambient().to_const_rgba()}')
|
||||||
|
# print(f'\tSpecular: {mtl.get_specular().to_const_rgba()}')
|
||||||
|
# print(f'\tEmissive: {mtl.get_emissive().to_const_rgba()}')
|
||||||
|
|
||||||
|
# print(f'\tSpecular Power: {mtl.get_specular_power()}')
|
||||||
|
|
||||||
|
# print(f'\tTexture Border Color: {mtl.get_texture_border_color().to_const_rgba()}')
|
||||||
|
|
||||||
|
# print(f'\tTexture Blend Mode: {mtl.get_texture_blend_mode()}')
|
||||||
|
# print(f'\tTexture Min Mode: {mtl.get_texture_min_mode()}')
|
||||||
|
# print(f'\tTexture Mag Mode: {mtl.get_texture_mag_mode()}')
|
||||||
|
# print(f'\tSource Blend: {mtl.get_source_blend()}')
|
||||||
|
# print(f'\tDest Blend: {mtl.get_dest_blend()}')
|
||||||
|
# print(f'\tFill Mode: {mtl.get_fill_mode()}')
|
||||||
|
# print(f'\tShade Mode: {mtl.get_shade_mode()}')
|
||||||
|
|
||||||
|
# print(f'\tAlpha Test Enabled: {mtl.get_alpha_test_enabled()}')
|
||||||
|
# print(f'\tAlpha Blend Enabled: {mtl.get_alpha_blend_enabled()}')
|
||||||
|
# print(f'\tPerspective Correction Enabled: {mtl.get_perspective_correction_enabled()}')
|
||||||
|
# print(f'\tZ Write Enabled: {mtl.get_z_write_enabled()}')
|
||||||
|
# print(f'\tTwo Sided Enabled: {mtl.get_two_sided_enabled()}')
|
||||||
|
|
||||||
|
# print(f'\tAlpha Ref: {mtl.get_alpha_ref()}')
|
||||||
|
|
||||||
|
# print(f'\tAlpha Func: {mtl.get_alpha_func()}')
|
||||||
|
# print(f'\tZ Func: {mtl.get_z_func()}')
|
||||||
|
|
||||||
|
# print('===== Textures =====')
|
||||||
|
# for tex in reader.get_textures():
|
||||||
|
# print(tex.get_name())
|
||||||
|
|
||||||
|
# print(f'\tFile Name: {tex.get_file_name()}')
|
||||||
|
# print(f'\tSave Options: {tex.get_save_options()}')
|
||||||
|
# print(f'\tVideo Format: {tex.get_video_format()}')
|
||||||
|
|
||||||
|
print('===== Target Lights =====')
|
||||||
|
for lit in reader.get_target_lights():
|
||||||
|
print(lit.get_name())
|
||||||
|
|
||||||
|
print(f'\tVisibility: {lit.get_visibility()}')
|
||||||
|
print(f'\tMatrix: {lit.get_world_matrix().to_const()}')
|
||||||
|
|
||||||
|
print(f'\tType: {lit.get_type()}')
|
||||||
|
print(f'\tColor: {lit.get_color().to_const_rgba()}')
|
||||||
|
print(f'\tConstant Attenuation: {lit.get_constant_attenuation()}')
|
||||||
|
print(f'\tLinear Attenuation: {lit.get_linear_attenuation()}')
|
||||||
|
print(f'\tQuadratic Attenuation: {lit.get_quadratic_attenuation()}')
|
||||||
|
print(f'\tRange: {lit.get_range()}')
|
||||||
|
print(f'\tHot Spot: {lit.get_hot_spot()}')
|
||||||
|
print(f'\tFalloff: {lit.get_falloff()}')
|
||||||
|
print(f'\tFalloff Shape: {lit.get_falloff_shape()}')
|
||||||
|
|
||||||
|
print('===== END =====')
|
||||||
|
|
||||||
|
def test_equatable(reader: bmap.BMFileReader):
|
||||||
|
# Check requirements
|
||||||
|
assert (reader.get_3dobject_count() >= 2), '''
|
||||||
|
Invalid file for test IEquatable.
|
||||||
|
We can not perform IEquatable test because the length of 3dObject is too short (must greater than 2). Please choose another file to perform.
|
||||||
|
'''
|
||||||
|
|
||||||
|
# Prepare variables
|
||||||
|
all_3dobjects: tuple[bmap.BM3dObject, ...] = tuple(reader.get_3dobjects())
|
||||||
|
first_3dobj: bmap.BM3dObject = all_3dobjects[0]
|
||||||
|
second_3dobj: bmap.BM3dObject = all_3dobjects[1]
|
||||||
|
all_3dobjects = tuple(reader.get_3dobjects())
|
||||||
|
first_3dobj_again: bmap.BM3dObject = all_3dobjects[0]
|
||||||
|
|
||||||
|
# Test set
|
||||||
|
test_set: set[bmap.BM3dObject] = set()
|
||||||
|
|
||||||
|
test_set.add(first_3dobj)
|
||||||
|
assert len(test_set) == 1
|
||||||
|
|
||||||
|
assert first_3dobj in test_set
|
||||||
|
assert first_3dobj_again in test_set
|
||||||
|
assert second_3dobj not in test_set
|
||||||
|
|
||||||
|
test_set.add(first_3dobj_again)
|
||||||
|
assert len(test_set) == 1
|
||||||
|
test_set.add(second_3dobj)
|
||||||
|
assert len(test_set) == 2
|
||||||
|
|
||||||
|
assert second_3dobj in test_set
|
||||||
|
|
||||||
|
# Test dict
|
||||||
|
test_dict: dict[bmap.BM3dObject, str | None] = {}
|
||||||
|
|
||||||
|
test_dict[first_3dobj] = first_3dobj.get_name()
|
||||||
|
assert len(test_dict) == 1
|
||||||
|
|
||||||
|
assert first_3dobj in test_dict
|
||||||
|
assert first_3dobj_again in test_dict
|
||||||
|
assert second_3dobj not in test_dict
|
||||||
|
|
||||||
|
test_dict[first_3dobj_again] = first_3dobj_again.get_name()
|
||||||
|
assert len(test_dict) == 1
|
||||||
|
test_dict[second_3dobj] = second_3dobj.get_name()
|
||||||
|
assert len(test_dict) == 2
|
||||||
|
|
||||||
|
assert second_3dobj in test_dict
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
# parse argument
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
prog='PyBMap Testbench',
|
||||||
|
description='The testbench of PyBMap.'
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--file-path',
|
||||||
|
action='store', dest='file_path', required=True,
|
||||||
|
help='The path to input Virtools file.'
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--temp-dir',
|
||||||
|
action='store', dest='temp_dir', required=True,
|
||||||
|
help='The temp folder used by BMap.'
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--texture-dir',
|
||||||
|
action='store', dest='texture_dir', required=True,
|
||||||
|
help='The texture folder containing Ballance texture resources.'
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--encodings',
|
||||||
|
action='extend', nargs='+', dest='encodings', required=True,
|
||||||
|
help='The encodings used to parse the names stroed in input Virtools file.'
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# run main function
|
||||||
|
main(args.file_path, args.temp_dir, args.texture_dir, tuple(args.encodings))
|
||||||
@@ -188,6 +188,7 @@ public class CSharpWriter {
|
|||||||
break;
|
break;
|
||||||
case "CK_TEXTURE_SAVEOPTIONS":
|
case "CK_TEXTURE_SAVEOPTIONS":
|
||||||
case "VX_PIXELFORMAT":
|
case "VX_PIXELFORMAT":
|
||||||
|
case "VXLIGHT_TYPE":
|
||||||
case "VXTEXTURE_BLENDMODE":
|
case "VXTEXTURE_BLENDMODE":
|
||||||
case "VXTEXTURE_FILTERMODE":
|
case "VXTEXTURE_FILTERMODE":
|
||||||
case "VXTEXTURE_ADDRESSMODE":
|
case "VXTEXTURE_ADDRESSMODE":
|
||||||
@@ -28,6 +28,7 @@ public class PythonWriter {
|
|||||||
cache.put("VxMatrix", "VxMatrix");
|
cache.put("VxMatrix", "VxMatrix");
|
||||||
cache.put("CK_TEXTURE_SAVEOPTIONS", "enum");
|
cache.put("CK_TEXTURE_SAVEOPTIONS", "enum");
|
||||||
cache.put("VX_PIXELFORMAT", "enum");
|
cache.put("VX_PIXELFORMAT", "enum");
|
||||||
|
cache.put("VXLIGHT_TYPE", "enum");
|
||||||
cache.put("VXTEXTURE_BLENDMODE", "enum");
|
cache.put("VXTEXTURE_BLENDMODE", "enum");
|
||||||
cache.put("VXTEXTURE_FILTERMODE", "enum");
|
cache.put("VXTEXTURE_FILTERMODE", "enum");
|
||||||
cache.put("VXTEXTURE_ADDRESSMODE", "enum");
|
cache.put("VXTEXTURE_ADDRESSMODE", "enum");
|
||||||
@@ -170,6 +170,14 @@ public class MainRunner {
|
|||||||
PythonWriter.writeAccVal("dest/CK_BITMAPDATA_FLAGS.AccVal.py", single);
|
PythonWriter.writeAccVal("dest/CK_BITMAPDATA_FLAGS.AccVal.py", single);
|
||||||
CSharpWriter.writeAccVal("dest/CK_BITMAPDATA_FLAGS.AccVal.cs", single);
|
CSharpWriter.writeAccVal("dest/CK_BITMAPDATA_FLAGS.AccVal.cs", single);
|
||||||
|
|
||||||
|
single = organiseDefines("src/CK_CAMERA_PROJECTION.txt", "CK_CAMERA_PROJECTION");
|
||||||
|
CppWriter.writeEnum("dest/CK_CAMERA_PROJECTION.hpp", single);
|
||||||
|
PythonWriter.writeEnum("dest/CK_CAMERA_PROJECTION.py", single);
|
||||||
|
CSharpWriter.writeEnum("dest/CK_CAMERA_PROJECTION.cs", single);
|
||||||
|
CppWriter.writeAccVal("dest/CK_CAMERA_PROJECTION.AccVal.hpp", single, CommonHelper.CKParts.CK2);
|
||||||
|
PythonWriter.writeAccVal("dest/CK_CAMERA_PROJECTION.AccVal.py", single);
|
||||||
|
CSharpWriter.writeAccVal("dest/CK_CAMERA_PROJECTION.AccVal.cs", single);
|
||||||
|
|
||||||
// print message.
|
// print message.
|
||||||
System.out.println("DONE!");
|
System.out.println("DONE!");
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
#define CK_PERSPECTIVEPROJECTION 1
|
||||||
|
|
||||||
|
#define CK_ORTHOGRAPHICPROJECTION 2
|
||||||
@@ -41,6 +41,25 @@ typedef enum VX_PIXELFORMAT {
|
|||||||
_4_ARGB8888_CLUT = 31 // 4 bits indexed CLUT (ARGB)
|
_4_ARGB8888_CLUT = 31 // 4 bits indexed CLUT (ARGB)
|
||||||
} VX_PIXELFORMAT;
|
} VX_PIXELFORMAT;
|
||||||
|
|
||||||
|
|
||||||
|
/******************************************************************
|
||||||
|
{filename:VXLIGHT_TYPE}
|
||||||
|
Summary: Light type.
|
||||||
|
|
||||||
|
Remarks:
|
||||||
|
+ Used by CKLight::SetType to specify the type of a light.
|
||||||
|
See also: CKLight::SetType,CKLight::GetType
|
||||||
|
******************************************************************/
|
||||||
|
typedef enum VXLIGHT_TYPE
|
||||||
|
{
|
||||||
|
VX_LIGHTPOINT = 1UL, // The Light is a point of light
|
||||||
|
VX_LIGHTSPOT = 2UL, // The light is a spotlight
|
||||||
|
VX_LIGHTDIREC = 3UL, // The light is directional light : Lights comes from an infinite point so only direction of light can be given
|
||||||
|
VX_LIGHTPARA = 4UL // Obsolete, do not use
|
||||||
|
} VXLIGHT_TYPE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************
|
/*****************************************************************
|
||||||
{filename:VXTEXTURE_BLENDMODE}
|
{filename:VXTEXTURE_BLENDMODE}
|
||||||
Summary: Blend Mode Flags
|
Summary: Blend Mode Flags
|
||||||
3
Assets/CodeGen/VectorGen/.gitignore
vendored
Normal file
3
Assets/CodeGen/VectorGen/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Result
|
||||||
|
VxTypes.hpp
|
||||||
|
VxTypes.cpp
|
||||||
3
Assets/CodeGen/VectorGen/README.md
Normal file
3
Assets/CodeGen/VectorGen/README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Vector Generator
|
||||||
|
|
||||||
|
Vector types (LibCmo::VxMath::VxVector3 and etc) and Vector-like types (LibCmo::VxMath::VxColor and etc) nearly have similar declaration except slight differences (basically is the count of factors). Manually writing these declarations is boring and easy to cause potential invisible bugs. So we use a Python script to generate these declarations batchly to prevent any defects indroduced above.
|
||||||
178
Assets/CodeGen/VectorGen/VxTypes.cpp.jinja
Normal file
178
Assets/CodeGen/VectorGen/VxTypes.cpp.jinja
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
{% import 'VxTypes.shared.jinja' as shared %}
|
||||||
|
{#
|
||||||
|
For friend operator overload, we do not need add CLASSNAME:: prefix for it.
|
||||||
|
Because they are not a part of that class.
|
||||||
|
#}
|
||||||
|
|
||||||
|
#pragma region {{ sname }}
|
||||||
|
|
||||||
|
{# Ctor type 1 - Default ctor -#}
|
||||||
|
{{ sname }}::{{ sname }}() : {{- shared.initialize_list_builder(svars, False) -}} {} {% if not is_vector %}// SET YOUR CUSTOM INIT{% endif %}
|
||||||
|
{#- Ctor type 2 - User specified ctor #}
|
||||||
|
{{ sname }}::{{ sname }}({{- shared.argument_list_builder(svars) -}}) : {{- shared.initialize_list_builder(svars, True) -}} {}
|
||||||
|
|
||||||
|
{#- Offset operator #}
|
||||||
|
CKFLOAT& {{ sname }}::operator[](size_t i) {
|
||||||
|
switch (i) {
|
||||||
|
{%- for item in svars %}
|
||||||
|
case {{ loop.index0 }}: return {{ item }};
|
||||||
|
{%- endfor %}
|
||||||
|
default: throw LogicException("Invalid index for {{ sname }}::operator[].");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const CKFLOAT& {{ sname }}::operator[](size_t i) const {
|
||||||
|
switch (i) {
|
||||||
|
{%- for item in svars %}
|
||||||
|
case {{ loop.index0 }}: return {{ item }};
|
||||||
|
{%- endfor %}
|
||||||
|
default: throw LogicException("Invalid index for {{ sname }}::operator[].");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{#- Equal operator #}
|
||||||
|
bool {{ sname }}::operator==(const {{ sname }}& rhs) const {
|
||||||
|
return (
|
||||||
|
{%- for item in svars -%}
|
||||||
|
{{ item }} == rhs.{{ item }} {%- if not loop.last %} && {% endif %}
|
||||||
|
{%- endfor -%}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
{#- Spaceship operator #}
|
||||||
|
auto {{ sname }}::operator<=>(const {{ sname }}& rhs) const {
|
||||||
|
{%- for item in svars[:-1] %}
|
||||||
|
if (auto cmp = {{ item }} <=> rhs.{{ item }}; cmp != 0) return cmp;
|
||||||
|
{%- endfor %}
|
||||||
|
return {{ svars[-1] }} <=> rhs.{{ svars[-1] }};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{#- BEGIN VECTOR SPECIFIC #}
|
||||||
|
{%- if is_vector %}
|
||||||
|
|
||||||
|
{#- Add, minus operators #}
|
||||||
|
{#- Unary operators #}
|
||||||
|
{{ sname }} {{ sname }}::operator+() const {
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
{{ sname }} {{ sname }}::operator-() const {
|
||||||
|
return {{ sname }}(
|
||||||
|
{%- for item in svars -%}
|
||||||
|
-{{ item }} {%- if not loop.last %}, {% endif %}
|
||||||
|
{%- endfor -%}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
{#- Additive operators #}
|
||||||
|
{{ sname }}& {{ sname }}::operator+=(const {{ sname }}& rhs) {
|
||||||
|
{%- for item in svars %}
|
||||||
|
{{ item }} += rhs.{{ item }};
|
||||||
|
{%- endfor %}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
{{ sname }} operator+(const {{ sname }}& lhs, const {{ sname }}& rhs) {
|
||||||
|
return {{ sname }}(
|
||||||
|
{%- for item in svars -%}
|
||||||
|
lhs.{{ item }} + rhs.{{ item }} {%- if not loop.last %}, {% endif %}
|
||||||
|
{%- endfor -%}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
{{ sname }}& {{ sname }}::operator-=(const {{ sname }}& rhs) {
|
||||||
|
{%- for item in svars %}
|
||||||
|
{{ item }} -= rhs.{{ item }};
|
||||||
|
{%- endfor %}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
{{ sname }} operator-(const {{ sname }}& lhs, const {{ sname }}& rhs) {
|
||||||
|
return {{ sname }}(
|
||||||
|
{%- for item in svars -%}
|
||||||
|
lhs.{{ item }} - rhs.{{ item }} {%- if not loop.last %}, {% endif %}
|
||||||
|
{%- endfor -%}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
{#- Mul operator #}
|
||||||
|
{{ sname }}& {{ sname }}::operator*=(CKFLOAT rhs) {
|
||||||
|
{%- for item in svars %}
|
||||||
|
{{ item }} *= rhs;
|
||||||
|
{%- endfor %}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
{{ sname }} operator*(const {{ sname }}& lhs, CKFLOAT rhs) {
|
||||||
|
return {{ sname }}(
|
||||||
|
{%- for item in svars -%}
|
||||||
|
lhs.{{ item }} * rhs {%- if not loop.last %}, {% endif %}
|
||||||
|
{%- endfor -%}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
{{ sname }} operator*(CKFLOAT lhs, const {{ sname }}& rhs) {
|
||||||
|
return {{ sname }}(
|
||||||
|
{%- for item in svars -%}
|
||||||
|
lhs * rhs.{{ item }} {%- if not loop.last %}, {% endif %}
|
||||||
|
{%- endfor -%}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
CKFLOAT operator*(const {{ sname }}& lhs, const {{ sname }}& rhs) {
|
||||||
|
return (
|
||||||
|
{%- for item in svars -%}
|
||||||
|
lhs.{{ item }} * rhs.{{ item }} {%- if not loop.last %} + {% endif %}
|
||||||
|
{%- endfor -%}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
{#- Div operator #}
|
||||||
|
{{ sname }}& {{ sname }}::operator/=(CKFLOAT rhs) {
|
||||||
|
if (rhs == 0.0f) return *this;
|
||||||
|
{%- for item in svars %}
|
||||||
|
{{ item }} /= rhs;
|
||||||
|
{%- endfor %}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
{{ sname }} operator/(const {{ sname }}& lhs, CKFLOAT rhs) {
|
||||||
|
if (rhs == 0.0f) return {{ sname }}();
|
||||||
|
else return {{ sname }}(
|
||||||
|
{%- for item in svars -%}
|
||||||
|
lhs.{{ item }} / rhs {%- if not loop.last %}, {% endif %}
|
||||||
|
{%- endfor -%}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
{#- Length functions #}
|
||||||
|
CKFLOAT {{ sname }}::SquaredLength() const {
|
||||||
|
return (
|
||||||
|
{%- for item in svars -%}
|
||||||
|
{{ item }} * {{ item }} {%- if not loop.last %} + {% endif %}
|
||||||
|
{%- endfor -%}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
CKFLOAT {{ sname }}::Length() const {
|
||||||
|
return std::sqrt(SquaredLength());
|
||||||
|
}
|
||||||
|
|
||||||
|
{#- Normalize functions #}
|
||||||
|
void {{ sname }}::Normalized() {
|
||||||
|
CKFLOAT len = Length();
|
||||||
|
if (len == 0.0f) return;
|
||||||
|
{%- for item in svars %}
|
||||||
|
{{ item }} /= len;
|
||||||
|
{%- endfor %}
|
||||||
|
}
|
||||||
|
{{ sname }} {{ sname }}::Normalize() const {
|
||||||
|
CKFLOAT len = Length();
|
||||||
|
if (len == 0.0f) return {{ sname }}();
|
||||||
|
else return {{ sname }}(
|
||||||
|
{%- for item in svars -%}
|
||||||
|
{{ item }} / len {%- if not loop.last %}, {% endif %}
|
||||||
|
{%- endfor -%}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
{%- endif %}
|
||||||
|
{#- END VECTOR SPECIFIC #}
|
||||||
|
|
||||||
|
|
||||||
|
{#- User custom region #}
|
||||||
|
|
||||||
|
/* ===== BEGIN USER CUSTOM ===== */
|
||||||
|
/* ===== END USER CUSTOM ===== */
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
65
Assets/CodeGen/VectorGen/VxTypes.hpp.jinja
Normal file
65
Assets/CodeGen/VectorGen/VxTypes.hpp.jinja
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
{% import 'VxTypes.shared.jinja' as shared %}
|
||||||
|
|
||||||
|
struct {{ sname }} {
|
||||||
|
{#- Variable declaration #}
|
||||||
|
CKFLOAT {{ ", ".join(svars) }};
|
||||||
|
|
||||||
|
{#- Ctor type 1 - Default ctor #}
|
||||||
|
{{ sname }}();
|
||||||
|
{#- Ctor type 2 - User specified ctor #}
|
||||||
|
{{ sname }}({{- shared.argument_list_builder(svars) -}});
|
||||||
|
|
||||||
|
{#- Default copy ctor, move ctor, copy assigner, move assigner #}
|
||||||
|
YYCC_DEF_CLS_COPY_MOVE({{ sname }});
|
||||||
|
|
||||||
|
{#- Offset operator #}
|
||||||
|
CKFLOAT& operator[](size_t i);
|
||||||
|
const CKFLOAT& operator[](size_t i) const;
|
||||||
|
|
||||||
|
{#- Equal operator #}
|
||||||
|
bool operator==(const {{ sname }}& rhs) const;
|
||||||
|
|
||||||
|
{#- Spaceship operator #}
|
||||||
|
auto operator<=>(const {{ sname }}& rhs) const;
|
||||||
|
|
||||||
|
|
||||||
|
{#- BEGIN VECTOR SPECIFIC #}
|
||||||
|
{%- if is_vector %}
|
||||||
|
|
||||||
|
{#- Add, minus operators #}
|
||||||
|
{#- Unary operators #}
|
||||||
|
{{ sname }} operator+() const;
|
||||||
|
{{ sname }} operator-() const;
|
||||||
|
{#- Additive operators #}
|
||||||
|
{{ sname }}& operator+=(const {{ sname }}& rhs);
|
||||||
|
friend {{ sname }} operator+(const {{ sname }}& lhs, const {{ sname }}& rhs);
|
||||||
|
{{ sname }}& operator-=(const {{ sname }}& rhs);
|
||||||
|
friend {{ sname }} operator-(const {{ sname }}& lhs, const {{ sname }}& rhs);
|
||||||
|
|
||||||
|
{#- Mul operator #}
|
||||||
|
{{ sname }}& operator*=(CKFLOAT rhs);
|
||||||
|
friend {{ sname }} operator*(const {{ sname }}& lhs, CKFLOAT rhs);
|
||||||
|
friend {{ sname }} operator*(CKFLOAT lhs, const {{ sname }}& rhs);
|
||||||
|
friend CKFLOAT operator*(const {{ sname }}& lhs, const {{ sname }}& rhs);
|
||||||
|
|
||||||
|
{#- Div operator #}
|
||||||
|
{{ sname }}& operator/=(CKFLOAT rhs);
|
||||||
|
friend {{ sname }} operator/(const {{ sname }}& lhs, CKFLOAT rhs);
|
||||||
|
|
||||||
|
{#- Length functions #}
|
||||||
|
CKFLOAT SquaredLength() const;
|
||||||
|
CKFLOAT Length() const;
|
||||||
|
|
||||||
|
{#- Normalize functions #}
|
||||||
|
void Normalized();
|
||||||
|
{{ sname }} Normalize() const;
|
||||||
|
|
||||||
|
{%- endif %}
|
||||||
|
{#- END VECTOR SPECIFIC #}
|
||||||
|
|
||||||
|
|
||||||
|
{#- User custom region #}
|
||||||
|
|
||||||
|
/* ===== BEGIN USER CUSTOM ===== */
|
||||||
|
/* ===== END USER CUSTOM ===== */
|
||||||
|
};
|
||||||
21
Assets/CodeGen/VectorGen/VxTypes.shared.jinja
Normal file
21
Assets/CodeGen/VectorGen/VxTypes.shared.jinja
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{#
|
||||||
|
The macro to generate C++ ctor argument list
|
||||||
|
It produce like this: `CKFLOAT _x, CKFLOAT _y, CKFLOAT _z, CKFLOAT _w`
|
||||||
|
#}
|
||||||
|
{% macro argument_list_builder(svars) %}
|
||||||
|
{%- for item in svars -%}
|
||||||
|
CKFLOAT _{{- item -}}{%- if not loop.last %}, {% endif -%}
|
||||||
|
{%- endfor -%}
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
{#
|
||||||
|
The macro to generate C++ ctor initialize list
|
||||||
|
It produce like this: `x(0.0f), y(0.0f), z(0.0f), w(0.0f)`
|
||||||
|
or this: `x(_x), y(_y), z(_z), w(_w)`
|
||||||
|
according to user request.
|
||||||
|
#}
|
||||||
|
{% macro initialize_list_builder(svars, is_user) %}
|
||||||
|
{%- for item in svars -%}
|
||||||
|
{{- item -}}({%- if is_user -%}_{{- item -}}{%- else -%}0.0f{%- endif -%}){%- if not loop.last %}, {% endif -%}
|
||||||
|
{%- endfor -%}
|
||||||
|
{% endmacro %}
|
||||||
63
Assets/CodeGen/VectorGen/VxVectorGen.py
Normal file
63
Assets/CodeGen/VectorGen/VxVectorGen.py
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
import os
|
||||||
|
import io
|
||||||
|
import typing
|
||||||
|
import jinja2
|
||||||
|
|
||||||
|
g_HppTemplateFile: str = 'VxTypes.hpp.jinja'
|
||||||
|
g_CppTemplateFile: str = 'VxTypes.cpp.jinja'
|
||||||
|
|
||||||
|
g_ResultHppFile: str = 'VxTypes.hpp'
|
||||||
|
g_ResultCppFile: str = 'VxTypes.cpp'
|
||||||
|
|
||||||
|
def get_root_directory() -> str:
|
||||||
|
return os.path.dirname(__file__)
|
||||||
|
|
||||||
|
class TemplateRender:
|
||||||
|
m_Loader: jinja2.BaseLoader
|
||||||
|
m_Environment: jinja2.Environment
|
||||||
|
|
||||||
|
m_HppTemplate: jinja2.Template
|
||||||
|
m_CppTemplate: jinja2.Template
|
||||||
|
|
||||||
|
m_OutputHpp: io.TextIOWrapper
|
||||||
|
m_OutputCpp: io.TextIOWrapper
|
||||||
|
|
||||||
|
def __init__(self, output_hpp_path: str, output_cpp_path: str) -> None:
|
||||||
|
self.m_Loader = jinja2.FileSystemLoader(get_root_directory())
|
||||||
|
self.m_Environment = jinja2.Environment(loader=self.m_Loader)
|
||||||
|
|
||||||
|
self.m_HppTemplate = self.m_Environment.get_template(g_HppTemplateFile)
|
||||||
|
self.m_CppTemplate = self.m_Environment.get_template(g_CppTemplateFile)
|
||||||
|
|
||||||
|
self.m_OutputHpp = open(os.path.join(get_root_directory(), output_hpp_path), 'w', encoding='utf-8')
|
||||||
|
self.m_OutputCpp = open(os.path.join(get_root_directory(), output_cpp_path), 'w', encoding='utf-8')
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __exit__(self, exc_type, exc_value, traceback):
|
||||||
|
self.m_OutputHpp.close()
|
||||||
|
self.m_OutputCpp.close()
|
||||||
|
|
||||||
|
def __render(self, sname: str, is_vector: bool, svars: tuple[str]) -> None:
|
||||||
|
template_argument: dict[str, typing.Any] = {
|
||||||
|
'sname': sname,
|
||||||
|
'is_vector': is_vector,
|
||||||
|
'svars': svars
|
||||||
|
}
|
||||||
|
self.m_OutputHpp.write(self.m_HppTemplate.render(**template_argument))
|
||||||
|
self.m_OutputCpp.write(self.m_CppTemplate.render(**template_argument))
|
||||||
|
|
||||||
|
def render_vector(self, sname: str, svars: tuple[str]) -> None:
|
||||||
|
self.__render(sname, True, svars)
|
||||||
|
|
||||||
|
def render_others(self, sname: str, svars: tuple[str]) -> None:
|
||||||
|
self.__render(sname, False, svars)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
with TemplateRender(g_ResultHppFile, g_ResultCppFile) as render:
|
||||||
|
render.render_vector('VxVector2', ('x', 'y', ))
|
||||||
|
render.render_vector('VxVector3', ('x', 'y', 'z', ))
|
||||||
|
render.render_vector('VxVector4', ('x', 'y', 'z', 'w', ))
|
||||||
|
render.render_others('VxQuaternion', ('x', 'y', 'z', 'w', ))
|
||||||
|
render.render_others('VxColor', ('r', 'g', 'b', 'a', ))
|
||||||
18
Assets/Tools/MeshConv/.gitignore
vendored
Normal file
18
Assets/Tools/MeshConv/.gitignore
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
## ======== Personal ========
|
||||||
|
# Ignore test used 3d Object
|
||||||
|
*.bin
|
||||||
|
*.obj
|
||||||
|
*.mtl
|
||||||
|
|
||||||
|
## ======== Python ========
|
||||||
|
# Python-generated files
|
||||||
|
__pycache__/
|
||||||
|
*.py[oc]
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
wheels/
|
||||||
|
*.egg-info
|
||||||
|
|
||||||
|
# Virtual environments
|
||||||
|
.venv
|
||||||
|
|
||||||
1
Assets/Tools/MeshConv/.python-version
Normal file
1
Assets/Tools/MeshConv/.python-version
Normal file
@@ -0,0 +1 @@
|
|||||||
|
3.11
|
||||||
13
Assets/Tools/MeshConv/README.md
Normal file
13
Assets/Tools/MeshConv/README.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# MeshConv
|
||||||
|
|
||||||
|
Build complete Wavefront OBJ file from separated data for debugging libcmo21.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
- Restore this project by Astral UV.
|
||||||
|
- Save all mesh components into separate files in this directory.
|
||||||
|
* Vertex position as `VertexPosition.bin` for example.
|
||||||
|
* Vertex normal as `VertexNormal.bin` for example.
|
||||||
|
* Vertex UV as `VertexUV.bin` for example.
|
||||||
|
* Face indices as `FaceIndices.bin` for example.
|
||||||
|
- Execute `uv run main.py -p VertexPosition.bin -n VertexNormal.bin -u VertexUV.bin -i FaceIndices.bin -o mesh.obj -m mesh.mtl` for example. It will utilize previous saved file to generate a Wavefront OBJ file `mesh.obj` and corresponding material file `mesh.mtl`. For the usage of these switches, please refer to the source code.
|
||||||
178
Assets/Tools/MeshConv/main.py
Normal file
178
Assets/Tools/MeshConv/main.py
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
import argparse
|
||||||
|
import io
|
||||||
|
import struct
|
||||||
|
import typing
|
||||||
|
import itertools
|
||||||
|
from pathlib import Path
|
||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
# region: Kernel
|
||||||
|
|
||||||
|
T = typing.TypeVar('T')
|
||||||
|
Vector = tuple[float, ...]
|
||||||
|
Indices = tuple[int, ...]
|
||||||
|
|
||||||
|
def get_file_length(fs: typing.BinaryIO) -> int:
|
||||||
|
"""
|
||||||
|
Get the full length of given file in bytes.
|
||||||
|
|
||||||
|
:param fs: File stream for measuring.
|
||||||
|
:return: File length in bytes.
|
||||||
|
"""
|
||||||
|
pos = fs.tell()
|
||||||
|
fs.seek(0, io.SEEK_END)
|
||||||
|
fsize = fs.tell()
|
||||||
|
fs.seek(pos, io.SEEK_SET)
|
||||||
|
return fsize
|
||||||
|
|
||||||
|
def evaluate_count(filename: Path, unit_size: int) -> int:
|
||||||
|
"""
|
||||||
|
Evaluate the count of items in given file.
|
||||||
|
|
||||||
|
:param filename: File name to evaluate.
|
||||||
|
:param unit_size: Size of each item in bytes.
|
||||||
|
:return: Count of items in given file.
|
||||||
|
"""
|
||||||
|
with open(filename, 'rb') as fs:
|
||||||
|
file_size = get_file_length(fs)
|
||||||
|
count, modrem = divmod(file_size, unit_size)
|
||||||
|
if modrem != 0:
|
||||||
|
raise Exception("invalid file length")
|
||||||
|
return count
|
||||||
|
|
||||||
|
def assert_file_size(fs: typing.BinaryIO, expected_size: int):
|
||||||
|
"""
|
||||||
|
Check whether given file has expected size.
|
||||||
|
|
||||||
|
:param fs: File stream to check.
|
||||||
|
:param expected_size: Expected file size.
|
||||||
|
"""
|
||||||
|
if expected_size != get_file_length(fs):
|
||||||
|
raise Exception("invalid file length")
|
||||||
|
|
||||||
|
def read_f32s(filename: Path, count: int) -> tuple[float, ...]:
|
||||||
|
with open(filename, 'rb') as fs:
|
||||||
|
# construct class
|
||||||
|
cstruct = struct.Struct(f'<{count}f')
|
||||||
|
# assert file size
|
||||||
|
assert_file_size(fs, cstruct.size)
|
||||||
|
# read
|
||||||
|
return cstruct.unpack(fs.read(cstruct.size))
|
||||||
|
|
||||||
|
def read_u16s(filename: Path, count: int) -> tuple[int, ...]:
|
||||||
|
with open(filename, 'rb') as fs:
|
||||||
|
# construct class
|
||||||
|
cstruct = struct.Struct(f'<{count}H')
|
||||||
|
# assert file size
|
||||||
|
assert_file_size(fs, cstruct.size)
|
||||||
|
# read
|
||||||
|
return cstruct.unpack(fs.read(cstruct.size))
|
||||||
|
|
||||||
|
def batched_tuple(full_list: tuple[T, ...], couple_count: int) -> tuple[tuple[T, ...], ...]:
|
||||||
|
"""
|
||||||
|
Batch a tuple into a tuple of tuples.
|
||||||
|
|
||||||
|
This function will check whether given tuple can be batched without any remnants.
|
||||||
|
If it is, throw exception, otherwise return the batched tuple.
|
||||||
|
|
||||||
|
For example, given `('roses', 'red', 'violets', 'blue', 'sugar', 'sweet')`,
|
||||||
|
it will produce `(('roses', 'red'), ('violets', 'blue'), ('sugar', 'sweet'))`.
|
||||||
|
|
||||||
|
:param full_list: The tuple to batch.
|
||||||
|
:param couple_count: The count of items in each batch.
|
||||||
|
:return: The batched tuple.
|
||||||
|
"""
|
||||||
|
# TODO: Replace the whole body with itertools.batched once we upgrade into Python 3.12
|
||||||
|
# return itertools.batched(full_list, couple_count, strict=True)
|
||||||
|
count, modrem = divmod(len(full_list), couple_count)
|
||||||
|
if modrem != 0:
|
||||||
|
raise Exception("invalid tuple length")
|
||||||
|
|
||||||
|
return tuple(map(lambda x: tuple(full_list[x * couple_count:x * couple_count + couple_count]), range(count)))
|
||||||
|
|
||||||
|
def build_obj_file(filename: Path, vpos: tuple[Vector, ...], vnml: tuple[Vector, ...], vuv: tuple[Vector, ...], findices: tuple[Indices, ...]):
|
||||||
|
with open(filename, 'w', encoding='utf-8') as fs:
|
||||||
|
for v in vpos:
|
||||||
|
fs.write(f'v {v[0]} {v[1]} {v[2]}\n')
|
||||||
|
for v in vnml:
|
||||||
|
fs.write(f'vn {v[0]} {v[1]} {v[2]}\n')
|
||||||
|
for v in vuv:
|
||||||
|
fs.write(f'vt {v[0]} {v[1]}\n')
|
||||||
|
for f in findices:
|
||||||
|
fs.write(f'f {f[0] + 1}/{f[0] + 1}/{f[0] + 1} {f[1] + 1}/{f[1] + 1}/{f[1] + 1} {f[2] + 1}/{f[2] + 1}/{f[2] + 1}\n')
|
||||||
|
fs.write('g obj\n')
|
||||||
|
|
||||||
|
# endregion
|
||||||
|
|
||||||
|
# region Command Line Processor
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Cli:
|
||||||
|
"""Command Line Arguments"""
|
||||||
|
|
||||||
|
in_vpos: Path
|
||||||
|
"""The path to file storing vertex positions"""
|
||||||
|
in_vnml: Path
|
||||||
|
"""The path to file storing vertex normals"""
|
||||||
|
in_vuv: Path
|
||||||
|
"""The path to file storing vertex UVs"""
|
||||||
|
in_findices: Path
|
||||||
|
"""The path to file storing face indices"""
|
||||||
|
out_obj: Path
|
||||||
|
"""The path to output OBJ file"""
|
||||||
|
out_mtl: Path
|
||||||
|
"""The path to output MTL file"""
|
||||||
|
|
||||||
|
def parse() -> Cli:
|
||||||
|
# construct parser
|
||||||
|
parser = argparse.ArgumentParser(description='The mesh data combinator for libcmo21 debugging.')
|
||||||
|
parser.add_argument('-p', '--in-vpos', required=True, type=str, action='store', dest='in_vpos', metavar='vpos.bin',
|
||||||
|
help='''The path to file storing vertex positions''')
|
||||||
|
parser.add_argument('-n', '--in-vnml', required=True, type=str, action='store', dest='in_vnml', metavar='vnml.bin',
|
||||||
|
help='''The path to file storing vertex normals''')
|
||||||
|
parser.add_argument('-u', '--in-vuv', required=True, type=str, action='store', dest='in_vuv', metavar='vuv.bin',
|
||||||
|
help='''The path to file storing vertex UVs''')
|
||||||
|
parser.add_argument('-i', '--in-findices', required=True, type=str, action='store', dest='in_findices', metavar='findices.bin',
|
||||||
|
help='''The path to file storing face indices''')
|
||||||
|
parser.add_argument('-o', '--out-obj', required=True, type=str, action='store', dest='out_obj', metavar='mesh.obj',
|
||||||
|
help='''The path to output OBJ file''')
|
||||||
|
parser.add_argument('-m', '--out-mtl', required=True, type=str, action='store', dest='out_mtl', metavar='mesh.mtl',
|
||||||
|
help='''The path to output MTL file''')
|
||||||
|
|
||||||
|
# parse arg
|
||||||
|
args = parser.parse_args()
|
||||||
|
# return value
|
||||||
|
return Cli(
|
||||||
|
Path(args.in_vpos),
|
||||||
|
Path(args.in_vnml),
|
||||||
|
Path(args.in_vuv),
|
||||||
|
Path(args.in_findices),
|
||||||
|
Path(args.out_obj),
|
||||||
|
Path(args.out_mtl)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# endregion
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# parse arguments
|
||||||
|
opts = parse()
|
||||||
|
|
||||||
|
vertex_count = evaluate_count(opts.in_vpos, 3 * 4) # 3 float(4 bytes)
|
||||||
|
print(f'Vertex Count Evaluated: {vertex_count}')
|
||||||
|
vpos = batched_tuple(read_f32s(opts.in_vpos, 3 * vertex_count), 3)
|
||||||
|
|
||||||
|
vnml = batched_tuple(read_f32s(opts.in_vnml, 3 * vertex_count), 3)
|
||||||
|
|
||||||
|
vuv = batched_tuple(read_f32s(opts.in_vuv, 2 * vertex_count), 2)
|
||||||
|
|
||||||
|
face_count = evaluate_count(opts.in_findices, 3 * 2) # 3 WORD(2 bytes)
|
||||||
|
print(f'Face Count Evaluated: {face_count}')
|
||||||
|
findices = batched_tuple(read_u16s(opts.in_findices, 3 * face_count), 3)
|
||||||
|
|
||||||
|
build_obj_file(opts.out_obj, vpos, vnml, vuv, findices)
|
||||||
|
print('Done')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
7
Assets/Tools/MeshConv/pyproject.toml
Normal file
7
Assets/Tools/MeshConv/pyproject.toml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[project]
|
||||||
|
name = "mesh-conv"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "Add your description here"
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.11"
|
||||||
|
dependencies = []
|
||||||
8
Assets/Tools/MeshConv/uv.lock
generated
Normal file
8
Assets/Tools/MeshConv/uv.lock
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
version = 1
|
||||||
|
revision = 2
|
||||||
|
requires-python = ">=3.11"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mesh-conv"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = { virtual = "." }
|
||||||
24
Assets/Tools/README.md
Normal file
24
Assets/Tools/README.md
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Tools
|
||||||
|
|
||||||
|
The developer need to know the loaded data whether is correct when testing LibCmo.
|
||||||
|
So we create this folder and you can use Unvirt and the tools located in this folder to test the correction of loaded data.
|
||||||
|
|
||||||
|
Unvirt can show the data of each CKObject, such as Texture, Mesh and etc.
|
||||||
|
For example, Unvirt can provide vertex's position, normal, UV, even the face's indices data for CKMesh.
|
||||||
|
You can use tools to broswer memory to get them, but you couldn't evaluate them how they shape a mesh.
|
||||||
|
This is the reason why this folder existed and in this README I will tell you how to debug the loaded data.
|
||||||
|
|
||||||
|
## Memory Inspector
|
||||||
|
|
||||||
|
I suggest you to use HxD to broswer memory, but if you have other softwares which you have been familiar with, use it freely.
|
||||||
|
|
||||||
|
## CKTexture Debugging
|
||||||
|
|
||||||
|
* Install [PixelViewer](https://github.com/carina-studio/PixelViewer) first.
|
||||||
|
* Change profile to `BGRA_8888` (actually is little-endian RGBA8888, but I think the developer of PixelViewer get confused).
|
||||||
|
* The image resolution can be gotten from Uvirt. Set it in PixelViewer.
|
||||||
|
* The image address also can be gotten from Unvirt. Save the image data from memory to local file and open it by PixelViewer.
|
||||||
|
|
||||||
|
## CKMesh Debugging
|
||||||
|
|
||||||
|
See [MeshConv README](./MeshConv/README.md)
|
||||||
@@ -42,10 +42,13 @@ _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 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 CheckCK3dEntity(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CK3dEntity*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_3DENTITY)
|
||||||
#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)
|
||||||
#define CheckCKMaterial(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CKMaterial*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_MATERIAL)
|
#define CheckCKMaterial(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CKMaterial*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_MATERIAL)
|
||||||
#define CheckCKTexture(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CKTexture*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_TEXTURE)
|
#define CheckCKTexture(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CKTexture*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_TEXTURE)
|
||||||
|
#define CheckCKLight(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CKLight*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_LIGHT)
|
||||||
|
#define CheckCKTargetLight(bmfile, objid) CheckGeneralObject<LibCmo::CK2::ObjImpls::CKTargetLight*>(bmfile, objid, LibCmo::CK2::CK_CLASSID::CKCID_TARGETLIGHT)
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
@@ -143,7 +146,7 @@ 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(LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS, texture_save_opt),
|
||||||
BMPARAM_IN(bool, use_compress),
|
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;
|
||||||
@@ -234,6 +237,21 @@ bool BMFile_CreateTexture(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK
|
|||||||
BMPARAM_OUT_ASSIGN(out_id, bmfile->CreateTexture());
|
BMPARAM_OUT_ASSIGN(out_id, bmfile->CreateTexture());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
bool BMFile_GetTargetLightCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count)) {
|
||||||
|
if (!CheckBMFile(bmfile)) return false;
|
||||||
|
BMPARAM_OUT_ASSIGN(out_count, bmfile->GetTargetLightCount());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool BMFile_GetTargetLight(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id)) {
|
||||||
|
if (!CheckBMFile(bmfile)) return false;
|
||||||
|
BMPARAM_OUT_ASSIGN(out_id, bmfile->GetTargetLight(idx));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool BMFile_CreateTargetLight(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id)) {
|
||||||
|
if (!CheckBMFile(bmfile)) return false;
|
||||||
|
BMPARAM_OUT_ASSIGN(out_id, bmfile->CreateTargetLight());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
@@ -841,34 +859,34 @@ bool BMMesh_SetMaterialSlot(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCm
|
|||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region CK3dObject
|
#pragma region CK3dEntity
|
||||||
|
|
||||||
bool BM3dObject_GetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxMatrix, out_mat)) {
|
bool BM3dEntity_GetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxMatrix, out_mat)) {
|
||||||
auto obj = CheckCK3dObject(bmfile, objid);
|
auto obj = CheckCK3dEntity(bmfile, objid);
|
||||||
if (obj == nullptr) return false;
|
if (obj == nullptr) return false;
|
||||||
|
|
||||||
BMPARAM_OUT_ASSIGN(out_mat, obj->GetWorldMatrix());
|
BMPARAM_OUT_ASSIGN(out_mat, obj->GetWorldMatrix());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BM3dObject_SetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxMatrix, mat)) {
|
bool BM3dEntity_SetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxMatrix, mat)) {
|
||||||
auto obj = CheckCK3dObject(bmfile, objid);
|
auto obj = CheckCK3dEntity(bmfile, objid);
|
||||||
if (obj == nullptr) return false;
|
if (obj == nullptr) return false;
|
||||||
|
|
||||||
obj->SetWorldMatrix(mat);
|
obj->SetWorldMatrix(mat);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BM3dObject_GetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_meshid)) {
|
bool BM3dEntity_GetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_meshid)) {
|
||||||
auto obj = CheckCK3dObject(bmfile, objid);
|
auto obj = CheckCK3dEntity(bmfile, objid);
|
||||||
if (obj == nullptr) return false;
|
if (obj == nullptr) return false;
|
||||||
|
|
||||||
BMPARAM_OUT_ASSIGN(out_meshid, SafeGetID(obj->GetCurrentMesh()));
|
BMPARAM_OUT_ASSIGN(out_meshid, SafeGetID(obj->GetCurrentMesh()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BM3dObject_SetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_ID, meshid)) {
|
bool BM3dEntity_SetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_ID, meshid)) {
|
||||||
auto obj = CheckCK3dObject(bmfile, objid);
|
auto obj = CheckCK3dEntity(bmfile, objid);
|
||||||
auto meshobj = CheckCKMesh(bmfile, meshid);
|
auto meshobj = CheckCKMesh(bmfile, meshid);
|
||||||
if (obj == nullptr /*|| meshobj == nullptr*/) return false; //allow nullptr assign
|
if (obj == nullptr /*|| meshobj == nullptr*/) return false; //allow nullptr assign
|
||||||
|
|
||||||
@@ -876,16 +894,16 @@ bool BM3dObject_SetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(Li
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BM3dObject_GetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_isVisible)) {
|
bool BM3dEntity_GetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_isVisible)) {
|
||||||
auto obj = CheckCK3dObject(bmfile, objid);
|
auto obj = CheckCK3dEntity(bmfile, objid);
|
||||||
if (obj == nullptr) return false;
|
if (obj == nullptr) return false;
|
||||||
|
|
||||||
BMPARAM_OUT_ASSIGN(out_isVisible, obj->IsVisible());
|
BMPARAM_OUT_ASSIGN(out_isVisible, obj->IsVisible());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BM3dObject_SetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, is_visible)) {
|
bool BM3dEntity_SetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, is_visible)) {
|
||||||
auto obj = CheckCK3dObject(bmfile, objid);
|
auto obj = CheckCK3dEntity(bmfile, objid);
|
||||||
if (obj == nullptr) return false;
|
if (obj == nullptr) return false;
|
||||||
|
|
||||||
obj->Show(is_visible ? LibCmo::CK2::CK_OBJECT_SHOWOPTION::CKSHOW : LibCmo::CK2::CK_OBJECT_SHOWOPTION::CKHIDE);
|
obj->Show(is_visible ? LibCmo::CK2::CK_OBJECT_SHOWOPTION::CKSHOW : LibCmo::CK2::CK_OBJECT_SHOWOPTION::CKHIDE);
|
||||||
@@ -894,3 +912,131 @@ bool BM3dObject_SetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(boo
|
|||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region CK3dObject
|
||||||
|
|
||||||
|
//nothing
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region CKLight
|
||||||
|
|
||||||
|
bool BMLight_GetType(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXLIGHT_TYPE, out_val)) {
|
||||||
|
auto obj = CheckCKLight(bmfile, objid);
|
||||||
|
if (obj == nullptr) return false;
|
||||||
|
BMPARAM_OUT_ASSIGN(out_val, obj->GetType());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool BMLight_SetType(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXLIGHT_TYPE, val)) {
|
||||||
|
auto obj = CheckCKLight(bmfile, objid);
|
||||||
|
if (obj == nullptr) return false;
|
||||||
|
obj->SetType(val);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMLight_GetColor(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxColor, out_val)) {
|
||||||
|
auto obj = CheckCKLight(bmfile, objid);
|
||||||
|
if (obj == nullptr) return false;
|
||||||
|
BMPARAM_OUT_ASSIGN(out_val, obj->GetColor());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool BMLight_SetColor(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxColor, col)) {
|
||||||
|
auto obj = CheckCKLight(bmfile, objid);
|
||||||
|
if (obj == nullptr) return false;
|
||||||
|
obj->SetColor(col);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMLight_GetConstantAttenuation(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKFLOAT, out_val)) {
|
||||||
|
auto obj = CheckCKLight(bmfile, objid);
|
||||||
|
if (obj == nullptr) return false;
|
||||||
|
BMPARAM_OUT_ASSIGN(out_val, obj->GetConstantAttenuation());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool BMLight_SetConstantAttenuation(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKFLOAT, val)) {
|
||||||
|
auto obj = CheckCKLight(bmfile, objid);
|
||||||
|
if (obj == nullptr) return false;
|
||||||
|
obj->SetConstantAttenuation(val);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool BMLight_GetLinearAttenuation(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKFLOAT, out_val)) {
|
||||||
|
auto obj = CheckCKLight(bmfile, objid);
|
||||||
|
if (obj == nullptr) return false;
|
||||||
|
BMPARAM_OUT_ASSIGN(out_val, obj->GetLinearAttenuation());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool BMLight_SetLinearAttenuation(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKFLOAT, val)) {
|
||||||
|
auto obj = CheckCKLight(bmfile, objid);
|
||||||
|
if (obj == nullptr) return false;
|
||||||
|
obj->SetLinearAttenuation(val);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool BMLight_GetQuadraticAttenuation(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKFLOAT, out_val)) {
|
||||||
|
auto obj = CheckCKLight(bmfile, objid);
|
||||||
|
if (obj == nullptr) return false;
|
||||||
|
BMPARAM_OUT_ASSIGN(out_val, obj->GetQuadraticAttenuation());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool BMLight_SetQuadraticAttenuation(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKFLOAT, val)) {
|
||||||
|
auto obj = CheckCKLight(bmfile, objid);
|
||||||
|
if (obj == nullptr) return false;
|
||||||
|
obj->SetQuadraticAttenuation(val);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMLight_GetRange(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKFLOAT, out_val)) {
|
||||||
|
auto obj = CheckCKLight(bmfile, objid);
|
||||||
|
if (obj == nullptr) return false;
|
||||||
|
BMPARAM_OUT_ASSIGN(out_val, obj->GetRange());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool BMLight_SetRange(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKFLOAT, val)) {
|
||||||
|
auto obj = CheckCKLight(bmfile, objid);
|
||||||
|
if (obj == nullptr) return false;
|
||||||
|
obj->SetRange(val);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMLight_GetHotSpot(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKFLOAT, out_val)) {
|
||||||
|
auto obj = CheckCKLight(bmfile, objid);
|
||||||
|
if (obj == nullptr) return false;
|
||||||
|
BMPARAM_OUT_ASSIGN(out_val, obj->GetHotSpot());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool BMLight_SetHotSpot(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKFLOAT, val)) {
|
||||||
|
auto obj = CheckCKLight(bmfile, objid);
|
||||||
|
if (obj == nullptr) return false;
|
||||||
|
obj->SetHotSpot(val);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool BMLight_GetFalloff(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKFLOAT, out_val)) {
|
||||||
|
auto obj = CheckCKLight(bmfile, objid);
|
||||||
|
if (obj == nullptr) return false;
|
||||||
|
BMPARAM_OUT_ASSIGN(out_val, obj->GetFalloff());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool BMLight_SetFalloff(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKFLOAT, val)) {
|
||||||
|
auto obj = CheckCKLight(bmfile, objid);
|
||||||
|
if (obj == nullptr) return false;
|
||||||
|
obj->SetFalloff(val);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool BMLight_GetFalloffShape(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKFLOAT, out_val)) {
|
||||||
|
auto obj = CheckCKLight(bmfile, objid);
|
||||||
|
if (obj == nullptr) return false;
|
||||||
|
BMPARAM_OUT_ASSIGN(out_val, obj->GetFalloffShape());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bool BMLight_SetFalloffShape(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKFLOAT, val)) {
|
||||||
|
auto obj = CheckCKLight(bmfile, objid);
|
||||||
|
if (obj == nullptr) return false;
|
||||||
|
obj->SetFalloffShape(val);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region CKTargetLight
|
||||||
|
|
||||||
|
// nothing
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
@@ -51,7 +51,7 @@ Each CK_ID also should be used with its corresponding BMFile*, because each BMfi
|
|||||||
// Do nothing and hope for the best?
|
// Do nothing and hope for the best?
|
||||||
#define BMAP_RAW_EXPORT
|
#define BMAP_RAW_EXPORT
|
||||||
#define BMAP_RAW_IMPORT
|
#define BMAP_RAW_IMPORT
|
||||||
#pragma error "Unknown dynamic link import/export semantics."
|
#error "Unknown dynamic link import/export semantics."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Choosee import or export command according to special macro.
|
// Choosee import or export command according to special macro.
|
||||||
@@ -81,7 +81,9 @@ Each CK_ID also should be used with its corresponding BMFile*, because each BMfi
|
|||||||
/** Declare an input parameter */
|
/** Declare an input parameter */
|
||||||
#define BMPARAM_IN(_t, _name) _t _name
|
#define BMPARAM_IN(_t, _name) _t _name
|
||||||
/**
|
/**
|
||||||
|
@brief
|
||||||
Declare an output parameter.
|
Declare an output parameter.
|
||||||
|
@details
|
||||||
A pointer will be added automatically for caller receive it.
|
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.
|
See BMPARAM_OUT_ASSIGN and BMPARAM_OUT_VAL to know how to use output param in function body.
|
||||||
@remark
|
@remark
|
||||||
@@ -91,8 +93,8 @@ bool some_interface_func(BMPARAM_OUT(Type_t, param_name)) {
|
|||||||
BMPARAM_OUT_ASSIGN(param_name, some_value); // assign to out param.
|
BMPARAM_OUT_ASSIGN(param_name, some_value); // assign to out param.
|
||||||
return BMPARAM_OUT_VAL(param_name) != other_value; // use out param value.
|
return BMPARAM_OUT_VAL(param_name) != other_value; // use out param value.
|
||||||
}
|
}
|
||||||
@see BMPARAM_OUT_ASSIGN, BMPARAM_OUT_VAL
|
|
||||||
```
|
```
|
||||||
|
@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. */
|
/** Assign value for out param in function body. */
|
||||||
@@ -154,6 +156,9 @@ BMAP_EXPORT bool BMFile_CreateMaterial(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(Li
|
|||||||
BMAP_EXPORT bool BMFile_GetTextureCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
BMAP_EXPORT bool BMFile_GetTextureCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
||||||
BMAP_EXPORT bool BMFile_GetTexture(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
BMAP_EXPORT bool BMFile_GetTexture(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
||||||
BMAP_EXPORT bool BMFile_CreateTexture(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
BMAP_EXPORT bool BMFile_CreateTexture(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
||||||
|
BMAP_EXPORT bool BMFile_GetTargetLightCount(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CKDWORD, out_count));
|
||||||
|
BMAP_EXPORT bool BMFile_GetTargetLight(BMPARAM_FILE_DECL(bmfile), BMPARAM_IN(LibCmo::CKDWORD, idx), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
||||||
|
BMAP_EXPORT bool BMFile_CreateTargetLight(BMPARAM_FILE_DECL(bmfile), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_id));
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
@@ -285,13 +290,52 @@ BMAP_EXPORT bool BMMesh_SetMaterialSlot(BMPARAM_OBJECT_DECL(bmfile, objid), BMPA
|
|||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region CK3dObject
|
#pragma region CK3dEntity
|
||||||
|
|
||||||
BMAP_EXPORT bool BM3dObject_GetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxMatrix, out_mat));
|
BMAP_EXPORT bool BM3dEntity_GetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxMatrix, out_mat));
|
||||||
BMAP_EXPORT bool BM3dObject_SetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxMatrix, mat));
|
BMAP_EXPORT bool BM3dEntity_SetWorldMatrix(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxMatrix, mat));
|
||||||
BMAP_EXPORT bool BM3dObject_GetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_meshid));
|
BMAP_EXPORT bool BM3dEntity_GetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CK2::CK_ID, out_meshid));
|
||||||
BMAP_EXPORT bool BM3dObject_SetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_ID, meshid));
|
BMAP_EXPORT bool BM3dEntity_SetCurrentMesh(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CK2::CK_ID, meshid));
|
||||||
BMAP_EXPORT bool BM3dObject_GetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_isVisible));
|
BMAP_EXPORT bool BM3dEntity_GetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(bool, out_isVisible));
|
||||||
BMAP_EXPORT bool BM3dObject_SetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, is_visible));
|
BMAP_EXPORT bool BM3dEntity_SetVisibility(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(bool, is_visible));
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region CK3dObject
|
||||||
|
|
||||||
|
// nothing
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region CKLight
|
||||||
|
|
||||||
|
BMAP_EXPORT bool BMLight_GetType(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VXLIGHT_TYPE, out_val));
|
||||||
|
BMAP_EXPORT bool BMLight_SetType(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VXLIGHT_TYPE, val));
|
||||||
|
|
||||||
|
BMAP_EXPORT bool BMLight_GetColor(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::VxMath::VxColor, out_val));
|
||||||
|
BMAP_EXPORT bool BMLight_SetColor(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::VxMath::VxColor, col));
|
||||||
|
|
||||||
|
BMAP_EXPORT bool BMLight_GetConstantAttenuation(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKFLOAT, out_val));
|
||||||
|
BMAP_EXPORT bool BMLight_SetConstantAttenuation(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKFLOAT, val));
|
||||||
|
BMAP_EXPORT bool BMLight_GetLinearAttenuation(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKFLOAT, out_val));
|
||||||
|
BMAP_EXPORT bool BMLight_SetLinearAttenuation(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKFLOAT, val));
|
||||||
|
BMAP_EXPORT bool BMLight_GetQuadraticAttenuation(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKFLOAT, out_val));
|
||||||
|
BMAP_EXPORT bool BMLight_SetQuadraticAttenuation(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKFLOAT, val));
|
||||||
|
|
||||||
|
BMAP_EXPORT bool BMLight_GetRange(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKFLOAT, out_val));
|
||||||
|
BMAP_EXPORT bool BMLight_SetRange(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKFLOAT, val));
|
||||||
|
|
||||||
|
BMAP_EXPORT bool BMLight_GetHotSpot(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKFLOAT, out_val));
|
||||||
|
BMAP_EXPORT bool BMLight_SetHotSpot(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKFLOAT, val));
|
||||||
|
BMAP_EXPORT bool BMLight_GetFalloff(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKFLOAT, out_val));
|
||||||
|
BMAP_EXPORT bool BMLight_SetFalloff(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKFLOAT, val));
|
||||||
|
BMAP_EXPORT bool BMLight_GetFalloffShape(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_OUT(LibCmo::CKFLOAT, out_val));
|
||||||
|
BMAP_EXPORT bool BMLight_SetFalloffShape(BMPARAM_OBJECT_DECL(bmfile, objid), BMPARAM_IN(LibCmo::CKFLOAT, val));
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region CKTargetLight
|
||||||
|
|
||||||
|
// nothing
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
@@ -2,6 +2,247 @@
|
|||||||
|
|
||||||
namespace BMap {
|
namespace BMap {
|
||||||
|
|
||||||
|
#pragma region BMfile
|
||||||
|
|
||||||
|
BMFile::BMFile(LibCmo::CKSTRING temp_folder, LibCmo::CKSTRING texture_folder, NakedOutputCallback raw_callback, LibCmo::CKDWORD encoding_count, LibCmo::CKSTRING* encodings, bool is_loader) :
|
||||||
|
m_IsInitError(false), m_IsLoader(is_loader), m_HasLoaded(false), m_HasSaved(false), m_Context(nullptr) {
|
||||||
|
m_Context = new LibCmo::CK2::CKContext();
|
||||||
|
// binding callback with lambda wrapper.
|
||||||
|
// check whether callback is nullptr.
|
||||||
|
m_IsInitError = m_IsInitError || (raw_callback == nullptr);
|
||||||
|
if (raw_callback != nullptr) {
|
||||||
|
m_Context->SetOutputCallback([raw_callback](LibCmo::CKSTRING strl) -> void {
|
||||||
|
raw_callback(strl);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// set temp folder and texture folder
|
||||||
|
auto pm = m_Context->GetPathManager();
|
||||||
|
m_IsInitError = m_IsInitError || !pm->AddPath(texture_folder);
|
||||||
|
m_IsInitError = m_IsInitError || !pm->SetTempFolder(temp_folder);
|
||||||
|
|
||||||
|
// set encoding
|
||||||
|
LibCmo::XContainer::XArray<LibCmo::XContainer::XString> cache;
|
||||||
|
for (LibCmo::CKDWORD i = 0; i < encoding_count; ++i) {
|
||||||
|
if (encodings[i] != nullptr)
|
||||||
|
cache.emplace_back(encodings[i]);
|
||||||
|
}
|
||||||
|
m_Context->SetEncoding(cache);
|
||||||
|
m_IsInitError = m_IsInitError || !m_Context->IsValidEncoding();
|
||||||
|
|
||||||
|
// set default texture save mode is external
|
||||||
|
m_Context->SetGlobalImagesSaveOptions(LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS::CKTEXTURE_EXTERNAL);
|
||||||
|
// set default file write mode is whole compressed
|
||||||
|
m_Context->SetFileWriteMode(LibCmo::CK2::CK_FILE_WRITEMODE::CKFILE_WHOLECOMPRESSED);
|
||||||
|
}
|
||||||
|
|
||||||
|
BMFile::~BMFile() {
|
||||||
|
delete m_Context;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma region Safe Check Function
|
||||||
|
|
||||||
|
bool BMFile::IsInitError() {
|
||||||
|
return m_IsInitError;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool BMFile::CanExecLoad() {
|
||||||
|
// no error, is loader, no prev load
|
||||||
|
return (!m_IsInitError && m_IsLoader && !m_HasLoaded);
|
||||||
|
}
|
||||||
|
bool BMFile::CanExecSave() {
|
||||||
|
// no error, is saver, no prev save
|
||||||
|
return (!m_IsInitError && !m_IsLoader && !m_HasSaved);
|
||||||
|
}
|
||||||
|
bool BMFile::CanExecLoaderVisitor() {
|
||||||
|
// no error, is loader, has loaded
|
||||||
|
return (!m_IsInitError && m_IsLoader && m_HasLoaded);
|
||||||
|
}
|
||||||
|
bool BMFile::CanExecSaverVisitor() {
|
||||||
|
// no error, is saver, not saveed yet
|
||||||
|
// same as CanExecSave
|
||||||
|
return (!m_IsInitError && !m_IsLoader && !m_HasSaved);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Help Function
|
||||||
|
|
||||||
|
bool BMFile::Load(LibCmo::CKSTRING filename) {
|
||||||
|
if (!CanExecLoad()) return false;
|
||||||
|
|
||||||
|
// create temp ckfile and load
|
||||||
|
LibCmo::CK2::CKFileReader reader(m_Context);
|
||||||
|
LibCmo::CK2::CKERROR err = reader.DeepLoad(filename);
|
||||||
|
|
||||||
|
// detect error
|
||||||
|
if (err != LibCmo::CK2::CKERROR::CKERR_OK) {
|
||||||
|
// failed. clear document and return false
|
||||||
|
m_Context->ClearAll();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// sync data list to our list
|
||||||
|
m_ObjGroups.clear();
|
||||||
|
m_Obj3dObjects.clear();
|
||||||
|
m_ObjMeshes.clear();
|
||||||
|
m_ObjMaterials.clear();
|
||||||
|
m_ObjTextures.clear();
|
||||||
|
m_ObjTargetLights.clear();
|
||||||
|
for (const auto& fileobj : reader.GetFileObjects()) {
|
||||||
|
if (fileobj.ObjPtr == nullptr) continue;
|
||||||
|
|
||||||
|
switch (fileobj.ObjectCid) {
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_GROUP:
|
||||||
|
m_ObjGroups.emplace_back(fileobj.CreatedObjectId);
|
||||||
|
break;
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_3DOBJECT:
|
||||||
|
m_Obj3dObjects.emplace_back(fileobj.CreatedObjectId);
|
||||||
|
break;
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_MESH:
|
||||||
|
m_ObjMeshes.emplace_back(fileobj.CreatedObjectId);
|
||||||
|
break;
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_MATERIAL:
|
||||||
|
m_ObjMaterials.emplace_back(fileobj.CreatedObjectId);
|
||||||
|
break;
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_TEXTURE:
|
||||||
|
m_ObjTextures.emplace_back(fileobj.CreatedObjectId);
|
||||||
|
break;
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_TARGETLIGHT:
|
||||||
|
m_ObjTargetLights.emplace_back(fileobj.CreatedObjectId);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break; // skip unknow objects
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_HasLoaded = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
// create temp writer
|
||||||
|
LibCmo::CK2::CKFileWriter writer(m_Context);
|
||||||
|
|
||||||
|
// fill object data
|
||||||
|
for (const auto& id : m_ObjGroups) {
|
||||||
|
writer.AddSavedObject(m_Context->GetObject(id));
|
||||||
|
}
|
||||||
|
for (const auto& id : m_Obj3dObjects) {
|
||||||
|
writer.AddSavedObject(m_Context->GetObject(id));
|
||||||
|
}
|
||||||
|
for (const auto& id : m_ObjMeshes) {
|
||||||
|
writer.AddSavedObject(m_Context->GetObject(id));
|
||||||
|
}
|
||||||
|
for (const auto& id : m_ObjMaterials) {
|
||||||
|
writer.AddSavedObject(m_Context->GetObject(id));
|
||||||
|
}
|
||||||
|
for (const auto& id : m_ObjTextures) {
|
||||||
|
writer.AddSavedObject(m_Context->GetObject(id));
|
||||||
|
}
|
||||||
|
for (const auto& id :m_ObjTargetLights) {
|
||||||
|
writer.AddSavedObject(m_Context->GetObject(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
// set global texture save mode
|
||||||
|
m_Context->SetGlobalImagesSaveOptions(texture_save_opt);
|
||||||
|
// set 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
|
||||||
|
LibCmo::CK2::CKERROR err = writer.Save(filename);
|
||||||
|
|
||||||
|
// return with error detect.
|
||||||
|
m_HasSaved = true;
|
||||||
|
return err == LibCmo::CK2::CKERROR::CKERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
LibCmo::CK2::ObjImpls::CKObject* BMFile::GetObjectPtr(LibCmo::CK2::CK_ID objid) {
|
||||||
|
// we fetch object from CKContext to get better performance
|
||||||
|
LibCmo::CK2::ObjImpls::CKObject* obj = m_Context->GetObject(objid);
|
||||||
|
|
||||||
|
// however, we can not directly return the pointer fetched fron CKContext.
|
||||||
|
// BMFile only provide limited type visiting, we must make sure it provided ID also is existed in out stored list.
|
||||||
|
// so we check its type here. if type is not matched, we reset it to nullptr.
|
||||||
|
if (obj != nullptr) {
|
||||||
|
switch (obj->GetClassID()) {
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_GROUP:
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_3DOBJECT:
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_MESH:
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_MATERIAL:
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_TEXTURE:
|
||||||
|
case LibCmo::CK2::CK_CLASSID::CKCID_TARGETLIGHT:
|
||||||
|
break; // okey. do nothing
|
||||||
|
default:
|
||||||
|
// this object should not be exposed to outside, reset it to nullptr
|
||||||
|
obj = nullptr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// return result
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma region Visitor
|
||||||
|
|
||||||
|
LibCmo::CKDWORD BMFile::CommonGetObjectCount(std::vector<LibCmo::CK2::CK_ID>& container) {
|
||||||
|
// only available in loader
|
||||||
|
if (!CanExecLoaderVisitor()) return 0;
|
||||||
|
return static_cast<LibCmo::CKDWORD>(container.size());
|
||||||
|
}
|
||||||
|
LibCmo::CK2::CK_ID BMFile::CommonGetObject(std::vector<LibCmo::CK2::CK_ID>& container, LibCmo::CKDWORD idx) {
|
||||||
|
// only available in loader
|
||||||
|
if (!CanExecLoaderVisitor()) return 0;
|
||||||
|
return container[idx];
|
||||||
|
}
|
||||||
|
LibCmo::CK2::CK_ID BMFile::CommonCreateObject(std::vector<LibCmo::CK2::CK_ID>& container, LibCmo::CK2::CK_CLASSID cid) {
|
||||||
|
// only available in saver
|
||||||
|
if (!CanExecSaverVisitor()) return 0;
|
||||||
|
|
||||||
|
// try create object and get its pointer
|
||||||
|
LibCmo::CK2::ObjImpls::CKObject* obj = m_Context->CreateObject(cid, nullptr);
|
||||||
|
// check creation validation
|
||||||
|
if (obj == nullptr) return 0;
|
||||||
|
|
||||||
|
// if success, write its id and emplace its id into list
|
||||||
|
LibCmo::CK2::CK_ID objid = obj->GetID();
|
||||||
|
container.emplace_back(objid);
|
||||||
|
return objid;
|
||||||
|
}
|
||||||
|
|
||||||
|
LibCmo::CKDWORD BMFile::GetGroupCount() { return CommonGetObjectCount(m_ObjGroups); }
|
||||||
|
LibCmo::CK2::CK_ID BMFile::GetGroup(LibCmo::CKDWORD idx) { return CommonGetObject(m_ObjGroups, idx); }
|
||||||
|
LibCmo::CK2::CK_ID BMFile::CreateGroup() { return CommonCreateObject(m_ObjGroups, LibCmo::CK2::CK_CLASSID::CKCID_GROUP); }
|
||||||
|
LibCmo::CKDWORD BMFile::Get3dObjectCount() { return CommonGetObjectCount(m_Obj3dObjects); }
|
||||||
|
LibCmo::CK2::CK_ID BMFile::Get3dObject(LibCmo::CKDWORD idx) { return CommonGetObject(m_Obj3dObjects, idx); }
|
||||||
|
LibCmo::CK2::CK_ID BMFile::Create3dObject() { return CommonCreateObject(m_Obj3dObjects, LibCmo::CK2::CK_CLASSID::CKCID_3DOBJECT); }
|
||||||
|
LibCmo::CKDWORD BMFile::GetMeshCount() { return CommonGetObjectCount(m_ObjMeshes); }
|
||||||
|
LibCmo::CK2::CK_ID BMFile::GetMesh(LibCmo::CKDWORD idx) { return CommonGetObject(m_ObjMeshes, idx); }
|
||||||
|
LibCmo::CK2::CK_ID BMFile::CreateMesh() { return CommonCreateObject(m_ObjMeshes, LibCmo::CK2::CK_CLASSID::CKCID_MESH); }
|
||||||
|
LibCmo::CKDWORD BMFile::GetMaterialCount() { return CommonGetObjectCount(m_ObjMaterials); }
|
||||||
|
LibCmo::CK2::CK_ID BMFile::GetMaterial(LibCmo::CKDWORD idx) { return CommonGetObject(m_ObjMaterials, idx); }
|
||||||
|
LibCmo::CK2::CK_ID BMFile::CreateMaterial() { return CommonCreateObject(m_ObjMaterials, LibCmo::CK2::CK_CLASSID::CKCID_MATERIAL); }
|
||||||
|
LibCmo::CKDWORD BMFile::GetTextureCount() { return CommonGetObjectCount(m_ObjTextures); }
|
||||||
|
LibCmo::CK2::CK_ID BMFile::GetTexture(LibCmo::CKDWORD idx) { return CommonGetObject(m_ObjTextures, idx); }
|
||||||
|
LibCmo::CK2::CK_ID BMFile::CreateTexture() { return CommonCreateObject(m_ObjTextures, LibCmo::CK2::CK_CLASSID::CKCID_TEXTURE); }
|
||||||
|
LibCmo::CKDWORD BMFile::GetTargetLightCount() { return CommonGetObjectCount(m_ObjTargetLights); }
|
||||||
|
LibCmo::CK2::CK_ID BMFile::GetTargetLight(LibCmo::CKDWORD idx) { return CommonGetObject(m_ObjTargetLights, idx); }
|
||||||
|
LibCmo::CK2::CK_ID BMFile::CreateTargetLight() { return CommonCreateObject(m_ObjTargetLights, LibCmo::CK2::CK_CLASSID::CKCID_TARGETLIGHT); }
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region BMMeshTransition
|
#pragma region BMMeshTransition
|
||||||
|
|
||||||
BMMeshTransition::TransitionVertex::TransitionVertex(
|
BMMeshTransition::TransitionVertex::TransitionVertex(
|
||||||
@@ -229,149 +470,4 @@ namespace BMap {
|
|||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#pragma region BMfile
|
|
||||||
|
|
||||||
BMFile::BMFile(LibCmo::CKSTRING temp_folder, LibCmo::CKSTRING texture_folder, NakedOutputCallback raw_callback, LibCmo::CKDWORD encoding_count, LibCmo::CKSTRING* encodings, bool is_loader) :
|
|
||||||
m_IsInitError(false), m_IsLoader(is_loader), m_HasLoaded(false), m_HasSaved(false), m_Context(nullptr) {
|
|
||||||
m_Context = new LibCmo::CK2::CKContext();
|
|
||||||
// binding callback with lambda wrapper.
|
|
||||||
// check whether callback is nullptr.
|
|
||||||
m_IsInitError = m_IsInitError || (raw_callback == nullptr);
|
|
||||||
if (raw_callback != nullptr) {
|
|
||||||
m_Context->SetOutputCallback([raw_callback](LibCmo::CKSTRING strl) -> void {
|
|
||||||
raw_callback(strl);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// set temp folder and texture folder
|
|
||||||
auto pm = m_Context->GetPathManager();
|
|
||||||
m_IsInitError = m_IsInitError || !pm->AddPath(texture_folder);
|
|
||||||
m_IsInitError = m_IsInitError || !pm->SetTempFolder(temp_folder);
|
|
||||||
|
|
||||||
// set encoding
|
|
||||||
LibCmo::XContainer::XArray<LibCmo::XContainer::XString> cache;
|
|
||||||
for (LibCmo::CKDWORD i = 0; i < encoding_count; ++i) {
|
|
||||||
if (encodings[i] != nullptr)
|
|
||||||
cache.emplace_back(encodings[i]);
|
|
||||||
}
|
|
||||||
m_Context->SetEncoding(cache);
|
|
||||||
m_IsInitError = m_IsInitError || !m_Context->IsValidEncoding();
|
|
||||||
|
|
||||||
// set default texture save mode is external
|
|
||||||
m_Context->SetGlobalImagesSaveOptions(LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS::CKTEXTURE_EXTERNAL);
|
|
||||||
// set default file write mode is whole compressed
|
|
||||||
m_Context->SetFileWriteMode(LibCmo::CK2::CK_FILE_WRITEMODE::CKFILE_WHOLECOMPRESSED);
|
|
||||||
}
|
|
||||||
|
|
||||||
BMFile::~BMFile() {
|
|
||||||
delete m_Context;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BMFile::Load(LibCmo::CKSTRING filename) {
|
|
||||||
if (!CanExecLoad()) return false;
|
|
||||||
|
|
||||||
// create temp ckfile and load
|
|
||||||
LibCmo::CK2::CKFileReader reader(m_Context);
|
|
||||||
LibCmo::CK2::CKERROR err = reader.DeepLoad(filename);
|
|
||||||
|
|
||||||
// detect error
|
|
||||||
if (err != LibCmo::CK2::CKERROR::CKERR_OK) {
|
|
||||||
// failed. clear document and return false
|
|
||||||
m_Context->ClearAll();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// sync data list to our list
|
|
||||||
m_ObjGroups.clear();
|
|
||||||
m_Obj3dObjects.clear();
|
|
||||||
m_ObjMeshs.clear();
|
|
||||||
m_ObjMaterials.clear();
|
|
||||||
m_ObjTextures.clear();
|
|
||||||
for (const auto& fileobj : reader.GetFileObjects()) {
|
|
||||||
if (fileobj.ObjPtr == nullptr) continue;
|
|
||||||
|
|
||||||
switch (fileobj.ObjectCid) {
|
|
||||||
case LibCmo::CK2::CK_CLASSID::CKCID_GROUP:
|
|
||||||
m_ObjGroups.emplace_back(fileobj.CreatedObjectId);
|
|
||||||
break;
|
|
||||||
case LibCmo::CK2::CK_CLASSID::CKCID_3DOBJECT:
|
|
||||||
m_Obj3dObjects.emplace_back(fileobj.CreatedObjectId);
|
|
||||||
break;
|
|
||||||
case LibCmo::CK2::CK_CLASSID::CKCID_MESH:
|
|
||||||
m_ObjMeshs.emplace_back(fileobj.CreatedObjectId);
|
|
||||||
break;
|
|
||||||
case LibCmo::CK2::CK_CLASSID::CKCID_MATERIAL:
|
|
||||||
m_ObjMaterials.emplace_back(fileobj.CreatedObjectId);
|
|
||||||
break;
|
|
||||||
case LibCmo::CK2::CK_CLASSID::CKCID_TEXTURE:
|
|
||||||
m_ObjTextures.emplace_back(fileobj.CreatedObjectId);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break; // skip unknow objects
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_HasLoaded = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
// create temp writer
|
|
||||||
LibCmo::CK2::CKFileWriter writer(m_Context);
|
|
||||||
|
|
||||||
// fill object data
|
|
||||||
for (const auto& id : m_ObjGroups) {
|
|
||||||
writer.AddSavedObject(m_Context->GetObject(id));
|
|
||||||
}
|
|
||||||
for (const auto& id : m_Obj3dObjects) {
|
|
||||||
writer.AddSavedObject(m_Context->GetObject(id));
|
|
||||||
}
|
|
||||||
for (const auto& id : m_ObjMeshs) {
|
|
||||||
writer.AddSavedObject(m_Context->GetObject(id));
|
|
||||||
}
|
|
||||||
for (const auto& id : m_ObjMaterials) {
|
|
||||||
writer.AddSavedObject(m_Context->GetObject(id));
|
|
||||||
}
|
|
||||||
for (const auto& id : m_ObjTextures) {
|
|
||||||
writer.AddSavedObject(m_Context->GetObject(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
// set global texture save mode
|
|
||||||
m_Context->SetGlobalImagesSaveOptions(texture_save_opt);
|
|
||||||
// set 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
|
|
||||||
LibCmo::CK2::CKERROR err = writer.Save(filename);
|
|
||||||
|
|
||||||
// return with error detect.
|
|
||||||
m_HasSaved = true;
|
|
||||||
return err == LibCmo::CK2::CKERROR::CKERR_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
LibCmo::CKDWORD BMFile::GetGroupCount() { return CommonGetObjectCount(m_ObjGroups); }
|
|
||||||
LibCmo::CK2::CK_ID BMFile::GetGroup(LibCmo::CKDWORD idx) { return CommonGetObject(m_ObjGroups, idx); }
|
|
||||||
LibCmo::CK2::CK_ID BMFile::CreateGroup() { return CommonCreateObject(m_ObjGroups, LibCmo::CK2::CK_CLASSID::CKCID_GROUP); }
|
|
||||||
LibCmo::CKDWORD BMFile::Get3dObjectCount() { return CommonGetObjectCount(m_Obj3dObjects); }
|
|
||||||
LibCmo::CK2::CK_ID BMFile::Get3dObject(LibCmo::CKDWORD idx) { return CommonGetObject(m_Obj3dObjects, idx); }
|
|
||||||
LibCmo::CK2::CK_ID BMFile::Create3dObject() { return CommonCreateObject(m_Obj3dObjects, LibCmo::CK2::CK_CLASSID::CKCID_3DOBJECT); }
|
|
||||||
LibCmo::CKDWORD BMFile::GetMeshCount() { return CommonGetObjectCount(m_ObjMeshs); }
|
|
||||||
LibCmo::CK2::CK_ID BMFile::GetMesh(LibCmo::CKDWORD idx) { return CommonGetObject(m_ObjMeshs, idx); }
|
|
||||||
LibCmo::CK2::CK_ID BMFile::CreateMesh() { return CommonCreateObject(m_ObjMeshs, LibCmo::CK2::CK_CLASSID::CKCID_MESH); }
|
|
||||||
LibCmo::CKDWORD BMFile::GetMaterialCount() { return CommonGetObjectCount(m_ObjMaterials); }
|
|
||||||
LibCmo::CK2::CK_ID BMFile::GetMaterial(LibCmo::CKDWORD idx) { return CommonGetObject(m_ObjMaterials, idx); }
|
|
||||||
LibCmo::CK2::CK_ID BMFile::CreateMaterial() { return CommonCreateObject(m_ObjMaterials, LibCmo::CK2::CK_CLASSID::CKCID_MATERIAL); }
|
|
||||||
LibCmo::CKDWORD BMFile::GetTextureCount() { return CommonGetObjectCount(m_ObjTextures); }
|
|
||||||
LibCmo::CK2::CK_ID BMFile::GetTexture(LibCmo::CKDWORD idx) { return CommonGetObject(m_ObjTextures, idx); }
|
|
||||||
LibCmo::CK2::CK_ID BMFile::CreateTexture() { return CommonCreateObject(m_ObjTextures, LibCmo::CK2::CK_CLASSID::CKCID_TEXTURE); }
|
|
||||||
|
|
||||||
#pragma endregion
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -16,93 +16,95 @@ namespace BMap {
|
|||||||
~BMFile();
|
~BMFile();
|
||||||
YYCC_DEL_CLS_COPY_MOVE(BMFile);
|
YYCC_DEL_CLS_COPY_MOVE(BMFile);
|
||||||
|
|
||||||
// ===== safe visit functions =====
|
// ===== Safe Check Function =====
|
||||||
|
|
||||||
/**
|
/*
|
||||||
Safe Visit Function will make sure this class is visited with safe mode.
|
Safe Check Function will make sure this class is visited in safe mode.
|
||||||
These function will block all other functions if this class init failed.
|
Some of them are exposed to outside to report current status of this class, for example, whether there is a issue when initialize this class.
|
||||||
Or, block any more operations if this class has loaded or saved once. In this time you only can free this class
|
And some of them are used by internal functions to make sure there is a safe environment to execute corresponding functions.
|
||||||
|
For example, #Load function will use #CanExecLoad to detect whether it can execute loading process.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool IsInitError() {
|
/**
|
||||||
return m_IsInitError;
|
* @brief Check whether there is an error when initializing this class.
|
||||||
}
|
* @details
|
||||||
|
* This class is exposed for outside code to check.
|
||||||
private:
|
* Internal code should use one of following 4 private check functions to check environment.
|
||||||
bool CanExecLoad() {
|
* @return True if there is an error when initializing this class.
|
||||||
// no error, is loader, no prev load
|
*/
|
||||||
return (!m_IsInitError && m_IsLoader && !m_HasLoaded);
|
bool IsInitError();
|
||||||
}
|
|
||||||
bool CanExecSave() {
|
|
||||||
// no error, is saver, no prev save
|
|
||||||
return (!m_IsInitError && !m_IsLoader && !m_HasSaved);
|
|
||||||
}
|
|
||||||
bool CanExecLoaderVisitor() {
|
|
||||||
// no error, is loader, has loaded
|
|
||||||
return (!m_IsInitError && m_IsLoader && m_HasLoaded);
|
|
||||||
}
|
|
||||||
bool CanExecSaverVisitor() {
|
|
||||||
// no error, is saver, not saveed yet
|
|
||||||
// same as CanExecSave
|
|
||||||
return (!m_IsInitError && !m_IsLoader && !m_HasSaved);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief True if an error occurs when initializing this class.
|
* @brief Check whether it's okey to execute #Load function.
|
||||||
|
* @return True if it is okey.
|
||||||
*/
|
*/
|
||||||
bool m_IsInitError;
|
bool CanExecLoad();
|
||||||
/**
|
/**
|
||||||
* @brief True if this class is a reader.
|
* @brief Check whether it's okey to execute #Save function.
|
||||||
|
* @return True if it is okey.
|
||||||
*/
|
*/
|
||||||
bool m_IsLoader;
|
bool CanExecSave();
|
||||||
/**
|
/**
|
||||||
* @brief True if this class has read. Only valid when this class is reader.
|
* @brief Check whether it's okey to execute Loader-related function.
|
||||||
|
* @details
|
||||||
|
* Due to implementation, saving file and loading file are use the same class, BMFile to represent.
|
||||||
|
* So obviously you can visit loader-related function in a saver.
|
||||||
|
* This operation is illegal. So we need block these operation.
|
||||||
|
* This is what this function does. Provide the condition which raise blocking.
|
||||||
|
* @return True if it is okey.
|
||||||
*/
|
*/
|
||||||
bool m_HasLoaded;
|
bool CanExecLoaderVisitor();
|
||||||
/**
|
/**
|
||||||
* @brief True if this class has written. Only valid when this class is writer.
|
* @brief Check whether it's okey to execute Saver-related function.
|
||||||
|
* @return True if it is okey.
|
||||||
|
* @see CanExecLoaderVisitor
|
||||||
*/
|
*/
|
||||||
bool m_HasSaved;
|
bool CanExecSaverVisitor();
|
||||||
|
|
||||||
// ===== help functions =====
|
private:
|
||||||
|
bool m_IsInitError; /**< True if an error occurs when initializing this class. */
|
||||||
|
bool m_IsLoader; /**< True if this class is a reader. */
|
||||||
|
bool m_HasLoaded; /**< True if this class has read. It's undefined behavior when visiting this variable if this class is not reader. */
|
||||||
|
bool m_HasSaved; /**< True if this class has written. It's undefined behavior when visiting this variable if this class is not writer. */
|
||||||
|
|
||||||
|
// ===== Help Function =====
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* @brief Load document to this class.
|
||||||
|
* @param[in] filename The path to file.
|
||||||
|
* @return True if no error, otherwise false.
|
||||||
|
*/
|
||||||
bool Load(LibCmo::CKSTRING filename);
|
bool Load(LibCmo::CKSTRING filename);
|
||||||
|
/**
|
||||||
|
* @brief Save current class into document.
|
||||||
|
* @param[in] filename The path to file.
|
||||||
|
* @param[in] texture_save_opt Global texture save option
|
||||||
|
* @param[in] use_compress True if use compression when saving.
|
||||||
|
* @param[in] compress_level The compress level if you choose using compression in file.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
bool Save(LibCmo::CKSTRING filename, LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS texture_save_opt, bool use_compress, 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) {
|
/**
|
||||||
return m_Context->GetObject(objid);;
|
* @brief Get object pointer from given ID.
|
||||||
}
|
* @details
|
||||||
|
* This function is specially exposed to outside for detecting whether given ID is valid in BMFile.
|
||||||
|
* Also used by BMMeshTransition to get essential objects.
|
||||||
|
* @param[in] objid The ID of object.
|
||||||
|
* @return The pointer to given ID represented object. nullptr if not found.
|
||||||
|
*/
|
||||||
|
LibCmo::CK2::ObjImpls::CKObject* GetObjectPtr(LibCmo::CK2::CK_ID objid);
|
||||||
|
|
||||||
// ===== visitors =====
|
// ===== Visitor =====
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LibCmo::CKDWORD CommonGetObjectCount(std::vector<LibCmo::CK2::CK_ID>& container) {
|
LibCmo::CKDWORD CommonGetObjectCount(std::vector<LibCmo::CK2::CK_ID>& container);
|
||||||
// only available in loader
|
LibCmo::CK2::CK_ID CommonGetObject(std::vector<LibCmo::CK2::CK_ID>& container, LibCmo::CKDWORD idx);
|
||||||
if (!CanExecLoaderVisitor()) return 0;
|
LibCmo::CK2::CK_ID CommonCreateObject(std::vector<LibCmo::CK2::CK_ID>& container, LibCmo::CK2::CK_CLASSID cid);
|
||||||
return static_cast<LibCmo::CKDWORD>(container.size());
|
|
||||||
}
|
|
||||||
LibCmo::CK2::CK_ID CommonGetObject(std::vector<LibCmo::CK2::CK_ID>& container, LibCmo::CKDWORD idx) {
|
|
||||||
// only available in loader
|
|
||||||
if (!CanExecLoaderVisitor()) return 0;
|
|
||||||
return container[idx];
|
|
||||||
}
|
|
||||||
LibCmo::CK2::CK_ID CommonCreateObject(std::vector<LibCmo::CK2::CK_ID>& container, LibCmo::CK2::CK_CLASSID cid) {
|
|
||||||
// only available in saver
|
|
||||||
if (!CanExecSaverVisitor()) return 0;
|
|
||||||
|
|
||||||
// try create object and get its pointer
|
|
||||||
LibCmo::CK2::ObjImpls::CKObject* obj = m_Context->CreateObject(cid, nullptr);
|
|
||||||
// check creation validation
|
|
||||||
if (obj == nullptr) return 0;
|
|
||||||
|
|
||||||
// if success, write its id and emplace its id into list
|
|
||||||
LibCmo::CK2::CK_ID objid = obj->GetID();
|
|
||||||
container.emplace_back(objid);
|
|
||||||
return objid;
|
|
||||||
}
|
|
||||||
public:
|
public:
|
||||||
LibCmo::CKDWORD GetGroupCount();
|
LibCmo::CKDWORD GetGroupCount();
|
||||||
LibCmo::CK2::CK_ID GetGroup(LibCmo::CKDWORD idx);
|
LibCmo::CK2::CK_ID GetGroup(LibCmo::CKDWORD idx);
|
||||||
@@ -119,15 +121,19 @@ namespace BMap {
|
|||||||
LibCmo::CKDWORD GetTextureCount();
|
LibCmo::CKDWORD GetTextureCount();
|
||||||
LibCmo::CK2::CK_ID GetTexture(LibCmo::CKDWORD idx);
|
LibCmo::CK2::CK_ID GetTexture(LibCmo::CKDWORD idx);
|
||||||
LibCmo::CK2::CK_ID CreateTexture();
|
LibCmo::CK2::CK_ID CreateTexture();
|
||||||
|
LibCmo::CKDWORD GetTargetLightCount();
|
||||||
|
LibCmo::CK2::CK_ID GetTargetLight(LibCmo::CKDWORD idx);
|
||||||
|
LibCmo::CK2::CK_ID CreateTargetLight();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LibCmo::CK2::CKContext* m_Context;
|
LibCmo::CK2::CKContext* m_Context;
|
||||||
|
|
||||||
std::vector<LibCmo::CK2::CK_ID> m_ObjGroups;
|
std::vector<LibCmo::CK2::CK_ID> m_ObjGroups;
|
||||||
std::vector<LibCmo::CK2::CK_ID> m_Obj3dObjects;
|
std::vector<LibCmo::CK2::CK_ID> m_Obj3dObjects;
|
||||||
std::vector<LibCmo::CK2::CK_ID> m_ObjMeshs;
|
std::vector<LibCmo::CK2::CK_ID> m_ObjMeshes;
|
||||||
std::vector<LibCmo::CK2::CK_ID> m_ObjMaterials;
|
std::vector<LibCmo::CK2::CK_ID> m_ObjMaterials;
|
||||||
std::vector<LibCmo::CK2::CK_ID> m_ObjTextures;
|
std::vector<LibCmo::CK2::CK_ID> m_ObjTextures;
|
||||||
|
std::vector<LibCmo::CK2::CK_ID> m_ObjTargetLights;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -3,21 +3,22 @@ add_library(BMap SHARED "")
|
|||||||
# Setup sources
|
# Setup sources
|
||||||
target_sources(BMap
|
target_sources(BMap
|
||||||
PRIVATE
|
PRIVATE
|
||||||
BMap.cpp
|
BMap/BMap.cpp
|
||||||
BMExports.cpp
|
BMap/BMExports.cpp
|
||||||
)
|
)
|
||||||
# Setup headers
|
# Setup headers
|
||||||
target_sources(BMap
|
target_sources(BMap
|
||||||
PRIVATE
|
PUBLIC
|
||||||
FILE_SET HEADERS
|
FILE_SET HEADERS
|
||||||
FILES
|
FILES
|
||||||
BMap.hpp
|
BMap/BMap.hpp
|
||||||
BMExports.hpp
|
BMap/BMExports.hpp
|
||||||
)
|
)
|
||||||
# Setup header infomation
|
# Setup header infomation
|
||||||
target_include_directories(BMap
|
target_include_directories(BMap
|
||||||
PRIVATE
|
PUBLIC
|
||||||
"${CMAKE_CURRENT_LIST_DIR}"
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>"
|
||||||
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||||
)
|
)
|
||||||
# Setup linked library infomation
|
# Setup linked library infomation
|
||||||
target_link_libraries(BMap
|
target_link_libraries(BMap
|
||||||
@@ -25,31 +26,42 @@ PRIVATE
|
|||||||
YYCC::YYCCommonplace
|
YYCC::YYCCommonplace
|
||||||
LibCmo
|
LibCmo
|
||||||
)
|
)
|
||||||
# Setup C++ standard
|
|
||||||
set_target_properties(BMap
|
|
||||||
PROPERTIES
|
|
||||||
CXX_STANDARD 20
|
|
||||||
CXX_STANDARD_REQUIRED 20
|
|
||||||
CXX_EXTENSION OFF
|
|
||||||
)
|
|
||||||
# Setup project macros
|
|
||||||
target_compile_definitions(BMap
|
|
||||||
# Enable export macro
|
# Enable export macro
|
||||||
|
target_compile_definitions(BMap
|
||||||
PRIVATE
|
PRIVATE
|
||||||
BMAP_EXPORTING
|
BMAP_EXPORTING
|
||||||
# Order Unicode charset for private using
|
|
||||||
PRIVATE
|
|
||||||
$<$<CXX_COMPILER_ID:MSVC>:UNICODE>
|
|
||||||
$<$<CXX_COMPILER_ID:MSVC>:_UNICODE>
|
|
||||||
)
|
|
||||||
# Order build as UTF-8 in MSVC
|
|
||||||
target_compile_options(BMap
|
|
||||||
PRIVATE
|
|
||||||
$<$<CXX_COMPILER_ID:MSVC>:/utf-8>
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Install BMap only on Release mode
|
# Install binary and headers
|
||||||
install(TARGETS BMap
|
install(TARGETS BMap
|
||||||
CONFIGURATIONS Release RelWithDebInfo MinSizeRel
|
EXPORT BMapTargets
|
||||||
RUNTIME DESTINATION ${YYCC_INSTALL_BIN_PATH}
|
LIBRARY DESTINATION ${NEMO_INSTALL_LIB_PATH}
|
||||||
|
ARCHIVE DESTINATION ${NEMO_INSTALL_LIB_PATH}
|
||||||
|
INCLUDES DESTINATION ${NEMO_INSTALL_INCLUDE_PATH}
|
||||||
|
FILE_SET HEADERS DESTINATION ${NEMO_INSTALL_INCLUDE_PATH}
|
||||||
|
)
|
||||||
|
# Install target
|
||||||
|
install(EXPORT BMapTargets
|
||||||
|
FILE BMapTargets.cmake
|
||||||
|
NAMESPACE NeMo::
|
||||||
|
DESTINATION ${NEMO_INSTALL_LIB_PATH}/cmake/BMap
|
||||||
|
)
|
||||||
|
# Package configuration file
|
||||||
|
write_basic_package_version_file(
|
||||||
|
BMapConfigVersion.cmake
|
||||||
|
VERSION ${PACKAGE_VERSION}
|
||||||
|
COMPATIBILITY SameMinorVersion
|
||||||
|
)
|
||||||
|
configure_package_config_file(
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/../CMake/BMapConfig.cmake.in
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/BMapConfig.cmake"
|
||||||
|
INSTALL_DESTINATION ${NEMO_INSTALL_LIB_PATH}/cmake/BMap
|
||||||
|
)
|
||||||
|
# Copy package files to install destination
|
||||||
|
install(
|
||||||
|
FILES
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/BMapConfig.cmake"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/BMapConfigVersion.cmake"
|
||||||
|
DESTINATION
|
||||||
|
${NEMO_INSTALL_LIB_PATH}/cmake/BMap
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,146 +0,0 @@
|
|||||||
using BMapSharp.BMapWrapper;
|
|
||||||
using System;
|
|
||||||
using System.Text;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
|
|
||||||
namespace BMapSharpTestbench {
|
|
||||||
internal class Program {
|
|
||||||
|
|
||||||
static void Main(string[] args) {
|
|
||||||
// Check environment
|
|
||||||
Console.OutputEncoding = Encoding.UTF8;
|
|
||||||
if (!BMapSharp.BMapWrapper.Utils.IsBMapAvailable()) {
|
|
||||||
Console.WriteLine("Fail to initialize native BMap.");
|
|
||||||
Environment.Exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Waiting debugger
|
|
||||||
int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
|
|
||||||
Console.WriteLine($"C# PID is {pid}. Waiting debugger, press any key to continue...");
|
|
||||||
Console.ReadKey(true);
|
|
||||||
|
|
||||||
// Start testbench
|
|
||||||
string file_name = "Level_02.NMO";
|
|
||||||
string temp_folder = "Temp";
|
|
||||||
string texture_folder = "F:\\Ballance\\Ballance\\Textures";
|
|
||||||
string[] encodings = ["cp1252", "gb2312"];
|
|
||||||
|
|
||||||
using (var reader = new BMapSharp.BMapWrapper.BMFileReader(file_name, temp_folder, texture_folder, encodings)) {
|
|
||||||
TestCommon(reader);
|
|
||||||
TestIEquatable(reader);
|
|
||||||
}
|
|
||||||
|
|
||||||
Console.WriteLine("Press any key to quit...");
|
|
||||||
Console.ReadKey(true);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static void TestCommon(BMapSharp.BMapWrapper.BMFileReader reader) {
|
|
||||||
// Console.WriteLine("===== Groups =====");
|
|
||||||
// foreach (var gp in reader.GetGroups()) {
|
|
||||||
// Console.WriteLine(gp.GetName());
|
|
||||||
// foreach (var gp_item in gp.GetObjects()) {
|
|
||||||
// Console.WriteLine($"\t{gp_item.GetName()}");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Console.WriteLine("===== 3dObjects =====");
|
|
||||||
// foreach (var obj in reader.Get3dObjects()) {
|
|
||||||
// Console.WriteLine(obj.GetName());
|
|
||||||
|
|
||||||
// var current_mesh = obj.GetCurrentMesh();
|
|
||||||
// var mesh_name = current_mesh is null ? "<null>" : current_mesh.GetName();
|
|
||||||
// Console.WriteLine($"\tMesh: {mesh_name}");
|
|
||||||
// Console.WriteLine($"\tVisibility: {obj.GetVisibility()}");
|
|
||||||
// Console.WriteLine($"\tMatrix: {obj.GetWorldMatrix().ToManaged()}");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Console.WriteLine("===== Meshes =====");
|
|
||||||
// foreach (var mesh in reader.GetMeshes()) {
|
|
||||||
// Console.WriteLine(mesh.GetName());
|
|
||||||
|
|
||||||
// Console.WriteLine($"\tLit Mode: {mesh.GetLitMode()}");
|
|
||||||
// Console.WriteLine($"\tVertex Count: {mesh.GetVertexCount()}");
|
|
||||||
// Console.WriteLine($"\tFace Count: {mesh.GetFaceCount()}");
|
|
||||||
// Console.WriteLine($"\tMaterial Slot Count: {mesh.GetMaterialSlotCount()}");
|
|
||||||
// }
|
|
||||||
|
|
||||||
Console.WriteLine("===== Materials =====");
|
|
||||||
foreach (var mtl in reader.GetMaterials()) {
|
|
||||||
Console.WriteLine(mtl.GetName());
|
|
||||||
|
|
||||||
Console.WriteLine($"\tDiffuse: {mtl.GetDiffuse().ToManagedRGBA()}");
|
|
||||||
Console.WriteLine($"\tAmbient: {mtl.GetAmbient().ToManagedRGBA()}");
|
|
||||||
Console.WriteLine($"\tSpecular: {mtl.GetSpecular().ToManagedRGBA()}");
|
|
||||||
Console.WriteLine($"\tEmissive: {mtl.GetEmissive().ToManagedRGBA()}");
|
|
||||||
|
|
||||||
Console.WriteLine($"\tSpecular Power: {mtl.GetSpecularPower()}");
|
|
||||||
|
|
||||||
Console.WriteLine($"\tTexture Border Color: {mtl.GetTextureBorderColor().ToManagedRGBA()}");
|
|
||||||
|
|
||||||
Console.WriteLine($"\tTexture Blend Mode: {mtl.GetTextureBlendMode()}");
|
|
||||||
Console.WriteLine($"\tTexture Min Mode: {mtl.GetTextureMinMode()}");
|
|
||||||
Console.WriteLine($"\tTexture Mag Mode: {mtl.GetTextureMagMode()}");
|
|
||||||
Console.WriteLine($"\tSource Blend: {mtl.GetSourceBlend()}");
|
|
||||||
Console.WriteLine($"\tDest Blend: {mtl.GetDestBlend()}");
|
|
||||||
Console.WriteLine($"\tFill Mode: {mtl.GetFillMode()}");
|
|
||||||
Console.WriteLine($"\tShade Mode: {mtl.GetShadeMode()}");
|
|
||||||
|
|
||||||
Console.WriteLine($"\tAlpha Test Enabled: {mtl.GetAlphaTestEnabled()}");
|
|
||||||
Console.WriteLine($"\tAlpha Blend Enabled: {mtl.GetAlphaBlendEnabled()}");
|
|
||||||
Console.WriteLine($"\tPerspective Correction Enabled: {mtl.GetPerspectiveCorrectionEnabled()}");
|
|
||||||
Console.WriteLine($"\tZ Write Enabled: {mtl.GetZWriteEnabled()}");
|
|
||||||
Console.WriteLine($"\tTwo Sided Enabled: {mtl.GetTwoSidedEnabled()}");
|
|
||||||
|
|
||||||
Console.WriteLine($"\tAlpha Ref: {mtl.GetAlphaRef()}");
|
|
||||||
|
|
||||||
Console.WriteLine($"\tAlpha Func: {mtl.GetAlphaFunc()}");
|
|
||||||
Console.WriteLine($"\tZ Func: {mtl.GetZFunc()}");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Console.WriteLine("===== Textures =====");
|
|
||||||
// foreach (var tex in reader.GetTextures()) {
|
|
||||||
// Console.WriteLine(tex.GetName());
|
|
||||||
|
|
||||||
// Console.WriteLine($"\tFile Name: {tex.GetFileName()}");
|
|
||||||
// Console.WriteLine($"\tSave Options: {tex.GetSaveOptions()}");
|
|
||||||
// Console.WriteLine($"\tVideo Format: {tex.GetVideoFormat()}");
|
|
||||||
// }
|
|
||||||
|
|
||||||
Console.WriteLine("===== END =====");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void TestIEquatable(BMapSharp.BMapWrapper.BMFileReader reader) {
|
|
||||||
if (reader.Get3dObjectCount() < 2u) {
|
|
||||||
Debug.Fail(
|
|
||||||
"Invalid file for test IEquatable.",
|
|
||||||
"We can not perform IEquatable test because the length of 3dObject is too short (must greater than 2). Please choose another file to perform."
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepare test variables
|
|
||||||
var all_3dobjects = new List<BM3dObject>(reader.Get3dObjects());
|
|
||||||
var first_3dobj = all_3dobjects[0];
|
|
||||||
var second_3dobj = all_3dobjects[1];
|
|
||||||
all_3dobjects = new List<BM3dObject>(reader.Get3dObjects());
|
|
||||||
var first_3dobj_again = all_3dobjects[0];
|
|
||||||
Debug.Assert(!Object.ReferenceEquals(first_3dobj, first_3dobj_again));
|
|
||||||
|
|
||||||
// Hashtable test
|
|
||||||
var test_hashset = new HashSet<BM3dObject>();
|
|
||||||
Debug.Assert(test_hashset.Add(first_3dobj));
|
|
||||||
Debug.Assert(!test_hashset.Add(first_3dobj_again));
|
|
||||||
Debug.Assert(test_hashset.Add(second_3dobj));
|
|
||||||
|
|
||||||
// Dictionary test
|
|
||||||
var test_dictionary = new Dictionary<BM3dObject, string>();
|
|
||||||
Debug.Assert(test_dictionary.TryAdd(first_3dobj, first_3dobj.GetName()));
|
|
||||||
Debug.Assert(!test_dictionary.TryAdd(first_3dobj_again, first_3dobj_again.GetName()));
|
|
||||||
Debug.Assert(test_dictionary.TryAdd(second_3dobj, second_3dobj.GetName()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
import os
|
|
||||||
import PyBMap.bmap_wrapper as bmap
|
|
||||||
|
|
||||||
def main() -> None:
|
|
||||||
input(f'Python PID is {os.getpid()}. Waiting for debugger, press any key to continue...')
|
|
||||||
|
|
||||||
file_name: str = 'Level_02.NMO'
|
|
||||||
temp_folder: str = 'Temp'
|
|
||||||
texture_folder: str = 'F:\\Ballance\\Ballance\\Textures'
|
|
||||||
encodings: tuple[str, ...] = ('cp1252', )
|
|
||||||
with bmap.BMFileReader(file_name, temp_folder, texture_folder, encodings) as reader:
|
|
||||||
test_common(reader)
|
|
||||||
test_equatable(reader)
|
|
||||||
|
|
||||||
def test_common(reader: bmap.BMFileReader):
|
|
||||||
# print('===== Groups =====')
|
|
||||||
# for gp in reader.get_groups():
|
|
||||||
# print(gp.get_name())
|
|
||||||
# for gp_item in gp.get_objects():
|
|
||||||
# print(f'\t{gp_item.get_name()}')
|
|
||||||
|
|
||||||
# print('===== 3dObjects =====')
|
|
||||||
# for obj in reader.get_3dobjects():
|
|
||||||
# print(obj.get_name())
|
|
||||||
|
|
||||||
# current_mesh = obj.get_current_mesh()
|
|
||||||
# mesh_name = '<null>' if current_mesh is None else current_mesh.get_name()
|
|
||||||
# print(f'\tMesh: {mesh_name}')
|
|
||||||
# print(f'\tVisibility: {obj.get_visibility()}')
|
|
||||||
# print(f'\tMatrix: {obj.get_world_matrix().to_const()}')
|
|
||||||
|
|
||||||
# print('===== Meshes =====')
|
|
||||||
# for mesh in reader.get_meshs():
|
|
||||||
# print(mesh.get_name())
|
|
||||||
|
|
||||||
# print(f'\tLit Mode: {mesh.get_lit_mode()}')
|
|
||||||
# print(f'\tVertex Count: {mesh.get_vertex_count()}')
|
|
||||||
# print(f'\tFace Count: {mesh.get_face_count()}')
|
|
||||||
# print(f'\tMaterial Slot Count: {mesh.get_material_slot_count()}')
|
|
||||||
|
|
||||||
print('===== Materials =====')
|
|
||||||
for mtl in reader.get_materials():
|
|
||||||
print(mtl.get_name())
|
|
||||||
|
|
||||||
print(f'\tDiffuse: {mtl.get_diffuse().to_const_rgba()}')
|
|
||||||
print(f'\tAmbient: {mtl.get_ambient().to_const_rgba()}')
|
|
||||||
print(f'\tSpecular: {mtl.get_specular().to_const_rgba()}')
|
|
||||||
print(f'\tEmissive: {mtl.get_emissive().to_const_rgba()}')
|
|
||||||
|
|
||||||
print(f'\tSpecular Power: {mtl.get_specular_power()}')
|
|
||||||
|
|
||||||
print(f'\tTexture Border Color: {mtl.get_texture_border_color().to_const_rgba()}')
|
|
||||||
|
|
||||||
print(f'\tTexture Blend Mode: {mtl.get_texture_blend_mode()}')
|
|
||||||
print(f'\tTexture Min Mode: {mtl.get_texture_min_mode()}')
|
|
||||||
print(f'\tTexture Mag Mode: {mtl.get_texture_mag_mode()}')
|
|
||||||
print(f'\tSource Blend: {mtl.get_source_blend()}')
|
|
||||||
print(f'\tDest Blend: {mtl.get_dest_blend()}')
|
|
||||||
print(f'\tFill Mode: {mtl.get_fill_mode()}')
|
|
||||||
print(f'\tShade Mode: {mtl.get_shade_mode()}')
|
|
||||||
|
|
||||||
print(f'\tAlpha Test Enabled: {mtl.get_alpha_test_enabled()}')
|
|
||||||
print(f'\tAlpha Blend Enabled: {mtl.get_alpha_blend_enabled()}')
|
|
||||||
print(f'\tPerspective Correction Enabled: {mtl.get_perspective_correction_enabled()}')
|
|
||||||
print(f'\tZ Write Enabled: {mtl.get_z_write_enabled()}')
|
|
||||||
print(f'\tTwo Sided Enabled: {mtl.get_two_sided_enabled()}')
|
|
||||||
|
|
||||||
print(f'\tAlpha Ref: {mtl.get_alpha_ref()}')
|
|
||||||
|
|
||||||
print(f'\tAlpha Func: {mtl.get_alpha_func()}')
|
|
||||||
print(f'\tZ Func: {mtl.get_z_func()}')
|
|
||||||
|
|
||||||
# print('===== Textures =====')
|
|
||||||
# for tex in reader.get_textures():
|
|
||||||
# print(tex.get_name())
|
|
||||||
|
|
||||||
# print(f'\tFile Name: {tex.get_file_name()}')
|
|
||||||
# print(f'\tSave Options: {tex.get_save_options()}')
|
|
||||||
# print(f'\tVideo Format: {tex.get_video_format()}')
|
|
||||||
|
|
||||||
print('===== END =====')
|
|
||||||
|
|
||||||
def test_equatable(reader: bmap.BMFileReader):
|
|
||||||
# Check requirements
|
|
||||||
assert (reader.get_3dobject_count() >= 2), '''
|
|
||||||
Invalid file for test IEquatable.
|
|
||||||
We can not perform IEquatable test because the length of 3dObject is too short (must greater than 2). Please choose another file to perform.
|
|
||||||
'''
|
|
||||||
|
|
||||||
# Prepare variables
|
|
||||||
all_3dobjects: tuple[bmap.BM3dObject, ...] = tuple(reader.get_3dobjects())
|
|
||||||
first_3dobj: bmap.BM3dObject = all_3dobjects[0]
|
|
||||||
second_3dobj: bmap.BM3dObject = all_3dobjects[1]
|
|
||||||
all_3dobjects = tuple(reader.get_3dobjects())
|
|
||||||
first_3dobj_again: bmap.BM3dObject = all_3dobjects[0]
|
|
||||||
|
|
||||||
# Test set
|
|
||||||
test_set: set[bmap.BM3dObject] = set()
|
|
||||||
|
|
||||||
test_set.add(first_3dobj)
|
|
||||||
assert len(test_set) == 1
|
|
||||||
|
|
||||||
assert first_3dobj in test_set
|
|
||||||
assert first_3dobj_again in test_set
|
|
||||||
assert second_3dobj not in test_set
|
|
||||||
|
|
||||||
test_set.add(first_3dobj_again)
|
|
||||||
assert len(test_set) == 1
|
|
||||||
test_set.add(second_3dobj)
|
|
||||||
assert len(test_set) == 2
|
|
||||||
|
|
||||||
assert second_3dobj in test_set
|
|
||||||
|
|
||||||
# Test dict
|
|
||||||
test_dict: dict[bmap.BM3dObject, str | None] = {}
|
|
||||||
|
|
||||||
test_dict[first_3dobj] = first_3dobj.get_name()
|
|
||||||
assert len(test_dict) == 1
|
|
||||||
|
|
||||||
assert first_3dobj in test_dict
|
|
||||||
assert first_3dobj_again in test_dict
|
|
||||||
assert second_3dobj not in test_dict
|
|
||||||
|
|
||||||
test_dict[first_3dobj_again] = first_3dobj_again.get_name()
|
|
||||||
assert len(test_dict) == 1
|
|
||||||
test_dict[second_3dobj] = second_3dobj.get_name()
|
|
||||||
assert len(test_dict) == 2
|
|
||||||
|
|
||||||
assert second_3dobj in test_dict
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
7
CMake/BMapConfig.cmake.in
Normal file
7
CMake/BMapConfig.cmake.in
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
# Include targets file
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/BMapTargets.cmake")
|
||||||
|
|
||||||
|
check_required_components(BMap)
|
||||||
52
CMake/FindSTB.cmake
Normal file
52
CMake/FindSTB.cmake
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# - Find STB library
|
||||||
|
# Find the STB headers
|
||||||
|
#
|
||||||
|
# This module defines the following variables:
|
||||||
|
# STB_FOUND - True if STB was found
|
||||||
|
# STB_INCLUDE_DIRS - Location of the STB headers
|
||||||
|
#
|
||||||
|
# This module defines the following imported targets:
|
||||||
|
# STB::STB - Header-only interface library for STB
|
||||||
|
|
||||||
|
# STB_ROOT must be specified by the user
|
||||||
|
if (NOT DEFINED STB_ROOT)
|
||||||
|
set(STB_FOUND FALSE)
|
||||||
|
else ()
|
||||||
|
# Look for STB_image.h in the specified STB_ROOT directory
|
||||||
|
find_path(STB_INCLUDE_DIR
|
||||||
|
NAMES STB_image.h
|
||||||
|
HINTS ${STB_ROOT}
|
||||||
|
NO_DEFAULT_PATH
|
||||||
|
)
|
||||||
|
|
||||||
|
# Check find status
|
||||||
|
if(STB_INCLUDE_DIR)
|
||||||
|
set(STB_FOUND TRUE)
|
||||||
|
set(STB_INCLUDE_DIRS ${STB_INCLUDE_DIR})
|
||||||
|
else()
|
||||||
|
set(STB_FOUND FALSE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Hide intermediate variables
|
||||||
|
mark_as_advanced(STB_INCLUDE_DIR)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Check find result
|
||||||
|
if (STB_FOUND)
|
||||||
|
# Add library
|
||||||
|
message(STATUS "Found STB library")
|
||||||
|
# Add library
|
||||||
|
add_library(STB INTERFACE IMPORTED)
|
||||||
|
# Add alias to it
|
||||||
|
add_library(STB::STB ALIAS STB)
|
||||||
|
# Setup header files
|
||||||
|
set_target_properties(STB PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES
|
||||||
|
"${STB_INCLUDE_DIRS}"
|
||||||
|
)
|
||||||
|
else ()
|
||||||
|
# If it is required, show infomations.
|
||||||
|
if (std_FIND_REQUIRED)
|
||||||
|
message(FATAL_ERROR "Fail to find STB library.")
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
if (WIN32)
|
|
||||||
# In Windows, we should not import Iconv.
|
|
||||||
# Send a notice to programmer.
|
|
||||||
message("Windows environment detected, skip finding Iconv!")
|
|
||||||
else ()
|
|
||||||
# In non-Windows, we simply import Iconv from CMake preset.
|
|
||||||
# It will produce Iconv::Iconv target for including and linking.
|
|
||||||
find_package(Iconv REQUIRED)
|
|
||||||
endif ()
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
# Check stb path variable
|
|
||||||
if (NOT DEFINED STB_IMAGE_PATH)
|
|
||||||
message(FATAL_ERROR "You must set STB_IMAGE_PATH variable to the root directory of std-image repository.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Add library
|
|
||||||
add_library(stb-image INTERFACE IMPORTED)
|
|
||||||
# Add alias for it
|
|
||||||
add_library(stb::stb-image ALIAS stb-image)
|
|
||||||
# Setup header files
|
|
||||||
set_target_properties(stb-image PROPERTIES
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES
|
|
||||||
"${STB_IMAGE_PATH}"
|
|
||||||
)
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
|
|
||||||
# Check YYCC path environment variable
|
|
||||||
if (NOT DEFINED YYCC_PATH)
|
|
||||||
message(FATAL_ERROR "You must set YYCC_PATH variable to one of YYCC CMake distribution installation path.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Find YYCC library
|
|
||||||
# It will produce YYCC::YYCCommonplace target for including and linking.
|
|
||||||
#
|
|
||||||
# Please note we MUST set CMake variable YYCCommonplace_ROOT to make sure CMake can found YYCC in out given path.
|
|
||||||
# The cache status of YYCCommonplace_ROOT is doesn't matter.
|
|
||||||
# CMake will throw error if we use HINTS feature in find_package to find YYCC.
|
|
||||||
set(YYCCommonplace_ROOT ${YYCC_PATH} CACHE PATH
|
|
||||||
"The path to YYCC CMake distribution installation path.")
|
|
||||||
find_package(YYCCommonplace REQUIRED)
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
if (WIN32)
|
|
||||||
# In Windows, we use custom way to import ZLib.
|
|
||||||
# Before using this CMake file in Windows, you should do following steps first.
|
|
||||||
# 1. Get ZLib repository: https://github.com/madler/zlib
|
|
||||||
# 2. Navigate to `contrib/vstudio` and choose a proper Visual Studio project according to your environment.
|
|
||||||
# 3. Open project file and build. Then you will get the built binary.
|
|
||||||
# 4. The directory binary located is the argument you should passed to ZLIB_BINARY_PATH, for example: `contrib/vstudio/vc14/x64/ZlibDllRelease`
|
|
||||||
|
|
||||||
# Check ZLib path variable
|
|
||||||
if (NOT DEFINED ZLIB_HEADER_PATH)
|
|
||||||
message(FATAL_ERROR "You must set ZLIB_HEADER_PATH to the root directory of ZLib repository.")
|
|
||||||
endif()
|
|
||||||
if (NOT DEFINED ZLIB_BINARY_PATH)
|
|
||||||
message(FATAL_ERROR "You must set ZLIB_BINARY_PATH to the directory where include binary built by contributed Visual Studio project.")
|
|
||||||
endif()
|
|
||||||
# Add imported library
|
|
||||||
add_library(ZLIB INTERFACE IMPORTED)
|
|
||||||
# Add alias for it to let it has the same behavior with CMake imported ZLib.
|
|
||||||
add_library(ZLIB::ZLIB ALIAS ZLIB)
|
|
||||||
# Setup header files
|
|
||||||
set_target_properties(ZLIB PROPERTIES
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES
|
|
||||||
"${ZLIB_HEADER_PATH}"
|
|
||||||
)
|
|
||||||
# Setup lib files
|
|
||||||
set_target_properties(ZLIB PROPERTIES
|
|
||||||
INTERFACE_LINK_LIBRARIES
|
|
||||||
"${ZLIB_BINARY_PATH}/zlibwapi.lib"
|
|
||||||
)
|
|
||||||
else ()
|
|
||||||
# In non-Windows, we simply import ZLib from CMake preset.
|
|
||||||
# It will produce ZLIB::ZLIB target for including and linking.
|
|
||||||
find_package(ZLIB REQUIRED)
|
|
||||||
endif ()
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
|
# Minimum required CMake version
|
||||||
cmake_minimum_required(VERSION 3.23)
|
cmake_minimum_required(VERSION 3.23)
|
||||||
|
# Project definition
|
||||||
project(NeMo
|
project(NeMo
|
||||||
VERSION 0.2.0
|
VERSION 0.4.0
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -9,6 +11,11 @@ option(NEMO_BUILD_UNVIRT "Build Unvirt, the console interface operator of LibCmo
|
|||||||
option(NEMO_BUILD_BMAP "Build BMap, the example use of LibCmo which can read and write Ballance game map." OFF)
|
option(NEMO_BUILD_BMAP "Build BMap, the example use of LibCmo which can read and write Ballance game map." OFF)
|
||||||
option(NEMO_BUILD_DOC "Build document of LibCmo and all related stuff." OFF)
|
option(NEMO_BUILD_DOC "Build document of LibCmo and all related stuff." OFF)
|
||||||
|
|
||||||
|
# Set C++ standards
|
||||||
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
# Setup install path from CMake provided install path for convenient use.
|
# Setup install path from CMake provided install path for convenient use.
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
set(NEMO_INSTALL_INCLUDE_PATH ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH
|
set(NEMO_INSTALL_INCLUDE_PATH ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH
|
||||||
@@ -20,11 +27,17 @@ set(NEMO_INSTALL_BIN_PATH ${CMAKE_INSTALL_BINDIR} CACHE PATH
|
|||||||
set(NEMO_INSTALL_DOC_PATH ${CMAKE_INSTALL_DOCDIR} CACHE PATH
|
set(NEMO_INSTALL_DOC_PATH ${CMAKE_INSTALL_DOCDIR} CACHE PATH
|
||||||
"Non-arch doc install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.")
|
"Non-arch doc install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.")
|
||||||
|
|
||||||
# Import essential packages
|
# Add our CMake in module found path
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/CMake/custom_import_zlib.cmake)
|
set(CMAKE_MODULE_PATH
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/CMake/custom_import_iconv.cmake)
|
"${CMAKE_CURRENT_LIST_DIR}/CMake"
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/CMake/custom_import_yycc.cmake)
|
)
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/CMake/custom_import_stb.cmake)
|
# Find required packages
|
||||||
|
find_package(ZLIB REQUIRED)
|
||||||
|
find_package(YYCCommonplace REQUIRED)
|
||||||
|
find_package(STB REQUIRED)
|
||||||
|
|
||||||
|
# Import package helper
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
|
||||||
# If we are not in Windows environment, and we need to build shared library BMap,
|
# If we are not in Windows environment, and we need to build shared library BMap,
|
||||||
# we should enable PIC (position independent code), otherwise build process will fail.
|
# we should enable PIC (position independent code), otherwise build process will fail.
|
||||||
@@ -36,7 +49,7 @@ if ((NOT WIN32) AND NEMO_BUILD_BMAP)
|
|||||||
set(CMAKE_POSITION_INDEPENDENT_CODE True)
|
set(CMAKE_POSITION_INDEPENDENT_CODE True)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# Import build targets
|
# Include build targets by options
|
||||||
add_subdirectory(LibCmo)
|
add_subdirectory(LibCmo)
|
||||||
if (NEMO_BUILD_UNVIRT)
|
if (NEMO_BUILD_UNVIRT)
|
||||||
add_subdirectory(Unvirt)
|
add_subdirectory(Unvirt)
|
||||||
@@ -47,31 +60,3 @@ endif ()
|
|||||||
if (NEMO_BUILD_DOC)
|
if (NEMO_BUILD_DOC)
|
||||||
add_subdirectory(Documents)
|
add_subdirectory(Documents)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# Install target and package
|
|
||||||
# Install target
|
|
||||||
install(EXPORT LibCmoTargets
|
|
||||||
FILE LibCmoTargets.cmake
|
|
||||||
NAMESPACE NeMo::
|
|
||||||
DESTINATION ${YYCC_INSTALL_LIB_PATH}/cmake/LibCmo
|
|
||||||
)
|
|
||||||
# Package configuration file
|
|
||||||
include(CMakePackageConfigHelpers)
|
|
||||||
write_basic_package_version_file(
|
|
||||||
LibCmoConfigVersion.cmake
|
|
||||||
VERSION ${PACKAGE_VERSION}
|
|
||||||
COMPATIBILITY SameMinorVersion
|
|
||||||
)
|
|
||||||
configure_package_config_file(
|
|
||||||
${CMAKE_CURRENT_LIST_DIR}/CMake/LibCmoConfig.cmake.in
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/LibCmoConfig.cmake"
|
|
||||||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LibCmo
|
|
||||||
)
|
|
||||||
# Copy package files to install destination
|
|
||||||
install(
|
|
||||||
FILES
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/LibCmoConfig.cmake"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/LibCmoConfigVersion.cmake"
|
|
||||||
DESTINATION
|
|
||||||
${CMAKE_INSTALL_LIBDIR}/cmake/LibCmo
|
|
||||||
)
|
|
||||||
|
|||||||
136
COMPILE.md
136
COMPILE.md
@@ -1,35 +1,43 @@
|
|||||||
# Compile Manual
|
# Compile Manual
|
||||||
|
|
||||||
|
## Choose Version
|
||||||
|
|
||||||
|
We suggest that you only use stable version (tagged commit).
|
||||||
|
The latest commit always present current works.
|
||||||
|
It means that it is not stable and work in progress.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
This project require:
|
|
||||||
|
|
||||||
* CMake 3.23 at least.
|
* CMake 3.23 at least.
|
||||||
* The common compiler supporting C++ 20 (GCC / Clang / MSVC).
|
* The common compiler supporting C++ 23 (GCC / Clang / MSVC).
|
||||||
* Littile-endian architecture system.
|
* Littile-endian architecture system.
|
||||||
* zlib.
|
* zlib.
|
||||||
* iconv (non-Windows system required).
|
* [stb](https://github.com/nothings/stb).
|
||||||
* [stb](https://github.com/nothings/stb): For image read and write.
|
* [YYCCommonplace](https://github.com/yyc12345/YYCCommonplace).
|
||||||
* [YYCCommonplace](https://github.com/yyc12345/YYCCommonplace): My personal invented library concentrating some common functions for mine.
|
* Doxygen (Required if you build documentation).
|
||||||
|
|
||||||
Since libcmo21 0.2.0, we only provide it in CMake build system. So Windows user should install CMake first or use Visual Studio directly (Visual Studio provides CMake build system supports).
|
|
||||||
|
|
||||||
## Preparations
|
## Preparations
|
||||||
|
|
||||||
### YYCCommonplace
|
### YYCCommonplace
|
||||||
|
|
||||||
You should clone YYCCommonplace and switch to the latest release tag (or specified commit hash provided with libcmo21 release infos if you are building for specific libcmo21 version). When configuring YYCCommonplace, you should notice following infos:
|
Following these steps to prepare YYCCommonplace:
|
||||||
|
|
||||||
* Please make sure that you have specified C++ 20 explicitly by passing `-DCMAKE_CXX_STANDARD=20` in command line. This is crucial because libcmo21 use C++ 20, and YYCCommonplace's ABI is incompatible between C++ 17 version and C++ 20 version.
|
1. Clone YYCCommonplace first.
|
||||||
* If you need `BMap` in final libcmo21 built artifacts, and you are in non-Windows system now, please specify position independent code flag by passing `-DCMAKE_POSITION_INDEPENDENT_CODE=True` in command line. GCC and Clang will reject linking if you don't flag it.
|
1. Switch to the latest **release** tag, or **specified commit hash** provided with libcmo21 release infos if you are building for specific libcmo21 version.
|
||||||
|
1. Following compile manual provided by YYCCommonplace to configure, compile and install it.
|
||||||
|
|
||||||
After configuring, you can normally build YYCCommonplace like a common CMake project.
|
> [!IMPORTANT]
|
||||||
|
> If you need `BMap` component in final libcmo21 built artifacts, and you are in non-Windows system now, please specify position independent code flag by passing `-DCMAKE_POSITION_INDEPENDENT_CODE=True` in command line when configuring YYCCommonplace. Otherwise GCC and Clang will reject linking.
|
||||||
Please note if your final program or dynamic library is provided for end user, please choose `RelWithDebInfo` build type (`Release` is not suggested because it will strip all debug infos and it is not good for bug reporter, which is embedded in program, to report crash). If final program is served for programmer debugging, please choose `Debug` build type.
|
|
||||||
|
|
||||||
### stb
|
### stb
|
||||||
|
|
||||||
You should clone stb repository first, then switch to a specific commit hash `2e2bef463a5b53ddf8bb788e25da6b8506314c08`. In ideally scenario, people like to choose the latest commit. However, I not frequently update this dependency.
|
Following these steps to prepare stb:
|
||||||
|
|
||||||
|
1. Clone stb repository first.
|
||||||
|
1. Switch to a **specific commit hash** `2e2bef463a5b53ddf8bb788e25da6b8506314c08`. I do not frequently update this dependency so using the latest commit is inviable.
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> std is a header-only C project. So we don't need compile it. libcmo21 will use homemade CMake script to find it.
|
||||||
|
|
||||||
### zlib
|
### zlib
|
||||||
|
|
||||||
@@ -37,47 +45,93 @@ If you are in Windows, you should download zlib source code and build it with gi
|
|||||||
|
|
||||||
If you are running on non-Windows system. You usually do not need to do anything. Because zlib development environment may be configured by your package manager correctly.
|
If you are running on non-Windows system. You usually do not need to do anything. Because zlib development environment may be configured by your package manager correctly.
|
||||||
|
|
||||||
## Compile
|
If you are in Windows, or in Linux but want to use specific zlib version due to various reasons, following these steps to prepare zlib:
|
||||||
|
|
||||||
### Directory Hierarchy
|
1. Download zlib source code from its official.
|
||||||
|
1. Extract it into a directory.
|
||||||
|
1. Enter this directory and create 2 subdirectory `build` and `install` for CMake build and install respectively.
|
||||||
|
1. Enter `build` directory and configure CMake with extra `-DCMAKE_CXX_STANDARD=23 -DZLIB_BUILD_EXAMPLES=OFF -DCMAKE_INSTALL_PREFIX=<path-to-install>` parameters. And `<path-to-install>` is the absolute path to your created `install` directory in previous step (Idk why `--prefix` argument is not works for zlib).
|
||||||
|
1. Use CMake to build zlib
|
||||||
|
1. Use CMake to install zlib into previous we created `install` directory.
|
||||||
|
|
||||||
First, create subdirectory `Bin/build` and `Bin/install` at the root directory of libcmo21.
|
> [!NOTE]
|
||||||
|
> We use CMake, rather than any other to compile zlib because zlib provide it, and we also use CMake as our build system, so that we do not need to write any extra files for adaption.
|
||||||
|
|
||||||
### Configuration
|
> [!CAUTION]
|
||||||
|
> Windows developer should highly notice that please do NOT use Visual Studio file located in `contrib/vstudio` directory to produce binary zlib on Windows. That project will produce `zlibwapi.dll` which is not our expected `zlib.dll`. Please use Visual Studio embedded CMake to configure zlib and compile it directly.
|
||||||
|
|
||||||
Then enter subdirectory `Bin/build` and use following command to configure CMake:
|
### Doxygen
|
||||||
|
|
||||||
- Windows (MSVC): `cmake -DNEMO_BUILD_UNVIRT=ON -DNEMO_BUILD_BMAP=ON -DNEMO_BUILD_DOC=OFF -DSTB_IMAGE_PATH=<path-to-stb> -DYYCC_PATH=<path-to-yycc-install> -DZLIB_HEADER_PATH=<path-to-zlib-hdr> -DZLIB_BINARY_PATH=<path-to-zlib-bin> ../..`
|
Doxygen is required only if you need to build documentation.
|
||||||
- non-Windows: `cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DNEMO_BUILD_UNVIRT=ON -DNEMO_BUILD_BMAP=ON -DNEMO_BUILD_DOC=OFF -DSTB_IMAGE_PATH=<path-to-stb> -DYYCC_PATH=<path-to-yycc-install> ../..`
|
If you don't need this please skip this chapter.
|
||||||
|
|
||||||
The arguments in command should be replaced by:
|
We use Doxygen 1.9.7.
|
||||||
|
It would be okey use other versions but I have not test on them.
|
||||||
|
|
||||||
* `<path-to-stb>`: The root directory of your cloned stb repository.
|
YYCCommonplace use Doxygen as its documentation system.
|
||||||
* `<path-to-yycc-install>`: The directory to installed CMake package you chosen when building YYCCommonplace.
|
So before compiling, you must make sure `doxygen` are presented in your environment.
|
||||||
* `<path-to-zlib-hdr>` (Windows only): The root directory of downloaded zlib source code.
|
|
||||||
* `<path-to-zlib-bin>` (Windows only): The directory where you can find built `zlibwapi.dll`.
|
|
||||||
|
|
||||||
The switches in command can be switched as you wish:
|
## Build and Install
|
||||||
|
|
||||||
* `NEMO_BUILD_UNVIRT`: Build `Unvirt`, a command line application debugging Virtools files.
|
Using CMake is the only viable way to build and install this repository.
|
||||||
* `NEMO_BUILD_BMAP`: Build `BMap`, a dynamic library specific used for loading Ballance map file. If you are coming from my another project [BallanceBlenderPlugin](https://github.com/yyc12345/BallanceBlenderHelper), this is what you need.
|
|
||||||
* `NEMO_BUILD_DOC`: Build the document of libcmo21.
|
|
||||||
|
|
||||||
### Build
|
### Configurable Variables
|
||||||
|
|
||||||
Execute following command to build libcmo21.
|
First, there is a list listing all variables you may configure during compiling.
|
||||||
|
|
||||||
* Windows: `cmake --build . --config RelWithDebInfo`
|
* `NEMO_BUILD_UNVIRT`: Set it to `ON` to build `Unvirt`. `ON` in default.
|
||||||
* non-Windows: `cmake --build .`
|
This is an interactive tool for loading, saving Virtools file.
|
||||||
|
It is extremely useful for debugging this project.
|
||||||
|
* `NEMO_BUILD_BMAP`: Set it to `ON` to build `BMap`. `OFF` in default.
|
||||||
|
It is a dynamic library specific used for loading Ballance map file.
|
||||||
|
If you are coming from my another project [BallanceBlenderPlugin](https://github.com/yyc12345/BallanceBlenderHelper), this is what you need.
|
||||||
|
* `NEMO_BUILD_DOC`: Set it to `ON` to build documentation. `OFF` in default.
|
||||||
|
It may be useful for the developer who firstly use this project in their own projects.
|
||||||
|
Please note that generated documentation is different in different platforms.
|
||||||
|
* `YYCCommonplace_ROOT`: Set to the install path of YYCCommonplace.
|
||||||
|
* `stb_ROOT`: Set to the root directory of stb.
|
||||||
|
* `ZLIB_ROOT`: Set to the install path of zlib.
|
||||||
|
If you are using zlib which is not build by your own, you usually do not need specify this variable.
|
||||||
|
|
||||||
### Build Type
|
### Configure CMake
|
||||||
|
|
||||||
Like YYCCommonplace, we suggest `RelWithDebInfo` for end user. If you want to build for programmer debugging, please replace all `RelWithDebInfo` to `Debug`. The build type between YYCCommonplace and libcmo21 should keep same to reduce any possibility about ABI incompatible issue.
|
When configure CMake, you may use different options on different platforms.
|
||||||
|
Following list may help you.
|
||||||
|
|
||||||
## Install
|
- On Windows:
|
||||||
|
* `-A Win32` or `-A x64` to specify architecture.
|
||||||
|
- On Linux or other POSIX systems:
|
||||||
|
* `-DCMAKE_BUILD_TYPE=Debug` or `-DCMAKE_BUILD_TYPE=Release` to specify build type.
|
||||||
|
|
||||||
Currently the CMake install script still has some bugs and can not work as expected. So as the alternative, just go into build directory and find your final program please. It's pretty simple.
|
Additionally, you can attach any variables introduced above with `-D` option during CMake configurations.
|
||||||
|
|
||||||
## Note
|
> [!NOTE]
|
||||||
|
> Position independent code flag is automatically added if you enable `BMap` so you don't need manually specify it. You just need to make sure that all dependencies enable this.
|
||||||
|
|
||||||
You may face issue when compiling this program on Linux or macOS because I develop this project on Windows frequently. The compatibility with Linux will only be checked just before releasing. And I don't have any Apple device to check the compatibility with macOS. So, for Linux issue, please report it directly and I will try to fix. For macOS bug, PR is welcomed.
|
### Build with CMake
|
||||||
|
|
||||||
|
After configuration, you can use `cmake --build .` to build project,
|
||||||
|
with additional options on different platforms.
|
||||||
|
Following list may help you.
|
||||||
|
|
||||||
|
- On Windows:
|
||||||
|
* `--config Debug` or `--config Release` to specify build type.
|
||||||
|
- On Linux or other POSIX systems:
|
||||||
|
* None
|
||||||
|
|
||||||
|
### Install with CMake
|
||||||
|
|
||||||
|
After building, you can use `cmake --install . --prefix <path-to-prefix>`
|
||||||
|
to install project into given path, with additional options on different platforms.
|
||||||
|
Following list may help you.
|
||||||
|
|
||||||
|
- On Windows:
|
||||||
|
* `--config Debug` or `--config Release` to specify build type.
|
||||||
|
- On Linux or other POSIX systems:
|
||||||
|
* None
|
||||||
|
|
||||||
|
## Compatibility Notes
|
||||||
|
|
||||||
|
You may face issue when compiling this program on Linux or macOS because I develop this project on Windows frequently.
|
||||||
|
The compatibility with Linux and macOS will only be checked just before releasing.
|
||||||
|
And, I don't have any Apple devices, so the compatibility with macOS is checked by GitHub Action.
|
||||||
|
|||||||
2
CodeGen/UniversalEncoding/.gitignore
vendored
2
CodeGen/UniversalEncoding/.gitignore
vendored
@@ -1,2 +0,0 @@
|
|||||||
# Result
|
|
||||||
*.cpp
|
|
||||||
@@ -1,98 +0,0 @@
|
|||||||
Encoding Alias Code Page Iconv Identifier
|
|
||||||
ascii 646, us-ascii 437 ASCII
|
|
||||||
big5 big5-tw, csbig5 950 BIG5
|
|
||||||
big5hkscs big5-hkscs, hkscs BIG5-HKSCS
|
|
||||||
cp037 IBM037, IBM039 037
|
|
||||||
cp273 273, IBM273, csIBM273
|
|
||||||
cp424 EBCDIC-CP-HE, IBM424
|
|
||||||
cp437 437, IBM437 437
|
|
||||||
cp500 EBCDIC-CP-BE, EBCDIC-CP-CH, IBM500 500
|
|
||||||
cp720 720
|
|
||||||
cp737 737
|
|
||||||
cp775 IBM775 775
|
|
||||||
cp850 850, IBM850 850 CP850
|
|
||||||
cp852 852, IBM852 852
|
|
||||||
cp855 855, IBM855 855
|
|
||||||
cp856
|
|
||||||
cp857 857, IBM857 857
|
|
||||||
cp858 858, IBM858 858
|
|
||||||
cp860 860, IBM860 860
|
|
||||||
cp861 861, CP-IS, IBM861 861
|
|
||||||
cp862 862, IBM862 862 CP862
|
|
||||||
cp863 863, IBM863 863
|
|
||||||
cp864 IBM864 864
|
|
||||||
cp865 865, IBM865 865
|
|
||||||
cp866 866, IBM866 866 CP866
|
|
||||||
cp869 869, CP-GR, IBM869 869
|
|
||||||
cp874 874 CP874
|
|
||||||
cp875 875
|
|
||||||
cp932 932, ms932, mskanji, ms-kanji, windows-31j 932 CP932
|
|
||||||
cp949 949, ms949, uhc 949 CP949
|
|
||||||
cp950 950, ms950 950 CP950
|
|
||||||
cp1006
|
|
||||||
cp1026 ibm1026 1026
|
|
||||||
cp1125 1125, ibm1125, cp866u, ruscii
|
|
||||||
cp1140 ibm1140 1140
|
|
||||||
cp1250 windows-1250 1250 CP1250
|
|
||||||
cp1251 windows-1251 1251 CP1251
|
|
||||||
cp1252 windows-1252 1252 CP1252
|
|
||||||
cp1253 windows-1253 1253 CP1253
|
|
||||||
cp1254 windows-1254 1254 CP1254
|
|
||||||
cp1255 windows-1255 1255 CP1255
|
|
||||||
cp1256 windows-1256 1256 CP1256
|
|
||||||
cp1257 windows-1257 1257 CP1257
|
|
||||||
cp1258 windows-1258 1258 CP1258
|
|
||||||
euc_jp eucjp, ujis, u-jis 20932 EUC-JP
|
|
||||||
euc_jis_2004 jisx0213, eucjis2004
|
|
||||||
euc_jisx0213 eucjisx0213
|
|
||||||
euc_kr euckr, korean, ksc5601, ks_c-5601, ks_c-5601-1987, ksx1001, ks_x-1001 51949 EUC-KR
|
|
||||||
gb2312 chinese, csiso58gb231280, euc-cn, euccn, eucgb2312-cn, gb2312-1980, gb2312-80, iso-ir-58 936 CP936
|
|
||||||
gbk 936, cp936, ms936 936 GBK
|
|
||||||
gb18030 gb18030-2000 54936 GB18030
|
|
||||||
hz hzgb, hz-gb, hz-gb-2312 52936 HZ
|
|
||||||
iso2022_jp csiso2022jp, iso2022jp, iso-2022-jp 50220 ISO-2022-JP
|
|
||||||
iso2022_jp_1 iso2022jp-1, iso-2022-jp-1 ISO-2022-JP-1
|
|
||||||
iso2022_jp_2 iso2022jp-2, iso-2022-jp-2 ISO-2022-JP-2
|
|
||||||
iso2022_jp_2004 iso2022jp-2004, iso-2022-jp-2004
|
|
||||||
iso2022_jp_3 iso2022jp-3, iso-2022-jp-3
|
|
||||||
iso2022_jp_ext iso2022jp-ext, iso-2022-jp-ext
|
|
||||||
iso2022_kr csiso2022kr, iso2022kr, iso-2022-kr 50225 ISO-2022-KR
|
|
||||||
latin_1 iso-8859-1, iso8859-1, 8859, cp819, latin, latin1, L1 28591 ISO-8859-1
|
|
||||||
iso8859_2 iso-8859-2, latin2, L2 28592 ISO-8859-2
|
|
||||||
iso8859_3 iso-8859-3, latin3, L3 28593 ISO-8859-3
|
|
||||||
iso8859_4 iso-8859-4, latin4, L4 28594 ISO-8859-4
|
|
||||||
iso8859_5 iso-8859-5, cyrillic 28595 ISO-8859-5
|
|
||||||
iso8859_6 iso-8859-6, arabic 28596 ISO-8859-6
|
|
||||||
iso8859_7 iso-8859-7, greek, greek8 28597 ISO-8859-7
|
|
||||||
iso8859_8 iso-8859-8, hebrew 28598 ISO-8859-8
|
|
||||||
iso8859_9 iso-8859-9, latin5, L5 28599 ISO-8859-9
|
|
||||||
iso8859_10 iso-8859-10, latin6, L6 ISO-8859-10
|
|
||||||
iso8859_11 iso-8859-11, thai ISO-8859-11
|
|
||||||
iso8859_13 iso-8859-13, latin7, L7 28603 ISO-8859-13
|
|
||||||
iso8859_14 iso-8859-14, latin8, L8 ISO-8859-14
|
|
||||||
iso8859_15 iso-8859-15, latin9, L9 28605 ISO-8859-15
|
|
||||||
iso8859_16 iso-8859-16, latin10, L10 ISO-8859-16
|
|
||||||
johab cp1361, ms1361 1361 JOHAB
|
|
||||||
koi8_r
|
|
||||||
koi8_t KOI8-T
|
|
||||||
koi8_u
|
|
||||||
kz1048 kz_1048, strk1048_2002, rk1048
|
|
||||||
mac_cyrillic maccyrillic 10007 MacCyrillic
|
|
||||||
mac_greek macgreek 10006 MacGreek
|
|
||||||
mac_iceland maciceland 10079 MacIceland
|
|
||||||
mac_latin2 maclatin2, maccentraleurope, mac_centeuro
|
|
||||||
mac_roman macroman, macintosh MacRoman
|
|
||||||
mac_turkish macturkish 10081 MacTurkish
|
|
||||||
ptcp154 csptcp154, pt154, cp154, cyrillic-asian PT154
|
|
||||||
shift_jis csshiftjis, shiftjis, sjis, s_jis 932 SHIFT_JIS
|
|
||||||
shift_jis_2004 shiftjis2004, sjis_2004, sjis2004
|
|
||||||
shift_jisx0213 shiftjisx0213, sjisx0213, s_jisx0213
|
|
||||||
utf_32 U32, utf32 UTF-32
|
|
||||||
utf_32_be UTF-32BE UTF-32BE
|
|
||||||
utf_32_le UTF-32LE UTF-32LE
|
|
||||||
utf_16 U16, utf16 UTF16
|
|
||||||
utf_16_be UTF-16BE UTF-16BE
|
|
||||||
utf_16_le UTF-16LE UTF-16LE
|
|
||||||
utf_7 U7, unicode-1-1-utf-7 65000 UTF-7
|
|
||||||
utf_8 U8, UTF, utf8, utf-8, cp65001 65001 UTF-8
|
|
||||||
utf_8_sig
|
|
||||||
|
@@ -1,63 +0,0 @@
|
|||||||
import typing
|
|
||||||
import io
|
|
||||||
import os
|
|
||||||
|
|
||||||
class LanguageToken:
|
|
||||||
m_Name: str
|
|
||||||
m_Alias: tuple[str, ...]
|
|
||||||
m_CodePage: str | None
|
|
||||||
m_IconvCode: str | None
|
|
||||||
|
|
||||||
def __init__(self, name: str, alias: typing.Iterator[str], code_page: str, iconv_code: str):
|
|
||||||
self.m_Name = name.lower()
|
|
||||||
self.m_Alias = tuple(map(lambda x: x.lower(), alias))
|
|
||||||
self.m_CodePage = None if code_page == '' else code_page
|
|
||||||
self.m_IconvCode = None if iconv_code == '' else iconv_code
|
|
||||||
|
|
||||||
def extract_data(fs: io.TextIOWrapper) -> tuple[str, ...]:
|
|
||||||
# remove first line to remove table header
|
|
||||||
return fs.readlines()[1:]
|
|
||||||
|
|
||||||
def extract_token(csv_data: tuple[str, ...]) -> tuple[LanguageToken, ...]:
|
|
||||||
ret: list[LanguageToken] = []
|
|
||||||
for line in csv_data:
|
|
||||||
line = line.strip('\n')
|
|
||||||
line_sp = line.split('\t')
|
|
||||||
alias_sp = filter(lambda x: x != '', map(lambda x: x.strip(), line_sp[1].split(',')))
|
|
||||||
ret.append(LanguageToken(line_sp[0], alias_sp, line_sp[2], line_sp[3]))
|
|
||||||
return tuple(ret)
|
|
||||||
|
|
||||||
def write_alias_map(fs: io.TextIOWrapper, data: tuple[LanguageToken, ...]) -> None:
|
|
||||||
fs.write('static const std::map<std::u8string, std::u8string> c_AliasMap {\n')
|
|
||||||
for i in data:
|
|
||||||
for j in i.m_Alias:
|
|
||||||
fs.write(f'\t{{ u8"{j}", u8"{i.m_Name}" }},\n')
|
|
||||||
fs.write('};\n')
|
|
||||||
|
|
||||||
def write_win_cp_map(fs: io.TextIOWrapper, data: tuple[LanguageToken, ...]) -> None:
|
|
||||||
fs.write('static const std::map<std::u8string, UINT> c_WinCPMap {\n')
|
|
||||||
for i in data:
|
|
||||||
if i.m_CodePage is not None:
|
|
||||||
fs.write(f'\t{{ u8"{i.m_Name}", static_cast<UINT>({i.m_CodePage}u) }},\n')
|
|
||||||
fs.write('};\n')
|
|
||||||
|
|
||||||
def write_iconv_map(fs: io.TextIOWrapper, data: tuple[LanguageToken, ...]) -> None:
|
|
||||||
fs.write('static const std::map<std::u8string, std::string> c_IconvMap {\n')
|
|
||||||
for i in data:
|
|
||||||
if i.m_IconvCode is not None:
|
|
||||||
fs.write(f'\t{{ u8"{i.m_Name}", "{i.m_IconvCode}" }},\n')
|
|
||||||
fs.write('};\n')
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
# get file path
|
|
||||||
self_path: str = os.path.dirname(__file__)
|
|
||||||
csv_file: str = os.path.join(self_path, 'EncodingTable.csv')
|
|
||||||
cpp_file: str = os.path.join(self_path, 'EncodingTable.cpp')
|
|
||||||
# process files
|
|
||||||
with open(csv_file, 'r', encoding='utf-8') as fr:
|
|
||||||
with open(cpp_file, 'w', encoding='utf-8') as fw:
|
|
||||||
data = extract_data(fr)
|
|
||||||
token = extract_token(data)
|
|
||||||
write_alias_map(fw, token)
|
|
||||||
write_win_cp_map(fw, token)
|
|
||||||
write_iconv_map(fw, token)
|
|
||||||
2
CodeGen/VectorGen/.gitignore
vendored
2
CodeGen/VectorGen/.gitignore
vendored
@@ -1,2 +0,0 @@
|
|||||||
# Result
|
|
||||||
*.hpp
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
# Vector Generator
|
|
||||||
|
|
||||||
Vector types (LibCmo::Vector3 and etc) and Vector-like types (LibCmo::Color and etc) nearly have similar declaration except slight differences (basically is the count of factors). Manually writing these declarations is boring and easy to cause potential invisible bugs. So we use a Python script to generate these declarations batchly to prevent any defects indroduced above.
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user