mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
The Blender FBX has models that are also meshes.
This commit is contained in:
parent
b294f5b13e
commit
871f97bd81
1 changed files with 122 additions and 114 deletions
|
@ -522,51 +522,7 @@ void appendModelIDs(const QString& parentID, const QMultiHash<QString, QString>&
|
|||
}
|
||||
}
|
||||
|
||||
FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) {
|
||||
QHash<QString, FBXMesh> meshes;
|
||||
QVector<ExtractedBlendshape> blendshapes;
|
||||
QMultiHash<QString, QString> parentMap;
|
||||
QMultiHash<QString, QString> childMap;
|
||||
QHash<QString, FBXModel> models;
|
||||
QHash<QString, Cluster> clusters;
|
||||
QHash<QString, QByteArray> textureFilenames;
|
||||
QHash<QString, Material> materials;
|
||||
QHash<QString, QString> diffuseTextures;
|
||||
QHash<QString, QString> bumpTextures;
|
||||
|
||||
QVariantHash joints = mapping.value("joint").toHash();
|
||||
QByteArray jointEyeLeftName = joints.value("jointEyeLeft", "jointEyeLeft").toByteArray();
|
||||
QByteArray jointEyeRightName = joints.value("jointEyeRight", "jointEyeRight").toByteArray();
|
||||
QByteArray jointNeckName = joints.value("jointNeck", "jointNeck").toByteArray();
|
||||
QString jointEyeLeftID;
|
||||
QString jointEyeRightID;
|
||||
QString jointNeckID;
|
||||
|
||||
QVariantHash blendshapeMappings = mapping.value("bs").toHash();
|
||||
QHash<QByteArray, QPair<int, float> > blendshapeIndices;
|
||||
for (int i = 0;; i++) {
|
||||
QByteArray blendshapeName = FACESHIFT_BLENDSHAPES[i];
|
||||
if (blendshapeName.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
QList<QVariant> mappings = blendshapeMappings.values(blendshapeName);
|
||||
if (mappings.isEmpty()) {
|
||||
blendshapeIndices.insert(blendshapeName, QPair<int, float>(i, 1.0f));
|
||||
} else {
|
||||
foreach (const QVariant& mapping, mappings) {
|
||||
QVariantList blendshapeMapping = mapping.toList();
|
||||
blendshapeIndices.insert(blendshapeMapping.at(0).toByteArray(),
|
||||
QPair<int, float>(i, blendshapeMapping.at(1).toFloat()));
|
||||
}
|
||||
}
|
||||
}
|
||||
QHash<QString, QPair<int, float> > blendshapeChannelIndices;
|
||||
|
||||
foreach (const FBXNode& child, node.children) {
|
||||
if (child.name == "Objects") {
|
||||
foreach (const FBXNode& object, child.children) {
|
||||
if (object.name == "Geometry") {
|
||||
if (object.properties.at(2) == "Mesh") {
|
||||
FBXMesh extractMesh(const FBXNode& object) {
|
||||
FBXMesh mesh;
|
||||
|
||||
QVector<int> polygonIndices;
|
||||
|
@ -679,7 +635,56 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
|||
beginIndex = endIndex;
|
||||
}
|
||||
}
|
||||
meshes.insert(object.properties.at(0).toString(), mesh);
|
||||
|
||||
return mesh;
|
||||
}
|
||||
|
||||
FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) {
|
||||
QHash<QString, FBXMesh> meshes;
|
||||
QVector<ExtractedBlendshape> blendshapes;
|
||||
QMultiHash<QString, QString> parentMap;
|
||||
QMultiHash<QString, QString> childMap;
|
||||
QHash<QString, FBXModel> models;
|
||||
QHash<QString, Cluster> clusters;
|
||||
QHash<QString, QByteArray> textureFilenames;
|
||||
QHash<QString, Material> materials;
|
||||
QHash<QString, QString> diffuseTextures;
|
||||
QHash<QString, QString> bumpTextures;
|
||||
|
||||
QVariantHash joints = mapping.value("joint").toHash();
|
||||
QByteArray jointEyeLeftName = joints.value("jointEyeLeft", "jointEyeLeft").toByteArray();
|
||||
QByteArray jointEyeRightName = joints.value("jointEyeRight", "jointEyeRight").toByteArray();
|
||||
QByteArray jointNeckName = joints.value("jointNeck", "jointNeck").toByteArray();
|
||||
QString jointEyeLeftID;
|
||||
QString jointEyeRightID;
|
||||
QString jointNeckID;
|
||||
|
||||
QVariantHash blendshapeMappings = mapping.value("bs").toHash();
|
||||
QHash<QByteArray, QPair<int, float> > blendshapeIndices;
|
||||
for (int i = 0;; i++) {
|
||||
QByteArray blendshapeName = FACESHIFT_BLENDSHAPES[i];
|
||||
if (blendshapeName.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
QList<QVariant> mappings = blendshapeMappings.values(blendshapeName);
|
||||
if (mappings.isEmpty()) {
|
||||
blendshapeIndices.insert(blendshapeName, QPair<int, float>(i, 1.0f));
|
||||
} else {
|
||||
foreach (const QVariant& mapping, mappings) {
|
||||
QVariantList blendshapeMapping = mapping.toList();
|
||||
blendshapeIndices.insert(blendshapeMapping.at(0).toByteArray(),
|
||||
QPair<int, float>(i, blendshapeMapping.at(1).toFloat()));
|
||||
}
|
||||
}
|
||||
}
|
||||
QHash<QString, QPair<int, float> > blendshapeChannelIndices;
|
||||
|
||||
foreach (const FBXNode& child, node.children) {
|
||||
if (child.name == "Objects") {
|
||||
foreach (const FBXNode& object, child.children) {
|
||||
if (object.name == "Geometry") {
|
||||
if (object.properties.at(2) == "Mesh") {
|
||||
meshes.insert(object.properties.at(0).toString(), extractMesh(object));
|
||||
|
||||
} else { // object.properties.at(2) == "Shape"
|
||||
ExtractedBlendshape extracted = { object.properties.at(0).toString() };
|
||||
|
@ -809,6 +814,9 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (subobject.name == "Vertices") {
|
||||
// it's a mesh as well as a model
|
||||
meshes.insert(object.properties.at(0).toString(), extractMesh(object));
|
||||
}
|
||||
}
|
||||
// see FBX documentation, http://download.autodesk.com/us/fbx/20112/FBX_SDK_HELP/index.html
|
||||
|
@ -986,7 +994,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
|||
FBXMesh& mesh = it.value();
|
||||
|
||||
// accumulate local transforms
|
||||
QString modelID = parentMap.value(it.key());
|
||||
QString modelID = models.contains(it.key()) ? it.key() : parentMap.value(it.key());
|
||||
mesh.springiness = springs.value(models.value(modelID).name, defaultSpring).toFloat();
|
||||
glm::mat4 modelTransform = getGlobalTransform(parentMap, models, modelID);
|
||||
|
||||
|
|
Loading…
Reference in a new issue