From 534c35c76fd39c0d4fabde9498e99a4d6716f0eb Mon Sep 17 00:00:00 2001 From: antopilo Date: Tue, 15 Oct 2024 19:00:56 -0400 Subject: [PATCH] Fixed sprites not working --- Nuake/dependencies/assimp | 2 +- Nuake/dependencies/assimp_p5.lua | 7 +- Nuake/dependencies/build/assimp/config.h | 1286 +++++++++-------- Nuake/src/Rendering/PostFX/Volumetric.cpp | 2 +- Nuake/src/Resource/ModelLoader.cpp | 64 +- Nuake/src/Resource/ModelLoader.h | 1 + .../src/Scene/Components/SpriteComponent.cpp | 14 +- Nuake/src/Scene/Components/SpriteComponent.h | 10 +- Nuake/src/Vendors/dds/dds.h | 952 ++++++++++++ 9 files changed, 1683 insertions(+), 655 deletions(-) create mode 100644 Nuake/src/Vendors/dds/dds.h diff --git a/Nuake/dependencies/assimp b/Nuake/dependencies/assimp index 9519a62d..97257a3b 160000 --- a/Nuake/dependencies/assimp +++ b/Nuake/dependencies/assimp @@ -1 +1 @@ -Subproject commit 9519a62dd20799c5493c638d1ef5a6f484e5faf1 +Subproject commit 97257a3bcc7188ad17863a4153c88c9b348fc3c0 diff --git a/Nuake/dependencies/assimp_p5.lua b/Nuake/dependencies/assimp_p5.lua index 659610d9..84735d8e 100644 --- a/Nuake/dependencies/assimp_p5.lua +++ b/Nuake/dependencies/assimp_p5.lua @@ -11,12 +11,15 @@ project 'assimp' warnings 'Off' optimize 'Speed' + cppdialect "C++20" + includedirs { 'build/', 'build/assimp', 'assimp/', 'assimp/contrib/irrXML/', 'assimp/contrib/unzip/', + 'assimp/contrib/utf8cpp/source', 'assimp/contrib/zlib/', 'assimp/contrib/rapidjson/include/', 'assimp/code', @@ -32,6 +35,7 @@ project 'assimp' 'assimp/code/Common/**', 'assimp/code/PostProcessing/**', 'assimp/code/Material/**', + 'assimp/code/Geometry/**', 'assimp/code/CApi/**', -- Importers 'assimp/code/AssetLib/Collada/**', @@ -99,7 +103,8 @@ project 'assimp' 'ASSIMP_BUILD_NO_X_IMPORTER', 'ASSIMP_BUILD_NO_X3D_IMPORTER', 'ASSIMP_BUILD_NO_XGL_IMPORTER', - 'ASSIMP_BUILD_NO_IQM_IMPORTER' + 'ASSIMP_BUILD_NO_IQM_IMPORTER', + 'ASSIMP_BUILD_NO_USD_IMPORTER' } -- Exporters defines { diff --git a/Nuake/dependencies/build/assimp/config.h b/Nuake/dependencies/build/assimp/config.h index 63e664ae..787237da 100644 --- a/Nuake/dependencies/build/assimp/config.h +++ b/Nuake/dependencies/build/assimp/config.h @@ -3,8 +3,7 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2020, assimp team - +Copyright (c) 2006-2024, assimp team All rights reserved. @@ -60,65 +59,40 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef AI_CONFIG_H_INC #define AI_CONFIG_H_INC + // ########################################################################### + // LIBRARY SETTINGS + // General, global settings + // ########################################################################### -// ########################################################################### -// LIBRARY SETTINGS -// General, global settings -// ########################################################################### - -// --------------------------------------------------------------------------- -/** @brief Enables time measurements. - * - * If enabled, measures the time needed for each part of the loading - * process (i.e. IO time, importing, postprocessing, ..) and dumps - * these timings to the DefaultLogger. See the @link perf Performance - * Page@endlink for more information on this topic. - * - * Property type: bool. Default value: false. - */ + // --------------------------------------------------------------------------- + /** @brief Enables time measurements. + * + * If enabled, measures the time needed for each part of the loading + * process (i.e. IO time, importing, postprocessing, ..) and dumps + * these timings to the DefaultLogger. See the @link perf Performance + * Page@endlink for more information on this topic. + * + * Property type: bool. Default value: false. + */ #define AI_CONFIG_GLOB_MEASURE_TIME \ "GLOB_MEASURE_TIME" - -// --------------------------------------------------------------------------- -/** @brief Global setting to disable generation of skeleton dummy meshes - * - * Skeleton dummy meshes are generated as a visualization aid in cases which - * the input data contains no geometry, but only animation data. - * Property data type: bool. Default value: false - */ -// --------------------------------------------------------------------------- + // --------------------------------------------------------------------------- + /** @brief Global setting to disable generation of skeleton dummy meshes + * + * Skeleton dummy meshes are generated as a visualization aid in cases which + * the input data contains no geometry, but only animation data. + * Property data type: bool. Default value: false + */ + // --------------------------------------------------------------------------- #define AI_CONFIG_IMPORT_NO_SKELETON_MESHES \ "IMPORT_NO_SKELETON_MESHES" - - -# if 0 // not implemented yet -// --------------------------------------------------------------------------- -/** @brief Set Assimp's multithreading policy. - * - * This setting is ignored if Assimp was built without boost.thread - * support (ASSIMP_BUILD_NO_THREADING, which is implied by ASSIMP_BUILD_BOOST_WORKAROUND). - * Possible values are: -1 to let Assimp decide what to do, 0 to disable - * multithreading entirely and any number larger than 0 to force a specific - * number of threads. Assimp is always free to ignore this settings, which is - * merely a hint. Usually, the default value (-1) will be fine. However, if - * Assimp is used concurrently from multiple user threads, it might be useful - * to limit each Importer instance to a specific number of cores. - * - * For more information, see the @link threading Threading page@endlink. - * Property type: int, default value: -1. - */ -#define AI_CONFIG_GLOB_MULTITHREADING \ - "GLOB_MULTITHREADING" -#endif - // ########################################################################### // POST PROCESSING SETTINGS // Various stuff to fine-tune the behavior of a specific post processing step. // ########################################################################### - // --------------------------------------------------------------------------- /** @brief Maximum bone count per mesh for the SplitbyBoneCount step. * @@ -127,17 +101,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * compile-time. * Property data type: integer. */ -// --------------------------------------------------------------------------- + // --------------------------------------------------------------------------- #define AI_CONFIG_PP_SBBC_MAX_BONES \ "PP_SBBC_MAX_BONES" - // default limit for bone count #if (!defined AI_SBBC_DEFAULT_MAX_BONES) # define AI_SBBC_DEFAULT_MAX_BONES 60 #endif - // --------------------------------------------------------------------------- /** @brief Specifies the maximum angle that may be between two vertex tangents * that their tangents and bi-tangents are smoothed. @@ -149,13 +121,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_CONFIG_PP_CT_MAX_SMOOTHING_ANGLE \ "PP_CT_MAX_SMOOTHING_ANGLE" -// --------------------------------------------------------------------------- -/** @brief Source UV channel for tangent space computation. - * - * The specified channel must exist or an error will be raised. - * Property type: integer. Default value: 0 - */ -// --------------------------------------------------------------------------- + // --------------------------------------------------------------------------- + /** @brief Source UV channel for tangent space computation. + * + * The specified channel must exist or an error will be raised. + * Property type: integer. Default value: 0 + */ + // --------------------------------------------------------------------------- #define AI_CONFIG_PP_CT_TEXTURE_CHANNEL_INDEX \ "PP_CT_TEXTURE_CHANNEL_INDEX" @@ -174,86 +146,100 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE \ "PP_GSN_MAX_SMOOTHING_ANGLE" - -// --------------------------------------------------------------------------- -/** @brief Sets the colormap (= palette) to be used to decode embedded - * textures in MDL (Quake or 3DGS) files. - * - * This must be a valid path to a file. The file is 768 (256*3) bytes - * large and contains RGB triplets for each of the 256 palette entries. - * The default value is colormap.lmp. If the file is not found, - * a default palette (from Quake 1) is used. - * Property type: string. - */ + // --------------------------------------------------------------------------- + /** @brief Sets the colormap (= palette) to be used to decode embedded + * textures in MDL (Quake or 3DGS) files. + * + * This must be a valid path to a file. The file is 768 (256*3) bytes + * large and contains RGB triplets for each of the 256 palette entries. + * The default value is colormap.lmp. If the file is not found, + * a default palette (from Quake 1) is used. + * Property type: string. + */ #define AI_CONFIG_IMPORT_MDL_COLORMAP \ "IMPORT_MDL_COLORMAP" -// --------------------------------------------------------------------------- -/** @brief Configures the #aiProcess_RemoveRedundantMaterials step to - * keep materials matching a name in a given list. - * - * This is a list of 1 to n strings, ' ' serves as delimiter character. - * Identifiers containing whitespaces must be enclosed in *single* - * quotation marks. For example: - * "keep-me and_me_to anotherMaterialToBeKept \'name with whitespace\'". - * If a material matches on of these names, it will not be modified or - * removed by the postprocessing step nor will other materials be replaced - * by a reference to it.
- * This option might be useful if you are using some magic material names - * to pass additional semantics through the content pipeline. This ensures - * they won't be optimized away, but a general optimization is still - * performed for materials not contained in the list. - * Property type: String. Default value: n/a - * @note Linefeeds, tabs or carriage returns are treated as whitespace. - * Material names are case sensitive. - */ + // --------------------------------------------------------------------------- + /** @brief Configures the #aiProcess_RemoveRedundantMaterials step to + * keep materials matching a name in a given list. + * + * This is a list of 1 to n strings, ' ' serves as delimiter character. + * Identifiers containing whitespaces must be enclosed in *single* + * quotation marks. For example: + * "keep-me and_me_to anotherMaterialToBeKept \'name with whitespace\'". + * If a material matches on of these names, it will not be modified or + * removed by the postprocessing step nor will other materials be replaced + * by a reference to it.
+ * This option might be useful if you are using some magic material names + * to pass additional semantics through the content pipeline. This ensures + * they won't be optimized away, but a general optimization is still + * performed for materials not contained in the list. + * Property type: String. Default value: n/a + * @note Linefeeds, tabs or carriage returns are treated as whitespace. + * Material names are case sensitive. + */ #define AI_CONFIG_PP_RRM_EXCLUDE_LIST \ "PP_RRM_EXCLUDE_LIST" -// --------------------------------------------------------------------------- -/** @brief Configures the #aiProcess_PreTransformVertices step to - * keep the scene hierarchy. Meshes are moved to worldspace, but - * no optimization is performed (read: meshes with equal materials are not - * joined. The total number of meshes won't change). - * - * This option could be of use for you if the scene hierarchy contains - * important additional information which you intend to parse. - * For rendering, you can still render all meshes in the scene without - * any transformations. - * Property type: bool. Default value: false. - */ + // --------------------------------------------------------------------------- + /** @brief Configures the #aiProcess_PreTransformVertices step to + * keep the scene hierarchy. Meshes are moved to worldspace, but + * no optimization is performed (read: meshes with equal materials are not + * joined. The total number of meshes won't change). + * + * This option could be of use for you if the scene hierarchy contains + * important additional information which you intend to parse. + * For rendering, you can still render all meshes in the scene without + * any transformations. + * Property type: bool. Default value: false. + */ #define AI_CONFIG_PP_PTV_KEEP_HIERARCHY \ "PP_PTV_KEEP_HIERARCHY" -// --------------------------------------------------------------------------- -/** @brief Configures the #aiProcess_PreTransformVertices step to normalize - * all vertex components into the [-1,1] range. That is, a bounding box - * for the whole scene is computed, the maximum component is taken and all - * meshes are scaled appropriately (uniformly of course!). - * This might be useful if you don't know the spatial dimension of the input - * data*/ + // --------------------------------------------------------------------------- + /** @brief Configures the #aiProcess_PreTransformVertices step to normalize + * all vertex components into the [-1,1] range. That is, a bounding box + * for the whole scene is computed, the maximum component is taken and all + * meshes are scaled appropriately (uniformly of course!). + * This might be useful if you don't know the spatial dimension of the input + * data*/ #define AI_CONFIG_PP_PTV_NORMALIZE \ "PP_PTV_NORMALIZE" -// --------------------------------------------------------------------------- -/** @brief Configures the #aiProcess_PreTransformVertices step to use - * a users defined matrix as the scene root node transformation before - * transforming vertices. - * Property type: bool. Default value: false. - */ + // --------------------------------------------------------------------------- + /** @brief Configures the #aiProcess_PreTransformVertices step to use + * a users defined matrix as the scene root node transformation before + * transforming vertices. + * Property type: bool. Default value: false. + */ #define AI_CONFIG_PP_PTV_ADD_ROOT_TRANSFORMATION \ "PP_PTV_ADD_ROOT_TRANSFORMATION" -// --------------------------------------------------------------------------- -/** @brief Configures the #aiProcess_PreTransformVertices step to use - * a users defined matrix as the scene root node transformation before - * transforming vertices. This property correspond to the 'a1' component - * of the transformation matrix. - * Property type: aiMatrix4x4. - */ + // --------------------------------------------------------------------------- + /** @brief Configures the #aiProcess_PreTransformVertices step to use + * a users defined matrix as the scene root node transformation before + * transforming vertices. This property correspond to the 'a1' component + * of the transformation matrix. + * Property type: aiMatrix4x4. + */ #define AI_CONFIG_PP_PTV_ROOT_TRANSFORMATION \ "PP_PTV_ROOT_TRANSFORMATION" + // --------------------------------------------------------------------------- + /** @brief Set epsilon to check the identity of the matrix 4x4. + * + * This is used by aiMatrix4x4t::IsIdentity(const TReal epsilon). + * @note The default value is 10e-3f for backward compatibility of legacy code. + * Property type: Float. + */ +#define AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON \ + "CHECK_IDENTITY_MATRIX_EPSILON" + + // default value for AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON +#if (!defined AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON_DEFAULT) +# define AI_CONFIG_CHECK_IDENTITY_MATRIX_EPSILON_DEFAULT 10e-3f +#endif + // --------------------------------------------------------------------------- /** @brief Configures the #aiProcess_FindDegenerates step to * remove degenerated primitives from the import - immediately. @@ -267,48 +253,48 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_CONFIG_PP_FD_REMOVE \ "PP_FD_REMOVE" -// --------------------------------------------------------------------------- -/** - * @brief Configures the #aiProcess_FindDegenerates to check the area of a - * trinagle to be greates than e-6. If this is not the case the triangle will - * be removed if #AI_CONFIG_PP_FD_REMOVE is set to true. - */ + // --------------------------------------------------------------------------- + /** + * @brief Configures the #aiProcess_FindDegenerates to check the area of a + * triangle to be greater than e-6. If this is not the case the triangle will + * be removed if #AI_CONFIG_PP_FD_REMOVE is set to true. + */ #define AI_CONFIG_PP_FD_CHECKAREA \ "PP_FD_CHECKAREA" -// --------------------------------------------------------------------------- -/** @brief Configures the #aiProcess_OptimizeGraph step to preserve nodes - * matching a name in a given list. - * - * This is a list of 1 to n strings, ' ' serves as delimiter character. - * Identifiers containing whitespaces must be enclosed in *single* - * quotation marks. For example: - * "keep-me and_me_to anotherNodeToBeKept \'name with whitespace\'". - * If a node matches on of these names, it will not be modified or - * removed by the postprocessing step.
- * This option might be useful if you are using some magic node names - * to pass additional semantics through the content pipeline. This ensures - * they won't be optimized away, but a general optimization is still - * performed for nodes not contained in the list. - * Property type: String. Default value: n/a - * @note Linefeeds, tabs or carriage returns are treated as whitespace. - * Node names are case sensitive. - */ + // --------------------------------------------------------------------------- + /** @brief Configures the #aiProcess_OptimizeGraph step to preserve nodes + * matching a name in a given list. + * + * This is a list of 1 to n strings, ' ' serves as delimiter character. + * Identifiers containing whitespaces must be enclosed in *single* + * quotation marks. For example: + * "keep-me and_me_to anotherNodeToBeKept \'name with whitespace\'". + * If a node matches on of these names, it will not be modified or + * removed by the postprocessing step.
+ * This option might be useful if you are using some magic node names + * to pass additional semantics through the content pipeline. This ensures + * they won't be optimized away, but a general optimization is still + * performed for nodes not contained in the list. + * Property type: String. Default value: n/a + * @note Linefeeds, tabs or carriage returns are treated as whitespace. + * Node names are case sensitive. + */ #define AI_CONFIG_PP_OG_EXCLUDE_LIST \ "PP_OG_EXCLUDE_LIST" -// --------------------------------------------------------------------------- -/** @brief Set the maximum number of triangles in a mesh. - * - * This is used by the "SplitLargeMeshes" PostProcess-Step to determine - * whether a mesh must be split or not. - * @note The default value is AI_SLM_DEFAULT_MAX_TRIANGLES - * Property type: integer. - */ + // --------------------------------------------------------------------------- + /** @brief Set the maximum number of triangles in a mesh. + * + * This is used by the "SplitLargeMeshes" PostProcess-Step to determine + * whether a mesh must be split or not. + * @note The default value is AI_SLM_DEFAULT_MAX_TRIANGLES + * Property type: integer. + */ #define AI_CONFIG_PP_SLM_TRIANGLE_LIMIT \ "PP_SLM_TRIANGLE_LIMIT" -// default value for AI_CONFIG_PP_SLM_TRIANGLE_LIMIT + // default value for AI_CONFIG_PP_SLM_TRIANGLE_LIMIT #if (!defined AI_SLM_DEFAULT_MAX_TRIANGLES) # define AI_SLM_DEFAULT_MAX_TRIANGLES 1000000 #endif @@ -324,7 +310,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_CONFIG_PP_SLM_VERTEX_LIMIT \ "PP_SLM_VERTEX_LIMIT" -// default value for AI_CONFIG_PP_SLM_VERTEX_LIMIT + // default value for AI_CONFIG_PP_SLM_VERTEX_LIMIT #if (!defined AI_SLM_DEFAULT_MAX_VERTICES) # define AI_SLM_DEFAULT_MAX_VERTICES 1000000 #endif @@ -338,7 +324,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_CONFIG_PP_LBW_MAX_WEIGHTS \ "PP_LBW_MAX_WEIGHTS" -// default value for AI_CONFIG_PP_LBW_MAX_WEIGHTS + // default value for AI_CONFIG_PP_LBW_MAX_WEIGHTS #if (!defined AI_LMW_MAX_WEIGHTS) # define AI_LMW_MAX_WEIGHTS 0x4 #endif // !! AI_LMW_MAX_WEIGHTS @@ -352,7 +338,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_CONFIG_PP_DB_THRESHOLD \ "PP_DB_THRESHOLD" -// default value for AI_CONFIG_PP_LBW_MAX_WEIGHTS + // default value for AI_CONFIG_PP_LBW_MAX_WEIGHTS #if (!defined AI_DEBONE_THRESHOLD) # define AI_DEBONE_THRESHOLD 1.0f #endif // !! AI_DEBONE_THRESHOLD @@ -366,31 +352,31 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define AI_CONFIG_PP_DB_ALL_OR_NONE \ "PP_DB_ALL_OR_NONE" -/** @brief Default value for the #AI_CONFIG_PP_ICL_PTCACHE_SIZE property - */ + /** @brief Default value for the #AI_CONFIG_PP_ICL_PTCACHE_SIZE property + */ #ifndef PP_ICL_PTCACHE_SIZE # define PP_ICL_PTCACHE_SIZE 12 #endif -// --------------------------------------------------------------------------- -/** @brief Set the size of the post-transform vertex cache to optimize the - * vertices for. This configures the #aiProcess_ImproveCacheLocality step. - * - * The size is given in vertices. Of course you can't know how the vertex - * format will exactly look like after the import returns, but you can still - * guess what your meshes will probably have. - * @note The default value is #PP_ICL_PTCACHE_SIZE. That results in slight - * performance improvements for most nVidia/AMD cards since 2002. - * Property type: integer. - */ + // --------------------------------------------------------------------------- + /** @brief Set the size of the post-transform vertex cache to optimize the + * vertices for. This configures the #aiProcess_ImproveCacheLocality step. + * + * The size is given in vertices. Of course you can't know how the vertex + * format will exactly look like after the import returns, but you can still + * guess what your meshes will probably have. + * @note The default value is #PP_ICL_PTCACHE_SIZE. That results in slight + * performance improvements for most nVidia/AMD cards since 2002. + * Property type: integer. + */ #define AI_CONFIG_PP_ICL_PTCACHE_SIZE "PP_ICL_PTCACHE_SIZE" -// --------------------------------------------------------------------------- -/** @brief Enumerates components of the aiScene and aiMesh data structures - * that can be excluded from the import using the #aiProcess_RemoveComponent step. - * - * See the documentation to #aiProcess_RemoveComponent for more details. - */ + // --------------------------------------------------------------------------- + /** @brief Enumerates components of the aiScene and aiMesh data structures + * that can be excluded from the import using the #aiProcess_RemoveComponent step. + * + * See the documentation to #aiProcess_RemoveComponent for more details. + */ enum aiComponent { /** Normal vectors */ @@ -474,39 +460,39 @@ enum aiComponent #define AI_CONFIG_PP_RVC_FLAGS \ "PP_RVC_FLAGS" -// --------------------------------------------------------------------------- -/** @brief Input parameter to the #aiProcess_SortByPType step: - * Specifies which primitive types are removed by the step. - * - * This is a bitwise combination of the aiPrimitiveType flags. - * Specifying all of them is illegal, of course. A typical use would - * be to exclude all line and point meshes from the import. This - * is an integer property, its default value is 0. - */ + // --------------------------------------------------------------------------- + /** @brief Input parameter to the #aiProcess_SortByPType step: + * Specifies which primitive types are removed by the step. + * + * This is a bitwise combination of the aiPrimitiveType flags. + * Specifying all of them is illegal, of course. A typical use would + * be to exclude all line and point meshes from the import. This + * is an integer property, its default value is 0. + */ #define AI_CONFIG_PP_SBP_REMOVE \ "PP_SBP_REMOVE" -// --------------------------------------------------------------------------- -/** @brief Input parameter to the #aiProcess_FindInvalidData step: - * Specifies the floating-point accuracy for animation values. The step - * checks for animation tracks where all frame values are absolutely equal - * and removes them. This tweakable controls the epsilon for floating-point - * comparisons - two keys are considered equal if the invariant - * abs(n0-n1)>epsilon holds true for all vector respectively quaternion - * components. The default value is 0.f - comparisons are exact then. - */ + // --------------------------------------------------------------------------- + /** @brief Input parameter to the #aiProcess_FindInvalidData step: + * Specifies the floating-point accuracy for animation values. The step + * checks for animation tracks where all frame values are absolutely equal + * and removes them. This tweakable controls the epsilon for floating-point + * comparisons - two keys are considered equal if the invariant + * abs(n0-n1)>epsilon holds true for all vector respectively quaternion + * components. The default value is 0.f - comparisons are exact then. + */ #define AI_CONFIG_PP_FID_ANIM_ACCURACY \ "PP_FID_ANIM_ACCURACY" -// --------------------------------------------------------------------------- -/** @brief Input parameter to the #aiProcess_FindInvalidData step: - * Set to true to ignore texture coordinates. This may be useful if you have - * to assign different kind of textures like one for the summer or one for the winter. - */ + // --------------------------------------------------------------------------- + /** @brief Input parameter to the #aiProcess_FindInvalidData step: + * Set to true to ignore texture coordinates. This may be useful if you have + * to assign different kind of textures like one for the summer or one for the winter. + */ #define AI_CONFIG_PP_FID_IGNORE_TEXTURECOORDS \ "PP_FID_IGNORE_TEXTURECOORDS" -// TransformUVCoords evaluates UV scalings + // TransformUVCoords evaluates UV scalings #define AI_UVTRAFO_SCALING 0x1 // TransformUVCoords evaluates UV rotations @@ -529,190 +515,202 @@ enum aiComponent #define AI_CONFIG_PP_TUV_EVALUATE \ "PP_TUV_EVALUATE" -// --------------------------------------------------------------------------- -/** @brief A hint to assimp to favour speed against import quality. - * - * Enabling this option may result in faster loading, but it needn't. - * It represents just a hint to loaders and post-processing steps to use - * faster code paths, if possible. - * This property is expected to be an integer, != 0 stands for true. - * The default value is 0. - */ + // --------------------------------------------------------------------------- + /** @brief A hint to assimp to favour speed against import quality. + * + * Enabling this option may result in faster loading, but it needn't. + * It represents just a hint to loaders and post-processing steps to use + * faster code paths, if possible. + * This property is expected to be an integer, != 0 stands for true. + * The default value is 0. + */ #define AI_CONFIG_FAVOUR_SPEED \ "FAVOUR_SPEED" + // ########################################################################### + // IMPORTER SETTINGS + // Various stuff to fine-tune the behaviour of specific importer plugins. + // ########################################################################### -// ########################################################################### -// IMPORTER SETTINGS -// Various stuff to fine-tune the behaviour of specific importer plugins. -// ########################################################################### - -// --------------------------------------------------------------------------- -/** @brief Importers which parse JSON may use this to obtain a pointer to a - * rapidjson::IRemoteSchemaDocumentProvider. - * - * The default value is nullptr - * Property type: void* - */ + // --------------------------------------------------------------------------- + /** @brief Importers which parse JSON may use this to obtain a pointer to a + * rapidjson::IRemoteSchemaDocumentProvider. + * + * The default value is nullptr + * Property type: void* + */ #define AI_CONFIG_IMPORT_SCHEMA_DOCUMENT_PROVIDER \ "IMPORT_SCHEMA_DOCUMENT_PROVIDER" -// --------------------------------------------------------------------------- -/** @brief Set whether the fbx importer will merge all geometry layers present - * in the source file or take only the first. - * - * The default value is true (1) - * Property type: bool - */ + // --------------------------------------------------------------------------- + /** @brief Set whether the fbx importer will merge all geometry layers present + * in the source file or take only the first. + * + * The default value is true (1) + * Property type: bool + */ #define AI_CONFIG_IMPORT_FBX_READ_ALL_GEOMETRY_LAYERS \ "IMPORT_FBX_READ_ALL_GEOMETRY_LAYERS" -// --------------------------------------------------------------------------- -/** @brief Set whether the fbx importer will read all materials present in the - * source file or take only the referenced materials. - * - * This is void unless IMPORT_FBX_READ_MATERIALS=1. - * - * The default value is false (0) - * Property type: bool - */ + // --------------------------------------------------------------------------- + /** @brief Set whether the fbx importer will read all materials present in the + * source file or take only the referenced materials. + * + * This is void unless IMPORT_FBX_READ_MATERIALS=1. + * + * The default value is false (0) + * Property type: bool + */ #define AI_CONFIG_IMPORT_FBX_READ_ALL_MATERIALS \ "IMPORT_FBX_READ_ALL_MATERIALS" -// --------------------------------------------------------------------------- -/** @brief Set whether the fbx importer will read materials. - * - * The default value is true (1) - * Property type: bool - */ + // --------------------------------------------------------------------------- + /** @brief Set whether the fbx importer will read materials. + * + * The default value is true (1) + * Property type: bool + */ #define AI_CONFIG_IMPORT_FBX_READ_MATERIALS \ "IMPORT_FBX_READ_MATERIALS" -// --------------------------------------------------------------------------- -/** @brief Set whether the fbx importer will read embedded textures. - * - * The default value is true (1) - * Property type: bool - */ + // --------------------------------------------------------------------------- + /** @brief Set whether the fbx importer will read embedded textures. + * + * The default value is true (1) + * Property type: bool + */ #define AI_CONFIG_IMPORT_FBX_READ_TEXTURES \ "IMPORT_FBX_READ_TEXTURES" -// --------------------------------------------------------------------------- -/** @brief Set whether the fbx importer will read cameras. - * - * The default value is true (1) - * Property type: bool - */ + // --------------------------------------------------------------------------- + /** @brief Set whether the fbx importer will read cameras. + * + * The default value is true (1) + * Property type: bool + */ #define AI_CONFIG_IMPORT_FBX_READ_CAMERAS \ "IMPORT_FBX_READ_CAMERAS" -// --------------------------------------------------------------------------- -/** @brief Set whether the fbx importer will read light sources. - * - * The default value is true (1) - * Property type: bool - */ + // --------------------------------------------------------------------------- + /** @brief Set whether the fbx importer will read light sources. + * + * The default value is true (1) + * Property type: bool + */ #define AI_CONFIG_IMPORT_FBX_READ_LIGHTS \ "IMPORT_FBX_READ_LIGHTS" -// --------------------------------------------------------------------------- -/** @brief Set whether the fbx importer will read animations. - * - * The default value is true (1) - * Property type: bool - */ + // --------------------------------------------------------------------------- + /** @brief Set whether the fbx importer will read animations. + * + * The default value is true (1) + * Property type: bool + */ #define AI_CONFIG_IMPORT_FBX_READ_ANIMATIONS \ "IMPORT_FBX_READ_ANIMATIONS" -// --------------------------------------------------------------------------- -/** @brief Set whether the fbx importer will read weights. - * - * The default value is true (1) - * Property type: bool - */ + // --------------------------------------------------------------------------- + /** @brief Set whether the fbx importer will read weights. + * + * The default value is true (1) + * Property type: bool + */ #define AI_CONFIG_IMPORT_FBX_READ_WEIGHTS \ "IMPORT_FBX_READ_WEIGHTS" -// --------------------------------------------------------------------------- -/** @brief Set whether the fbx importer will act in strict mode in which only - * FBX 2013 is supported and any other sub formats are rejected. FBX 2013 - * is the primary target for the importer, so this format is best - * supported and well-tested. - * - * The default value is false (0) - * Property type: bool - */ + // --------------------------------------------------------------------------- + /** @brief Set whether the fbx importer will act in strict mode in which only + * FBX 2013 is supported and any other sub formats are rejected. FBX 2013 + * is the primary target for the importer, so this format is best + * supported and well-tested. + * + * The default value is false (0) + * Property type: bool + */ #define AI_CONFIG_IMPORT_FBX_STRICT_MODE \ "IMPORT_FBX_STRICT_MODE" -// --------------------------------------------------------------------------- -/** @brief Set whether the fbx importer will preserve pivot points for - * transformations (as extra nodes). If set to false, pivots and offsets - * will be evaluated whenever possible. - * - * The default value is true (1) - * Property type: bool - */ + // --------------------------------------------------------------------------- + /** @brief Set whether the fbx importer will preserve pivot points for + * transformations (as extra nodes). If set to false, pivots and offsets + * will be evaluated whenever possible. + * + * The default value is true (1) + * Property type: bool + */ #define AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS \ "IMPORT_FBX_PRESERVE_PIVOTS" -// --------------------------------------------------------------------------- -/** @brief Specifies whether the importer will drop empty animation curves or - * animation curves which match the bind pose transformation over their - * entire defined range. - * - * The default value is true (1) - * Property type: bool - */ + // --------------------------------------------------------------------------- + /** @brief Specifies whether the importer will drop empty animation curves or + * animation curves which match the bind pose transformation over their + * entire defined range. + * + * The default value is true (1) + * Property type: bool + */ #define AI_CONFIG_IMPORT_FBX_OPTIMIZE_EMPTY_ANIMATION_CURVES \ "IMPORT_FBX_OPTIMIZE_EMPTY_ANIMATION_CURVES" -// --------------------------------------------------------------------------- -/** @brief Set whether the fbx importer will use the legacy embedded texture naming. - * - * The default value is false (0) - * Property type: bool - */ + // --------------------------------------------------------------------------- + /** @brief Set whether the fbx importer will use the legacy embedded texture naming. + * + * The default value is false (0) + * Property type: bool + */ #define AI_CONFIG_IMPORT_FBX_EMBEDDED_TEXTURES_LEGACY_NAMING \ "AI_CONFIG_IMPORT_FBX_EMBEDDED_TEXTURES_LEGACY_NAMING" -// --------------------------------------------------------------------------- -/** @brief Set wether the importer shall not remove empty bones. - * - * Empty bone are often used to define connections for other models. - */ + // --------------------------------------------------------------------------- + /** @brief Set wether the importer shall not remove empty bones. + * + * Empty bone are often used to define connections for other models. + */ #define AI_CONFIG_IMPORT_REMOVE_EMPTY_BONES \ "AI_CONFIG_IMPORT_REMOVE_EMPTY_BONES" -// --------------------------------------------------------------------------- -/** @brief Set wether the FBX importer shall convert the unit from cm to m. - */ + // --------------------------------------------------------------------------- + /** @brief Set wether the FBX importer shall convert the unit from cm to m. + */ #define AI_CONFIG_FBX_CONVERT_TO_M \ "AI_CONFIG_FBX_CONVERT_TO_M" - // --------------------------------------------------------------------------- - /** @brief Will enable the skeleton struct to store bone data. - * - * This will decouple the bone coupling to the mesh. This feature is - * experimental. - */ + // --------------------------------------------------------------------------- + /** @brief Set whether the FBX importer shall ignore the provided axis configuration + * + * If this property is set to true, the axis directions provided in the FBX file + * will be ignored and the file will be loaded as is. + * + * Set to true for Assimp 5.3.x and earlier behavior + * Equivalent to AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION + * Property type: Bool. Default value: false. + */ +#define AI_CONFIG_IMPORT_FBX_IGNORE_UP_DIRECTION \ + "AI_CONFIG_IMPORT_FBX_IGNORE_UP_DIRECTION" + + // --------------------------------------------------------------------------- + /** @brief Will enable the skeleton struct to store bone data. + * + * This will decouple the bone coupling to the mesh. This feature is + * experimental. + */ #define AI_CONFIG_FBX_USE_SKELETON_BONE_CONTAINER \ "AI_CONFIG_FBX_USE_SKELETON_BONE_CONTAINER" -// --------------------------------------------------------------------------- -/** @brief Set the vertex animation keyframe to be imported - * - * ASSIMP does not support vertex keyframes (only bone animation is supported). - * The library reads only one frame of models with vertex animations. - * By default this is the first frame. - * \note The default value is 0. This option applies to all importers. - * However, it is also possible to override the global setting - * for a specific loader. You can use the AI_CONFIG_IMPORT_XXX_KEYFRAME - * options (where XXX is a placeholder for the file format for which you - * want to override the global setting). - * Property type: integer. - */ + // --------------------------------------------------------------------------- + /** @brief Set the vertex animation keyframe to be imported + * + * ASSIMP does not support vertex keyframes (only bone animation is supported). + * The library reads only one frame of models with vertex animations. + * By default this is the first frame. + * \note The default value is 0. This option applies to all importers. + * However, it is also possible to override the global setting + * for a specific loader. You can use the AI_CONFIG_IMPORT_XXX_KEYFRAME + * options (where XXX is a placeholder for the file format for which you + * want to override the global setting). + * Property type: integer. + */ #define AI_CONFIG_IMPORT_GLOBAL_KEYFRAME "IMPORT_GLOBAL_KEYFRAME" #define AI_CONFIG_IMPORT_MD3_KEYFRAME "IMPORT_MD3_KEYFRAME" @@ -722,320 +720,326 @@ enum aiComponent #define AI_CONFIG_IMPORT_SMD_KEYFRAME "IMPORT_SMD_KEYFRAME" #define AI_CONFIG_IMPORT_UNREAL_KEYFRAME "IMPORT_UNREAL_KEYFRAME" -// --------------------------------------------------------------------------- -/** @brief Set whether the MDL (HL1) importer will read animations. - * - * The default value is true (1) - * Property type: bool - */ + // --------------------------------------------------------------------------- + /** @brief Set whether the MDL (HL1) importer will read animations. + * + * The default value is true (1) + * Property type: bool + */ #define AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATIONS "IMPORT_MDL_HL1_READ_ANIMATIONS" -// --------------------------------------------------------------------------- -/** @brief Set whether the MDL (HL1) importer will read animation events. - * \note This property requires AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATIONS to be set to true. - * - * The default value is true (1) - * Property type: bool - */ + // --------------------------------------------------------------------------- + /** @brief Set whether the MDL (HL1) importer will read animation events. + * \note This property requires AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATIONS to be set to true. + * + * The default value is true (1) + * Property type: bool + */ #define AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATION_EVENTS "IMPORT_MDL_HL1_READ_ANIMATION_EVENTS" -// --------------------------------------------------------------------------- -/** @brief Set whether the MDL (HL1) importer will read blend controllers. - * \note This property requires AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATIONS to be set to true. - * - * The default value is true (1) - * Property type: bool - */ + // --------------------------------------------------------------------------- + /** @brief Set whether you want to convert the HS1 coordinate system in a special way. + * The default value is true (S1) + * Property type: bool + */ +#define AI_CONFIG_IMPORT_MDL_HL1_TRANSFORM_COORD_SYSTEM "TRANSFORM COORDSYSTEM FOR HS! MODELS" + // --------------------------------------------------------------------------- + /** @brief Set whether the MDL (HL1) importer will read blend controllers. + * \note This property requires AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATIONS to be set to true. + * + * The default value is true (1) + * Property type: bool + */ #define AI_CONFIG_IMPORT_MDL_HL1_READ_BLEND_CONTROLLERS "IMPORT_MDL_HL1_READ_BLEND_CONTROLLERS" -// --------------------------------------------------------------------------- -/** @brief Set whether the MDL (HL1) importer will read sequence transition graph. - * \note This property requires AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATIONS to be set to true. - * - * The default value is true (1) - * Property type: bool - */ + // --------------------------------------------------------------------------- + /** @brief Set whether the MDL (HL1) importer will read sequence transition graph. + * \note This property requires AI_CONFIG_IMPORT_MDL_HL1_READ_ANIMATIONS to be set to true. + * + * The default value is true (1) + * Property type: bool + */ #define AI_CONFIG_IMPORT_MDL_HL1_READ_SEQUENCE_TRANSITIONS "IMPORT_MDL_HL1_READ_SEQUENCE_TRANSITIONS" -// --------------------------------------------------------------------------- -/** @brief Set whether the MDL (HL1) importer will read attachments info. - * - * The default value is true (1) - * Property type: bool - */ + // --------------------------------------------------------------------------- + /** @brief Set whether the MDL (HL1) importer will read attachments info. + * + * The default value is true (1) + * Property type: bool + */ #define AI_CONFIG_IMPORT_MDL_HL1_READ_ATTACHMENTS "IMPORT_MDL_HL1_READ_ATTACHMENTS" -// --------------------------------------------------------------------------- -/** @brief Set whether the MDL (HL1) importer will read bone controllers info. - * - * The default value is true (1) - * Property type: bool - */ + // --------------------------------------------------------------------------- + /** @brief Set whether the MDL (HL1) importer will read bone controllers info. + * + * The default value is true (1) + * Property type: bool + */ #define AI_CONFIG_IMPORT_MDL_HL1_READ_BONE_CONTROLLERS "IMPORT_MDL_HL1_READ_BONE_CONTROLLERS" -// --------------------------------------------------------------------------- -/** @brief Set whether the MDL (HL1) importer will read hitboxes info. - * - * The default value is true (1) - * Property type: bool - */ + // --------------------------------------------------------------------------- + /** @brief Set whether the MDL (HL1) importer will read hitboxes info. + * + * The default value is true (1) + * Property type: bool + */ #define AI_CONFIG_IMPORT_MDL_HL1_READ_HITBOXES "IMPORT_MDL_HL1_READ_HITBOXES" -// --------------------------------------------------------------------------- -/** @brief Set whether the MDL (HL1) importer will read miscellaneous global model info. - * - * The default value is true (1) - * Property type: bool - */ + // --------------------------------------------------------------------------- + /** @brief Set whether the MDL (HL1) importer will read miscellaneous global model info. + * + * The default value is true (1) + * Property type: bool + */ #define AI_CONFIG_IMPORT_MDL_HL1_READ_MISC_GLOBAL_INFO "IMPORT_MDL_HL1_READ_MISC_GLOBAL_INFO" -// --------------------------------------------------------------------------- -/** Smd load multiple animations - * - * Property type: bool. Default value: true. - */ + // --------------------------------------------------------------------------- + /** Smd load multiple animations + * + * Property type: bool. Default value: true. + */ #define AI_CONFIG_IMPORT_SMD_LOAD_ANIMATION_LIST "IMPORT_SMD_LOAD_ANIMATION_LIST" -// --------------------------------------------------------------------------- -/** @brief Configures the AC loader to collect all surfaces which have the - * "Backface cull" flag set in separate meshes. - * - * Property type: bool. Default value: true. - */ + // --------------------------------------------------------------------------- + /** @brief Configures the AC loader to collect all surfaces which have the + * "Backface cull" flag set in separate meshes. + * + * Property type: bool. Default value: true. + */ #define AI_CONFIG_IMPORT_AC_SEPARATE_BFCULL \ "IMPORT_AC_SEPARATE_BFCULL" -// --------------------------------------------------------------------------- -/** @brief Configures whether the AC loader evaluates subdivision surfaces ( - * indicated by the presence of the 'subdiv' attribute in the file). By - * default, Assimp performs the subdivision using the standard - * Catmull-Clark algorithm - * - * * Property type: bool. Default value: true. - */ + // --------------------------------------------------------------------------- + /** @brief Configures whether the AC loader evaluates subdivision surfaces ( + * indicated by the presence of the 'subdiv' attribute in the file). By + * default, Assimp performs the subdivision using the standard + * Catmull-Clark algorithm + * + * * Property type: bool. Default value: true. + */ #define AI_CONFIG_IMPORT_AC_EVAL_SUBDIVISION \ "IMPORT_AC_EVAL_SUBDIVISION" -// --------------------------------------------------------------------------- -/** @brief Configures the UNREAL 3D loader to separate faces with different - * surface flags (e.g. two-sided vs. single-sided). - * - * * Property type: bool. Default value: true. - */ + // --------------------------------------------------------------------------- + /** @brief Configures the UNREAL 3D loader to separate faces with different + * surface flags (e.g. two-sided vs. single-sided). + * + * * Property type: bool. Default value: true. + */ #define AI_CONFIG_IMPORT_UNREAL_HANDLE_FLAGS \ "UNREAL_HANDLE_FLAGS" -// --------------------------------------------------------------------------- -/** @brief Configures the terragen import plugin to compute uv's for - * terrains, if not given. Furthermore a default texture is assigned. - * - * UV coordinates for terrains are so simple to compute that you'll usually - * want to compute them on your own, if you need them. This option is intended - * for model viewers which want to offer an easy way to apply textures to - * terrains. - * * Property type: bool. Default value: false. - */ + // --------------------------------------------------------------------------- + /** @brief Configures the terragen import plugin to compute uv's for + * terrains, if not given. Furthermore a default texture is assigned. + * + * UV coordinates for terrains are so simple to compute that you'll usually + * want to compute them on your own, if you need them. This option is intended + * for model viewers which want to offer an easy way to apply textures to + * terrains. + * * Property type: bool. Default value: false. + */ #define AI_CONFIG_IMPORT_TER_MAKE_UVS \ "IMPORT_TER_MAKE_UVS" -// --------------------------------------------------------------------------- -/** @brief Configures the ASE loader to always reconstruct normal vectors - * basing on the smoothing groups loaded from the file. - * - * Some ASE files have carry invalid normals, other don't. - * * Property type: bool. Default value: true. - */ + // --------------------------------------------------------------------------- + /** @brief Configures the ASE loader to always reconstruct normal vectors + * basing on the smoothing groups loaded from the file. + * + * Some ASE files have carry invalid normals, other don't. + * * Property type: bool. Default value: true. + */ #define AI_CONFIG_IMPORT_ASE_RECONSTRUCT_NORMALS \ "IMPORT_ASE_RECONSTRUCT_NORMALS" -// --------------------------------------------------------------------------- -/** @brief Configures the M3D loader to detect and process multi-part - * Quake player models. - * - * These models usually consist of 3 files, lower.md3, upper.md3 and - * head.md3. If this property is set to true, Assimp will try to load and - * combine all three files if one of them is loaded. - * Property type: bool. Default value: true. - */ + // --------------------------------------------------------------------------- + /** @brief Configures the M3D loader to detect and process multi-part + * Quake player models. + * + * These models usually consist of 3 files, lower.md3, upper.md3 and + * head.md3. If this property is set to true, Assimp will try to load and + * combine all three files if one of them is loaded. + * Property type: bool. Default value: true. + */ #define AI_CONFIG_IMPORT_MD3_HANDLE_MULTIPART \ "IMPORT_MD3_HANDLE_MULTIPART" -// --------------------------------------------------------------------------- -/** @brief Tells the MD3 loader which skin files to load. - * - * When loading MD3 files, Assimp checks whether a file - * [md3_file_name]_[skin_name].skin is existing. These files are used by - * Quake III to be able to assign different skins (e.g. red and blue team) - * to models. 'default', 'red', 'blue' are typical skin names. - * Property type: String. Default value: "default". - */ + // --------------------------------------------------------------------------- + /** @brief Tells the MD3 loader which skin files to load. + * + * When loading MD3 files, Assimp checks whether a file + * [md3_file_name]_[skin_name].skin is existing. These files are used by + * Quake III to be able to assign different skins (e.g. red and blue team) + * to models. 'default', 'red', 'blue' are typical skin names. + * Property type: String. Default value: "default". + */ #define AI_CONFIG_IMPORT_MD3_SKIN_NAME \ "IMPORT_MD3_SKIN_NAME" -// --------------------------------------------------------------------------- -/** @brief Specify if to try load Quake 3 shader files. This also controls - * original surface name handling: when disabled it will be used unchanged. - * - * Property type: bool. Default value: true. - */ + // --------------------------------------------------------------------------- + /** @brief Specify if to try load Quake 3 shader files. This also controls + * original surface name handling: when disabled it will be used unchanged. + * + * Property type: bool. Default value: true. + */ #define AI_CONFIG_IMPORT_MD3_LOAD_SHADERS \ "IMPORT_MD3_LOAD_SHADERS" -// --------------------------------------------------------------------------- -/** @brief Specify the Quake 3 shader file to be used for a particular - * MD3 file. This can also be a search path. - * - * By default Assimp's behaviour is as follows: If a MD3 file - * any_path/models/any_q3_subdir/model_name/file_name.md3 is - * loaded, the library tries to locate the corresponding shader file in - * any_path/scripts/model_name.shader. This property overrides this - * behaviour. It can either specify a full path to the shader to be loaded - * or alternatively the path (relative or absolute) to the directory where - * the shaders for all MD3s to be loaded reside. Assimp attempts to open - * IMPORT_MD3_SHADER_SRC/model_name.shader first, IMPORT_MD3_SHADER_SRC/file_name.shader - * is the fallback file. Note that IMPORT_MD3_SHADER_SRC should have a terminal (back)slash. - * Property type: String. Default value: n/a. - */ + // --------------------------------------------------------------------------- + /** @brief Specify the Quake 3 shader file to be used for a particular + * MD3 file. This can also be a search path. + * + * By default Assimp's behaviour is as follows: If a MD3 file + * any_path/models/any_q3_subdir/model_name/file_name.md3 is + * loaded, the library tries to locate the corresponding shader file in + * any_path/scripts/model_name.shader. This property overrides this + * behaviour. It can either specify a full path to the shader to be loaded + * or alternatively the path (relative or absolute) to the directory where + * the shaders for all MD3s to be loaded reside. Assimp attempts to open + * IMPORT_MD3_SHADER_SRC/model_name.shader first, IMPORT_MD3_SHADER_SRC/file_name.shader + * is the fallback file. Note that IMPORT_MD3_SHADER_SRC should have a terminal (back)slash. + * Property type: String. Default value: n/a. + */ #define AI_CONFIG_IMPORT_MD3_SHADER_SRC \ "IMPORT_MD3_SHADER_SRC" -// --------------------------------------------------------------------------- -/** @brief Configures the LWO loader to load just one layer from the model. - * - * LWO files consist of layers and in some cases it could be useful to load - * only one of them. This property can be either a string - which specifies - * the name of the layer - or an integer - the index of the layer. If the - * property is not set the whole LWO model is loaded. Loading fails if the - * requested layer is not available. The layer index is zero-based and the - * layer name may not be empty.
- * Property type: Integer. Default value: all layers are loaded. - */ + // --------------------------------------------------------------------------- + /** @brief Configures the LWO loader to load just one layer from the model. + * + * LWO files consist of layers and in some cases it could be useful to load + * only one of them. This property can be either a string - which specifies + * the name of the layer - or an integer - the index of the layer. If the + * property is not set the whole LWO model is loaded. Loading fails if the + * requested layer is not available. The layer index is zero-based and the + * layer name may not be empty.
+ * Property type: Integer. Default value: all layers are loaded. + */ #define AI_CONFIG_IMPORT_LWO_ONE_LAYER_ONLY \ "IMPORT_LWO_ONE_LAYER_ONLY" -// --------------------------------------------------------------------------- -/** @brief Configures the MD5 loader to not load the MD5ANIM file for - * a MD5MESH file automatically. - * - * The default strategy is to look for a file with the same name but the - * MD5ANIM extension in the same directory. If it is found, it is loaded - * and combined with the MD5MESH file. This configuration option can be - * used to disable this behaviour. - * - * * Property type: bool. Default value: false. - */ + // --------------------------------------------------------------------------- + /** @brief Configures the MD5 loader to not load the MD5ANIM file for + * a MD5MESH file automatically. + * + * The default strategy is to look for a file with the same name but the + * MD5ANIM extension in the same directory. If it is found, it is loaded + * and combined with the MD5MESH file. This configuration option can be + * used to disable this behaviour. + * + * * Property type: bool. Default value: false. + */ #define AI_CONFIG_IMPORT_MD5_NO_ANIM_AUTOLOAD \ "IMPORT_MD5_NO_ANIM_AUTOLOAD" -// --------------------------------------------------------------------------- -/** @brief Defines the begin of the time range for which the LWS loader - * evaluates animations and computes aiNodeAnim's. - * - * Assimp provides full conversion of LightWave's envelope system, including - * pre and post conditions. The loader computes linearly subsampled animation - * chanels with the frame rate given in the LWS file. This property defines - * the start time. Note: animation channels are only generated if a node - * has at least one envelope with more tan one key assigned. This property. - * is given in frames, '0' is the first frame. By default, if this property - * is not set, the importer takes the animation start from the input LWS - * file ('FirstFrame' line)
- * Property type: Integer. Default value: taken from file. - * - * @see AI_CONFIG_IMPORT_LWS_ANIM_END - end of the imported time range - */ + // --------------------------------------------------------------------------- + /** @brief Defines the begin of the time range for which the LWS loader + * evaluates animations and computes aiNodeAnim's. + * + * Assimp provides full conversion of LightWave's envelope system, including + * pre and post conditions. The loader computes linearly subsampled animation + * chanels with the frame rate given in the LWS file. This property defines + * the start time. Note: animation channels are only generated if a node + * has at least one envelope with more tan one key assigned. This property. + * is given in frames, '0' is the first frame. By default, if this property + * is not set, the importer takes the animation start from the input LWS + * file ('FirstFrame' line)
+ * Property type: Integer. Default value: taken from file. + * + * @see AI_CONFIG_IMPORT_LWS_ANIM_END - end of the imported time range + */ #define AI_CONFIG_IMPORT_LWS_ANIM_START \ "IMPORT_LWS_ANIM_START" #define AI_CONFIG_IMPORT_LWS_ANIM_END \ "IMPORT_LWS_ANIM_END" -// --------------------------------------------------------------------------- -/** @brief Defines the output frame rate of the IRR loader. - * - * IRR animations are difficult to convert for Assimp and there will - * always be a loss of quality. This setting defines how many keys per second - * are returned by the converter.
- * Property type: integer. Default value: 100 - */ + // --------------------------------------------------------------------------- + /** @brief Defines the output frame rate of the IRR loader. + * + * IRR animations are difficult to convert for Assimp and there will + * always be a loss of quality. This setting defines how many keys per second + * are returned by the converter.
+ * Property type: integer. Default value: 100 + */ #define AI_CONFIG_IMPORT_IRR_ANIM_FPS \ "IMPORT_IRR_ANIM_FPS" -// --------------------------------------------------------------------------- -/** @brief Ogre Importer will try to find referenced materials from this file. - * - * Ogre meshes reference with material names, this does not tell Assimp the file - * where it is located in. Assimp will try to find the source file in the following - * order: .material, .material and - * lastly the material name defined by this config property. - *
- * Property type: String. Default value: Scene.material. - */ + // --------------------------------------------------------------------------- + /** @brief Ogre Importer will try to find referenced materials from this file. + * + * Ogre meshes reference with material names, this does not tell Assimp the file + * where it is located in. Assimp will try to find the source file in the following + * order: .material, .material and + * lastly the material name defined by this config property. + *
+ * Property type: String. Default value: Scene.material. + */ #define AI_CONFIG_IMPORT_OGRE_MATERIAL_FILE \ "IMPORT_OGRE_MATERIAL_FILE" -// --------------------------------------------------------------------------- -/** @brief Ogre Importer detect the texture usage from its filename. - * - * Ogre material texture units do not define texture type, the textures usage - * depends on the used shader or Ogre's fixed pipeline. If this config property - * is true Assimp will try to detect the type from the textures filename postfix: - * _n, _nrm, _nrml, _normal, _normals and _normalmap for normal map, _s, _spec, - * _specular and _specularmap for specular map, _l, _light, _lightmap, _occ - * and _occlusion for light map, _disp and _displacement for displacement map. - * The matching is case insensitive. Post fix is taken between the last - * underscore and the last period. - * Default behavior is to detect type from lower cased texture unit name by - * matching against: normalmap, specularmap, lightmap and displacementmap. - * For both cases if no match is found aiTextureType_DIFFUSE is used. - *
- * Property type: Bool. Default value: false. - */ + // --------------------------------------------------------------------------- + /** @brief Ogre Importer detect the texture usage from its filename. + * + * Ogre material texture units do not define texture type, the textures usage + * depends on the used shader or Ogre's fixed pipeline. If this config property + * is true Assimp will try to detect the type from the textures filename postfix: + * _n, _nrm, _nrml, _normal, _normals and _normalmap for normal map, _s, _spec, + * _specular and _specularmap for specular map, _l, _light, _lightmap, _occ + * and _occlusion for light map, _disp and _displacement for displacement map. + * The matching is case insensitive. Post fix is taken between the last + * underscore and the last period. + * Default behavior is to detect type from lower cased texture unit name by + * matching against: normalmap, specularmap, lightmap and displacementmap. + * For both cases if no match is found aiTextureType_DIFFUSE is used. + *
+ * Property type: Bool. Default value: false. + */ #define AI_CONFIG_IMPORT_OGRE_TEXTURETYPE_FROM_FILENAME \ "IMPORT_OGRE_TEXTURETYPE_FROM_FILENAME" - /** @brief Specifies whether the Android JNI asset extraction is supported. - * - * Turn on this option if you want to manage assets in native - * Android application without having to keep the internal directory and asset - * manager pointer. - */ - #define AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT "AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT" + /** @brief Specifies whether the Android JNI asset extraction is supported. + * + * Turn on this option if you want to manage assets in native + * Android application without having to keep the internal directory and asset + * manager pointer. + */ +#define AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT "AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT" -// --------------------------------------------------------------------------- -/** @brief Specifies whether the IFC loader skips over IfcSpace elements. - * - * IfcSpace elements (and their geometric representations) are used to - * represent, well, free space in a building storey.
- * Property type: Bool. Default value: true. - */ + // --------------------------------------------------------------------------- + /** @brief Specifies whether the IFC loader skips over IfcSpace elements. + * + * IfcSpace elements (and their geometric representations) are used to + * represent, well, free space in a building storey.
+ * Property type: Bool. Default value: true. + */ #define AI_CONFIG_IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS "IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS" -// --------------------------------------------------------------------------- -/** @brief Specifies whether the IFC loader will use its own, custom triangulation - * algorithm to triangulate wall and floor meshes. - * - * If this property is set to false, walls will be either triangulated by - * #aiProcess_Triangulate or will be passed through as huge polygons with - * faked holes (i.e. holes that are connected with the outer boundary using - * a dummy edge). It is highly recommended to set this property to true - * if you want triangulated data because #aiProcess_Triangulate is known to - * have problems with the kind of polygons that the IFC loader spits out for - * complicated meshes. - * Property type: Bool. Default value: true. - */ + // --------------------------------------------------------------------------- + /** @brief Specifies whether the IFC loader will use its own, custom triangulation + * algorithm to triangulate wall and floor meshes. + * + * If this property is set to false, walls will be either triangulated by + * #aiProcess_Triangulate or will be passed through as huge polygons with + * faked holes (i.e. holes that are connected with the outer boundary using + * a dummy edge). It is highly recommended to set this property to true + * if you want triangulated data because #aiProcess_Triangulate is known to + * have problems with the kind of polygons that the IFC loader spits out for + * complicated meshes. + * Property type: Bool. Default value: true. + */ #define AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION "IMPORT_IFC_CUSTOM_TRIANGULATION" -// --------------------------------------------------------------------------- -/** @brief Set the tessellation conic angle for IFC smoothing curves. - * - * This is used by the IFC importer to determine the tessellation parameter - * for smoothing curves. - * @note The default value is AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE and the - * accepted values are in range [5.0, 120.0]. - * Property type: Float. - */ + // --------------------------------------------------------------------------- + /** @brief Set the tessellation conic angle for IFC smoothing curves. + * + * This is used by the IFC importer to determine the tessellation parameter + * for smoothing curves. + * @note The default value is AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE and the + * accepted values are in range [5.0, 120.0]. + * Property type: Float. + */ #define AI_CONFIG_IMPORT_IFC_SMOOTHING_ANGLE "IMPORT_IFC_SMOOTHING_ANGLE" -// default value for AI_CONFIG_IMPORT_IFC_SMOOTHING_ANGLE + // default value for AI_CONFIG_IMPORT_IFC_SMOOTHING_ANGLE #if (!defined AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE) # define AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE 10.0f #endif @@ -1051,7 +1055,7 @@ enum aiComponent */ #define AI_CONFIG_IMPORT_IFC_CYLINDRICAL_TESSELLATION "IMPORT_IFC_CYLINDRICAL_TESSELLATION" -// default value for AI_CONFIG_IMPORT_IFC_CYLINDRICAL_TESSELLATION + // default value for AI_CONFIG_IMPORT_IFC_CYLINDRICAL_TESSELLATION #if (!defined AI_IMPORT_IFC_DEFAULT_CYLINDRICAL_TESSELLATION) # define AI_IMPORT_IFC_DEFAULT_CYLINDRICAL_TESSELLATION 32 #endif @@ -1065,54 +1069,99 @@ enum aiComponent */ #define AI_CONFIG_IMPORT_COLLADA_IGNORE_UP_DIRECTION "IMPORT_COLLADA_IGNORE_UP_DIRECTION" -// --------------------------------------------------------------------------- -/** @brief Specifies whether the Collada loader should use Collada names. - * - * If this property is set to true, the Collada names will be used as the node and - * mesh names. The default is to use the id tag (resp. sid tag, if no id tag is present) - * instead. - * Property type: Bool. Default value: false. - */ + // --------------------------------------------------------------------------- + /** @brief Specifies whether the Collada loader will ignore the provided unit size. + * + * If this property is set to true, the unit size provided in the file header will + * be ignored and the file will be loaded without scaling the assets. + * Property type: Bool. Default value: false. + */ +#define AI_CONFIG_IMPORT_COLLADA_IGNORE_UNIT_SIZE "IMPORT_COLLADA_IGNORE_UNIT_SIZE" + + // --------------------------------------------------------------------------- + /** @brief Specifies whether the Collada loader should use Collada names. + * + * If this property is set to true, the Collada names will be used as the node and + * mesh names. The default is to use the id tag (resp. sid tag, if no id tag is present) + * instead. + * Property type: Bool. Default value: false. + */ #define AI_CONFIG_IMPORT_COLLADA_USE_COLLADA_NAMES "IMPORT_COLLADA_USE_COLLADA_NAMES" -// ---------- All the Export defines ------------ + // ---------- All the Export defines ------------ -/** @brief Specifies the xfile use double for real values of float - * - * Property type: Bool. Default value: false. - */ + /** @brief Specifies the xfile use double for real values of float + * + * Property type: Bool. Default value: false. + */ #define AI_CONFIG_EXPORT_XFILE_64BIT "EXPORT_XFILE_64BIT" -/** @brief Specifies whether the assimp export shall be able to export point clouds - * - * When this flag is not defined the render data has to contain valid faces. - * Point clouds are only a collection of vertices which have nor spatial organization - * by a face and the validation process will remove them. Enabling this feature will - * switch off the flag and enable the functionality to export pure point clouds. - */ + /** @brief Specifies whether the assimp export shall be able to export point clouds + * + * When this flag is not defined the render data has to contain valid faces. + * Point clouds are only a collection of vertices which have nor spatial organization + * by a face and the validation process will remove them. Enabling this feature will + * switch off the flag and enable the functionality to export pure point clouds. + * + * Property type: Bool. Default value: false. + */ #define AI_CONFIG_EXPORT_POINT_CLOUDS "EXPORT_POINT_CLOUDS" -/** - * @brief Specifies the blob name, assimp uses for exporting. - * - * Some formats require auxiliary files to be written, that need to be linked back into - * the original file. For example, OBJ files export materials to a separate MTL file and - * use the `mtllib` keyword to reference this file. - * - * When exporting blobs using #ExportToBlob, assimp does not know the name of the blob - * file and thus outputs `mtllib $blobfile.mtl`, which might not be desired, since the - * MTL file might be called differently. - * - * This property can be used to give the exporter a hint on how to use the magic - * `$blobfile` keyword. If the exporter detects the keyword and is provided with a name - * for the blob, it instead uses this name. - */ + /** @brief Specifies whether to use the deprecated KHR_materials_pbrSpecularGlossiness extension + * + * When this flag is undefined any material with specularity will use the new KHR_materials_specular + * extension. Enabling this flag will revert to the deprecated extension. Note that exporting + * KHR_materials_pbrSpecularGlossiness with extensions other than KHR_materials_unlit is unsupported, + * including the basic pbrMetallicRoughness spec. + * + * Property type: Bool. Default value: false. + */ +#define AI_CONFIG_USE_GLTF_PBR_SPECULAR_GLOSSINESS "USE_GLTF_PBR_SPECULAR_GLOSSINESS" + + /** @brief Specifies whether to apply a limit on the number of four bones per vertex in skinning + * + * When this flag is not defined, all bone weights and indices are limited to a + * maximum of four bones for each vertex (attributes JOINT_0 and WEIGHT_0 only). + * By enabling this flag, the number of bones per vertex is unlimited. + * In both cases, indices and bone weights are sorted by weight in descending order. + * In the case of the limit of up to four bones, a maximum of the four largest values are exported. + * Weights are not normalized. + * Property type: Bool. Default value: false. + */ +#define AI_CONFIG_EXPORT_GLTF_UNLIMITED_SKINNING_BONES_PER_VERTEX \ + "USE_UNLIMITED_BONES_PER VERTEX" + + /** @brief Specifies whether to write the value referenced to opacity in TransparencyFactor of each material. + * + * When this flag is not defined, the TransparencyFactor value of each meterial is 1.0. + * By enabling this flag, the value is 1.0 - opacity; + + * Property type: Bool. Default value: false. + */ +#define AI_CONFIG_EXPORT_FBX_TRANSPARENCY_FACTOR_REFER_TO_OPACITY \ + "EXPORT_FBX_TRANSPARENCY_FACTOR_REFER_TO_OPACITY" + + /** + * @brief Specifies the blob name, assimp uses for exporting. + * + * Some formats require auxiliary files to be written, that need to be linked back into + * the original file. For example, OBJ files export materials to a separate MTL file and + * use the `mtllib` keyword to reference this file. + * + * When exporting blobs using #ExportToBlob, assimp does not know the name of the blob + * file and thus outputs `mtllib $blobfile.mtl`, which might not be desired, since the + * MTL file might be called differently. + * + * This property can be used to give the exporter a hint on how to use the magic + * `$blobfile` keyword. If the exporter detects the keyword and is provided with a name + * for the blob, it instead uses this name. + */ #define AI_CONFIG_EXPORT_BLOB_NAME "EXPORT_BLOB_NAME" -/** - * @brief Specifies a gobal key factor for scale, float value - */ + /** + * @brief Specifies a global key factor for scale, float value + */ #define AI_CONFIG_GLOBAL_SCALE_FACTOR_KEY "GLOBAL_SCALE_FACTOR" #if (!defined AI_CONFIG_GLOBAL_SCALE_FACTOR_DEFAULT) @@ -1126,12 +1175,11 @@ enum aiComponent #endif // AI_CONFIG_APP_SCALE_KEY -// ---------- All the Build/Compile-time defines ------------ + // ---------- All the Build/Compile-time defines ------------ -/** @brief Specifies if double precision is supported inside assimp - * - * Property type: Bool. Default value: undefined. - */ + /** @brief Specifies if double precision is supported inside assimp + * + * Property type: Bool. Default value: undefined. + */ - -#endif // !! AI_CONFIG_H_INC +#endif // !! AI_CONFIG_H_INC \ No newline at end of file diff --git a/Nuake/src/Rendering/PostFX/Volumetric.cpp b/Nuake/src/Rendering/PostFX/Volumetric.cpp index 93f0eee2..63946707 100644 --- a/Nuake/src/Rendering/PostFX/Volumetric.cpp +++ b/Nuake/src/Rendering/PostFX/Volumetric.cpp @@ -62,7 +62,7 @@ namespace Nuake { std::string u_light = "u_Lights[" + std::to_string(i) + "]."; volumetricShader->SetUniform(u_light + "transform", light.mViewProjections[0]); - volumetricShader->SetUniform(u_light + "color", light.Color); + volumetricShader->SetUniform(u_light + "color", light.Color * light.Strength); volumetricShader->SetUniform(u_light + "direction", light.GetDirection()); volumetricShader->SetUniform(u_light + "shadowmap", light.m_Framebuffers[0]->GetTexture(GL_DEPTH_ATTACHMENT).get(), 5 + i); diff --git a/Nuake/src/Resource/ModelLoader.cpp b/Nuake/src/Resource/ModelLoader.cpp index da726ef7..ec703407 100644 --- a/Nuake/src/Resource/ModelLoader.cpp +++ b/Nuake/src/Resource/ModelLoader.cpp @@ -258,17 +258,14 @@ namespace Nuake Ref ModelLoader::ProcessMesh(aiMesh* meshNode, aiNode* node, const aiScene* scene) { auto vertices = ProcessVertices(meshNode); - auto indices = ProcessIndices(meshNode); - auto material = ProcessMaterials(scene, meshNode); - for(auto& vert : vertices) { vert.position = ConvertMatrixToGLMFormat(node->mTransformation) * Vector4(vert.position, 1.0f); } Ref mesh = CreateRef(); - mesh->AddSurface(vertices, indices); - mesh->SetMaterial(material); + mesh->AddSurface(std::move(vertices), ProcessIndices(meshNode)); + mesh->SetMaterial(ProcessMaterials(scene, meshNode)); return mesh; } @@ -276,6 +273,7 @@ namespace Nuake std::vector ModelLoader::ProcessVertices(aiMesh* mesh) { auto vertices = std::vector(); + vertices.reserve(mesh->mNumVertices); for (uint32_t i = 0; i < mesh->mNumVertices; i++) { Vertex vertex {}; @@ -283,32 +281,26 @@ namespace Nuake Vector3 current; // Position - current.x = mesh->mVertices[i].x; - current.y = mesh->mVertices[i].y; - current.z = mesh->mVertices[i].z; - vertex.position = current; - - // Normals - current.x = mesh->mNormals[i].x; - current.y = mesh->mNormals[i].y; - current.z = mesh->mNormals[i].z; - vertex.normal = current; + vertex.position = { mesh->mVertices[i].x, mesh->mVertices[i].y, mesh->mVertices[i].z } ; + vertex.normal = { mesh->mNormals[i].x, mesh->mNormals[i].y, mesh->mNormals[i].z}; // Tangents if (mesh->mTangents) { - current.x = mesh->mTangents[i].x; - current.y = mesh->mTangents[i].z; - current.z = mesh->mTangents[i].y; - vertex.tangent = current; + vertex.tangent = { + mesh->mTangents[i].x, + mesh->mTangents[i].z, + mesh->mTangents[i].y + } ; } if (mesh->mBitangents) { - current.x = mesh->mBitangents[i].x; - current.y = mesh->mBitangents[i].z; - current.z = mesh->mBitangents[i].y; - vertex.bitangent = current; + vertex.bitangent = { + mesh->mBitangents[i].x, + mesh->mBitangents[i].z, + mesh->mBitangents[i].y + }; } vertex.uv = glm::vec2(0.0f, 0.0f); @@ -316,12 +308,13 @@ namespace Nuake // Does it contain UVs? if (mesh->mTextureCoords[0]) { - float u = mesh->mTextureCoords[0][i].x; - float v = mesh->mTextureCoords[0][i].y; - vertex.uv = Vector2(u, v); + vertex.uv = { + mesh->mTextureCoords[0][i].x, + mesh->mTextureCoords[0][i].y + }; } - vertices.push_back(vertex); + vertices.push_back(std::move(vertex)); } return vertices; @@ -330,6 +323,7 @@ namespace Nuake std::vector ModelLoader::ProcessSkinnedVertices(aiMesh* mesh) { auto vertices = std::vector(); + vertices.reserve(mesh->mNumVertices); for (uint32_t i = 0; i < mesh->mNumVertices; i++) { SkinnedVertex vertex; @@ -467,11 +461,17 @@ namespace Nuake if (mesh->mMaterialIndex < 0) return nullptr; - aiMaterial* materialNode = scene->mMaterials[mesh->mMaterialIndex]; - Ref material = CreateRef(); - aiString materialName; + aiMaterial* materialNode = scene->mMaterials[mesh->mMaterialIndex]; materialNode->Get(AI_MATKEY_NAME, materialName); + const std::string& materialNameStr = std::string(materialName.C_Str()); + if (auto found = m_Materials.find(materialNameStr); + found != m_Materials.end()) + { + return found->second; + } + + Ref material = CreateRef(); material->SetName(std::string(materialName.C_Str())); aiString str; @@ -507,7 +507,7 @@ namespace Nuake { materialNode->GetTexture(aiTextureType_DIFFUSE_ROUGHNESS, 0, &str); Ref albedoTexture = ProcessTextures(scene, str.C_Str()); - //material->SetRoughness(albedoTexture); + material->SetRoughness(albedoTexture); } if (materialNode->GetTextureCount(aiTextureType_DISPLACEMENT) > 0) @@ -517,6 +517,8 @@ namespace Nuake material->SetDisplacement(albedoTexture); } + m_Materials[materialNameStr] = material; + return material; } diff --git a/Nuake/src/Resource/ModelLoader.h b/Nuake/src/Resource/ModelLoader.h index 40ea7feb..be9edcbd 100644 --- a/Nuake/src/Resource/ModelLoader.h +++ b/Nuake/src/Resource/ModelLoader.h @@ -35,6 +35,7 @@ namespace Nuake std::vector> m_SkinnedMeshes; std::unordered_map m_BoneIDMap; std::unordered_map m_BoneMap; + std::map> m_Materials; void ProcessNode(aiNode* node, const aiScene* scene); Ref ProcessMesh(aiMesh* mesh, aiNode* node, const aiScene* scene); diff --git a/Nuake/src/Scene/Components/SpriteComponent.cpp b/Nuake/src/Scene/Components/SpriteComponent.cpp index 0e0cb3d0..67d91ab7 100644 --- a/Nuake/src/Scene/Components/SpriteComponent.cpp +++ b/Nuake/src/Scene/Components/SpriteComponent.cpp @@ -15,8 +15,15 @@ namespace Nuake { } - bool SpriteComponent::LoadSprite() + void SpriteComponent::SetSprite(ResourceFile path) { + if (!FileSystem::FileExists(path.GetRelativePath())) + { + return; + } + + SpritePath = FileSystem::GetFile(path.GetRelativePath()); + std::vector quadVertices = { { Vector3(-1.0f, 1.0f, 0.0f), Vector2(0.0f, 1.0f), Vector3(0, 0, 1), Vector3(1, 0, 0), Vector3(0, 1, 0) }, @@ -40,6 +47,10 @@ namespace Nuake Ref material = MaterialManager::Get()->GetMaterial(absPath); bool hasNormal = material->HasNormal(); SpriteMesh->SetMaterial(material); + } + + bool SpriteComponent::LoadSprite() + { return true; } @@ -67,6 +78,7 @@ namespace Nuake } DESERIALIZE_RES_FILE(SpritePath); + SetSprite(SpritePath); if (j.contains("PositionFacing")) { diff --git a/Nuake/src/Scene/Components/SpriteComponent.h b/Nuake/src/Scene/Components/SpriteComponent.h index ab2bacf2..622d34cc 100644 --- a/Nuake/src/Scene/Components/SpriteComponent.h +++ b/Nuake/src/Scene/Components/SpriteComponent.h @@ -19,7 +19,9 @@ namespace Nuake BindComponentField<&SpriteComponent::Billboard>("Billboard", "Billboard"); BindComponentField<&SpriteComponent::LockYRotation>("LockYRotation", "Lock Y Rotation"); BindComponentField<&SpriteComponent::PositionFacing>("PositionFacing", "Position Facing"); - BindComponentField<&SpriteComponent::SpritePath>("SpritePath", "Sprite Path"); + //BindComponentField<&SpriteComponent::SpritePath>("SpritePath", "Sprite Path"); + BindComponentProperty<&SpriteComponent::SetSprite, &SpriteComponent::GetSprite>("SpritePath", "Sprite Path"); + ResourceFileRestriction("_Image"); } public: @@ -33,6 +35,12 @@ namespace Nuake SpriteComponent(); public: + void SetSprite(ResourceFile file); + ResourceFile GetSprite() + { + return SpritePath; + } + bool LoadSprite(); json Serialize(); diff --git a/Nuake/src/Vendors/dds/dds.h b/Nuake/src/Vendors/dds/dds.h new file mode 100644 index 00000000..d46e9a03 --- /dev/null +++ b/Nuake/src/Vendors/dds/dds.h @@ -0,0 +1,952 @@ +#ifndef DDS_H +#define DDS_H +// Minimal cross-platform DDS texture utility created by Turánszki János for Wicked Engine: https://github.com/turanszkij/WickedEngine +// This is not using any includes or memory allocations, and computes relative memory offsets designed for texture streaming +// Based on DDS specification: https://learn.microsoft.com/en-us/windows/win32/direct3ddds/dx-graphics-dds-pguide#dds-file-layout +// +// How to read DDS textures: +// 1) Read the whole DDS file, or sizeof(dds::Header) bytes from the beginning of the file +// 2) Use dds::read_header() to parse the header of the DDS texture +// 3) from the dds::Header structure that was created by dds::read_header(), you can compute parameters of the texture required for loading +// 4) any function of the header returning an offset is relative to the beginning of the file, usable for texture streaming to read only the required data from files +// 5) enjoy +// +// Example: +// dds::Header header = dds::read_header(filedata, filesize); +// if(header.is_valid()) +// { +// TextureDesc desc; +// desc.width = header.width(); +// desc.mip_levels = header.mip_levels(); +// desc.array_size = header.array_size(); +// +// SubresourceData initdata; +// initdata.data_ptr = filedata + header.mip_offset(0); +// initdata.row_pitch = header.row_pitch(0); +// +// ...continue loading texture data... +// } +// +// How to write DDS textures: +// 1) Allocate memory of: sizeof(dds::Header) + your whole texture size +// 2) Use dds::write_header() to write DDS header into memory +// 3) write your texture data into memory manually after allocation + sizeof(dds::Header) +// 4) this only writes to memory, so write the result into file manually if you want to +// 5) enjoy +// +// Example: +// std::vector texturedata; // your texture data in a GPU format +// std::vector filedata; // DDS file data container +// filedata.resize(sizeof(dds::Header) + texturedata.size()); // allocate memory +// +// dds::write_header( +// filedata.data(), +// dds::DXGI_FORMAT_R8G8B8A8_UNORM, +// width, +// height, +// mip_count, // optional +// array_size, // optional +// false, // optional (is_cubemap) +// depth // optional +// ); +// std::memcpy(filedata.data() + sizeof(dds::Header), texturedata.data(), texturedata.size()); +// +// ...Or you can just freely use the structures here to write your own DDS header +// +// Note: texture data need to be in the following layout in the DDS file, tightly packed: +// - Array slice 0 / cubemap face +X +// - mipmap 0 +// - depth slice 0 +// - depth slice 1 +// - ... +// - mipmap 1 +// - depth slice 0 +// - depth slice 1 +// - ... +// - ... +// - Array slice 1 / cubemap face -X +// - mipmap 0 +// - depth slice 0 +// - depth slice 1 +// - ... +// - mipmap 1 +// - depth slice 0 +// - depth slice 1 +// - ... +// - ... +// - ... +// Note: This is similar to how you would provide the texture with DirectX 11 API's D3D11_SUBRESOURCE_DATA when creating textures +// +// Support: +// - This will only create DX10 version of DDS, doesn't support legacy +// - Tested with Texture 1D, Texture 2D, Texture 2D Array, Cubemap, Cubemap array, 3D Texture +// - Tested with uncompressed formats and block compressed +// - mipmaps: Yes +// - arrays: Yes +// +// MIT License (see the end of this file) + +namespace dds +{ + enum DDS_PIXELFORMAT_FLAGS + { + DDPF_ALPHAPIXELS = 0x1, // Texture contains alpha data; dwRGBAlphaBitMask contains valid data. + DDPF_ALPHA = 0x2, // Used in some older DDS files for alpha channel only uncompressed data (dwRGBBitCount contains the alpha channel bitcount; dwABitMask contains valid data) + DDPF_FOURCC = 0x4, // Texture contains compressed RGB data; dwFourCC contains valid data. + DDPF_RGB = 0x40, // Texture contains uncompressed RGB data; dwRGBBitCount and the RGB masks (dwRBitMask, dwGBitMask, dwBBitMask) contain valid data. + DDPF_YUV = 0x200, // Used in some older DDS files for YUV uncompressed data (dwRGBBitCount contains the YUV bit count; dwRBitMask contains the Y mask, dwGBitMask contains the U mask, dwBBitMask contains the V mask) + DDPF_LUMINANCE = 0x20000 // Used in some older DDS files for single channel color uncompressed data (dwRGBBitCount contains the luminance channel bit count; dwRBitMask contains the channel mask). Can be combined with DDPF_ALPHAPIXELS for a two channel DDS file. + }; + struct DDS_PIXELFORMAT { + unsigned dwSize; + unsigned dwFlags; + unsigned dwFourCC; + unsigned dwRGBBitCount; + unsigned dwRBitMask; + unsigned dwGBitMask; + unsigned dwBBitMask; + unsigned dwABitMask; + }; + enum DDSD_CAPS + { + DDSD_CAPS = 0x1, // Required in every .dds file. + DDSD_HEIGHT = 0x2, // Required in every .dds file. + DDSD_WIDTH = 0x4, // Required in every .dds file. + DDSD_PITCH = 0x8, // Required when pitch is provided for an uncompressed texture. + DDSD_PIXELFORMAT = 0x1000, // Required in every .dds file. + DDSD_MIPMAPCOUNT = 0x20000, // Required in a mipmapped texture. + DDSD_LINEARSIZE = 0x80000, // Required when pitch is provided for a compressed texture. + DDSD_DEPTH = 0x800000 // Required in a depth texture. + }; + enum DDSCAPS + { + DDSCAPS_COMPLEX = 0x8, // Optional; must be used on any file that contains more than one surface (a mipmap, a cubic environment map, or mipmapped volume texture). + DDSCAPS_MIPMAP = 0x400000, // Optional; should be used for a mipmap. + DDSCAPS_TEXTURE = 0x1000, // Required + }; + enum DDSCAPS2 + { + DDSCAPS2_CUBEMAP = 0x200, // Required for a cube map. + DDSCAPS2_CUBEMAP_POSITIVEX = 0x400, // Required when these surfaces are stored in a cube map. + DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800, // Required when these surfaces are stored in a cube map. + DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,// Required when these surfaces are stored in a cube map. + DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,// Required when these surfaces are stored in a cube map. + DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,// Required when these surfaces are stored in a cube map. + DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,// Required when these surfaces are stored in a cube map. + DDSCAPS2_VOLUME = 0x200000, // Required for a volume texture. + }; + typedef struct { + unsigned dwSize; + unsigned dwFlags; + unsigned dwHeight; + unsigned dwWidth; + unsigned dwPitchOrLinearSize; + unsigned dwDepth; + unsigned dwMipMapCount; + unsigned dwReserved1[11]; + DDS_PIXELFORMAT ddspf; + unsigned dwCaps; + unsigned dwCaps2; + unsigned dwCaps3; + unsigned dwCaps4; + unsigned dwReserved2; + } DDS_HEADER; + enum DXGI_FORMAT { + DXGI_FORMAT_UNKNOWN = 0, + DXGI_FORMAT_R32G32B32A32_TYPELESS = 1, + DXGI_FORMAT_R32G32B32A32_FLOAT = 2, + DXGI_FORMAT_R32G32B32A32_UINT = 3, + DXGI_FORMAT_R32G32B32A32_SINT = 4, + DXGI_FORMAT_R32G32B32_TYPELESS = 5, + DXGI_FORMAT_R32G32B32_FLOAT = 6, + DXGI_FORMAT_R32G32B32_UINT = 7, + DXGI_FORMAT_R32G32B32_SINT = 8, + DXGI_FORMAT_R16G16B16A16_TYPELESS = 9, + DXGI_FORMAT_R16G16B16A16_FLOAT = 10, + DXGI_FORMAT_R16G16B16A16_UNORM = 11, + DXGI_FORMAT_R16G16B16A16_UINT = 12, + DXGI_FORMAT_R16G16B16A16_SNORM = 13, + DXGI_FORMAT_R16G16B16A16_SINT = 14, + DXGI_FORMAT_R32G32_TYPELESS = 15, + DXGI_FORMAT_R32G32_FLOAT = 16, + DXGI_FORMAT_R32G32_UINT = 17, + DXGI_FORMAT_R32G32_SINT = 18, + DXGI_FORMAT_R32G8X24_TYPELESS = 19, + DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20, + DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21, + DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22, + DXGI_FORMAT_R10G10B10A2_TYPELESS = 23, + DXGI_FORMAT_R10G10B10A2_UNORM = 24, + DXGI_FORMAT_R10G10B10A2_UINT = 25, + DXGI_FORMAT_R11G11B10_FLOAT = 26, + DXGI_FORMAT_R8G8B8A8_TYPELESS = 27, + DXGI_FORMAT_R8G8B8A8_UNORM = 28, + DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29, + DXGI_FORMAT_R8G8B8A8_UINT = 30, + DXGI_FORMAT_R8G8B8A8_SNORM = 31, + DXGI_FORMAT_R8G8B8A8_SINT = 32, + DXGI_FORMAT_R16G16_TYPELESS = 33, + DXGI_FORMAT_R16G16_FLOAT = 34, + DXGI_FORMAT_R16G16_UNORM = 35, + DXGI_FORMAT_R16G16_UINT = 36, + DXGI_FORMAT_R16G16_SNORM = 37, + DXGI_FORMAT_R16G16_SINT = 38, + DXGI_FORMAT_R32_TYPELESS = 39, + DXGI_FORMAT_D32_FLOAT = 40, + DXGI_FORMAT_R32_FLOAT = 41, + DXGI_FORMAT_R32_UINT = 42, + DXGI_FORMAT_R32_SINT = 43, + DXGI_FORMAT_R24G8_TYPELESS = 44, + DXGI_FORMAT_D24_UNORM_S8_UINT = 45, + DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46, + DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47, + DXGI_FORMAT_R8G8_TYPELESS = 48, + DXGI_FORMAT_R8G8_UNORM = 49, + DXGI_FORMAT_R8G8_UINT = 50, + DXGI_FORMAT_R8G8_SNORM = 51, + DXGI_FORMAT_R8G8_SINT = 52, + DXGI_FORMAT_R16_TYPELESS = 53, + DXGI_FORMAT_R16_FLOAT = 54, + DXGI_FORMAT_D16_UNORM = 55, + DXGI_FORMAT_R16_UNORM = 56, + DXGI_FORMAT_R16_UINT = 57, + DXGI_FORMAT_R16_SNORM = 58, + DXGI_FORMAT_R16_SINT = 59, + DXGI_FORMAT_R8_TYPELESS = 60, + DXGI_FORMAT_R8_UNORM = 61, + DXGI_FORMAT_R8_UINT = 62, + DXGI_FORMAT_R8_SNORM = 63, + DXGI_FORMAT_R8_SINT = 64, + DXGI_FORMAT_A8_UNORM = 65, + DXGI_FORMAT_R1_UNORM = 66, + DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67, + DXGI_FORMAT_R8G8_B8G8_UNORM = 68, + DXGI_FORMAT_G8R8_G8B8_UNORM = 69, + DXGI_FORMAT_BC1_TYPELESS = 70, + DXGI_FORMAT_BC1_UNORM = 71, + DXGI_FORMAT_BC1_UNORM_SRGB = 72, + DXGI_FORMAT_BC2_TYPELESS = 73, + DXGI_FORMAT_BC2_UNORM = 74, + DXGI_FORMAT_BC2_UNORM_SRGB = 75, + DXGI_FORMAT_BC3_TYPELESS = 76, + DXGI_FORMAT_BC3_UNORM = 77, + DXGI_FORMAT_BC3_UNORM_SRGB = 78, + DXGI_FORMAT_BC4_TYPELESS = 79, + DXGI_FORMAT_BC4_UNORM = 80, + DXGI_FORMAT_BC4_SNORM = 81, + DXGI_FORMAT_BC5_TYPELESS = 82, + DXGI_FORMAT_BC5_UNORM = 83, + DXGI_FORMAT_BC5_SNORM = 84, + DXGI_FORMAT_B5G6R5_UNORM = 85, + DXGI_FORMAT_B5G5R5A1_UNORM = 86, + DXGI_FORMAT_B8G8R8A8_UNORM = 87, + DXGI_FORMAT_B8G8R8X8_UNORM = 88, + DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89, + DXGI_FORMAT_B8G8R8A8_TYPELESS = 90, + DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91, + DXGI_FORMAT_B8G8R8X8_TYPELESS = 92, + DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93, + DXGI_FORMAT_BC6H_TYPELESS = 94, + DXGI_FORMAT_BC6H_UF16 = 95, + DXGI_FORMAT_BC6H_SF16 = 96, + DXGI_FORMAT_BC7_TYPELESS = 97, + DXGI_FORMAT_BC7_UNORM = 98, + DXGI_FORMAT_BC7_UNORM_SRGB = 99, + DXGI_FORMAT_AYUV = 100, + DXGI_FORMAT_Y410 = 101, + DXGI_FORMAT_Y416 = 102, + DXGI_FORMAT_NV12 = 103, + DXGI_FORMAT_P010 = 104, + DXGI_FORMAT_P016 = 105, + DXGI_FORMAT_420_OPAQUE = 106, + DXGI_FORMAT_YUY2 = 107, + DXGI_FORMAT_Y210 = 108, + DXGI_FORMAT_Y216 = 109, + DXGI_FORMAT_NV11 = 110, + DXGI_FORMAT_AI44 = 111, + DXGI_FORMAT_IA44 = 112, + DXGI_FORMAT_P8 = 113, + DXGI_FORMAT_A8P8 = 114, + DXGI_FORMAT_B4G4R4A4_UNORM = 115, + DXGI_FORMAT_P208 = 130, + DXGI_FORMAT_V208 = 131, + DXGI_FORMAT_V408 = 132, + DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE, + DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE, + D3DFMT_R8G8B8, // Note: you will need to handle conversion of this legacy format yourself + DXGI_FORMAT_FORCE_DWORD = 0xffffffff + }; + enum D3D10_RESOURCE_DIMENSION { + D3D10_RESOURCE_DIMENSION_UNKNOWN = 0, + D3D10_RESOURCE_DIMENSION_BUFFER = 1, + D3D10_RESOURCE_DIMENSION_TEXTURE1D = 2, + D3D10_RESOURCE_DIMENSION_TEXTURE2D = 3, + D3D10_RESOURCE_DIMENSION_TEXTURE3D = 4 + }; + enum DDS_RESOURCE_MISC_TEXTURECUBE + { + DDS_RESOURCE_MISC_TEXTURECUBE = 0x4, // Indicates a 2D texture is a cube-map texture. + }; + enum DDS_ALPHA_MODE + { + DDS_ALPHA_MODE_UNKNOWN = 0x0, // Alpha channel content is unknown. This is the value for legacy files, which typically is assumed to be 'straight' alpha. + DDS_ALPHA_MODE_STRAIGHT = 0x1, // Any alpha channel content is presumed to use straight alpha. + DDS_ALPHA_MODE_PREMULTIPLIED = 0x2, // Any alpha channel content is using premultiplied alpha. The only legacy file formats that indicate this information are 'DX2' and 'DX4'. + DDS_ALPHA_MODE_OPAQUE = 0x3, // Any alpha channel content is all set to fully opaque. + DDS_ALPHA_MODE_CUSTOM = 0x4, // Any alpha channel content is being used as a 4th channel and is not intended to represent transparency (straight or premultiplied). + }; + typedef struct { + DXGI_FORMAT dxgiFormat; + D3D10_RESOURCE_DIMENSION resourceDimension; + unsigned miscFlag; + unsigned arraySize; + unsigned miscFlags2; + } DDS_HEADER_DXT10; + + static constexpr unsigned fourcc(char a, char b, char c, char d) + { + return (((unsigned)(d) << 24) | ((unsigned)(c) << 16) | ((unsigned)(b) << 8) | (unsigned)(a)); + } + + struct Header + { + unsigned magic; + DDS_HEADER header; + DDS_HEADER_DXT10 header10; + + // Returns true if this structure can be used, false otherwise + constexpr bool is_valid() const + { + return + magic == fourcc('D', 'D', 'S', ' ') && + header.ddspf.dwSize == sizeof(DDS_PIXELFORMAT); + } + // Returns true if the header10 member is valid + constexpr bool is_dx10() const + { + return + (header.ddspf.dwFlags & DDPF_FOURCC) && + header.ddspf.dwFourCC == fourcc('D', 'X', '1', '0'); + } + // returns the width of the texture in pixels + constexpr unsigned width() const + { + return header.dwWidth < 1 ? 1 : header.dwWidth; + } + // returns the height of the texture in pixels + constexpr unsigned height() const + { + return header.dwHeight < 1 ? 1 : header.dwHeight; + } + // returns the depth of the texture in pixels + constexpr unsigned depth() const + { + return header.dwDepth < 1 ? 1 : header.dwDepth; + } + // returns the mipmap levels in the texture per slice + constexpr unsigned mip_levels() const + { + return header.dwMipMapCount > 0 ? header.dwMipMapCount : 1; + } + // returns the number of slices in the texture + constexpr unsigned array_size() const + { + if (!is_dx10()) + { + if (is_cubemap()) + return 6; + return 1; + } + unsigned count = 0; + if (is_cubemap()) + count = header10.arraySize * 6; + else + count = header10.arraySize; + count = count < 1 ? 1 : count; + return count; + } + // returns the format of the texture in the DXGI_FORMAT that is complatible with DX10, even when the texture is using legacy format + constexpr DXGI_FORMAT format() const + { + if (!is_dx10()) + { + if (header.ddspf.dwFlags & DDPF_RGB) + { + switch (header.ddspf.dwRGBBitCount) + { + case 32: + if (header.ddspf.dwRBitMask == 0x000000ff && + header.ddspf.dwGBitMask == 0x0000ff00 && + header.ddspf.dwBBitMask == 0x00ff0000 && + header.ddspf.dwABitMask == 0xff000000) { + return DXGI_FORMAT_R8G8B8A8_UNORM; + } + if (header.ddspf.dwRBitMask == 0x00ff0000 && + header.ddspf.dwGBitMask == 0x0000ff00 && + header.ddspf.dwBBitMask == 0x000000ff && + header.ddspf.dwABitMask == 0xff000000) { + return DXGI_FORMAT_B8G8R8A8_UNORM; + } + if (header.ddspf.dwRBitMask == 0x00ff0000 && + header.ddspf.dwGBitMask == 0x0000ff00 && + header.ddspf.dwBBitMask == 0x000000ff && + header.ddspf.dwABitMask == 0x00000000) { + return DXGI_FORMAT_B8G8R8X8_UNORM; + } + + if (header.ddspf.dwRBitMask == 0x0000ffff && + header.ddspf.dwGBitMask == 0xffff0000 && + header.ddspf.dwBBitMask == 0x00000000 && + header.ddspf.dwABitMask == 0x00000000) { + return DXGI_FORMAT_R16G16_UNORM; + } + + if (header.ddspf.dwRBitMask == 0xffffffff && + header.ddspf.dwGBitMask == 0x00000000 && + header.ddspf.dwBBitMask == 0x00000000 && + header.ddspf.dwABitMask == 0x00000000) { + return DXGI_FORMAT_R32_FLOAT; + } + break; + case 24: + return D3DFMT_R8G8B8; + case 16: + if (header.ddspf.dwRBitMask == 0x7c00 && header.ddspf.dwGBitMask == 0x03e0 && + header.ddspf.dwBBitMask == 0x001f && header.ddspf.dwABitMask == 0x8000) { + return DXGI_FORMAT_B5G5R5A1_UNORM; + } + if (header.ddspf.dwRBitMask == 0xf800 && header.ddspf.dwGBitMask == 0x07e0 && + header.ddspf.dwBBitMask == 0x001f && header.ddspf.dwABitMask == 0x0000) { + return DXGI_FORMAT_B5G6R5_UNORM; + } + + if (header.ddspf.dwRBitMask == 0x0f00 && header.ddspf.dwGBitMask == 0x00f0 && + header.ddspf.dwBBitMask == 0x000f && header.ddspf.dwABitMask == 0xf000) { + return DXGI_FORMAT_B4G4R4A4_UNORM; + } + break; + default: + break; + } + } + else if (header.ddspf.dwFlags & DDPF_LUMINANCE) { + if (8 == header.ddspf.dwRGBBitCount) { + if (header.ddspf.dwRBitMask == 0x000000ff && header.ddspf.dwGBitMask == 0x00000000 && + header.ddspf.dwBBitMask == 0x00000000 && header.ddspf.dwABitMask == 0x00000000) { + return DXGI_FORMAT_R8_UNORM; + } + if (header.ddspf.dwRBitMask == 0x000000ff && header.ddspf.dwGBitMask == 0x0000ff00 && + header.ddspf.dwBBitMask == 0x00000000 && header.ddspf.dwABitMask == 0x00000000) { + return DXGI_FORMAT_R8G8_UNORM; + } + } + if (16 == header.ddspf.dwRGBBitCount) { + if (header.ddspf.dwRBitMask == 0x0000ffff && header.ddspf.dwGBitMask == 0x00000000 && + header.ddspf.dwBBitMask == 0x00000000 && header.ddspf.dwABitMask == 0x00000000) { + return DXGI_FORMAT_R16_UNORM; + } + if (header.ddspf.dwRBitMask == 0x000000ff && header.ddspf.dwGBitMask == 0x0000ff00 && + header.ddspf.dwBBitMask == 0x00000000 && header.ddspf.dwABitMask == 0x00000000) { + return DXGI_FORMAT_R8G8_UNORM; + } + } + } + else if (header.ddspf.dwFlags & DDPF_ALPHA) { + if (8 == header.ddspf.dwRGBBitCount) { + return DXGI_FORMAT_A8_UNORM; + } + } + else if (header.ddspf.dwFlags & DDPF_FOURCC) { + if (fourcc('D', 'X', 'T', '1') == header.ddspf.dwFourCC) { + return DXGI_FORMAT_BC1_UNORM; + } + if (fourcc('D', 'X', 'T', '3') == header.ddspf.dwFourCC) { + return DXGI_FORMAT_BC2_UNORM; + } + if (fourcc('D', 'X', 'T', '5') == header.ddspf.dwFourCC) { + return DXGI_FORMAT_BC3_UNORM; + } + + if (fourcc('D', 'X', 'T', '4') == header.ddspf.dwFourCC) { + return DXGI_FORMAT_BC2_UNORM; + } + if (fourcc('D', 'X', 'T', '5') == header.ddspf.dwFourCC) { + return DXGI_FORMAT_BC3_UNORM; + } + + if (fourcc('A', 'T', 'I', '1') == header.ddspf.dwFourCC) { + return DXGI_FORMAT_BC4_UNORM; + } + if (fourcc('B', 'C', '4', 'U') == header.ddspf.dwFourCC) { + return DXGI_FORMAT_BC4_UNORM; + } + if (fourcc('B', 'C', '4', 'S') == header.ddspf.dwFourCC) { + return DXGI_FORMAT_BC4_SNORM; + } + + if (fourcc('A', 'T', 'I', '2') == header.ddspf.dwFourCC) { + return DXGI_FORMAT_BC5_UNORM; + } + if (fourcc('B', 'C', '5', 'U') == header.ddspf.dwFourCC) { + return DXGI_FORMAT_BC5_UNORM; + } + if (fourcc('B', 'C', '5', 'S') == header.ddspf.dwFourCC) { + return DXGI_FORMAT_BC5_SNORM; + } + + if (fourcc('R', 'G', 'B', 'G') == header.ddspf.dwFourCC) { + return DXGI_FORMAT_R8G8_B8G8_UNORM; + } + if (fourcc('G', 'R', 'G', 'B') == header.ddspf.dwFourCC) { + return DXGI_FORMAT_G8R8_G8B8_UNORM; + } + + if (fourcc('Y', 'U', 'Y', '2') == header.ddspf.dwFourCC) { + return DXGI_FORMAT_YUY2; + } + + switch (header.ddspf.dwFourCC) { + case 36: + return DXGI_FORMAT_R16G16B16A16_UNORM; + case 110: + return DXGI_FORMAT_R16G16B16A16_SNORM; + case 111: + return DXGI_FORMAT_R16_FLOAT; + case 112: + return DXGI_FORMAT_R16G16_FLOAT; + case 113: + return DXGI_FORMAT_R16G16B16A16_FLOAT; + case 114: + return DXGI_FORMAT_R32_FLOAT; + case 115: + return DXGI_FORMAT_R32G32_FLOAT; + case 116: + return DXGI_FORMAT_R32G32B32A32_FLOAT; + } + } + return DXGI_FORMAT_UNKNOWN; + } + return header10.dxgiFormat; + } + // returns tru if the texture is a cubemap, false otherwise + constexpr bool is_cubemap() const + { + if (is_dx10()) + { + return header10.miscFlag & DDS_RESOURCE_MISC_TEXTURECUBE; + } + return + (header.dwCaps2 & DDSCAPS2_CUBEMAP) && + (header.dwCaps2 & DDSCAPS2_CUBEMAP_POSITIVEX) && + (header.dwCaps2 & DDSCAPS2_CUBEMAP_NEGATIVEX) && + (header.dwCaps2 & DDSCAPS2_CUBEMAP_POSITIVEY) && + (header.dwCaps2 & DDSCAPS2_CUBEMAP_NEGATIVEY) && + (header.dwCaps2 & DDSCAPS2_CUBEMAP_POSITIVEZ) && + (header.dwCaps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ) + ; + } + // returns true if the texture is one dimensional, false otherwise + constexpr bool is_1d() const + { + if (!is_dx10()) + return false; + return header10.resourceDimension == D3D10_RESOURCE_DIMENSION_TEXTURE1D; + } + // returns true if the texture is three dimensional, false otherwise + constexpr bool is_3d() const + { + if (!is_dx10()) + return false; + return + (header.dwCaps2 & DDSCAPS2_VOLUME) && + header10.resourceDimension == D3D10_RESOURCE_DIMENSION_TEXTURE3D + ; + } + // returns the number of bits per element. Element refers to a block of pixels if the texture is block compressed, or a single pixel otherwise + constexpr unsigned bits_per_element() const + { + switch (format()) + { + case DXGI_FORMAT_R32G32B32A32_TYPELESS: + case DXGI_FORMAT_R32G32B32A32_FLOAT: + case DXGI_FORMAT_R32G32B32A32_UINT: + case DXGI_FORMAT_R32G32B32A32_SINT: + return 128; + + case DXGI_FORMAT_R32G32B32_TYPELESS: + case DXGI_FORMAT_R32G32B32_FLOAT: + case DXGI_FORMAT_R32G32B32_UINT: + case DXGI_FORMAT_R32G32B32_SINT: + return 96; + + case DXGI_FORMAT_R16G16B16A16_TYPELESS: + case DXGI_FORMAT_R16G16B16A16_FLOAT: + case DXGI_FORMAT_R16G16B16A16_UNORM: + case DXGI_FORMAT_R16G16B16A16_UINT: + case DXGI_FORMAT_R16G16B16A16_SNORM: + case DXGI_FORMAT_R16G16B16A16_SINT: + case DXGI_FORMAT_R32G32_TYPELESS: + case DXGI_FORMAT_R32G32_FLOAT: + case DXGI_FORMAT_R32G32_UINT: + case DXGI_FORMAT_R32G32_SINT: + case DXGI_FORMAT_R32G8X24_TYPELESS: + case DXGI_FORMAT_D32_FLOAT_S8X24_UINT: + case DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS: + case DXGI_FORMAT_X32_TYPELESS_G8X24_UINT: + case DXGI_FORMAT_Y416: + case DXGI_FORMAT_Y210: + case DXGI_FORMAT_Y216: + return 64; + + case DXGI_FORMAT_R10G10B10A2_TYPELESS: + case DXGI_FORMAT_R10G10B10A2_UNORM: + case DXGI_FORMAT_R10G10B10A2_UINT: + case DXGI_FORMAT_R11G11B10_FLOAT: + case DXGI_FORMAT_R8G8B8A8_TYPELESS: + case DXGI_FORMAT_R8G8B8A8_UNORM: + case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: + case DXGI_FORMAT_R8G8B8A8_UINT: + case DXGI_FORMAT_R8G8B8A8_SNORM: + case DXGI_FORMAT_R8G8B8A8_SINT: + case DXGI_FORMAT_R16G16_TYPELESS: + case DXGI_FORMAT_R16G16_FLOAT: + case DXGI_FORMAT_R16G16_UNORM: + case DXGI_FORMAT_R16G16_UINT: + case DXGI_FORMAT_R16G16_SNORM: + case DXGI_FORMAT_R16G16_SINT: + case DXGI_FORMAT_R32_TYPELESS: + case DXGI_FORMAT_D32_FLOAT: + case DXGI_FORMAT_R32_FLOAT: + case DXGI_FORMAT_R32_UINT: + case DXGI_FORMAT_R32_SINT: + case DXGI_FORMAT_R24G8_TYPELESS: + case DXGI_FORMAT_D24_UNORM_S8_UINT: + case DXGI_FORMAT_R24_UNORM_X8_TYPELESS: + case DXGI_FORMAT_X24_TYPELESS_G8_UINT: + case DXGI_FORMAT_R9G9B9E5_SHAREDEXP: + case DXGI_FORMAT_R8G8_B8G8_UNORM: + case DXGI_FORMAT_G8R8_G8B8_UNORM: + case DXGI_FORMAT_B8G8R8A8_UNORM: + case DXGI_FORMAT_B8G8R8X8_UNORM: + case DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM: + case DXGI_FORMAT_B8G8R8A8_TYPELESS: + case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: + case DXGI_FORMAT_B8G8R8X8_TYPELESS: + case DXGI_FORMAT_B8G8R8X8_UNORM_SRGB: + case DXGI_FORMAT_AYUV: + case DXGI_FORMAT_Y410: + case DXGI_FORMAT_YUY2: + case D3DFMT_R8G8B8: // need to be expanded with alpha + return 32; + + case DXGI_FORMAT_P010: + case DXGI_FORMAT_P016: + return 24; + + case DXGI_FORMAT_R8G8_TYPELESS: + case DXGI_FORMAT_R8G8_UNORM: + case DXGI_FORMAT_R8G8_UINT: + case DXGI_FORMAT_R8G8_SNORM: + case DXGI_FORMAT_R8G8_SINT: + case DXGI_FORMAT_R16_TYPELESS: + case DXGI_FORMAT_R16_FLOAT: + case DXGI_FORMAT_D16_UNORM: + case DXGI_FORMAT_R16_UNORM: + case DXGI_FORMAT_R16_UINT: + case DXGI_FORMAT_R16_SNORM: + case DXGI_FORMAT_R16_SINT: + case DXGI_FORMAT_B5G6R5_UNORM: + case DXGI_FORMAT_B5G5R5A1_UNORM: + case DXGI_FORMAT_A8P8: + case DXGI_FORMAT_B4G4R4A4_UNORM: + return 16; + + case DXGI_FORMAT_NV12: + case DXGI_FORMAT_NV11: + return 12; + + case DXGI_FORMAT_R8_TYPELESS: + case DXGI_FORMAT_R8_UNORM: + case DXGI_FORMAT_R8_UINT: + case DXGI_FORMAT_R8_SNORM: + case DXGI_FORMAT_R8_SINT: + case DXGI_FORMAT_A8_UNORM: + case DXGI_FORMAT_AI44: + case DXGI_FORMAT_IA44: + case DXGI_FORMAT_P8: + return 8; + + case DXGI_FORMAT_R1_UNORM: + return 1; + + case DXGI_FORMAT_BC1_TYPELESS: + case DXGI_FORMAT_BC1_UNORM: + case DXGI_FORMAT_BC1_UNORM_SRGB: + case DXGI_FORMAT_BC4_TYPELESS: + case DXGI_FORMAT_BC4_UNORM: + case DXGI_FORMAT_BC4_SNORM: + return 64; + + case DXGI_FORMAT_BC2_TYPELESS: + case DXGI_FORMAT_BC2_UNORM: + case DXGI_FORMAT_BC2_UNORM_SRGB: + case DXGI_FORMAT_BC3_TYPELESS: + case DXGI_FORMAT_BC3_UNORM: + case DXGI_FORMAT_BC3_UNORM_SRGB: + case DXGI_FORMAT_BC5_TYPELESS: + case DXGI_FORMAT_BC5_UNORM: + case DXGI_FORMAT_BC5_SNORM: + case DXGI_FORMAT_BC6H_TYPELESS: + case DXGI_FORMAT_BC6H_UF16: + case DXGI_FORMAT_BC6H_SF16: + case DXGI_FORMAT_BC7_TYPELESS: + case DXGI_FORMAT_BC7_UNORM: + case DXGI_FORMAT_BC7_UNORM_SRGB: + return 128; + default: + return 0; + } + } + // returns 1 for non-block compressed formats, or the block size if it's compressed + constexpr unsigned block_size() const + { + switch (format()) + { + case DXGI_FORMAT_BC1_TYPELESS: + case DXGI_FORMAT_BC1_UNORM: + case DXGI_FORMAT_BC1_UNORM_SRGB: + case DXGI_FORMAT_BC4_TYPELESS: + case DXGI_FORMAT_BC4_UNORM: + case DXGI_FORMAT_BC4_SNORM: + case DXGI_FORMAT_BC2_TYPELESS: + case DXGI_FORMAT_BC2_UNORM: + case DXGI_FORMAT_BC2_UNORM_SRGB: + case DXGI_FORMAT_BC3_TYPELESS: + case DXGI_FORMAT_BC3_UNORM: + case DXGI_FORMAT_BC3_UNORM_SRGB: + case DXGI_FORMAT_BC5_TYPELESS: + case DXGI_FORMAT_BC5_UNORM: + case DXGI_FORMAT_BC5_SNORM: + case DXGI_FORMAT_BC6H_TYPELESS: + case DXGI_FORMAT_BC6H_UF16: + case DXGI_FORMAT_BC6H_SF16: + case DXGI_FORMAT_BC7_TYPELESS: + case DXGI_FORMAT_BC7_UNORM: + case DXGI_FORMAT_BC7_UNORM_SRGB: + return 4; + default: + return 1; + } + } + // returns the size of a specific mipmap in bytes + constexpr unsigned long long mip_size(unsigned mip) const + { + const unsigned long long bpe = bits_per_element(); + const unsigned long long blocksize = block_size(); + unsigned long long num_blocks_x = (width() + blocksize - 1) / blocksize; + unsigned long long num_blocks_y = (height() + blocksize - 1) / blocksize; + unsigned long long num_elements_z = depth(); + num_blocks_x >>= mip; + num_blocks_y >>= mip; + num_elements_z >>= mip; + num_blocks_x = num_blocks_x < 1 ? 1 : num_blocks_x; + num_blocks_y = num_blocks_y < 1 ? 1 : num_blocks_y; + num_elements_z = num_elements_z < 1 ? 1 : num_elements_z; + return num_blocks_x * num_blocks_y * num_elements_z * bpe / 8ull; + } + // returns the size of one slice in bytes + constexpr unsigned long long slice_size() const + { + const unsigned mips = mip_levels(); + unsigned long long size = 0; + for (unsigned mip = 0; mip < mips; ++mip) + { + size += mip_size(mip); + } + return size; + } + // returns the size of the whole pixel data in bytes, including all slices and mipmaps + constexpr unsigned long long data_size() const + { + return array_size() * slice_size(); + } + // returns the offset of the pixel data relative to the beginning of the file, in bytes + constexpr unsigned long long data_offset() const + { + unsigned long long offset = sizeof(Header); + if (!is_dx10()) + offset -= sizeof(Header::header10); + return offset; + } + // returns the offset of a specific slice relative to the beginning of the file, in bytes + constexpr unsigned long long slice_offset(unsigned slice) const + { + return data_offset() + slice_size() * slice; + } + // returns the offset of a specific mipmap of a specific slice relative to the beginning of the file, in bytes + constexpr unsigned long long mip_offset(unsigned mip, unsigned slice = 0) const + { + unsigned long long offset = slice_offset(slice); + const unsigned mips = mip_levels(); + for (unsigned i = 0; i < mip; ++i) + { + offset += mip_size(i); + } + return offset; + } + // returns the size of one row in a specific mip level in bytes + constexpr unsigned row_pitch(unsigned mip) const + { + const unsigned long long bpe = bits_per_element(); + const unsigned long long blocksize = block_size(); + unsigned long long num_blocks_x = (width() + blocksize - 1) / blocksize; + num_blocks_x >>= mip; + num_blocks_x = num_blocks_x < 1 ? 1 : num_blocks_x; + return unsigned(num_blocks_x * bpe / 8); + } + // returns the size of a specific slice at a specific mip level in bytes + constexpr unsigned slice_pitch(unsigned mip) const + { + const unsigned long long blocksize = block_size(); + unsigned long long num_blocks_y = (width() + blocksize - 1) / blocksize; + unsigned long long num_elements_z = depth(); + num_blocks_y >>= mip; + num_elements_z >>= mip; + num_blocks_y = num_blocks_y < 1 ? 1 : num_blocks_y; + num_elements_z = num_elements_z < 1 ? 1 : num_elements_z; + return unsigned(row_pitch(mip) * num_blocks_y * num_elements_z); + } + }; + + // Read DDS header from memory + // data: pointer to memory, this should be the very start of the DDS file (fourcc bytes included) + // size: size of memory that data points to. It should be sizeof(dds::Header) or larger + // + // returns dds::Header, which you can use to determine relative memory offsets and sizes required to reference certain parts of the texture + inline Header read_header( + const void* data, + unsigned long long size + ) + { + Header h = {}; + if (data == nullptr) + return h; // invalid pointer + if (size < sizeof(Header::magic) + sizeof(Header::header)) + return h; // magic and header is a must have + h.magic = *(const unsigned*)data; + if (h.magic != fourcc('D', 'D', 'S', ' ')) + return h; // fourcc is invalid + + h.header = *(const DDS_HEADER*)((const char*)data + sizeof(h.magic)); + if (size >= sizeof(Header) && h.is_dx10()) + { + h.header10 = (*(const Header*)data).header10; + } + + return h; + } + + // Write the DDS header into memory. + // dst: destination file in memory, must be at least of sizeof(dds::Header) + // format: data format of texture data that will be placed after header + // width: width of top mip level + // height: height of top mip level (you can set this to 0 to indicate 1D texture) + // mip_levels: number of mip levels in the file + // array_size: number of slices in the file. For cubemaps, there is one slice for every face. For 3D texture, there is always only 1 slice. + // is_cubemap: whether the texture is a cubemap. If it is a cubemap, it must have at least array_size = 6 + // depth: depth of 3D texture (you can set this to 0 to indicate that the texture is not 3D) + inline void write_header( + void* dst, + DXGI_FORMAT format, + unsigned int width, + unsigned int height, + unsigned int mip_levels = 1, + unsigned int array_size = 1, + bool is_cubemap = false, + unsigned int depth = 0 + ) + { + Header h = {}; + h.magic = fourcc('D', 'D', 'S', ' '); + h.header.dwSize = sizeof(DDS_HEADER); + h.header.dwFlags = + DDSD_CAPS | + DDSD_WIDTH | + DDSD_HEIGHT | + DDSD_PIXELFORMAT | + DDSD_MIPMAPCOUNT + ; + h.header.dwWidth = width; + h.header.dwHeight = height; + h.header.dwDepth = depth; + h.header.dwMipMapCount = mip_levels; + h.header.ddspf.dwSize = sizeof(DDS_PIXELFORMAT); + h.header.ddspf.dwFlags = DDPF_FOURCC; + h.header.ddspf.dwFourCC = fourcc('D', 'X', '1', '0'); + h.header.dwCaps = DDSCAPS_TEXTURE; + + h.header10.dxgiFormat = format; + h.header10.resourceDimension = D3D10_RESOURCE_DIMENSION_TEXTURE2D; + h.header10.miscFlags2 = DDS_ALPHA_MODE_UNKNOWN; + + if (is_cubemap) + { + h.header10.arraySize = array_size / 6; + h.header.dwCaps |= DDSCAPS_COMPLEX; + h.header.dwCaps2 = + DDSCAPS2_CUBEMAP | + DDSCAPS2_CUBEMAP_POSITIVEX | + DDSCAPS2_CUBEMAP_NEGATIVEX | + DDSCAPS2_CUBEMAP_POSITIVEY | + DDSCAPS2_CUBEMAP_NEGATIVEY | + DDSCAPS2_CUBEMAP_POSITIVEZ | + DDSCAPS2_CUBEMAP_NEGATIVEZ + ; + h.header10.miscFlag = DDS_RESOURCE_MISC_TEXTURECUBE; + } + else if (depth > 0) + { + h.header10.arraySize = 1; + h.header10.resourceDimension = D3D10_RESOURCE_DIMENSION_TEXTURE3D; + h.header.dwCaps2 = DDSCAPS2_VOLUME; + } + else + { + h.header10.arraySize = array_size; + } + + if (height == 0) + { + h.header10.resourceDimension = D3D10_RESOURCE_DIMENSION_TEXTURE1D; + h.header.dwHeight = 1; + } + if (mip_levels > 1) + { + h.header.dwCaps |= DDSCAPS_COMPLEX; + } + + *(Header*)dst = h; + } +} + +#endif // DDS_H + +//Copyright(c) 2024 Turánszki János +// +//Permission is hereby granted, free of charge, to any person obtaining a copy +//of this software and associated documentation files(the "Software"), to deal +//in the Software without restriction, including without limitation the rights +//to use, copy, modify, merge, publish, distribute, sublicense, and /or sell +//copies of the Software, and to permit persons to whom the Software is +//furnished to do so, subject to the following conditions : +// +//The above copyright notice and this permission notice shall be included in +//all copies or substantial portions of the Software. +// +//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +//THE SOFTWARE. \ No newline at end of file