Added option to import non-skinning bones in AssetImporter. Closes #82.
Added case-sensitivity option to String::Contains().
This commit is contained in:
parent
2748d2bea6
commit
8b8790e481
@ -393,8 +393,8 @@ void AppendUTF8(uint);
|
||||
String SubstringUTF8(uint) const;
|
||||
String SubstringUTF8(uint, uint) const;
|
||||
int Compare(const String&, bool = true) const;
|
||||
bool Contains(const String&) const;
|
||||
bool Contains(uint8) const;
|
||||
bool Contains(const String&, bool = true) const;
|
||||
bool Contains(uint8, bool = true) const;
|
||||
void Clear();
|
||||
Array<String> Split(uint8) const;
|
||||
void Join(Array<String>&, const String&);
|
||||
|
@ -1691,27 +1691,31 @@ Usage:
|
||||
AssetImporter <command> <input file> <output file> [options]
|
||||
|
||||
Commands:
|
||||
model Output a model
|
||||
scene Output a scene
|
||||
dump Dump scene node structure. No output file is generated
|
||||
lod Combine several Urho3D models as LOD levels of the output model
|
||||
Syntax: lod <dist0> <mdl0> <dist1 <mdl1> ... <output file>
|
||||
model Output a model
|
||||
scene Output a scene
|
||||
dump Dump scene node structure. No output file is generated
|
||||
lod Combine several Urho3D models as LOD levels of the output model
|
||||
Syntax: lod <dist0> <mdl0> <dist1 <mdl1> ... <output file>
|
||||
|
||||
Options:
|
||||
-b Save scene in binary format, default format is XML
|
||||
-h Generate hard instead of smooth normals if input file has no normals
|
||||
-i Use local ID's for scene nodes
|
||||
-l Output a material list file for models
|
||||
-na Do not output animations
|
||||
-nm Do not output materials
|
||||
-ns Do not create subdirectories for resources
|
||||
-nz Do not create a zone and a directional light (scene mode only)
|
||||
-nf Do not fix infacing normals
|
||||
-p <path> Set path for scene resources. Default is output file path\n"
|
||||
-r <name> Use the named scene node as root node\n"
|
||||
-f <freq> Animation tick frequency to use if unspecified. Default 4800\n"
|
||||
-o Optimize redundant submeshes. Loses scene hierarchy and animations
|
||||
-t Generate tangents
|
||||
-b Save scene in binary format, default format is XML
|
||||
-h Generate hard instead of smooth normals if input file has no normals
|
||||
-i Use local ID's for scene nodes
|
||||
-l Output a material list file for models
|
||||
-na Do not output animations
|
||||
-nm Do not output materials
|
||||
-ns Do not create subdirectories for resources
|
||||
-nz Do not create a zone and a directional light (scene mode only)
|
||||
-nf Do not fix infacing normals
|
||||
-p <path> Set path for scene resources. Default is output file path\n"
|
||||
-r <name> Use the named scene node as root node\n"
|
||||
-f <freq> Animation tick frequency to use if unspecified. Default 4800\n"
|
||||
-o Optimize redundant submeshes. Loses scene hierarchy and animations
|
||||
-s <filter> Include non-skinning bones in the model's skeleton. Can be given a
|
||||
case-insensitive semicolon separated filter list. Bone is included
|
||||
if its name contains any of the filters. Prefix filter with minus
|
||||
sign to use as an exclude. For example -s "Bip01;-Dummy;-Helper"
|
||||
-t Generate tangents
|
||||
\endverbatim
|
||||
|
||||
The material list is a text file, one material per line, saved alongside the Urho3D model. It is used by the scene editor to automatically apply the imported default materials when setting a new model for a StaticModel, StaticModelGroup, AnimatedModel or Skybox component, and can also be manually invoked by calling \ref StaticModel::ApplyMaterialList "ApplyMaterialList()". The list files can safely be deleted if not needed.
|
||||
|
@ -390,8 +390,8 @@ Methods:
|
||||
- String SubstringUTF8(uint) const
|
||||
- String SubstringUTF8(uint, uint) const
|
||||
- int Compare(const String&, bool = true) const
|
||||
- bool Contains(const String&) const
|
||||
- bool Contains(uint8) const
|
||||
- bool Contains(const String&, bool = true) const
|
||||
- bool Contains(uint8, bool = true) const
|
||||
- void Clear()
|
||||
- String[]@ Split(uint8) const
|
||||
- void Join(String[]&, const String&)
|
||||
|
@ -373,9 +373,9 @@ public:
|
||||
/// Return comparision result with a C string.
|
||||
int Compare(const char* str, bool caseSensitive = true) const;
|
||||
/// Return whether contains a specific occurences of string.
|
||||
bool Contains(const String& str) const { return Find(str) != NPOS; }
|
||||
bool Contains(const String& str, bool caseSensitive = true) const { return Find(str, 0, caseSensitive) != NPOS; }
|
||||
/// Return whether contains a specific character.
|
||||
bool Contains(char c) const { return Find(c) != NPOS; }
|
||||
bool Contains(char c, bool caseSensitive = true) const { return Find(c, 0, caseSensitive) != NPOS; }
|
||||
|
||||
/// Construct UTF8 content from Latin1.
|
||||
void SetUTF8FromLatin1(const char* str);
|
||||
|
@ -2173,8 +2173,8 @@ void RegisterString(asIScriptEngine *engine)
|
||||
engine->RegisterObjectMethod("String", "uint get_length() const", asMETHOD(String, Length), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("String", "bool get_empty() const", asMETHOD(String, Empty), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("String", "int Compare(const String&in, bool caseSensitive = true) const", asMETHODPR(String, Compare, (const String&, bool) const, int), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("String", "bool Contains(const String&in) const", asMETHODPR(String, Contains, (const String&) const, bool), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("String", "bool Contains(uint8) const", asMETHODPR(String, Contains, (char) const, bool), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("String", "bool Contains(const String&in, bool caseSensitive = true) const", asMETHODPR(String, Contains, (const String&, bool) const, bool), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("String", "bool Contains(uint8, bool caseSensitive = true) const", asMETHODPR(String, Contains, (char, bool) const, bool), asCALL_THISCALL);
|
||||
engine->RegisterObjectMethod("String", "void Clear()", asMETHOD(String, Clear), asCALL_THISCALL);
|
||||
|
||||
// Register automatic conversion functions for convenience
|
||||
|
@ -104,6 +104,9 @@ bool createZone_ = true;
|
||||
bool noAnimations_ = false;
|
||||
bool noMaterials_ = false;
|
||||
bool saveMaterialList_ = false;
|
||||
bool includeNonSkinningBones_ = false;
|
||||
Vector<String> nonSkinningBoneIncludes_;
|
||||
Vector<String> nonSkinningBoneExcludes_;
|
||||
|
||||
HashSet<aiAnimation*> allAnimations_;
|
||||
PODVector<aiAnimation*> sceneAnimations_;
|
||||
@ -185,27 +188,31 @@ void Run(const Vector<String>& arguments)
|
||||
"Usage: AssetImporter <command> <input file> <output file> [options]\n"
|
||||
"See http://assimp.sourceforge.net/main_features_formats.html for input formats\n\n"
|
||||
"Commands:\n"
|
||||
"model Output a model\n"
|
||||
"scene Output a scene\n"
|
||||
"dump Dump scene node structure. No output file is generated\n"
|
||||
"lod Combine several Urho3D models as LOD levels of the output model\n"
|
||||
" Syntax: lod <dist0> <mdl0> <dist1 <mdl1> ... <output file>\n"
|
||||
"model Output a model\n"
|
||||
"scene Output a scene\n"
|
||||
"dump Dump scene node structure. No output file is generated\n"
|
||||
"lod Combine several Urho3D models as LOD levels of the output model\n"
|
||||
" Syntax: lod <dist0> <mdl0> <dist1 <mdl1> ... <output file>\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
"-b Save scene in binary format, default format is XML\n"
|
||||
"-h Generate hard instead of smooth normals if input file has no normals\n"
|
||||
"-i Use local ID's for scene nodes\n"
|
||||
"-l Output a material list file for models\n"
|
||||
"-na Do not output animations\n"
|
||||
"-nm Do not output materials\n"
|
||||
"-ns Do not create subdirectories for resources\n"
|
||||
"-nz Do not create a zone and a directional light (scene mode only)\n"
|
||||
"-nf Do not fix infacing normals\n"
|
||||
"-p <path> Set path for scene resources. Default is output file path\n"
|
||||
"-r <name> Use the named scene node as root node\n"
|
||||
"-f <freq> Animation tick frequency to use if unspecified. Default 4800\n"
|
||||
"-o Optimize redundant submeshes. Loses scene hierarchy and animations\n"
|
||||
"-t Generate tangents\n"
|
||||
"-b Save scene in binary format, default format is XML\n"
|
||||
"-h Generate hard instead of smooth normals if input file has no normals\n"
|
||||
"-i Use local ID's for scene nodes\n"
|
||||
"-l Output a material list file for models\n"
|
||||
"-na Do not output animations\n"
|
||||
"-nm Do not output materials\n"
|
||||
"-ns Do not create subdirectories for resources\n"
|
||||
"-nz Do not create a zone and a directional light (scene mode only)\n"
|
||||
"-nf Do not fix infacing normals\n"
|
||||
"-p <path> Set path for scene resources. Default is output file path\n"
|
||||
"-r <name> Use the named scene node as root node\n"
|
||||
"-f <freq> Animation tick frequency to use if unspecified. Default 4800\n"
|
||||
"-o Optimize redundant submeshes. Loses scene hierarchy and animations\n"
|
||||
"-s <filter> Include non-skinning bones in the model's skeleton. Can be given a\n"
|
||||
" case-insensitive semicolon separated filter list. Bone is included\n"
|
||||
" if its name contains any of the filters. Prefix filter with minus\n"
|
||||
" sign to use as an exclude. For example -s \"Bip01;-Dummy;-Helper\"\n"
|
||||
"-t Generate tangents\n"
|
||||
);
|
||||
}
|
||||
|
||||
@ -295,6 +302,21 @@ void Run(const Vector<String>& arguments)
|
||||
defaultTicksPerSecond_ = ToFloat(value);
|
||||
++i;
|
||||
}
|
||||
else if (argument == "s")
|
||||
{
|
||||
includeNonSkinningBones_ = true;
|
||||
if (value.Length() && (value[0] != '-' || value.Length() > 3))
|
||||
{
|
||||
Vector<String> filters = value.Split(';');
|
||||
for (unsigned i = 0; i < filters.Size(); ++i)
|
||||
{
|
||||
if (filters[i][0] == '-')
|
||||
nonSkinningBoneExcludes_.Push(filters[i].Substring(1));
|
||||
else
|
||||
nonSkinningBoneIncludes_.Push(filters[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -541,12 +563,43 @@ void CollectBones(OutModel& model)
|
||||
|
||||
void CollectBonesFinal(PODVector<aiNode*>& dest, const HashSet<aiNode*>& necessary, aiNode* node)
|
||||
{
|
||||
if (necessary.Find(node) != necessary.End())
|
||||
bool includeBone = necessary.Find(node) != necessary.End();
|
||||
String boneName = FromAIString(node->mName);
|
||||
|
||||
// Check include/exclude filters for non-skinned bones
|
||||
if (!includeBone && includeNonSkinningBones_)
|
||||
{
|
||||
dest.Push(node);
|
||||
for (unsigned i = 0; i < node->mNumChildren; ++i)
|
||||
CollectBonesFinal(dest, necessary, node->mChildren[i]);
|
||||
// If no includes specified, include by default but check for excludes
|
||||
if (nonSkinningBoneIncludes_.Empty())
|
||||
includeBone = true;
|
||||
|
||||
// Check against includes/excludes
|
||||
for (unsigned i = 0; i < nonSkinningBoneIncludes_.Size(); ++i)
|
||||
{
|
||||
if (boneName.Contains(nonSkinningBoneIncludes_[i], false))
|
||||
{
|
||||
includeBone = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (unsigned i = 0; i < nonSkinningBoneExcludes_.Size(); ++i)
|
||||
{
|
||||
if (boneName.Contains(nonSkinningBoneExcludes_[i], false))
|
||||
{
|
||||
includeBone = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (includeBone)
|
||||
PrintLine("Including non-skinning bone " + boneName);
|
||||
}
|
||||
|
||||
if (includeBone)
|
||||
dest.Push(node);
|
||||
|
||||
for (unsigned i = 0; i < node->mNumChildren; ++i)
|
||||
CollectBonesFinal(dest, necessary, node->mChildren[i]);
|
||||
}
|
||||
|
||||
void CollectAnimations(OutModel* model)
|
||||
|
Loading…
Reference in New Issue
Block a user