diff --git a/Assets/BMapBindings/BMapSharp/BMapSharp/BMap.cs b/Assets/BMapBindings/BMapSharp/BMapSharp/BMap.cs index b80f62e..01e7e63 100644 --- a/Assets/BMapBindings/BMapSharp/BMapSharp/BMap.cs +++ b/Assets/BMapBindings/BMapSharp/BMapSharp/BMap.cs @@ -1,293 +1,26 @@ using System; using System.Runtime.InteropServices; using System.Text; +using BMapSharp.BMapMarshalers; using BMapSharp.VirtoolsTypes; namespace BMapSharp { - /// BMapSharp module specific exception. - public class BMapException : Exception { - public BMapException() {} - public BMapException(string message) - : base(message) {} - public BMapException(string message, Exception inner) - : base(message, inner) {} - public static void ThrowIfFailed(bool condition) { - if (!condition) throw new BMapException("BMap operation failed."); - } - } - public static class BMap { - #region Custom Marshalers - - // References: - // https://stackoverflow.com/questions/18498452/how-do-i-write-a-custom-marshaler-which-allows-data-to-flow-from-native-to-manag - // https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-runtime-interopservices-icustommarshaler - // - // NOTE: I do not create a member to store the object we are marshaling. - // Because my binding do not have In, Out parameter. All parameters are In OR Out. - // So there is no reason to keep that member. - - // IDK why Microsoft try to call ICustomMarshaler.CleanUpNativeData without calling ICustomMarshaler.MarshalManagedToNative. - // It is trying to free the pointer managed by LibCmo self (for example, it will try to free we got string when getting object name)! - // So as the compromise, we use "cookie" feature to explicit specify the marshaler In/Out behavior when getting it. - [Flags] - internal enum MarshalerType { - None = 0b0, - In = 0b1, - Out = 0b10 - } - - /// The custom marshaler for BMap string array. - public class BMStringArrayMarshaler : ICustomMarshaler { - private static readonly BMStringArrayMarshaler g_InInstance = new BMStringArrayMarshaler(MarshalerType.In); - private static readonly BMStringArrayMarshaler g_OutInstance = new BMStringArrayMarshaler(MarshalerType.Out); - public static ICustomMarshaler GetInstance(string pstrCookie) { - if (pstrCookie == "In") return g_InInstance; - else if (pstrCookie == "Out") return g_OutInstance; - else throw new MarshalDirectiveException("Not supported cookie string for BMStringArrayMarshaler."); - } - - private readonly MarshalerType m_MarshalerType; - private BMStringArrayMarshaler(MarshalerType marshaler_type) { - m_MarshalerType = marshaler_type; - } - - // For respecting the standard of BMap, - // the native memory we created is a simple array and each item is a pointer to a NULL-terminated UTF8 string. - // Please note the array self is also NULL-terminated otherwise we don't know its length. - - public IntPtr MarshalManagedToNative(object ManagedObj) { - // Check marshaler type - if (!m_MarshalerType.HasFlag(MarshalerType.In)) return IntPtr.Zero; - // Check nullptr object. - if (ManagedObj is null) return IntPtr.Zero; - // Check argument type. - string[] castManagedObj = ManagedObj as string[]; - if (castManagedObj is null) - throw new MarshalDirectiveException("BMStringArrayMashaler must be used on an string array."); - - // Allocate string items first - int szArrayItemCount = castManagedObj.Length; - int szArrayItemSize = Marshal.SizeOf(); - IntPtr[] apString = new IntPtr[szArrayItemCount]; - for (int i = 0; i < szArrayItemCount; ++i) { - // Check null string - string stringObj = castManagedObj[i]; - if (stringObj is null) apString[i] = IntPtr.Zero; - else apString[i] = BMStringMarshaler.ToNative(stringObj); - } - - // Allocate array pointer now. - IntPtr pArray = Marshal.AllocHGlobal(szArrayItemSize * (szArrayItemCount + 1)); - // Copy string pointer data - Marshal.Copy(apString, 0, pArray, szArrayItemCount); - // Setup NULL ternimal - Marshal.WriteIntPtr(pArray + (szArrayItemSize * szArrayItemCount), IntPtr.Zero); - - // Return value - return pArray; - } - - public object MarshalNativeToManaged(IntPtr pNativeData) { - // Check marshaler type - if (!m_MarshalerType.HasFlag(MarshalerType.Out)) return null; - // Check nullptr - if (pNativeData == IntPtr.Zero) return null; - - // Get the length of array - int szArrayItemCount = BMStringArrayMarshaler.GetArrayLength(pNativeData); - int szArrayItemSize = Marshal.SizeOf(); - // Prepare array cache and read it. - IntPtr[] apString = new IntPtr[szArrayItemCount]; - Marshal.Copy(pNativeData, apString, 0, szArrayItemCount); - - // Iterate the array and process each string one by one. - string[] ret = new string[szArrayItemCount]; - for (int i = 0; i < szArrayItemCount; ++i) { - // Get string pointer - IntPtr pString = apString[i]; - if (pString == IntPtr.Zero) { - ret[i] = null; - continue; - } - // Extract string - ret[i] = BMStringMarshaler.ToManaged(pString); - } - - // Return result - return ret; - } - - public void CleanUpNativeData(IntPtr pNativeData) { - // Check marshaler type - if (!m_MarshalerType.HasFlag(MarshalerType.In)) return; - // Check nullptr - if (pNativeData == IntPtr.Zero) return; - - // Get the length of array - int szArrayItemCount = BMStringArrayMarshaler.GetArrayLength(pNativeData); - int szArrayItemSize = Marshal.SizeOf(); - // Prepare array cache and read it. - IntPtr[] apString = new IntPtr[szArrayItemCount]; - Marshal.Copy(pNativeData, apString, 0, szArrayItemCount); - // Free array self - Marshal.FreeHGlobal(pNativeData); - - // Iterate the string pointer array and free them one by one. - foreach (IntPtr pString in apString) { - // Free string pointer - if (pString == IntPtr.Zero) continue; - Marshal.FreeHGlobal(pString); - } - } - - public void CleanUpManagedData(object ManagedObj) { - // Do nothing, because managed data do not need any clean up. - } - - public int GetNativeDataSize() { - // Return -1 to indicate the managed type this marshaler handles is not a value type. - return -1; - } - - /// - /// Return the length of array created by this marshaler. - /// - /// The pointer to array for checking. - /// The length of array (NULL terminal exclusive). - internal static int GetArrayLength(IntPtr ptr) { - int count = 0, unit = Marshal.SizeOf(); - while (Marshal.ReadIntPtr(ptr) != IntPtr.Zero) { - ptr += unit; - ++count; - } - return count; - } - } - - public class BMStringMarshaler : ICustomMarshaler { - private static readonly BMStringMarshaler g_InInstance = new BMStringMarshaler(MarshalerType.In); - private static readonly BMStringMarshaler g_OutInstance = new BMStringMarshaler(MarshalerType.Out); - public static ICustomMarshaler GetInstance(string pstrCookie) { - if (pstrCookie == "In") return g_InInstance; - else if (pstrCookie == "Out") return g_OutInstance; - else throw new MarshalDirectiveException("Not supported cookie string for BMStringMarshaler."); - } - - private readonly MarshalerType m_MarshalerType; - private BMStringMarshaler(MarshalerType marshaler_type) { - m_MarshalerType = marshaler_type; - } - - public IntPtr MarshalManagedToNative(object ManagedObj) { - // Check marshaler type - if (!m_MarshalerType.HasFlag(MarshalerType.In)) return IntPtr.Zero; - // Check requirements. - if (ManagedObj is null) return IntPtr.Zero; - string castManagedObj = ManagedObj as string; - if (castManagedObj is null) - throw new MarshalDirectiveException("BMStringMarshaler must be used on a string."); - // Call self - return BMStringMarshaler.ToNative(castManagedObj); - } - - public object MarshalNativeToManaged(IntPtr pNativeData) { - // Check marshaler type - if (!m_MarshalerType.HasFlag(MarshalerType.Out)) return null; - // Check nullptr - if (pNativeData == IntPtr.Zero) return null; - // Call self - return BMStringMarshaler.ToManaged(pNativeData); - } - - public void CleanUpNativeData(IntPtr pNativeData) { - // Check marshaler type - if (!m_MarshalerType.HasFlag(MarshalerType.In)) return; - // Check nullptr - if (pNativeData == IntPtr.Zero) return; - // Free native pointer - Marshal.FreeHGlobal(pNativeData); - } - - public void CleanUpManagedData(object ManagedObj) { - // Do nothing, because managed data do not need any clean up. - } - - public int GetNativeDataSize() { - // Return -1 to indicate the managed type this marshaler handles is not a value type. - return -1; - } - - /// - /// Return the length in byte of given pointer represented C style string. - /// - /// The pointer for checking. - /// The length of C style string (NUL exclusive). - internal static int GetCStringLength(IntPtr ptr) { - int count = 0, unit = Marshal.SizeOf(); - while (Marshal.ReadByte(ptr) != (byte)0) { - ptr += unit; - ++count; - } - return count; - } - - /// - /// Convert given string object to native data. - /// This function is shared by 2 marshalers. - /// - /// String object. Caller must make sure this object is not null. - /// The created native data pointer. - internal static IntPtr ToNative(string obj) { - // Encode string first - byte[] encString = Encoding.UTF8.GetBytes(obj); - // Allocate string memory with extra NUL. - int szStringItemCount = encString.Length; - int szStringItemSize = Marshal.SizeOf(); - IntPtr pString = Marshal.AllocHGlobal(szStringItemSize * (szStringItemCount + 1)); - // Copy encoded string data - Marshal.Copy(encString, 0, pString, szStringItemCount); - // Setup NUL - Marshal.WriteByte(pString + (szStringItemSize * szStringItemCount), (byte)0); - // Return value - return pString; - } - /// - /// Extract managed string from given native pointer holding C style string data. - /// This function is shared by 2 marshalers. - /// - /// Native pointer holding string data. Caller must make sure this pointer is not nullptr. - /// The extracted managed string data. - internal static string ToManaged(IntPtr ptr) { - // Get the length of given string. - int szStringItemCount = BMStringMarshaler.GetCStringLength(ptr); - int szStringItemSize = Marshal.SizeOf(); - // Prepare cache and copy string data - byte[] encString = new byte[szStringItemCount]; - Marshal.Copy(ptr, encString, 0, szStringItemCount); - // Decode string and return - return Encoding.UTF8.GetString(encString); - } - } - - #endregion - /// The callback function of BMap. /// The message content need to be printed. internal delegate void OutputCallback([In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(BMStringMarshaler))] string msg); // Decide the file name of loaded DLL. - #if BMAP_OS_WINDOWS - private const string g_DllName = "BMap.dll"; + private const string DLL_NAME = "BMap.dll"; #elif BMAP_OS_LINUX - private const string g_DllName = "BMap.so"; + private const string DLL_NAME = "BMap.so"; #elif BMAP_OS_MACOS - private const string g_DllName = "BMap.dylib"; + private const string DLL_NAME = "BMap.dylib"; #else - private const string g_DllName = "BMap.bin"; + private const string DLL_NAME = "BMap.bin"; #endif #region Function Defines @@ -296,12 +29,12 @@ namespace BMapSharp { /// BMInit /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMInit", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMInit", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMInit(); /// BMDispose /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMDispose", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMDispose", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMDispose(); /// BMFile_Load @@ -313,7 +46,7 @@ namespace BMapSharp { /// Type: LibCmo::CKSTRING*. /// Type: BMap::BMFile*. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_Load", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMFile_Load", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMFile_Load([In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(BMStringMarshaler), MarshalCookie = "In")] string file_name, [In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(BMStringMarshaler), MarshalCookie = "In")] string temp_folder, [In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(BMStringMarshaler), MarshalCookie = "In")] string texture_folder, [In, MarshalAs(UnmanagedType.FunctionPtr)] OutputCallback raw_callback, [In, MarshalAs(UnmanagedType.U4)] uint encoding_count, [In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(BMStringArrayMarshaler), MarshalCookie = "In")] string[] encodings, [Out, MarshalAs(UnmanagedType.SysInt)] out IntPtr out_file); /// BMFile_Create @@ -324,7 +57,7 @@ namespace BMapSharp { /// Type: LibCmo::CKSTRING*. /// Type: BMap::BMFile*. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_Create", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMFile_Create", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMFile_Create([In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(BMStringMarshaler), MarshalCookie = "In")] string temp_folder, [In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(BMStringMarshaler), MarshalCookie = "In")] string texture_folder, [In, MarshalAs(UnmanagedType.FunctionPtr)] OutputCallback raw_callback, [In, MarshalAs(UnmanagedType.U4)] uint encoding_count, [In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(BMStringArrayMarshaler), MarshalCookie = "In")] string[] encodings, [Out, MarshalAs(UnmanagedType.SysInt)] out IntPtr out_file); /// BMFile_Save @@ -334,20 +67,20 @@ namespace BMapSharp { /// Type: bool. /// Type: LibCmo::CKINT. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_Save", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMFile_Save", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMFile_Save([In, MarshalAs(UnmanagedType.SysInt)] IntPtr map_file, [In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(BMStringMarshaler), MarshalCookie = "In")] string file_name, [In, MarshalAs(UnmanagedType.U4)] CK_TEXTURE_SAVEOPTIONS texture_save_opt, [In, MarshalAs(UnmanagedType.U1)] bool use_compress, [In, MarshalAs(UnmanagedType.I4)] int compreess_level); /// BMFile_Free /// Type: BMap::BMFile*. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_Free", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMFile_Free", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMFile_Free([In, MarshalAs(UnmanagedType.SysInt)] IntPtr map_file); /// BMFile_GetGroupCount /// Type: BMap::BMFile*. The pointer to corresponding BMFile. /// Type: LibCmo::CKDWORD. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_GetGroupCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMFile_GetGroupCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMFile_GetGroupCount([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [Out, MarshalAs(UnmanagedType.U4)] out uint out_count); /// BMFile_GetGroup @@ -355,21 +88,21 @@ namespace BMapSharp { /// Type: LibCmo::CKDWORD. /// Type: LibCmo::CK2::CK_ID. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_GetGroup", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMFile_GetGroup", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMFile_GetGroup([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint idx, [Out, MarshalAs(UnmanagedType.U4)] out uint out_id); /// BMFile_CreateGroup /// Type: BMap::BMFile*. The pointer to corresponding BMFile. /// Type: LibCmo::CK2::CK_ID. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_CreateGroup", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMFile_CreateGroup", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMFile_CreateGroup([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [Out, MarshalAs(UnmanagedType.U4)] out uint out_id); /// BMFile_Get3dObjectCount /// Type: BMap::BMFile*. The pointer to corresponding BMFile. /// Type: LibCmo::CKDWORD. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_Get3dObjectCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMFile_Get3dObjectCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMFile_Get3dObjectCount([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [Out, MarshalAs(UnmanagedType.U4)] out uint out_count); /// BMFile_Get3dObject @@ -377,21 +110,21 @@ namespace BMapSharp { /// Type: LibCmo::CKDWORD. /// Type: LibCmo::CK2::CK_ID. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_Get3dObject", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMFile_Get3dObject", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMFile_Get3dObject([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint idx, [Out, MarshalAs(UnmanagedType.U4)] out uint out_id); /// BMFile_Create3dObject /// Type: BMap::BMFile*. The pointer to corresponding BMFile. /// Type: LibCmo::CK2::CK_ID. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_Create3dObject", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMFile_Create3dObject", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMFile_Create3dObject([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [Out, MarshalAs(UnmanagedType.U4)] out uint out_id); /// BMFile_GetMeshCount /// Type: BMap::BMFile*. The pointer to corresponding BMFile. /// Type: LibCmo::CKDWORD. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_GetMeshCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMFile_GetMeshCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMFile_GetMeshCount([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [Out, MarshalAs(UnmanagedType.U4)] out uint out_count); /// BMFile_GetMesh @@ -399,21 +132,21 @@ namespace BMapSharp { /// Type: LibCmo::CKDWORD. /// Type: LibCmo::CK2::CK_ID. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_GetMesh", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMFile_GetMesh", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMFile_GetMesh([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint idx, [Out, MarshalAs(UnmanagedType.U4)] out uint out_id); /// BMFile_CreateMesh /// Type: BMap::BMFile*. The pointer to corresponding BMFile. /// Type: LibCmo::CK2::CK_ID. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_CreateMesh", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMFile_CreateMesh", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMFile_CreateMesh([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [Out, MarshalAs(UnmanagedType.U4)] out uint out_id); /// BMFile_GetMaterialCount /// Type: BMap::BMFile*. The pointer to corresponding BMFile. /// Type: LibCmo::CKDWORD. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_GetMaterialCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMFile_GetMaterialCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMFile_GetMaterialCount([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [Out, MarshalAs(UnmanagedType.U4)] out uint out_count); /// BMFile_GetMaterial @@ -421,21 +154,21 @@ namespace BMapSharp { /// Type: LibCmo::CKDWORD. /// Type: LibCmo::CK2::CK_ID. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_GetMaterial", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMFile_GetMaterial", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMFile_GetMaterial([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint idx, [Out, MarshalAs(UnmanagedType.U4)] out uint out_id); /// BMFile_CreateMaterial /// Type: BMap::BMFile*. The pointer to corresponding BMFile. /// Type: LibCmo::CK2::CK_ID. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_CreateMaterial", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMFile_CreateMaterial", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMFile_CreateMaterial([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [Out, MarshalAs(UnmanagedType.U4)] out uint out_id); /// BMFile_GetTextureCount /// Type: BMap::BMFile*. The pointer to corresponding BMFile. /// Type: LibCmo::CKDWORD. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_GetTextureCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMFile_GetTextureCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMFile_GetTextureCount([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [Out, MarshalAs(UnmanagedType.U4)] out uint out_count); /// BMFile_GetTexture @@ -443,21 +176,21 @@ namespace BMapSharp { /// Type: LibCmo::CKDWORD. /// Type: LibCmo::CK2::CK_ID. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_GetTexture", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMFile_GetTexture", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMFile_GetTexture([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint idx, [Out, MarshalAs(UnmanagedType.U4)] out uint out_id); /// BMFile_CreateTexture /// Type: BMap::BMFile*. The pointer to corresponding BMFile. /// Type: LibCmo::CK2::CK_ID. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_CreateTexture", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMFile_CreateTexture", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMFile_CreateTexture([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [Out, MarshalAs(UnmanagedType.U4)] out uint out_id); /// BMFile_GetTargetLightCount /// Type: BMap::BMFile*. The pointer to corresponding BMFile. /// Type: LibCmo::CKDWORD. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_GetTargetLightCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); /// BMFile_GetTargetLight @@ -465,117 +198,117 @@ namespace BMapSharp { /// Type: LibCmo::CKDWORD. /// Type: LibCmo::CK2::CK_ID. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_GetTargetLight", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); /// BMFile_CreateTargetLight /// Type: BMap::BMFile*. The pointer to corresponding BMFile. /// Type: LibCmo::CK2::CK_ID. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMFile_CreateTargetLight", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); /// BMMeshTrans_New /// Type: BMap::BMMeshTransition*. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMeshTrans_New", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMeshTrans_New", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMeshTrans_New([Out, MarshalAs(UnmanagedType.SysInt)] out IntPtr out_trans); /// BMMeshTrans_Delete /// Type: BMap::BMMeshTransition*. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMeshTrans_Delete", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMeshTrans_Delete", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMeshTrans_Delete([In, MarshalAs(UnmanagedType.SysInt)] IntPtr trans); /// BMMeshTrans_PrepareVertexCount /// Type: BMap::BMMeshTransition*. The pointer to corresponding BMMeshTransition. /// Type: LibCmo::CKDWORD. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMeshTrans_PrepareVertexCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMeshTrans_PrepareVertexCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMeshTrans_PrepareVertexCount([In, MarshalAs(UnmanagedType.SysInt)] IntPtr trans, [In, MarshalAs(UnmanagedType.U4)] uint count); /// BMMeshTrans_PrepareVertex /// Type: BMap::BMMeshTransition*. The pointer to corresponding BMMeshTransition. /// Type: LibCmo::VxMath::VxVector3*. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMeshTrans_PrepareVertex", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMeshTrans_PrepareVertex", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMeshTrans_PrepareVertex([In, MarshalAs(UnmanagedType.SysInt)] IntPtr trans, [Out, MarshalAs(UnmanagedType.SysInt)] out IntPtr out_mem); /// BMMeshTrans_PrepareNormalCount /// Type: BMap::BMMeshTransition*. The pointer to corresponding BMMeshTransition. /// Type: LibCmo::CKDWORD. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMeshTrans_PrepareNormalCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMeshTrans_PrepareNormalCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMeshTrans_PrepareNormalCount([In, MarshalAs(UnmanagedType.SysInt)] IntPtr trans, [In, MarshalAs(UnmanagedType.U4)] uint count); /// BMMeshTrans_PrepareNormal /// Type: BMap::BMMeshTransition*. The pointer to corresponding BMMeshTransition. /// Type: LibCmo::VxMath::VxVector3*. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMeshTrans_PrepareNormal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMeshTrans_PrepareNormal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMeshTrans_PrepareNormal([In, MarshalAs(UnmanagedType.SysInt)] IntPtr trans, [Out, MarshalAs(UnmanagedType.SysInt)] out IntPtr out_mem); /// BMMeshTrans_PrepareUVCount /// Type: BMap::BMMeshTransition*. The pointer to corresponding BMMeshTransition. /// Type: LibCmo::CKDWORD. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMeshTrans_PrepareUVCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMeshTrans_PrepareUVCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMeshTrans_PrepareUVCount([In, MarshalAs(UnmanagedType.SysInt)] IntPtr trans, [In, MarshalAs(UnmanagedType.U4)] uint count); /// BMMeshTrans_PrepareUV /// Type: BMap::BMMeshTransition*. The pointer to corresponding BMMeshTransition. /// Type: LibCmo::VxMath::VxVector2*. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMeshTrans_PrepareUV", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMeshTrans_PrepareUV", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMeshTrans_PrepareUV([In, MarshalAs(UnmanagedType.SysInt)] IntPtr trans, [Out, MarshalAs(UnmanagedType.SysInt)] out IntPtr out_mem); /// BMMeshTrans_PrepareMtlSlotCount /// Type: BMap::BMMeshTransition*. The pointer to corresponding BMMeshTransition. /// Type: LibCmo::CKDWORD. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMeshTrans_PrepareMtlSlotCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMeshTrans_PrepareMtlSlotCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMeshTrans_PrepareMtlSlotCount([In, MarshalAs(UnmanagedType.SysInt)] IntPtr trans, [In, MarshalAs(UnmanagedType.U4)] uint count); /// BMMeshTrans_PrepareMtlSlot /// Type: BMap::BMMeshTransition*. The pointer to corresponding BMMeshTransition. /// Type: LibCmo::CK2::CK_ID*. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMeshTrans_PrepareMtlSlot", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMeshTrans_PrepareMtlSlot", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMeshTrans_PrepareMtlSlot([In, MarshalAs(UnmanagedType.SysInt)] IntPtr trans, [Out, MarshalAs(UnmanagedType.SysInt)] out IntPtr out_mem); /// BMMeshTrans_PrepareFaceCount /// Type: BMap::BMMeshTransition*. The pointer to corresponding BMMeshTransition. /// Type: LibCmo::CKDWORD. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMeshTrans_PrepareFaceCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMeshTrans_PrepareFaceCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMeshTrans_PrepareFaceCount([In, MarshalAs(UnmanagedType.SysInt)] IntPtr trans, [In, MarshalAs(UnmanagedType.U4)] uint count); /// BMMeshTrans_PrepareFaceVertexIndices /// Type: BMap::BMMeshTransition*. The pointer to corresponding BMMeshTransition. /// Type: LibCmo::CKDWORD*. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMeshTrans_PrepareFaceVertexIndices", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMeshTrans_PrepareFaceVertexIndices", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMeshTrans_PrepareFaceVertexIndices([In, MarshalAs(UnmanagedType.SysInt)] IntPtr trans, [Out, MarshalAs(UnmanagedType.SysInt)] out IntPtr out_mem); /// BMMeshTrans_PrepareFaceNormalIndices /// Type: BMap::BMMeshTransition*. The pointer to corresponding BMMeshTransition. /// Type: LibCmo::CKDWORD*. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMeshTrans_PrepareFaceNormalIndices", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMeshTrans_PrepareFaceNormalIndices", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMeshTrans_PrepareFaceNormalIndices([In, MarshalAs(UnmanagedType.SysInt)] IntPtr trans, [Out, MarshalAs(UnmanagedType.SysInt)] out IntPtr out_mem); /// BMMeshTrans_PrepareFaceUVIndices /// Type: BMap::BMMeshTransition*. The pointer to corresponding BMMeshTransition. /// Type: LibCmo::CKDWORD*. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMeshTrans_PrepareFaceUVIndices", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMeshTrans_PrepareFaceUVIndices", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMeshTrans_PrepareFaceUVIndices([In, MarshalAs(UnmanagedType.SysInt)] IntPtr trans, [Out, MarshalAs(UnmanagedType.SysInt)] out IntPtr out_mem); /// BMMeshTrans_PrepareFaceMtlSlot /// Type: BMap::BMMeshTransition*. The pointer to corresponding BMMeshTransition. /// Type: LibCmo::CKDWORD*. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMeshTrans_PrepareFaceMtlSlot", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMeshTrans_PrepareFaceMtlSlot", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMeshTrans_PrepareFaceMtlSlot([In, MarshalAs(UnmanagedType.SysInt)] IntPtr trans, [Out, MarshalAs(UnmanagedType.SysInt)] out IntPtr out_mem); /// BMMeshTrans_Parse @@ -583,7 +316,7 @@ namespace BMapSharp { /// Type: BMap::BMFile*. /// Type: LibCmo::CK2::CK_ID. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMeshTrans_Parse", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMeshTrans_Parse", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMeshTrans_Parse([In, MarshalAs(UnmanagedType.SysInt)] IntPtr trans, [In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid); /// BMObject_GetName @@ -591,7 +324,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKSTRING. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMObject_GetName", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMObject_GetName", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMObject_GetName([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(BMStringMarshaler), MarshalCookie = "Out")] out string out_name); /// BMObject_SetName @@ -599,7 +332,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKSTRING. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMObject_SetName", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMObject_SetName", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMObject_SetName([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(BMStringMarshaler), MarshalCookie = "In")] string name); /// BMGroup_AddObject @@ -607,7 +340,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CK2::CK_ID. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMGroup_AddObject", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMGroup_AddObject", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMGroup_AddObject([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] uint memberid); /// BMGroup_GetObjectCount @@ -615,7 +348,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKDWORD. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMGroup_GetObjectCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMGroup_GetObjectCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMGroup_GetObjectCount([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out uint out_count); /// BMGroup_GetObject @@ -624,7 +357,7 @@ namespace BMapSharp { /// Type: LibCmo::CKDWORD. /// Type: LibCmo::CK2::CK_ID. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMGroup_GetObject", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMGroup_GetObject", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMGroup_GetObject([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] uint pos, [Out, MarshalAs(UnmanagedType.U4)] out uint out_objid); /// BMTexture_GetFileName @@ -632,7 +365,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKSTRING. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMTexture_GetFileName", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMTexture_GetFileName", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMTexture_GetFileName([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(BMStringMarshaler), MarshalCookie = "Out")] out string out_filename); /// BMTexture_LoadImage @@ -640,7 +373,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKSTRING. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMTexture_LoadImage", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMTexture_LoadImage", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMTexture_LoadImage([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(BMStringMarshaler), MarshalCookie = "In")] string filename); /// BMTexture_SaveImage @@ -648,7 +381,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKSTRING. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMTexture_SaveImage", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMTexture_SaveImage", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMTexture_SaveImage([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(BMStringMarshaler), MarshalCookie = "In")] string filename); /// BMTexture_GetSaveOptions @@ -656,7 +389,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMTexture_GetSaveOptions", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMTexture_GetSaveOptions", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMTexture_GetSaveOptions([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out CK_TEXTURE_SAVEOPTIONS out_saveopt); /// BMTexture_SetSaveOptions @@ -664,7 +397,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CK2::CK_TEXTURE_SAVEOPTIONS. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMTexture_SetSaveOptions", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMTexture_SetSaveOptions", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMTexture_SetSaveOptions([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] CK_TEXTURE_SAVEOPTIONS saveopt); /// BMTexture_GetVideoFormat @@ -672,7 +405,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VX_PIXELFORMAT. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMTexture_GetVideoFormat", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMTexture_GetVideoFormat", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMTexture_GetVideoFormat([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out VX_PIXELFORMAT out_vfmt); /// BMTexture_SetVideoFormat @@ -680,7 +413,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VX_PIXELFORMAT. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMTexture_SetVideoFormat", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMTexture_SetVideoFormat", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMTexture_SetVideoFormat([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] VX_PIXELFORMAT vfmt); /// BMMaterial_GetDiffuse @@ -688,7 +421,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VxColor. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetDiffuse", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetDiffuse", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetDiffuse([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.Struct)] out VxColor out_val); /// BMMaterial_SetDiffuse @@ -696,7 +429,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VxColor. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetDiffuse", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetDiffuse", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetDiffuse([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.Struct)] VxColor col); /// BMMaterial_GetAmbient @@ -704,7 +437,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VxColor. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetAmbient", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetAmbient", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetAmbient([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.Struct)] out VxColor out_val); /// BMMaterial_SetAmbient @@ -712,7 +445,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VxColor. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetAmbient", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetAmbient", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetAmbient([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.Struct)] VxColor col); /// BMMaterial_GetSpecular @@ -720,7 +453,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VxColor. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetSpecular", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetSpecular", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetSpecular([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.Struct)] out VxColor out_val); /// BMMaterial_SetSpecular @@ -728,7 +461,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VxColor. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetSpecular", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetSpecular", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetSpecular([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.Struct)] VxColor col); /// BMMaterial_GetEmissive @@ -736,7 +469,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VxColor. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetEmissive", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetEmissive", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetEmissive([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.Struct)] out VxColor out_val); /// BMMaterial_SetEmissive @@ -744,7 +477,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VxColor. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetEmissive", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetEmissive", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetEmissive([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.Struct)] VxColor col); /// BMMaterial_GetSpecularPower @@ -752,7 +485,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKFLOAT. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetSpecularPower", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetSpecularPower", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetSpecularPower([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.R4)] out float out_val); /// BMMaterial_SetSpecularPower @@ -760,7 +493,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKFLOAT. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetSpecularPower", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetSpecularPower", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetSpecularPower([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.R4)] float val); /// BMMaterial_GetTexture @@ -768,7 +501,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CK2::CK_ID. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetTexture", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetTexture", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetTexture([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out uint out_texid); /// BMMaterial_SetTexture @@ -776,7 +509,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CK2::CK_ID. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetTexture", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetTexture", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetTexture([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] uint texid); /// BMMaterial_GetTextureBorderColor @@ -784,7 +517,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKDWORD. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetTextureBorderColor", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetTextureBorderColor", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetTextureBorderColor([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out uint out_val); /// BMMaterial_SetTextureBorderColor @@ -792,7 +525,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKDWORD. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetTextureBorderColor", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetTextureBorderColor", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetTextureBorderColor([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] uint val); /// BMMaterial_GetTextureBlendMode @@ -800,7 +533,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXTEXTURE_BLENDMODE. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetTextureBlendMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetTextureBlendMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetTextureBlendMode([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out VXTEXTURE_BLENDMODE out_val); /// BMMaterial_SetTextureBlendMode @@ -808,7 +541,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXTEXTURE_BLENDMODE. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetTextureBlendMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetTextureBlendMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetTextureBlendMode([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] VXTEXTURE_BLENDMODE val); /// BMMaterial_GetTextureMinMode @@ -816,7 +549,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXTEXTURE_FILTERMODE. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetTextureMinMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetTextureMinMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetTextureMinMode([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out VXTEXTURE_FILTERMODE out_val); /// BMMaterial_SetTextureMinMode @@ -824,7 +557,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXTEXTURE_FILTERMODE. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetTextureMinMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetTextureMinMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetTextureMinMode([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] VXTEXTURE_FILTERMODE val); /// BMMaterial_GetTextureMagMode @@ -832,7 +565,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXTEXTURE_FILTERMODE. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetTextureMagMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetTextureMagMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetTextureMagMode([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out VXTEXTURE_FILTERMODE out_val); /// BMMaterial_SetTextureMagMode @@ -840,7 +573,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXTEXTURE_FILTERMODE. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetTextureMagMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetTextureMagMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetTextureMagMode([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] VXTEXTURE_FILTERMODE val); /// BMMaterial_GetTextureAddressMode @@ -848,7 +581,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXTEXTURE_ADDRESSMODE. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetTextureAddressMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetTextureAddressMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetTextureAddressMode([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out VXTEXTURE_ADDRESSMODE out_val); /// BMMaterial_SetTextureAddressMode @@ -856,7 +589,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXTEXTURE_ADDRESSMODE. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetTextureAddressMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetTextureAddressMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetTextureAddressMode([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] VXTEXTURE_ADDRESSMODE val); /// BMMaterial_GetSourceBlend @@ -864,7 +597,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXBLEND_MODE. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetSourceBlend", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetSourceBlend", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetSourceBlend([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out VXBLEND_MODE out_val); /// BMMaterial_SetSourceBlend @@ -872,7 +605,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXBLEND_MODE. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetSourceBlend", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetSourceBlend", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetSourceBlend([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] VXBLEND_MODE val); /// BMMaterial_GetDestBlend @@ -880,7 +613,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXBLEND_MODE. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetDestBlend", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetDestBlend", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetDestBlend([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out VXBLEND_MODE out_val); /// BMMaterial_SetDestBlend @@ -888,7 +621,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXBLEND_MODE. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetDestBlend", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetDestBlend", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetDestBlend([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] VXBLEND_MODE val); /// BMMaterial_GetFillMode @@ -896,7 +629,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXFILL_MODE. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetFillMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetFillMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetFillMode([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out VXFILL_MODE out_val); /// BMMaterial_SetFillMode @@ -904,7 +637,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXFILL_MODE. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetFillMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetFillMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetFillMode([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] VXFILL_MODE val); /// BMMaterial_GetShadeMode @@ -912,7 +645,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXSHADE_MODE. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetShadeMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetShadeMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetShadeMode([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out VXSHADE_MODE out_val); /// BMMaterial_SetShadeMode @@ -920,7 +653,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXSHADE_MODE. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetShadeMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetShadeMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetShadeMode([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] VXSHADE_MODE val); /// BMMaterial_GetAlphaTestEnabled @@ -928,7 +661,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: bool. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetAlphaTestEnabled", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetAlphaTestEnabled", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetAlphaTestEnabled([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U1)] out bool out_val); /// BMMaterial_SetAlphaTestEnabled @@ -936,7 +669,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: bool. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetAlphaTestEnabled", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetAlphaTestEnabled", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetAlphaTestEnabled([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U1)] bool enabled); /// BMMaterial_GetAlphaBlendEnabled @@ -944,7 +677,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: bool. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetAlphaBlendEnabled", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetAlphaBlendEnabled", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetAlphaBlendEnabled([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U1)] out bool out_val); /// BMMaterial_SetAlphaBlendEnabled @@ -952,7 +685,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: bool. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetAlphaBlendEnabled", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetAlphaBlendEnabled", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetAlphaBlendEnabled([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U1)] bool enabled); /// BMMaterial_GetPerspectiveCorrectionEnabled @@ -960,7 +693,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: bool. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetPerspectiveCorrectionEnabled", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetPerspectiveCorrectionEnabled", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetPerspectiveCorrectionEnabled([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U1)] out bool out_val); /// BMMaterial_SetPerspectiveCorrectionEnabled @@ -968,7 +701,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: bool. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetPerspectiveCorrectionEnabled", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetPerspectiveCorrectionEnabled", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetPerspectiveCorrectionEnabled([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U1)] bool enabled); /// BMMaterial_GetZWriteEnabled @@ -976,7 +709,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: bool. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetZWriteEnabled", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetZWriteEnabled", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetZWriteEnabled([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U1)] out bool out_val); /// BMMaterial_SetZWriteEnabled @@ -984,7 +717,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: bool. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetZWriteEnabled", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetZWriteEnabled", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetZWriteEnabled([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U1)] bool enabled); /// BMMaterial_GetTwoSidedEnabled @@ -992,7 +725,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: bool. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetTwoSidedEnabled", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetTwoSidedEnabled", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetTwoSidedEnabled([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U1)] out bool out_val); /// BMMaterial_SetTwoSidedEnabled @@ -1000,7 +733,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: bool. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetTwoSidedEnabled", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetTwoSidedEnabled", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetTwoSidedEnabled([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U1)] bool enabled); /// BMMaterial_GetAlphaRef @@ -1008,7 +741,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKBYTE. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetAlphaRef", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetAlphaRef", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetAlphaRef([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U1)] out byte out_val); /// BMMaterial_SetAlphaRef @@ -1016,7 +749,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKBYTE. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetAlphaRef", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetAlphaRef", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetAlphaRef([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U1)] byte val); /// BMMaterial_GetAlphaFunc @@ -1024,7 +757,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXCMPFUNC. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetAlphaFunc", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetAlphaFunc", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetAlphaFunc([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out VXCMPFUNC out_val); /// BMMaterial_SetAlphaFunc @@ -1032,7 +765,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXCMPFUNC. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetAlphaFunc", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetAlphaFunc", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetAlphaFunc([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] VXCMPFUNC val); /// BMMaterial_GetZFunc @@ -1040,7 +773,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXCMPFUNC. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_GetZFunc", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_GetZFunc", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_GetZFunc([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out VXCMPFUNC out_val); /// BMMaterial_SetZFunc @@ -1048,7 +781,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXCMPFUNC. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMaterial_SetZFunc", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMaterial_SetZFunc", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMaterial_SetZFunc([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] VXCMPFUNC val); /// BMMesh_GetLitMode @@ -1056,7 +789,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXMESH_LITMODE. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMesh_GetLitMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMesh_GetLitMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMesh_GetLitMode([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out VXMESH_LITMODE out_mode); /// BMMesh_SetLitMode @@ -1064,7 +797,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXMESH_LITMODE. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMesh_SetLitMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMesh_SetLitMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMesh_SetLitMode([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] VXMESH_LITMODE mode); /// BMMesh_GetVertexCount @@ -1072,7 +805,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKDWORD. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMesh_GetVertexCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMesh_GetVertexCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMesh_GetVertexCount([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out uint out_count); /// BMMesh_SetVertexCount @@ -1080,7 +813,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKDWORD. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMesh_SetVertexCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMesh_SetVertexCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMesh_SetVertexCount([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] uint count); /// BMMesh_GetVertexPositions @@ -1088,7 +821,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VxVector3*. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMesh_GetVertexPositions", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMesh_GetVertexPositions", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMesh_GetVertexPositions([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.SysInt)] out IntPtr out_mem); /// BMMesh_GetVertexNormals @@ -1096,7 +829,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VxVector3*. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMesh_GetVertexNormals", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMesh_GetVertexNormals", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMesh_GetVertexNormals([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.SysInt)] out IntPtr out_mem); /// BMMesh_GetVertexUVs @@ -1104,7 +837,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VxVector2*. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMesh_GetVertexUVs", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMesh_GetVertexUVs", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMesh_GetVertexUVs([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.SysInt)] out IntPtr out_mem); /// BMMesh_GetFaceCount @@ -1112,7 +845,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKDWORD. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMesh_GetFaceCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMesh_GetFaceCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMesh_GetFaceCount([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out uint out_count); /// BMMesh_SetFaceCount @@ -1120,7 +853,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKDWORD. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMesh_SetFaceCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMesh_SetFaceCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMesh_SetFaceCount([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] uint count); /// BMMesh_GetFaceIndices @@ -1128,7 +861,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKWORD*. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMesh_GetFaceIndices", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMesh_GetFaceIndices", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMesh_GetFaceIndices([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.SysInt)] out IntPtr out_mem); /// BMMesh_GetFaceMaterialSlotIndexs @@ -1136,7 +869,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKWORD*. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMesh_GetFaceMaterialSlotIndexs", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMesh_GetFaceMaterialSlotIndexs", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMesh_GetFaceMaterialSlotIndexs([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.SysInt)] out IntPtr out_mem); /// BMMesh_GetMaterialSlotCount @@ -1144,7 +877,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKDWORD. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMesh_GetMaterialSlotCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMesh_GetMaterialSlotCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMesh_GetMaterialSlotCount([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [Out, MarshalAs(UnmanagedType.U4)] out uint out_count); /// BMMesh_SetMaterialSlotCount @@ -1152,7 +885,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKDWORD. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMesh_SetMaterialSlotCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMesh_SetMaterialSlotCount", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMesh_SetMaterialSlotCount([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] uint count); /// BMMesh_GetMaterialSlot @@ -1161,7 +894,7 @@ namespace BMapSharp { /// Type: LibCmo::CKDWORD. /// Type: LibCmo::CK2::CK_ID. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMesh_GetMaterialSlot", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMesh_GetMaterialSlot", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BMMesh_GetMaterialSlot([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] uint index, [Out, MarshalAs(UnmanagedType.U4)] out uint out_mtlid); /// BMMesh_SetMaterialSlot @@ -1170,7 +903,7 @@ namespace BMapSharp { /// Type: LibCmo::CKDWORD. /// Type: LibCmo::CK2::CK_ID. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMMesh_SetMaterialSlot", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BMMesh_SetMaterialSlot", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [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); /// BM3dEntity_GetWorldMatrix @@ -1178,7 +911,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VxMatrix. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BM3dEntity_GetWorldMatrix", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BM3dEntity_GetWorldMatrix", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] 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); /// BM3dEntity_SetWorldMatrix @@ -1186,7 +919,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VxMatrix. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BM3dEntity_SetWorldMatrix", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BM3dEntity_SetWorldMatrix", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BM3dEntity_SetWorldMatrix([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.Struct)] VxMatrix mat); /// BM3dEntity_GetCurrentMesh @@ -1194,7 +927,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CK2::CK_ID. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BM3dEntity_GetCurrentMesh", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BM3dEntity_GetCurrentMesh", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] 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); /// BM3dEntity_SetCurrentMesh @@ -1202,7 +935,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CK2::CK_ID. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BM3dEntity_SetCurrentMesh", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BM3dEntity_SetCurrentMesh", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] internal static extern bool BM3dEntity_SetCurrentMesh([In, MarshalAs(UnmanagedType.SysInt)] IntPtr bmfile, [In, MarshalAs(UnmanagedType.U4)] uint objid, [In, MarshalAs(UnmanagedType.U4)] uint meshid); /// BM3dEntity_GetVisibility @@ -1210,7 +943,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: bool. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BM3dEntity_GetVisibility", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BM3dEntity_GetVisibility", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] 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); /// BM3dEntity_SetVisibility @@ -1218,7 +951,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: bool. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BM3dEntity_SetVisibility", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, EntryPoint = "BM3dEntity_SetVisibility", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] 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); /// BMLight_GetType @@ -1226,7 +959,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXLIGHT_TYPE. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMLight_GetType", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); /// BMLight_SetType @@ -1234,7 +967,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VXLIGHT_TYPE. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMLight_SetType", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); /// BMLight_GetColor @@ -1242,7 +975,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VxColor. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMLight_GetColor", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); /// BMLight_SetColor @@ -1250,7 +983,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::VxMath::VxColor. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMLight_SetColor", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); /// BMLight_GetConstantAttenuation @@ -1258,7 +991,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKFLOAT. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMLight_GetConstantAttenuation", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); /// BMLight_SetConstantAttenuation @@ -1266,7 +999,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKFLOAT. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMLight_SetConstantAttenuation", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); /// BMLight_GetLinearAttenuation @@ -1274,7 +1007,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKFLOAT. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMLight_GetLinearAttenuation", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); /// BMLight_SetLinearAttenuation @@ -1282,7 +1015,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKFLOAT. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMLight_SetLinearAttenuation", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); /// BMLight_GetQuadraticAttenuation @@ -1290,7 +1023,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKFLOAT. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMLight_GetQuadraticAttenuation", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); /// BMLight_SetQuadraticAttenuation @@ -1298,7 +1031,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKFLOAT. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMLight_SetQuadraticAttenuation", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); /// BMLight_GetRange @@ -1306,7 +1039,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKFLOAT. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMLight_GetRange", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); /// BMLight_SetRange @@ -1314,7 +1047,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKFLOAT. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMLight_SetRange", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); /// BMLight_GetHotSpot @@ -1322,7 +1055,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKFLOAT. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMLight_GetHotSpot", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); /// BMLight_SetHotSpot @@ -1330,7 +1063,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKFLOAT. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMLight_SetHotSpot", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); /// BMLight_GetFalloff @@ -1338,7 +1071,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKFLOAT. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMLight_GetFalloff", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); /// BMLight_SetFalloff @@ -1346,7 +1079,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKFLOAT. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMLight_SetFalloff", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); /// BMLight_GetFalloffShape @@ -1354,7 +1087,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKFLOAT. This is OUT parameter. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMLight_GetFalloffShape", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); /// BMLight_SetFalloffShape @@ -1362,7 +1095,7 @@ namespace BMapSharp { /// Type: LibCmo::CK2::CK_ID. The CKID of object you accessing. /// Type: LibCmo::CKFLOAT. /// True if no error, otherwise False. - [DllImport(g_DllName, EntryPoint = "BMLight_SetFalloffShape", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, ExactSpelling = true)] + [DllImport(DLL_NAME, 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); diff --git a/Assets/BMapBindings/BMapSharp/BMapSharp/BMapMarshalers.cs b/Assets/BMapBindings/BMapSharp/BMapSharp/BMapMarshalers.cs new file mode 100644 index 0000000..297da65 --- /dev/null +++ b/Assets/BMapBindings/BMapSharp/BMapSharp/BMapMarshalers.cs @@ -0,0 +1,303 @@ +using System; +using System.Text; +using System.Runtime.InteropServices; + +namespace BMapSharp.BMapMarshalers { + + // References: + // https://stackoverflow.com/questions/18498452/how-do-i-write-a-custom-marshaler-which-allows-data-to-flow-from-native-to-manag + // https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-runtime-interopservices-icustommarshaler + // + // NOTE: I do not create a member to store the object we are marshaling. + // Because my binding do not have In, Out parameter. All parameters are In OR Out. + // So there is no reason to keep that member. + + // YYC MARK: + // When receiving UTF8 string pointer given by BMap as managed string, + // I don't know why Microsoft try to call ICustomMarshaler.CleanUpNativeData without calling ICustomMarshaler.MarshalManagedToNative. + // It is trying to free the pointer managed by LibCmo self (for example, it will try to free we got string when getting object name)! + // So as the compromise, we introduce 2 different marshalers for In / Out string marshaling respectively. + // BMStringMarshaler for receiving string from BMap (OUT direction), and BMPOwnedStringMarshaler for passing string to BMap (IN direction). + // The name of marshaler for string array marshaling also following this pattern. + + public class BMStringMarshaler : ICustomMarshaler { + private static readonly BMStringMarshaler INSTANCE = new BMStringMarshaler(); + + public static ICustomMarshaler GetInstance(string pstrCookie) { + return BMStringMarshaler.INSTANCE; + } + + public IntPtr MarshalManagedToNative(object ManagedObj) { + // For OUT direction, we do not convert any managed data into native data. + // Return nullptr instead. + return IntPtr.Zero; + } + + public object MarshalNativeToManaged(IntPtr pNativeData) { + // Check nullptr + if (pNativeData == IntPtr.Zero) return null; + // Call self + return BMStringMarshaler.ToManaged(pNativeData); + } + + public void CleanUpNativeData(IntPtr pNativeData) { + // For OUT direction, we do not convert any managed data into native data. + // Do nothing here. + } + + public void CleanUpManagedData(object ManagedObj) { + // Managed data will be cleaned by C# GC. + // So we do nothing here. + } + + public int GetNativeDataSize() { + // Return -1 to indicate the size of the native data to be marshaled is variable. + return -1; + } + + /// + /// Return the length in byte of given pointer represented C style string. + /// + /// The pointer for checking. + /// The length of C style string (NUL exclusive). + internal static int GetCStringLength(IntPtr ptr) { + int count = 0, unit = Marshal.SizeOf(); + while (Marshal.ReadByte(ptr) != (byte)0) { + ptr += unit; + ++count; + } + return count; + } + + /// + /// Extract managed string from given native pointer holding C style string data. + /// This function is shared by 2 marshalers. + /// + /// Native pointer holding string data. Caller must make sure this pointer is not nullptr. + /// The extracted managed string data. + internal static string ToManaged(IntPtr ptr) { + // Get the length of given string. + int szStringItemCount = BMStringMarshaler.GetCStringLength(ptr); + int szStringItemSize = Marshal.SizeOf(); + // Prepare cache and copy string data + byte[] encString = new byte[szStringItemCount]; + Marshal.Copy(ptr, encString, 0, szStringItemCount); + // Decode string and return + return Encoding.UTF8.GetString(encString); + } + } + + public class BMOwnedStringMarshaler : ICustomMarshaler { + private static readonly BMOwnedStringMarshaler INSTANCE = new BMOwnedStringMarshaler(); + + public static ICustomMarshaler GetInstance(string pstrCookie) { + return BMOwnedStringMarshaler.INSTANCE; + } + + public IntPtr MarshalManagedToNative(object ManagedObj) { + // Check requirements. + if (ManagedObj is null) return IntPtr.Zero; + string castManagedObj = ManagedObj as string; + if (castManagedObj is null) + throw new MarshalDirectiveException("BMStringMarshaler must be used on a string."); + // Call self + return BMOwnedStringMarshaler.ToNative(castManagedObj); + } + + public object MarshalNativeToManaged(IntPtr pNativeData) { + // For IN direction, we do not convert any native data into managed data. + // Return null instead. + return null; + } + + public void CleanUpNativeData(IntPtr pNativeData) { + // Check nullptr + if (pNativeData == IntPtr.Zero) return; + // Free native pointer + Marshal.FreeHGlobal(pNativeData); + } + + public void CleanUpManagedData(object ManagedObj) { + // For IN direction, we do not convert any native data into managed data. + // Do nothing here. + } + + public int GetNativeDataSize() { + // Return -1 to indicate the size of the native data to be marshaled is variable. + return -1; + } + + /// + /// Convert given string object to native data. + /// This function is shared by 2 marshalers. + /// + /// String object. Caller must make sure this object is not null. + /// The created native data pointer. + internal static IntPtr ToNative(string obj) { + // Encode string first + byte[] encString = Encoding.UTF8.GetBytes(obj); + // Allocate string memory with extra NUL. + int szStringItemCount = encString.Length; + int szStringItemSize = Marshal.SizeOf(); + IntPtr pString = Marshal.AllocHGlobal(szStringItemSize * (szStringItemCount + 1)); + // Copy encoded string data + Marshal.Copy(encString, 0, pString, szStringItemCount); + // Setup NUL + Marshal.WriteByte(pString + (szStringItemSize * szStringItemCount), (byte)0); + // Return value + return pString; + } + } + + // YYC MARK: + // For respecting the standard of BMap, + // the native memory we created for string array is a simple array and each item is a pointer to a NULL-terminated UTF8 string. + // Please note the array self is also NULL-terminated otherwise we don't know its length. + + public class BMStringArrayMarshaler : ICustomMarshaler { + private static readonly BMStringArrayMarshaler INSTANCE = new BMStringArrayMarshaler(); + + public static ICustomMarshaler GetInstance(string pstrCookie) { + return BMStringArrayMarshaler.INSTANCE; + } + + public IntPtr MarshalManagedToNative(object ManagedObj) { + // For OUT direction, we do not convert any managed data into native data. + // Return nullptr instead. + return IntPtr.Zero; + } + + public object MarshalNativeToManaged(IntPtr pNativeData) { + // Check nullptr + if (pNativeData == IntPtr.Zero) return null; + + // Get the length of array + int szArrayItemCount = BMStringArrayMarshaler.GetArrayLength(pNativeData); + int szArrayItemSize = Marshal.SizeOf(); + // Prepare array cache and read it. + IntPtr[] apString = new IntPtr[szArrayItemCount]; + Marshal.Copy(pNativeData, apString, 0, szArrayItemCount); + + // Iterate the array and process each string one by one. + string[] ret = new string[szArrayItemCount]; + for (int i = 0; i < szArrayItemCount; ++i) { + // Get string pointer + IntPtr pString = apString[i]; + if (pString == IntPtr.Zero) { + ret[i] = null; + continue; + } + // Extract string + ret[i] = BMStringMarshaler.ToManaged(pString); + } + + // Return result + return ret; + } + + public void CleanUpNativeData(IntPtr pNativeData) { + // For OUT direction, we do not convert any managed data into native data. + // Do nothing here. + } + + public void CleanUpManagedData(object ManagedObj) { + // Managed data will be cleaned by C# GC. + // So we do nothing here. + } + + public int GetNativeDataSize() { + // Return -1 to indicate the size of the native data to be marshaled is variable. + return -1; + } + + /// + /// Return the length of array created by this marshaler. + /// + /// The pointer to array for checking. + /// The length of array (NULL terminal exclusive). + internal static int GetArrayLength(IntPtr ptr) { + int count = 0, unit = Marshal.SizeOf(); + while (Marshal.ReadIntPtr(ptr) != IntPtr.Zero) { + ptr += unit; + ++count; + } + return count; + } + } + + public class BMOwnedStringArrayMarshaler : ICustomMarshaler { + private static readonly BMOwnedStringArrayMarshaler INSTANCE = new BMOwnedStringArrayMarshaler(); + + public static ICustomMarshaler GetInstance(string pstrCookie) { + return BMOwnedStringArrayMarshaler.INSTANCE; + } + + public IntPtr MarshalManagedToNative(object ManagedObj) { + // Check nullptr object. + if (ManagedObj is null) return IntPtr.Zero; + // Check argument type. + string[] castManagedObj = ManagedObj as string[]; + if (castManagedObj is null) + throw new MarshalDirectiveException("BMStringArrayMashaler must be used on an string array."); + + // Allocate string items first + int szArrayItemCount = castManagedObj.Length; + int szArrayItemSize = Marshal.SizeOf(); + IntPtr[] apString = new IntPtr[szArrayItemCount]; + for (int i = 0; i < szArrayItemCount; ++i) { + // Check null string + string stringObj = castManagedObj[i]; + if (stringObj is null) apString[i] = IntPtr.Zero; + else apString[i] = BMOwnedStringMarshaler.ToNative(stringObj); + } + + // Allocate array pointer now. + IntPtr pArray = Marshal.AllocHGlobal(szArrayItemSize * (szArrayItemCount + 1)); + // Copy string pointer data + Marshal.Copy(apString, 0, pArray, szArrayItemCount); + // Setup NULL ternimal + Marshal.WriteIntPtr(pArray + (szArrayItemSize * szArrayItemCount), IntPtr.Zero); + + // Return value + return pArray; + } + + public object MarshalNativeToManaged(IntPtr pNativeData) { + // For IN direction, we do not convert any native data into managed data. + // Return null instead. + return null; + } + + public void CleanUpNativeData(IntPtr pNativeData) { + // Check nullptr + if (pNativeData == IntPtr.Zero) return; + + // Get the length of array + int szArrayItemCount = BMStringArrayMarshaler.GetArrayLength(pNativeData); + int szArrayItemSize = Marshal.SizeOf(); + // Prepare array cache and read it. + IntPtr[] apString = new IntPtr[szArrayItemCount]; + Marshal.Copy(pNativeData, apString, 0, szArrayItemCount); + // Free array self + Marshal.FreeHGlobal(pNativeData); + + // Iterate the string pointer array and free them one by one. + foreach (IntPtr pString in apString) { + // Free string pointer + if (pString == IntPtr.Zero) continue; + Marshal.FreeHGlobal(pString); + } + } + + public void CleanUpManagedData(object ManagedObj) { + // For IN direction, we do not convert any native data into managed data. + // Do nothing here. + } + + public int GetNativeDataSize() { + // Return -1 to indicate the size of the native data to be marshaled is variable. + return -1; + } + } + +} diff --git a/Assets/BMapBindings/BMapSharp/BMapSharp/BMapWrapper.cs b/Assets/BMapBindings/BMapSharp/BMapSharp/BMapWrapper.cs index 1536bbb..9fc22dc 100644 --- a/Assets/BMapBindings/BMapSharp/BMapSharp/BMapWrapper.cs +++ b/Assets/BMapBindings/BMapSharp/BMapSharp/BMapWrapper.cs @@ -5,6 +5,20 @@ using BMapSharp.VirtoolsTypes; namespace BMapSharp.BMapWrapper { + /// + /// BMapSharp module specific exception. + /// + public class BMapException : Exception { + public BMapException() { } + public BMapException(string message) + : base(message) { } + public BMapException(string message, Exception inner) + : base(message, inner) { } + public static void ThrowIfFailed(bool condition) { + if (!condition) throw new BMapException("BMap operation failed."); + } + } + /// /// The guard of native BMap environment. /// This class initialize native BMap environment when constructing and free it when destructing.