Added config interface.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@90 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
aramis_acg 2008-08-08 11:51:00 +00:00
parent 1d57539d20
commit 3720faf771
4 changed files with 200 additions and 32 deletions

113
include/aiConfig.h 100644
View File

@ -0,0 +1,113 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (ASSIMP)
---------------------------------------------------------------------------
Copyright (c) 2006-2008, ASSIMP Development Team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the ASSIMP team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the ASSIMP Development Team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
/** @file Defines constants for configurable properties */
#ifndef AI_CONFIG_H_INC
#define AI_CONFIG_H_INC
// ---------------------------------------------------------------------------
/** \brief Set the maximum number of vertices in a mesh.
*
* This is used by the "SplitLargeMeshes" PostProcess-Step to determine
* whether a mesh must be splitted or not.
* \note The default value is AI_SLM_DEFAULT_MAX_VERTICES, defined in
* the internal header file SplitLargeMeshes.h
*/
#define AI_CONFIG_PP_SLM_TRIANGLE_LIMIT "pp.slm.triangle_limit"
// ---------------------------------------------------------------------------
/** \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 splitted or not.
* \note The default value is AI_SLM_DEFAULT_MAX_TRIANGLES, defined in
* the internal header file SplitLargeMeshes.h
*/
#define AI_CONFIG_PP_SLM_VERTEX_LIMIT "pp.slm.vertex_limit"
// ---------------------------------------------------------------------------
/** \brief Set the maximum number of bones affecting a single vertex
*
* This is used by the aiProcess_LimitBoneWeights PostProcess-Step.
* \note The default value is AI_LBW_MAX_WEIGHTS, defined in
* the internal header file LimitBoneWeightsProcess.h
*/
#define AI_CONFIG_PP_LBW_MAX_WEIGHTS "pp.lbw.weights_limit"
// ---------------------------------------------------------------------------
/** \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).
*/
#define AI_CONFIG_IMPORT_GLOBAL_KEYFRAME "imp.global.kf"
#define AI_CONFIG_IMPORT_MD3_KEYFRAME "imp.md3.kf"
#define AI_CONFIG_IMPORT_MD2_KEYFRAME "imp.md2.kf"
#define AI_CONFIG_IMPORT_MDL_KEYFRAME "imp.mdl.kf"
#define AI_CONFIG_IMPORT_MDC_KEYFRAME "imp.mdc.kf"
#define AI_CONFIG_IMPORT_MDR_KEYFRAME "imp.mdr.kf"
#define AI_CONFIG_IMPORT_SMD_KEYFRAME "imp.smd.kf"
// ---------------------------------------------------------------------------
/** \brief Causes the 3DS loader to ignore pivot points in the file
*
* There are some faulty 3DS files which look only correctly with
* pivot points disabled
*/
#define AI_CONFIG_IMPORT_3DS_IGNORE_PIVOT "imp.3ds.nopivot"
#define AI_CONFIG_PP_OG_MAX_DEPTH "pp.og.max_depth"
#define AI_CONFIG_PP_OG_MIN_TRIS_PER_NODE "pp.og.min_tris"
#define AI_CONFIG_PP_OG_MAXIMALLY_SMALL "pp.og.maximally_small"
#endif // !! AI_CONFIG_H_INC

View File

@ -148,6 +148,17 @@ enum aiPostProcessSteps
*/
aiProcess_ValidateDataStructure = 0x400,
/** This step tries to determine which meshes have normal vectors
* that are facing inwards. The algorithm is simple but effective:
* the bounding box of all vertices + their normals is compared against
* the volume of the bounding box of all vertices without their normals.
* This works well for most objects, problems might occur with planar
* surfaces. However the step tries to filter such cases out.
* The step inverts all infacing normals. Generally it is recommended
* to enable this step.
*/
aiProcess_FixInfacingNormals = 0x800,
/** Reorders triangles for vertex cache locality and thus better performance.
* The step tries to improve the ACMR (average post-transform vertex cache
* miss ratio) for all meshes. The step runs in O(n) and is roughly
@ -165,37 +176,6 @@ enum aiPostProcessSteps
aiProcess_RemoveRedundantMaterials = 0x1000,
};
// ---------------------------------------------------------------------------
/** \brief Set the maximum number of vertices in a mesh.
*
* This is used by the SplitLargeMeshes PostProcess-Step to determine
* whether a mesh must be splitted or not.
* \param pLimit Vertex limit.
* \note The default value is AI_SLM_DEFAULT_MAX_VERTICES, defined in
* the internal header file SplitLargeMeshes.h
*/
ASSIMP_API aiReturn aiSetVertexSplitLimit(unsigned int pLimit);
// ---------------------------------------------------------------------------
/** \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 splitted or not.
* \param pLimit Triangle limit
* \note The default value is AI_SLM_DEFAULT_MAX_TRIANGLES, defined in
* the internal header file SplitLargeMeshes.h
*/
ASSIMP_API aiReturn aiSetTriangleSplitLimit(unsigned int pLimit);
// ---------------------------------------------------------------------------
/** \brief Set the maximum number of bones affecting a single vertex
*
* This is used by the aiProcess_LimitBoneWeights PostProcess-Step.
* \param pLimit Bone limit
* \note The default value is AI_LMW_MAX_WEIGHTS, defined in
* the internal header file LimitBoneWeightsProcess.h
*/
ASSIMP_API aiReturn aiSetBoneWeightLimit(unsigned int pLimit);
#ifdef __cplusplus
} // end of extern "C"

View File

@ -141,6 +141,16 @@ ASSIMP_API int aiIsExtensionSupported(const char* szExtension);
// ---------------------------------------------------------------------------
ASSIMP_API void aiGetExtensionList(C_STRUCT aiString* szOut);
// ---------------------------------------------------------------------------
/** Get the storage required by an imported asset
* \param pIn Input asset.
* \param in Data structure to be filled.
*/
// ---------------------------------------------------------------------------
ASSIMP_API void aiGetMemoryRequirements(const C_STRUCT aiScene* pIn,
C_STRUCT aiMemoryInfo* in);
#ifdef __cplusplus
}
#endif

View File

@ -47,10 +47,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#error This header requires C++ to be used.
#endif
// STL headers
#include <string>
#include <vector>
// public ASSIMP headers
#include "aiDefines.h"
#include "aiConfig.h"
#define AI_PROPERTY_WAS_NOT_EXISTING 0xffffffff
struct aiScene;
@ -88,6 +94,28 @@ class ASSIMP_API Importer
// used internally
friend class BaseProcess;
protected:
template <typename Type>
struct PropertyInfo
{
std::string name;
Type value;
bool operator==(const PropertyInfo<Type>& other) const
{
return other.name == this->name &&
other.value == this->value;
}
bool operator!=(const PropertyInfo<Type>& other) const
{
return !(other == *this);
}
};
typedef PropertyInfo<int> IntPropertyInfo;
public:
// -------------------------------------------------------------------
@ -104,6 +132,31 @@ public:
~Importer();
// -------------------------------------------------------------------
/** Set a configuration property.
* @param szName Name of the property. All supported properties
* are defined in the aiConfig.g header (the constants start
* with AI_CONFIG_XXX).
* @param iValue New value of the property
* @return Old value of the property or AI_PROPERTY_WAS_NOT_EXISTING
* if the property has not yet been set.
*/
int SetProperty(const char* szName, int iValue);
// -------------------------------------------------------------------
/** Get a configuration property.
* @param szName Name of the property. All supported properties
* are defined in the aiConfig.g header (the constants start
* with AI_CONFIG_XXX).
* @param iErrorReturn Value that is returned if the property
* is not found. Note that this value, not the default value
* for the requested property is returned!
* @return Current value of the property
*/
int GetProperty(const char* szName, int iErrorReturn = 0xffffffff);
// -------------------------------------------------------------------
/** Supplies a custom IO handler to the importer to use to open and
* access files. If you need the importer to use custion IO logic to
@ -199,6 +252,14 @@ public:
{return this->mScene;}
// -------------------------------------------------------------------
/** Returns the storage allocated by ASSIMP to hold the asset data
* in memory.
* \param in Data structure to be filled.
*/
void GetMemoryRequirements(aiMemoryInfo& in) const;
// -------------------------------------------------------------------
/** Enables the "extra verbose" mode. In this mode the data
* structure is validated after each post-process step to make sure
@ -215,6 +276,7 @@ private:
protected:
/** IO handler to use for all file accesses. */
IOSystem* mIOHandler;
bool mIsDefaultHandler;
@ -233,10 +295,13 @@ protected:
/** The error description, if there was one. */
std::string mErrorString;
/** List of integer properties */
std::vector<IntPropertyInfo> mIntProperties;
/** Used for testing */
bool bExtraVerbose;
};
} // End of namespace Assimp
#endif // AI_ASSIMP_HPP_INC
#endif // AI_ASSIMP_HPP_INC