Merge remote-tracking branch 'official/master' into contrib

Conflicts:
	code/IFCLoader.cpp
pull/261/head
Léo Terziman 2014-02-26 18:06:46 +01:00
commit b90718bd21
4 changed files with 1017 additions and 998 deletions

View File

@ -223,6 +223,9 @@ private:
name_carrier = nodes_chain.back(); name_carrier = nodes_chain.back();
} }
//setup metadata on newest node
SetupNodeMetadata(*model, *nodes_chain.back());
// link all nodes in a row // link all nodes in a row
aiNode* last_parent = &parent; aiNode* last_parent = &parent;
BOOST_FOREACH(aiNode* prenode, nodes_chain) { BOOST_FOREACH(aiNode* prenode, nodes_chain) {
@ -755,6 +758,27 @@ private:
} }
} }
// ------------------------------------------------------------------------------------------------
void SetupNodeMetadata(const Model& model, aiNode& nd)
{
const PropertyTable& props = model.Props();
// find user defined properties
const std::string& userProps = PropertyGet<std::string>(props, "UDP3DSMAX", "");
//setup metadata //TODO: make metadata more friendly (eg. have Add()/Remove() functions to be easier to use)
aiMetadata* data = new aiMetadata();
data->mNumProperties = 1;
data->mKeys = new aiString[data->mNumProperties]();
data->mValues = new aiString[data->mNumProperties]();
//add user properties
data->mKeys[0].Set("UserProperties");
data->mValues[0].Set(userProps);
nd.mMetaData = data;
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void ConvertModel(const Model& model, aiNode& nd, const aiMatrix4x4& node_global_transform) void ConvertModel(const Model& model, aiNode& nd, const aiMatrix4x4& node_global_transform)

View File

@ -711,14 +711,14 @@ aiNode* ProcessSpatialStructure(aiNode* parent, const IfcProduct& el, Conversion
if (!properties.empty()) { if (!properties.empty()) {
aiMetadata* data = new aiMetadata(); aiMetadata* data = new aiMetadata();
data->mNumProperties = properties.size(); data->mNumProperties = properties.size();
data->mKeys = new aiString*[data->mNumProperties](); data->mKeys = new aiString[data->mNumProperties]();
data->mValues = new aiString*[data->mNumProperties](); data->mValues = new aiString[data->mNumProperties]();
unsigned int i = 0; unsigned int i = 0;
BOOST_FOREACH(const Metadata::value_type& kv, properties) { BOOST_FOREACH(const Metadata::value_type& kv, properties) {
data->mKeys[i] = new aiString(kv.first); data->mKeys[i].Set(kv.first);
if (kv.second.length() > 0) { if (kv.second.length() > 0) {
data->mValues[i] = new aiString(kv.second); data->mValues[i].Set(kv.second);
} }
++i; ++i;
} }

View File

@ -62,11 +62,11 @@ struct aiMetadata
unsigned int mNumProperties; unsigned int mNumProperties;
/** Arrays of keys, may not be NULL. Entries in this array may not be NULL as well. */ /** Arrays of keys, may not be NULL. Entries in this array may not be NULL as well. */
C_STRUCT aiString** mKeys; C_STRUCT aiString* mKeys;
/** Arrays of values, may not be NULL. Entries in this array may be NULL if the /** Arrays of values, may not be NULL. Entries in this array may be NULL if the
* corresponding property key has no assigned value. */ * corresponding property key has no assigned value. */
C_STRUCT aiString** mValues; C_STRUCT aiString* mValues;
#ifdef __cplusplus #ifdef __cplusplus
@ -83,26 +83,18 @@ struct aiMetadata
/** Destructor */ /** Destructor */
~aiMetadata() ~aiMetadata()
{ {
if (mKeys && mValues) { if (mKeys)
for (unsigned i=0; i<mNumProperties; ++i) {
if (mKeys[i]) {
delete mKeys[i];
}
if (mValues[i]) {
delete mValues[i];
}
}
delete [] mKeys; delete [] mKeys;
if (mValues)
delete [] mValues; delete [] mValues;
} }
}
inline bool Get(const aiString& key, aiString& value) inline bool Get(const aiString& key, aiString& value)
{ {
for (unsigned i=0; i<mNumProperties; ++i) { for (unsigned i=0; i<mNumProperties; ++i) {
if (mKeys[i] && *mKeys[i]==key) { if (mKeys[i]==key) {
value=*mValues[i]; value=mValues[i];
return true; return true;
} }
} }

View File

@ -54,7 +54,10 @@ extern "C" {
/** @enum aiPostProcessSteps /** @enum aiPostProcessSteps
* @brief Defines the flags for all possible post processing steps. * @brief Defines the flags for all possible post processing steps.
* *
* @see Importer::ReadFile * @note Some steps are influenced by properties set on the Assimp::Importer itself
*
* @see Assimp::Importer::ReadFile()
* @see Assimp::Importer::SetPropertyInteger()
* @see aiImportFile * @see aiImportFile
* @see aiImportFileEx * @see aiImportFileEx
*/ */
@ -67,7 +70,7 @@ enum aiPostProcessSteps
* *
* Does nothing if a mesh does not have normals. You might want this post * Does nothing if a mesh does not have normals. You might want this post
* processing step to be executed if you plan to use tangent space calculations * processing step to be executed if you plan to use tangent space calculations
* such as normal mapping applied to the meshes. There's a config setting, * such as normal mapping applied to the meshes. There's an importer property,
* <tt>#AI_CONFIG_PP_CT_MAX_SMOOTHING_ANGLE</tt>, which allows you to specify * <tt>#AI_CONFIG_PP_CT_MAX_SMOOTHING_ANGLE</tt>, which allows you to specify
* a maximum smoothing angle for the algorithm. However, usually you'll * a maximum smoothing angle for the algorithm. However, usually you'll
* want to leave it at the default value. * want to leave it at the default value.
@ -114,7 +117,7 @@ enum aiPostProcessSteps
* solution: * solution:
* <ul> * <ul>
* <li>Specify both #aiProcess_Triangulate and #aiProcess_SortByPType </li> * <li>Specify both #aiProcess_Triangulate and #aiProcess_SortByPType </li>
* </li>Ignore all point and line meshes when you process assimp's output</li> * <li>Ignore all point and line meshes when you process assimp's output</li>
* </ul> * </ul>
*/ */
aiProcess_Triangulate = 0x8, aiProcess_Triangulate = 0x8,
@ -124,7 +127,7 @@ enum aiPostProcessSteps
* light sources, cameras, textures, vertex components). * light sources, cameras, textures, vertex components).
* *
* The components to be removed are specified in a separate * The components to be removed are specified in a separate
* configuration option, <tt>#AI_CONFIG_PP_RVC_FLAGS</tt>. This is quite useful * importer property, <tt>#AI_CONFIG_PP_RVC_FLAGS</tt>. This is quite useful
* if you don't need all parts of the output structure. Vertex colors * if you don't need all parts of the output structure. Vertex colors
* are rarely used today for example... Calling this step to remove unneeded * are rarely used today for example... Calling this step to remove unneeded
* data from the pipeline as early as possible results in increased * data from the pipeline as early as possible results in increased
@ -167,7 +170,7 @@ enum aiPostProcessSteps
* they're usually already there. * they're usually already there.
* *
* This flag may not be specified together with * This flag may not be specified together with
* #aiProcess_GenNormals. There's a configuration option, * #aiProcess_GenNormals. There's a importer property,
* <tt>#AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE</tt> which allows you to specify * <tt>#AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE</tt> which allows you to specify
* an angle maximum for the normal smoothing algorithm. Normals exceeding * an angle maximum for the normal smoothing algorithm. Normals exceeding
* this limit are not smoothed, resulting in a 'hard' seam between two faces. * this limit are not smoothed, resulting in a 'hard' seam between two faces.
@ -187,7 +190,7 @@ enum aiPostProcessSteps
* *
* The split limits can (and should!) be set through the * The split limits can (and should!) be set through the
* <tt>#AI_CONFIG_PP_SLM_VERTEX_LIMIT</tt> and <tt>#AI_CONFIG_PP_SLM_TRIANGLE_LIMIT</tt> * <tt>#AI_CONFIG_PP_SLM_VERTEX_LIMIT</tt> and <tt>#AI_CONFIG_PP_SLM_TRIANGLE_LIMIT</tt>
* settings. The default values are <tt>#AI_SLM_DEFAULT_MAX_VERTICES</tt> and * importer properties. The default values are <tt>#AI_SLM_DEFAULT_MAX_VERTICES</tt> and
* <tt>#AI_SLM_DEFAULT_MAX_TRIANGLES</tt>. * <tt>#AI_SLM_DEFAULT_MAX_TRIANGLES</tt>.
* *
* Note that splitting is generally a time-consuming task, but only if there's * Note that splitting is generally a time-consuming task, but only if there's
@ -224,8 +227,8 @@ enum aiPostProcessSteps
* important vertex weights are removed and the remaining vertex weights are * important vertex weights are removed and the remaining vertex weights are
* renormalized so that the weights still sum up to 1. * renormalized so that the weights still sum up to 1.
* The default bone weight limit is 4 (defined as <tt>#AI_LMW_MAX_WEIGHTS</tt> in * The default bone weight limit is 4 (defined as <tt>#AI_LMW_MAX_WEIGHTS</tt> in
* config.h), but you can use the <tt>#AI_CONFIG_PP_LBW_MAX_WEIGHTS</tt> setting to * config.h), but you can use the <tt>#AI_CONFIG_PP_LBW_MAX_WEIGHTS</tt> importer
* supply your own limit to the post processing step. * property to supply your own limit to the post processing step.
* *
* If you intend to perform the skinning in hardware, this post processing * If you intend to perform the skinning in hardware, this post processing
* step might be of interest to you. * step might be of interest to you.
@ -270,8 +273,8 @@ enum aiPostProcessSteps
* paper</a>). * paper</a>).
* *
* If you intend to render huge models in hardware, this step might * If you intend to render huge models in hardware, this step might
* be of interest to you. The <tt>#AI_CONFIG_PP_ICL_PTCACHE_SIZE</tt>config * be of interest to you. The <tt>#AI_CONFIG_PP_ICL_PTCACHE_SIZE</tt>
* setting can be used to fine-tune the cache optimization. * importer property can be used to fine-tune the cache optimization.
*/ */
aiProcess_ImproveCacheLocality = 0x800, aiProcess_ImproveCacheLocality = 0x800,
@ -292,7 +295,7 @@ enum aiPostProcessSteps
* So, if you're passing additional information through the * So, if you're passing additional information through the
* content pipeline (probably using *magic* material names), don't * content pipeline (probably using *magic* material names), don't
* specify this flag. Alternatively take a look at the * specify this flag. Alternatively take a look at the
* <tt>#AI_CONFIG_PP_RRM_EXCLUDE_LIST</tt> setting. * <tt>#AI_CONFIG_PP_RRM_EXCLUDE_LIST</tt> importer property.
*/ */
aiProcess_RemoveRedundantMaterials = 0x1000, aiProcess_RemoveRedundantMaterials = 0x1000,
@ -318,9 +321,9 @@ enum aiPostProcessSteps
* returns, just one bit is set in aiMesh::mPrimitiveTypes. This is * returns, just one bit is set in aiMesh::mPrimitiveTypes. This is
* especially useful for real-time rendering where point and line * especially useful for real-time rendering where point and line
* primitives are often ignored or rendered separately. * primitives are often ignored or rendered separately.
* You can use the <tt>#AI_CONFIG_PP_SBP_REMOVE</tt> option to specify which * You can use the <tt>#AI_CONFIG_PP_SBP_REMOVE</tt> importer property to
* primitive types you need. This can be used to easily exclude * specify which primitive types you need. This can be used to easily
* lines and points, which are rarely used, from the import. * exclude lines and points, which are rarely used, from the import.
*/ */
aiProcess_SortByPType = 0x8000, aiProcess_SortByPType = 0x8000,
@ -336,9 +339,9 @@ enum aiPostProcessSteps
* <ul> * <ul>
* <li>Specify the #aiProcess_FindDegenerates flag. * <li>Specify the #aiProcess_FindDegenerates flag.
* </li> * </li>
* <li>Set the <tt>AI_CONFIG_PP_FD_REMOVE</tt> option to 1. This will * <li>Set the <tt>#AI_CONFIG_PP_FD_REMOVE</tt> importer property to
* cause the step to remove degenerate triangles from the import * 1. This will cause the step to remove degenerate triangles from the
* as soon as they're detected. They won't pass any further * import as soon as they're detected. They won't pass any further
* pipeline steps. * pipeline steps.
* </li> * </li>
* </ul> * </ul>
@ -349,7 +352,7 @@ enum aiPostProcessSteps
* <li>Specify the #aiProcess_SortByPType flag. This moves line and * <li>Specify the #aiProcess_SortByPType flag. This moves line and
* point primitives to separate meshes. * point primitives to separate meshes.
* </li> * </li>
* <li>Set the <tt>AI_CONFIG_PP_SBP_REMOVE</tt> option to * <li>Set the <tt>#AI_CONFIG_PP_SBP_REMOVE</tt> importer property to
* @code aiPrimitiveType_POINTS | aiPrimitiveType_LINES * @code aiPrimitiveType_POINTS | aiPrimitiveType_LINES
* @endcode to cause SortByPType to reject point * @endcode to cause SortByPType to reject point
* and line meshes from the scene. * and line meshes from the scene.
@ -446,9 +449,9 @@ enum aiPostProcessSteps
* *
* Node names can be lost during this step. If you use special 'tag nodes' * Node names can be lost during this step. If you use special 'tag nodes'
* to pass additional information through your content pipeline, use the * to pass additional information through your content pipeline, use the
* <tt>#AI_CONFIG_PP_OG_EXCLUDE_LIST</tt> setting to specify a list of node * <tt>#AI_CONFIG_PP_OG_EXCLUDE_LIST</tt> importer property to specify a
* names you want to be kept. Nodes matching one of the names in this list won't * list of node names you want to be kept. Nodes matching one of the names
* be touched or modified. * in this list won't be touched or modified.
* *
* Use this flag with caution. Most simple files will be collapsed to a * Use this flag with caution. Most simple files will be collapsed to a
* single node, so complex hierarchies are usually completely lost. This is not * single node, so complex hierarchies are usually completely lost. This is not