diff --git a/BBMOD.yyp b/BBMOD.yyp index 80052d45..c2620b7e 100644 --- a/BBMOD.yyp +++ b/BBMOD.yyp @@ -105,6 +105,15 @@ {"CopyToMask":-1,"filePath":"datafiles/BBMOD/Skies","resourceVersion":"1.0","name":"NoonSky.png","resourceType":"GMIncludedFile",}, {"CopyToMask":-1,"filePath":"datafiles/BBMOD","resourceVersion":"1.0","name":"assimp-vc140-mt.dll","resourceType":"GMIncludedFile",}, {"CopyToMask":-1,"filePath":"datafiles/BBMOD","resourceVersion":"1.0","name":"BBMOD.exe","resourceType":"GMIncludedFile",}, + {"CopyToMask":-1,"filePath":"datafiles/Assets","resourceVersion":"1.0","name":"Character.bbmod","resourceType":"GMIncludedFile",}, + {"CopyToMask":-1,"filePath":"datafiles/Assets","resourceVersion":"1.0","name":"Idle.bbanim","resourceType":"GMIncludedFile",}, + {"CopyToMask":-1,"filePath":"datafiles/BBMOD/Models","resourceVersion":"1.0","name":"Sphere.bbmod","resourceType":"GMIncludedFile",}, + {"CopyToMask":-1,"filePath":"datafiles/BBMOD/Skies","resourceVersion":"1.0","name":"NoonIBL.png","resourceType":"GMIncludedFile",}, + {"CopyToMask":-1,"filePath":"datafiles/BBMOD/Skies","resourceVersion":"1.0","name":"NoonSky.png","resourceType":"GMIncludedFile",}, + {"CopyToMask":-1,"filePath":"datafiles/BBMOD","resourceVersion":"1.0","name":"BBMOD.dll","resourceType":"GMIncludedFile",}, + {"CopyToMask":-1,"filePath":"datafiles/BBMOD","resourceVersion":"1.0","name":"assimp-vc140-mt.dll","resourceType":"GMIncludedFile",}, + {"CopyToMask":-1,"filePath":"datafiles/BBMOD","resourceVersion":"1.0","name":"BBMOD.exe","resourceType":"GMIncludedFile",}, + {"CopyToMask":-1,"filePath":"datafiles/BBMOD","resourceVersion":"1.0","name":"LICENSE","resourceType":"GMIncludedFile",}, ], "MetaData": { "IDEVersion": "2.3.0.529", diff --git a/cpp/include/BBMOD/Config.hpp b/cpp/include/BBMOD/Config.hpp index 46091724..76042dfc 100644 --- a/cpp/include/BBMOD/Config.hpp +++ b/cpp/include/BBMOD/Config.hpp @@ -50,6 +50,15 @@ struct SConfig /** Flip normal vectors. */ bool FlipNormals = false; + /** Removes redundant/unreferenced materials. */ + bool OptimizeMaterials = true; + + /** Optimizes node hierarchy by joining multiple nodes into one. */ + bool OptimizeNodes = true; + + /** Reduces number of meshes. */ + bool OptimizeMeshes = true; + /** * Configures generation of normal vectors. * diff --git a/cpp/src/BBMOD/Importer.cpp b/cpp/src/BBMOD/Importer.cpp index 125ae5c7..1319a25f 100644 --- a/cpp/src/BBMOD/Importer.cpp +++ b/cpp/src/BBMOD/Importer.cpp @@ -72,12 +72,13 @@ int ConvertToBBMOD(const char* fin, const char* fout, const SConfig& config) //importer->SetPropertyBool(AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS, false); int flags = (0 - // aiProcessPreset_TargetRealtime_Quality + //aiProcessPreset_TargetRealtime_Quality | aiProcess_CalcTangentSpace + //| aiProcess_GenSmoothNormals | aiProcess_JoinIdenticalVertices | aiProcess_ImproveCacheLocality | aiProcess_LimitBoneWeights - | aiProcess_RemoveRedundantMaterials + //| aiProcess_RemoveRedundantMaterials | aiProcess_SplitLargeMeshes | aiProcess_Triangulate | aiProcess_GenUVCoords @@ -86,8 +87,9 @@ int ConvertToBBMOD(const char* fin, const char* fout, const SConfig& config) | aiProcess_FindInvalidData // | aiProcess_TransformUVCoords - | aiProcess_OptimizeGraph - | aiProcess_OptimizeMeshes); + //| aiProcess_OptimizeGraph + //| aiProcess_OptimizeMeshes + ); if (config.GenNormals == BBMOD_NORMALS_FLAT) { @@ -98,6 +100,21 @@ int ConvertToBBMOD(const char* fin, const char* fout, const SConfig& config) flags |= aiProcess_GenSmoothNormals; } + if (config.OptimizeMaterials) + { + flags |= aiProcess_RemoveRedundantMaterials; + } + + if (config.OptimizeNodes) + { + flags |= aiProcess_OptimizeGraph; + } + + if (config.OptimizeMeshes) + { + flags |= aiProcess_OptimizeMeshes; + } + if (config.LeftHanded) { flags |= aiProcess_ConvertToLeftHanded; diff --git a/cpp/src/exports.cpp b/cpp/src/exports.cpp index 24dcf763..adc8fd5c 100644 --- a/cpp/src/exports.cpp +++ b/cpp/src/exports.cpp @@ -137,6 +137,39 @@ GM_EXPORT gmreal_t bbmod_dll_set_disable_bone(gmreal_t disable) return BBMOD_SUCCESS; } +GM_EXPORT gmreal_t bbmod_dll_get_optimize_materials() +{ + return (gmreal_t)gConfig.OptimizeMaterials; +} + +GM_EXPORT gmreal_t bbmod_dll_set_optimize_materials(gmreal_t optimize) +{ + gConfig.OptimizeMaterials = (bool)optimize; + return BBMOD_SUCCESS; +} + +GM_EXPORT gmreal_t bbmod_dll_get_optimize_meshes() +{ + return (gmreal_t)gConfig.OptimizeMeshes; +} + +GM_EXPORT gmreal_t bbmod_dll_set_optimize_meshes(gmreal_t optimize) +{ + gConfig.OptimizeMeshes = (bool)optimize; + return BBMOD_SUCCESS; +} + +GM_EXPORT gmreal_t bbmod_dll_get_optimize_nodes() +{ + return (gmreal_t)gConfig.OptimizeNodes; +} + +GM_EXPORT gmreal_t bbmod_dll_set_optimize_nodes(gmreal_t optimize) +{ + gConfig.OptimizeNodes = (bool)optimize; + return BBMOD_SUCCESS; +} + GM_EXPORT gmreal_t bbmod_dll_convert(gmstring_t fin, gmstring_t fout) { return ConvertToBBMOD(fin, fout, gConfig); diff --git a/cpp/src/main.cpp b/cpp/src/main.cpp index 99e4ce19..137db5fd 100644 --- a/cpp/src/main.cpp +++ b/cpp/src/main.cpp @@ -8,6 +8,8 @@ #include #include +// TODO: Implement class for argument parsing + const char* gUsage = "Usage: BBMOD.exe [-h] input_file [output_file] [args...]"; #define PRINT_BOOL(b) (b ? "true" : "false") @@ -21,37 +23,43 @@ void PrintHelp() << std::endl << "Arguments:" << std::endl << std::endl - << " -h Show this help message and exit." << std::endl - << " input_file Path to the model to convert." << std::endl - << " output_file Where to save the converted model. If not specified, " << std::endl - << " then the input file path is used. Extensions .bbmod" << std::endl - << " and .bbanim are added automatically." << std::endl - << " -db|--disable-bone=true|false Enable/disable saving bones and animations." << std::endl - << " Default is " << PRINT_BOOL(config.DisableBones) << "." << std::endl - << " -dc|--disable-color=true|false Enable/disable saving vertex colors." << std::endl - << " Default is " << PRINT_BOOL(config.DisableVertexColors) << "." << std::endl - << " -dn|--disable-normal=true|false Enable/disable saving normal vectors. This also automatically" << std::endl - << " applies --disable-tangent." << std::endl - << " Default is " << PRINT_BOOL(config.DisableNormals) << "." << std::endl - << " -dt|--disable-tangent=true|false Enable/disable saving tangent vectors and bitangent signs." << std::endl - << " Default is " << PRINT_BOOL(config.DisableTangentW) << "." << std::endl - << " -duv|--disable-uv=true|false Enable/disable saving texture coordinates." << std::endl - << " Default is " << PRINT_BOOL(config.DisableTextureCoords) << "." << std::endl - << " -fn|--flip-normal=true|false Enable/disable flipping normal vectors." << std::endl - << " Default is " << PRINT_BOOL(config.FlipNormals) << "." << std::endl - << " -fuvx|--flip-uv-x=true|false Enable/disable flipping texture coordinates horizontally." << std::endl - << " Default is " << PRINT_BOOL(config.FlipTextureHorizontally) << "." << std::endl - << " -fuvy|--flip-uv-y=true|false Enable/disable flipping texture coordinates vertically." << std::endl - << " Default is " << PRINT_BOOL(config.FlipTextureVertically) << "." << std::endl - << " -gn|--gen-normal=0|1|2 Enable/disable generating normal vectors if the model doesn't have any." << std::endl - << " * 0 - Do not generate any normal vectors." << std::endl - << " * 1 - Generate flat normal vectors." << std::endl - << " * 2 - Generate smooth normal vectors." << std::endl - << " Default is " << config.GenNormals << "." << std::endl - << " -iw|--invert-winding=true|false Invert winding order of vertices." << std::endl - << " Default is " << PRINT_BOOL(config.InvertWinding) << "." << std::endl - << " -lh|--left-handed=true|false Convert to left-handed coordinate system." << std::endl - << " Default is " << PRINT_BOOL(config.LeftHanded) << "." << std::endl + << " -h Show this help message and exit." << std::endl + << " input_file Path to the model to convert." << std::endl + << " output_file Where to save the converted model. If not specified, " << std::endl + << " then the input file path is used. Extensions .bbmod" << std::endl + << " and .bbanim are added automatically." << std::endl + << " -db|--disable-bone=true|false Enable/disable saving bones and animations." << std::endl + << " Default is " << PRINT_BOOL(config.DisableBones) << "." << std::endl + << " -dc|--disable-color=true|false Enable/disable saving vertex colors." << std::endl + << " Default is " << PRINT_BOOL(config.DisableVertexColors) << "." << std::endl + << " -dn|--disable-normal=true|false Enable/disable saving normal vectors. This also automatically" << std::endl + << " applies --disable-tangent." << std::endl + << " Default is " << PRINT_BOOL(config.DisableNormals) << "." << std::endl + << " -dt|--disable-tangent=true|false Enable/disable saving tangent vectors and bitangent signs." << std::endl + << " Default is " << PRINT_BOOL(config.DisableTangentW) << "." << std::endl + << " -duv|--disable-uv=true|false Enable/disable saving texture coordinates." << std::endl + << " Default is " << PRINT_BOOL(config.DisableTextureCoords) << "." << std::endl + << " -fn|--flip-normal=true|false Enable/disable flipping normal vectors." << std::endl + << " Default is " << PRINT_BOOL(config.FlipNormals) << "." << std::endl + << " -fuvx|--flip-uv-x=true|false Enable/disable flipping texture coordinates horizontally." << std::endl + << " Default is " << PRINT_BOOL(config.FlipTextureHorizontally) << "." << std::endl + << " -fuvy|--flip-uv-y=true|false Enable/disable flipping texture coordinates vertically." << std::endl + << " Default is " << PRINT_BOOL(config.FlipTextureVertically) << "." << std::endl + << " -gn|--gen-normal=0|1|2 Enable/disable generating normal vectors if the model doesn't have any." << std::endl + << " * 0 - Do not generate any normal vectors." << std::endl + << " * 1 - Generate flat normal vectors." << std::endl + << " * 2 - Generate smooth normal vectors." << std::endl + << " Default is " << config.GenNormals << "." << std::endl + << " -iw|--invert-winding=true|false Invert winding order of vertices." << std::endl + << " Default is " << PRINT_BOOL(config.InvertWinding) << "." << std::endl + << " -lh|--left-handed=true|false Convert to left-handed coordinate system." << std::endl + << " Default is " << PRINT_BOOL(config.LeftHanded) << "." << std::endl + << " -on|--optimize-nodes=true|false Join multiple nodes (without animations, bones, ...) into one." << std::endl + << " Default is " << PRINT_BOOL(config.OptimizeNodes) << "." << std::endl + << " -ome|--optimize-meshes=true|false Join multiple meshes with the same material into one." << std::endl + << " Default is " << PRINT_BOOL(config.OptimizeMeshes) << "." << std::endl + << " -oma|--optimize-materials=true|false Join redundant materials into one and remove unused materials." << std::endl + << " Default is " << PRINT_BOOL(config.OptimizeMaterials) << "." << std::endl << std::endl; } @@ -130,6 +138,18 @@ int main(int argc, const char* argv[]) { config.DisableBones = b; } + else if (o == "-on" || o == "--optimize-nodes") + { + config.OptimizeNodes = b; + } + else if (o == "-ome" || o == "--optimize-meshes") + { + config.OptimizeMeshes = b; + } + else if (o == "-oma" || o == "--optimize-materials") + { + config.OptimizeMaterials = b; + } else { PRINT_ERROR("Unrecognized option %s!", argv[i]); diff --git a/datafiles/BBMOD/BBMOD.dll b/datafiles/BBMOD/BBMOD.dll index b3ef71e9..a826dfbc 100644 Binary files a/datafiles/BBMOD/BBMOD.dll and b/datafiles/BBMOD/BBMOD.dll differ diff --git a/datafiles/BBMOD/BBMOD.exe b/datafiles/BBMOD/BBMOD.exe index b7764331..c4eeb0f8 100644 Binary files a/datafiles/BBMOD/BBMOD.exe and b/datafiles/BBMOD/BBMOD.exe differ diff --git a/scripts/bbmod_dll/bbmod_dll.gml b/scripts/bbmod_dll/bbmod_dll.gml index 4a0f29f1..71cff15d 100644 --- a/scripts/bbmod_dll/bbmod_dll.gml +++ b/scripts/bbmod_dll/bbmod_dll.gml @@ -65,63 +65,76 @@ function BBMOD_DLL(_path) constructor { /// @var {string} Path to the DLL file. /// @readonly - path = !is_undefined(_path) ? _path : "BBMOD/BBMOD.dll"; + Path = !is_undefined(_path) ? _path : "BBMOD/BBMOD.dll"; - if (!file_exists(path)) + if (!file_exists(Path)) { - throw new BBMOD_Error("File " + path + " does not exist!"); + throw new BBMOD_Error("File " + Path + " does not exist!"); } - dll_get_left_handed = external_define(path, "bbmod_dll_get_left_handed", dll_cdecl, ty_real, 0); + dll_get_left_handed = external_define(Path, "bbmod_dll_get_left_handed", dll_cdecl, ty_real, 0); - dll_set_left_handed = external_define(path, "bbmod_dll_set_left_handed", dll_cdecl, ty_real, 1, ty_real); + dll_set_left_handed = external_define(Path, "bbmod_dll_set_left_handed", dll_cdecl, ty_real, 1, ty_real); - dll_get_invert_winding = external_define(path, "bbmod_dll_get_invert_winding", dll_cdecl, ty_real, 0); + dll_get_invert_winding = external_define(Path, "bbmod_dll_get_invert_winding", dll_cdecl, ty_real, 0); - dll_set_invert_winding = external_define(path, "bbmod_dll_set_invert_winding", dll_cdecl, ty_real, 1, ty_real); + dll_set_invert_winding = external_define(Path, "bbmod_dll_set_invert_winding", dll_cdecl, ty_real, 1, ty_real); - dll_get_disable_normal = external_define(path, "bbmod_dll_get_disable_normal", dll_cdecl, ty_real, 0); + dll_get_disable_normal = external_define(Path, "bbmod_dll_get_disable_normal", dll_cdecl, ty_real, 0); - dll_set_disable_normal = external_define(path, "bbmod_dll_set_disable_normal", dll_cdecl, ty_real, 1, ty_real); + dll_set_disable_normal = external_define(Path, "bbmod_dll_set_disable_normal", dll_cdecl, ty_real, 1, ty_real); - dll_get_flip_normal = external_define(path, "bbmod_dll_get_flip_normal", dll_cdecl, ty_real, 0); + dll_get_flip_normal = external_define(Path, "bbmod_dll_get_flip_normal", dll_cdecl, ty_real, 0); - dll_set_flip_normal = external_define(path, "bbmod_dll_set_flip_normal", dll_cdecl, ty_real, 1, ty_real); + dll_set_flip_normal = external_define(Path, "bbmod_dll_set_flip_normal", dll_cdecl, ty_real, 1, ty_real); - dll_get_gen_normal = external_define(path, "bbmod_dll_get_gen_normal", dll_cdecl, ty_real, 0); + dll_get_gen_normal = external_define(Path, "bbmod_dll_get_gen_normal", dll_cdecl, ty_real, 0); - dll_set_gen_normal = external_define(path, "bbmod_dll_set_gen_normal", dll_cdecl, ty_real, 1, ty_real); + dll_set_gen_normal = external_define(Path, "bbmod_dll_set_gen_normal", dll_cdecl, ty_real, 1, ty_real); - dll_get_disable_uv = external_define(path, "bbmod_dll_get_disable_uv", dll_cdecl, ty_real, 0); + dll_get_disable_uv = external_define(Path, "bbmod_dll_get_disable_uv", dll_cdecl, ty_real, 0); - dll_set_disable_uv = external_define(path, "bbmod_dll_set_disable_uv", dll_cdecl, ty_real, 1, ty_real); + dll_set_disable_uv = external_define(Path, "bbmod_dll_set_disable_uv", dll_cdecl, ty_real, 1, ty_real); - dll_get_flip_uv_horizontally = external_define(path, "bbmod_dll_get_flip_uv_horizontally", dll_cdecl, ty_real, 0); + dll_get_flip_uv_horizontally = external_define(Path, "bbmod_dll_get_flip_uv_horizontally", dll_cdecl, ty_real, 0); - dll_set_flip_uv_horizontally = external_define(path, "bbmod_dll_set_flip_uv_horizontally", dll_cdecl, ty_real, 1, ty_real); + dll_set_flip_uv_horizontally = external_define(Path, "bbmod_dll_set_flip_uv_horizontally", dll_cdecl, ty_real, 1, ty_real); - dll_get_flip_uv_vertically = external_define(path, "bbmod_dll_get_flip_uv_vertically", dll_cdecl, ty_real, 0); + dll_get_flip_uv_vertically = external_define(Path, "bbmod_dll_get_flip_uv_vertically", dll_cdecl, ty_real, 0); - dll_set_flip_uv_vertically = external_define(path, "bbmod_dll_set_flip_uv_vertically", dll_cdecl, ty_real, 1, ty_real); + dll_set_flip_uv_vertically = external_define(Path, "bbmod_dll_set_flip_uv_vertically", dll_cdecl, ty_real, 1, ty_real); - dll_get_disable_color = external_define(path, "bbmod_dll_get_disable_color", dll_cdecl, ty_real, 0); + dll_get_disable_color = external_define(Path, "bbmod_dll_get_disable_color", dll_cdecl, ty_real, 0); - dll_set_disable_color = external_define(path, "bbmod_dll_set_disable_color", dll_cdecl, ty_real, 1, ty_real); + dll_set_disable_color = external_define(Path, "bbmod_dll_set_disable_color", dll_cdecl, ty_real, 1, ty_real); - dll_get_disable_tangent = external_define(path, "bbmod_dll_get_disable_tangent", dll_cdecl, ty_real, 0); + dll_get_disable_tangent = external_define(Path, "bbmod_dll_get_disable_tangent", dll_cdecl, ty_real, 0); - dll_set_disable_tangent = external_define(path, "bbmod_dll_set_disable_tangent", dll_cdecl, ty_real, 1, ty_real); + dll_set_disable_tangent = external_define(Path, "bbmod_dll_set_disable_tangent", dll_cdecl, ty_real, 1, ty_real); - dll_get_disable_bone = external_define(path, "bbmod_dll_get_disable_bone", dll_cdecl, ty_real, 0); + dll_get_disable_bone = external_define(Path, "bbmod_dll_get_disable_bone", dll_cdecl, ty_real, 0); - dll_set_disable_bone = external_define(path, "bbmod_dll_set_disable_bone", dll_cdecl, ty_real, 1, ty_real); + dll_set_disable_bone = external_define(Path, "bbmod_dll_set_disable_bone", dll_cdecl, ty_real, 1, ty_real); - dll_convert = external_define(path, "bbmod_dll_convert", dll_cdecl, ty_real, 2, ty_string, ty_string); + dll_get_optimize_nodes = external_define(Path, "bbmod_dll_get_optimize_nodes", dll_cdecl, ty_real, 0); + + dll_set_optimize_nodes = external_define(Path, "bbmod_dll_set_optimize_nodes", dll_cdecl, ty_real, 1, ty_real); + + dll_get_optimize_meshes = external_define(Path, "bbmod_dll_get_optimize_meshes", dll_cdecl, ty_real, 0); + + dll_set_optimize_meshes = external_define(Path, "bbmod_dll_set_optimize_meshes", dll_cdecl, ty_real, 1, ty_real); + + dll_get_optimize_materials = external_define(Path, "bbmod_dll_get_optimize_materials", dll_cdecl, ty_real, 0); + + dll_set_optimize_materials = external_define(Path, "bbmod_dll_set_optimize_materials", dll_cdecl, ty_real, 1, ty_real); + + dll_convert = external_define(Path, "bbmod_dll_convert", dll_cdecl, ty_real, 2, ty_string, ty_string); /// @func convert(_fin, _fout) /// @desc Converts a model into a BBMOD. /// @param {string} _fin Path to the original model. /// @param {string} _fout Path to the converted model. + /// @return {BBMOD_DLL} Returns `self` to allow method chaining. /// @throws {BBMOD_Error} If the model conversion fails. static convert = function (_fin, _fout) { gml_pragma("forceinline"); @@ -130,12 +143,13 @@ function BBMOD_DLL(_path) constructor { throw new BBMOD_Error(); } + return self; }; /// @func get_disable_bone() /// @desc Checks whether bones are disabled. /// @return {bool} `true` if bones are disabled. - /// @see set_disable_bone + /// @see BBMOD_DLL.set_disable_bone static get_disable_bone = function () { gml_pragma("forceinline"); return external_call(dll_get_disable_bone); @@ -145,8 +159,9 @@ function BBMOD_DLL(_path) constructor /// @desc Enables/disables bones and animations. These are by default /// **enabled**. /// @param {bool} _disable `true` to disable. + /// @return {BBMOD_DLL} Returns `self` to allow method chaining. /// @throws {BBMOD_Error} If the operation fails. - /// @see get_disable_bone + /// @see BBMOD_DLL.get_disable_bone static set_disable_bone = function (_disable) { gml_pragma("forceinline"); var _retval = external_call(dll_set_disable_bone, _disable); @@ -154,12 +169,13 @@ function BBMOD_DLL(_path) constructor { throw new BBMOD_Error(); } + return self; }; /// @func get_disable_color() /// @desc Checks whether vertex colors are disabled. /// @return {bool} `true` if vertex colors are disabled. - /// @see set_disable_color + /// @see BBMOD_DLL.set_disable_color static get_disable_color = function () { gml_pragma("forceinline"); return external_call(dll_get_disable_color); @@ -170,8 +186,9 @@ function BBMOD_DLL(_path) constructor /// **disabled**. Changing this makes the model incompatible with the default /// shaders! /// @param {bool} _disable `true` to disable. + /// @return {BBMOD_DLL} Returns `self` to allow method chaining. /// @throws {BBMOD_Error} If the operation fails. - /// @see get_disable_color + /// @see BBMOD_DLL.get_disable_color static set_disable_color = function (_disable) { gml_pragma("forceinline"); var _retval = external_call(dll_set_disable_color, _disable); @@ -179,12 +196,13 @@ function BBMOD_DLL(_path) constructor { throw new BBMOD_Error(); } + return self; }; /// @func get_disable_normal() /// @desc Checks whether vertex normals are disabled. /// @return {bool} `true` if vertex normals are disabled. - /// @see set_disable_normal + /// @see BBMOD_DLL.set_disable_normal static get_disable_normal = function () { gml_pragma("forceinline"); return external_call(dll_get_disable_normal); @@ -195,8 +213,9 @@ function BBMOD_DLL(_path) constructor /// **enabled**. Changing this makes the model incompatible with the default /// shaders! /// @param {bool} _disable `true` to disable. + /// @return {BBMOD_DLL} Returns `self` to allow method chaining. /// @throws {BBMOD_Error} If the operation fails. - /// @see get_disable_normal + /// @see BBMOD_DLL.get_disable_normal static set_disable_normal = function (_disable) { gml_pragma("forceinline"); var _retval = external_call(dll_set_disable_normal, _disable); @@ -204,11 +223,13 @@ function BBMOD_DLL(_path) constructor { throw new BBMOD_Error(); } + return self; }; /// @func get_flip_normal() /// @desc Checks whether flipping vertex normals is enabled. /// @return {bool} Returns `true` if enabled. + /// @see BBMOD_DLL.set_flip_normal static get_flip_normal = function () { gml_pragma("forceinline"); return external_call(dll_get_flip_normal); @@ -218,7 +239,9 @@ function BBMOD_DLL(_path) constructor /// @desc Enables/disables flipping vertex normals. This is by default /// **disabled**. /// @param {bool} _flip `true` to enable. + /// @return {BBMOD_DLL} Returns `self` to allow method chaining. /// @throws {BBMOD_Error} If the operation fails. + /// @see BBMOD_DLL.get_flip_normal static set_flip_normal = function (_flip) { gml_pragma("forceinline"); var _retval = external_call(dll_set_flip_normal, _flip); @@ -226,11 +249,13 @@ function BBMOD_DLL(_path) constructor { throw new BBMOD_Error(); } + return self; }; /// @func get_gen_normal() /// @desc Checks whether generating normal vectors is enabled. /// @return {real} Returns one of the `BBMOD_NORMALS_*` macros. + /// @see BBMOD_DLL.set_gen_normal /// @see BBMOD_NORMALS_NONE /// @see BBMOD_NORMALS_FLAT /// @see BBMOD_NORMALS_SMOOTH @@ -244,7 +269,9 @@ function BBMOD_DLL(_path) constructor /// set to {@link BBMOD_NORMALS_SMOOTH}. Vertex normals are required /// by the default shaders! /// @param {real} _normals Use one of the `BBMOD_NORMALS_*` macros. + /// @return {BBMOD_DLL} Returns `self` to allow method chaining. /// @throws {BBMOD_Error} If the operation fails. + /// @see BBMOD_DLL.get_gen_normal /// @see BBMOD_NORMALS_NONE /// @see BBMOD_NORMALS_FLAT /// @see BBMOD_NORMALS_SMOOTH @@ -255,12 +282,13 @@ function BBMOD_DLL(_path) constructor { throw new BBMOD_Error(); } + return self; }; /// @func get_disable_tangent() /// @desc Checks whether tangent and bitangent vectors are disabled. /// @return {bool} `true` if tangent and bitangent vectors are disabled. - /// @see set_disable_tangent + /// @see BBMOD_DLL.set_disable_tangent static get_disable_tangent = function () { gml_pragma("forceinline"); return external_call(dll_get_disable_tangent); @@ -271,8 +299,9 @@ function BBMOD_DLL(_path) constructor /// default **enabled**. Changing this makes the model incompatible with /// the default shaders! /// @param {bool} _disable `true` to disable tangent and bitangent vectors. + /// @return {BBMOD_DLL} Returns `self` to allow method chaining. /// @throws {BBMOD_Error} If the operation fails. - /// @see get_disable_tangent + /// @see BBMOD_DLL.get_disable_tangent static set_disable_tangent = function (_disable) { gml_pragma("forceinline"); var _retval = external_call(dll_set_disable_tangent, _disable); @@ -280,12 +309,13 @@ function BBMOD_DLL(_path) constructor { throw new BBMOD_Error(); } + return self; }; /// @func get_disable_uv() /// @desc Checks whether texture coordinates are disabled. /// @return {bool} `true` if texture coordinates are disabled. - /// @see set_disable_uv + /// @see BBMOD_DLL.set_disable_uv static get_disable_uv = function () { gml_pragma("forceinline"); return external_call(dll_get_disable_uv); @@ -296,8 +326,9 @@ function BBMOD_DLL(_path) constructor /// are by default **enabled**. Changing this makes the model incompatible /// with the default shaders! /// @param {bool} _disable `true` to disable texture coordinates. + /// @return {BBMOD_DLL} Returns `self` to allow method chaining. /// @throws {BBMOD_Error} If the operation fails. - /// @see get_disable_uv + /// @see BBMOD_DLL.get_disable_uv static set_disable_uv = function (_disable) { gml_pragma("forceinline"); var _retval = external_call(dll_set_disable_uv, _disable); @@ -305,11 +336,13 @@ function BBMOD_DLL(_path) constructor { throw new BBMOD_Error(); } + return self; }; /// @func get_flip_uv_horizontally() /// @desc Checks whether flipping texture coordinates horizontally is enabled. /// @return {bool} Returns `true` if enabled. + /// @see BBMOD_DLL.set_flip_uv_horizontally static get_flip_uv_horizontally = function () { gml_pragma("forceinline"); return external_call(dll_get_flip_uv_horizontally); @@ -319,7 +352,9 @@ function BBMOD_DLL(_path) constructor /// @desc Enables/disables flipping texture coordinates horizontally. This is /// by default **disabled**. /// @param {bool} _flip `true` to enable. + /// @return {BBMOD_DLL} Returns `self` to allow method chaining. /// @throws {BBMOD_Error} If the operation fails. + /// @see BBMOD_DLL.get_flip_uv_horizontally static set_flip_uv_horizontally = function (_flip) { gml_pragma("forceinline"); var _retval = external_call(dll_set_flip_uv_horizontally, _flip); @@ -327,11 +362,13 @@ function BBMOD_DLL(_path) constructor { throw new BBMOD_Error(); } + return self; }; /// @func get_flip_uv_vertically() /// @desc Checks whether flipping texture coordinates vertically is enabled. /// @return {bool} Returns `true` if enabled. + /// @see BBMOD_DLL.set_flip_uv_vertically static get_flip_uv_vertically = function () { gml_pragma("forceinline"); return external_call(dll_get_flip_uv_vertically); @@ -341,7 +378,9 @@ function BBMOD_DLL(_path) constructor /// @desc Enables/disables flipping texture coordinates vertically. This is /// by default **enabled**. /// @param {bool} _flip `true` to enable. + /// @return {BBMOD_DLL} Returns `self` to allow method chaining. /// @throws {BBMOD_Error} If the operation fails. + /// @see BBMOD_DLL.get_flip_uv_vertically static set_flip_uv_vertically = function (_flip) { gml_pragma("forceinline"); var _retval = external_call(dll_set_flip_uv_vertically, _flip); @@ -349,12 +388,13 @@ function BBMOD_DLL(_path) constructor { throw new BBMOD_Error(); } + return self; }; /// @func get_invert_winding() /// @desc Checks whether inverse vertex winding is enabled. /// @return {bool} `true` if inverse vertex winding is enabled. - /// @see set_invert_winding + /// @see BBMOD_DLL.set_invert_winding static get_invert_winding = function () { gml_pragma("forceinline"); return external_call(dll_get_invert_winding); @@ -364,8 +404,9 @@ function BBMOD_DLL(_path) constructor /// @desc Enables/disables inverse vertex winding. This is by default /// **disabled**. /// @param {bool} _invert `true` to invert winding. + /// @return {BBMOD_DLL} Returns `self` to allow method chaining. /// @throws {BBMOD_Error} If the operation fails. - /// @see get_invert_winding + /// @see BBMOD_DLL.get_invert_winding static set_invert_winding = function (_invert) { gml_pragma("forceinline"); var _retval = external_call(dll_set_invert_winding, _invert); @@ -373,6 +414,7 @@ function BBMOD_DLL(_path) constructor { throw new BBMOD_Error(); } + return self; }; /// @func get_left_handed() @@ -380,7 +422,7 @@ function BBMOD_DLL(_path) constructor /// enabled. /// @return {bool} `true` if conversion to left-handed coordinate /// system is enabled. - /// @see set_left_handed + /// @see BBMOD_DLL.set_left_handed static get_left_handed = function () { gml_pragma("forceinline"); return external_call(dll_get_left_handed); @@ -391,8 +433,9 @@ function BBMOD_DLL(_path) constructor /// This is by default **enabled**. /// @param {bool} _left_handed `true` to enable conversion to left-handed /// coordinate system. + /// @return {BBMOD_DLL} Returns `self` to allow method chaining. /// @throws {BBMOD_Error} If the operation fails. - /// @see get_left_handed + /// @see BBMOD_DLL.get_left_handed static set_left_handed = function (_left_handed) { gml_pragma("forceinline"); var _retval = external_call(dll_set_left_handed, _left_handed); @@ -400,6 +443,88 @@ function BBMOD_DLL(_path) constructor { throw new BBMOD_Error(); } + return self; + }; + + /// @func get_optimize_nodes() + /// @desc Checks whether node optimization is enabled. + /// @return {bool} `true` if node optimization is enabled. + /// @see BBMOD_DLL.set_optimize_nodes + static get_optimize_nodes = function () { + gml_pragma("forceinline"); + return external_call(dll_get_optimize_nodes); + }; + + /// @func set_optimize_nodes(_optimize) + /// @desc Enable/disable node optimization. When enabled, multiple + /// nodes (without bones, animations, ...) are joined into one. + /// This is by default **enabled**. + /// @param {bool} _optimize `true` to enable node optimization. + /// @return {BBMOD_DLL} Returns `self` to allow method chaining. + /// @throws {BBMOD_Error} If the operation fails. + /// @see BBMOD_DLL.get_optimize_nodes + static set_optimize_nodes = function (_optimize) { + gml_pragma("forceinline"); + var _retval = external_call(dll_set_optimize_nodes, _optimize); + if (_retval != BBMOD_DLL_SUCCESS) + { + throw new BBMOD_Error(); + } + return self; + }; + + /// @func get_optimize_meshes() + /// @desc Checks whether mesh optimization is enabled. + /// @return {bool} `true` if mesh optimization is enabled. + /// @see BBMOD_DLL.set_optimize_meshes + static get_optimize_meshes = function () { + gml_pragma("forceinline"); + return external_call(dll_get_optimize_meshes); + }; + + /// @func set_optimize_meshes(_optimize) + /// @desc Enables/disables mesh optimization. When enabled, multiple + /// meshes with the same material are joined into one to reduce draw + /// calls. This is by default **enabled**. + /// @param {bool} _optimize `true` to enable mesh optimization. + /// @return {BBMOD_DLL} Returns `self` to allow method chaining. + /// @throws {BBMOD_Error} If the operation fails. + /// @see BBMOD_DLL.get_optimize_meshes + static set_optimize_meshes = function (_optimize) { + gml_pragma("forceinline"); + var _retval = external_call(dll_set_optimize_meshes, _optimize); + if (_retval != BBMOD_DLL_SUCCESS) + { + throw new BBMOD_Error(); + } + return self; + }; + + /// @func get_optimize_materials() + /// @desc Checks whether material optimization is enabled. + /// @return {bool} `true` if material optimization is enabled. + /// @see BBMOD_DLL.set_optimize_materials + static get_optimize_materials = function () { + gml_pragma("forceinline"); + return external_call(dll_get_optimize_materials); + }; + + /// @func set_optimize_materials(_optimize) + /// @desc Enables/disables material optimization. When enabled, redundant + /// materials are joined into one and unused materials are removed. + /// This is by default **enabled**. + /// @param {bool} _optimize `true` to enable material optimization. + /// @return {BBMOD_DLL} Returns `self` to allow method chaining. + /// @throws {BBMOD_Error} If the operation fails. + /// @see BBMOD_DLL.get_optimize_materials + static set_optimize_materials = function (_optimize) { + gml_pragma("forceinline"); + var _retval = external_call(dll_set_optimize_materials, _optimize); + if (_retval != BBMOD_DLL_SUCCESS) + { + throw new BBMOD_Error(); + } + return self; }; /// @func destroy() diff --git a/scripts/bbmod_error/bbmod_error.gml b/scripts/bbmod_error/bbmod_error.gml index 31e76d4b..3bfc7bdd 100644 --- a/scripts/bbmod_error/bbmod_error.gml +++ b/scripts/bbmod_error/bbmod_error.gml @@ -5,5 +5,5 @@ function BBMOD_Error(_msg) constructor { /// @var {string} The error message. /// @readonly - msg = !is_undefined(_msg) ? _msg : ""; + Message = !is_undefined(_msg) ? _msg : ""; } \ No newline at end of file