mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 12:08:54 +02:00
Fixes to load my test model.
This commit is contained in:
parent
7ddac20c62
commit
49acca3587
1 changed files with 57 additions and 82 deletions
|
@ -390,6 +390,11 @@ QVector<double> getDoubleVector(const QVariantList& properties, int index) {
|
||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::vec3 getVec3(const QVariantList& properties, int index) {
|
||||||
|
return glm::vec3(properties.at(index).value<double>(), properties.at(index + 1).value<double>(),
|
||||||
|
properties.at(index + 2).value<double>());
|
||||||
|
}
|
||||||
|
|
||||||
const char* FACESHIFT_BLENDSHAPES[] = {
|
const char* FACESHIFT_BLENDSHAPES[] = {
|
||||||
"EyeBlink_L",
|
"EyeBlink_L",
|
||||||
"EyeBlink_R",
|
"EyeBlink_R",
|
||||||
|
@ -724,93 +729,45 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
glm::vec3 scalePivot, rotationPivot;
|
glm::vec3 scalePivot, rotationPivot;
|
||||||
FBXModel model = { name, -1 };
|
FBXModel model = { name, -1 };
|
||||||
foreach (const FBXNode& subobject, object.children) {
|
foreach (const FBXNode& subobject, object.children) {
|
||||||
|
bool properties = false;
|
||||||
|
QByteArray propertyName;
|
||||||
|
int index;
|
||||||
if (subobject.name == "Properties60") {
|
if (subobject.name == "Properties60") {
|
||||||
foreach (const FBXNode& property, subobject.children) {
|
properties = true;
|
||||||
if (property.name == "Property") {
|
propertyName = "Property";
|
||||||
if (property.properties.at(0) == "Lcl Translation") {
|
index = 3;
|
||||||
translation = glm::vec3(property.properties.at(3).value<double>(),
|
|
||||||
property.properties.at(4).value<double>(),
|
|
||||||
property.properties.at(5).value<double>());
|
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "RotationOffset") {
|
|
||||||
rotationOffset = glm::vec3(property.properties.at(3).value<double>(),
|
|
||||||
property.properties.at(4).value<double>(),
|
|
||||||
property.properties.at(5).value<double>());
|
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "RotationPivot") {
|
|
||||||
rotationPivot = glm::vec3(property.properties.at(3).value<double>(),
|
|
||||||
property.properties.at(4).value<double>(),
|
|
||||||
property.properties.at(5).value<double>());
|
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "PreRotation") {
|
|
||||||
preRotation = glm::vec3(property.properties.at(3).value<double>(),
|
|
||||||
property.properties.at(4).value<double>(),
|
|
||||||
property.properties.at(5).value<double>());
|
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "Lcl Rotation") {
|
|
||||||
rotation = glm::vec3(property.properties.at(3).value<double>(),
|
|
||||||
property.properties.at(4).value<double>(),
|
|
||||||
property.properties.at(5).value<double>());
|
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "PostRotation") {
|
|
||||||
postRotation = glm::vec3(property.properties.at(3).value<double>(),
|
|
||||||
property.properties.at(4).value<double>(),
|
|
||||||
property.properties.at(5).value<double>());
|
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "ScalingPivot") {
|
|
||||||
scalePivot = glm::vec3(property.properties.at(3).value<double>(),
|
|
||||||
property.properties.at(4).value<double>(),
|
|
||||||
property.properties.at(5).value<double>());
|
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "Lcl Scaling") {
|
|
||||||
scale = glm::vec3(property.properties.at(3).value<double>(),
|
|
||||||
property.properties.at(4).value<double>(),
|
|
||||||
property.properties.at(5).value<double>());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (subobject.name == "Properties70") {
|
} else if (subobject.name == "Properties70") {
|
||||||
|
properties = true;
|
||||||
|
propertyName = "P";
|
||||||
|
index = 4;
|
||||||
|
}
|
||||||
|
if (properties) {
|
||||||
foreach (const FBXNode& property, subobject.children) {
|
foreach (const FBXNode& property, subobject.children) {
|
||||||
if (property.name == "P") {
|
if (property.name == propertyName) {
|
||||||
if (property.properties.at(0) == "Lcl Translation") {
|
if (property.properties.at(0) == "Lcl Translation") {
|
||||||
translation = glm::vec3(property.properties.at(4).value<double>(),
|
translation = getVec3(property.properties, index);
|
||||||
property.properties.at(5).value<double>(),
|
|
||||||
property.properties.at(6).value<double>());
|
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "RotationOffset") {
|
} else if (property.properties.at(0) == "RotationOffset") {
|
||||||
rotationOffset = glm::vec3(property.properties.at(4).value<double>(),
|
rotationOffset = getVec3(property.properties, index);
|
||||||
property.properties.at(5).value<double>(),
|
|
||||||
property.properties.at(6).value<double>());
|
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "RotationPivot") {
|
} else if (property.properties.at(0) == "RotationPivot") {
|
||||||
rotationPivot = glm::vec3(property.properties.at(4).value<double>(),
|
rotationPivot = getVec3(property.properties, index);
|
||||||
property.properties.at(5).value<double>(),
|
|
||||||
property.properties.at(6).value<double>());
|
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "PreRotation") {
|
} else if (property.properties.at(0) == "PreRotation") {
|
||||||
preRotation = glm::vec3(property.properties.at(4).value<double>(),
|
preRotation = getVec3(property.properties, index);
|
||||||
property.properties.at(5).value<double>(),
|
|
||||||
property.properties.at(6).value<double>());
|
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "Lcl Rotation") {
|
} else if (property.properties.at(0) == "Lcl Rotation") {
|
||||||
rotation = glm::vec3(property.properties.at(4).value<double>(),
|
rotation = getVec3(property.properties, index);
|
||||||
property.properties.at(5).value<double>(),
|
|
||||||
property.properties.at(6).value<double>());
|
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "PostRotation") {
|
} else if (property.properties.at(0) == "PostRotation") {
|
||||||
postRotation = glm::vec3(property.properties.at(4).value<double>(),
|
postRotation = getVec3(property.properties, index);
|
||||||
property.properties.at(5).value<double>(),
|
|
||||||
property.properties.at(6).value<double>());
|
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "ScalingPivot") {
|
} else if (property.properties.at(0) == "ScalingPivot") {
|
||||||
scalePivot = glm::vec3(property.properties.at(4).value<double>(),
|
scalePivot = getVec3(property.properties, index);
|
||||||
property.properties.at(5).value<double>(),
|
|
||||||
property.properties.at(6).value<double>());
|
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "Lcl Scaling") {
|
} else if (property.properties.at(0) == "Lcl Scaling") {
|
||||||
scale = glm::vec3(property.properties.at(4).value<double>(),
|
scale = getVec3(property.properties, index);
|
||||||
property.properties.at(5).value<double>(),
|
|
||||||
property.properties.at(6).value<double>());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -840,21 +797,30 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
} else if (object.name == "Material") {
|
} else if (object.name == "Material") {
|
||||||
Material material = { glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(1.0f, 1.0f, 1.0f), 96.0f };
|
Material material = { glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(1.0f, 1.0f, 1.0f), 96.0f };
|
||||||
foreach (const FBXNode& subobject, object.children) {
|
foreach (const FBXNode& subobject, object.children) {
|
||||||
if (subobject.name == "Properties70") {
|
bool properties = false;
|
||||||
|
QByteArray propertyName;
|
||||||
|
int index;
|
||||||
|
if (subobject.name == "Properties60") {
|
||||||
|
properties = true;
|
||||||
|
propertyName = "Property";
|
||||||
|
index = 3;
|
||||||
|
|
||||||
|
} else if (subobject.name == "Properties70") {
|
||||||
|
properties = true;
|
||||||
|
propertyName = "P";
|
||||||
|
index = 4;
|
||||||
|
}
|
||||||
|
if (properties) {
|
||||||
foreach (const FBXNode& property, subobject.children) {
|
foreach (const FBXNode& property, subobject.children) {
|
||||||
if (property.name == "P") {
|
if (property.name == propertyName) {
|
||||||
if (property.properties.at(0) == "DiffuseColor") {
|
if (property.properties.at(0) == "DiffuseColor") {
|
||||||
material.diffuse = glm::vec3(property.properties.at(4).value<double>(),
|
material.diffuse = getVec3(property.properties, index);
|
||||||
property.properties.at(5).value<double>(),
|
|
||||||
property.properties.at(6).value<double>());
|
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "SpecularColor") {
|
} else if (property.properties.at(0) == "SpecularColor") {
|
||||||
material.specular = glm::vec3(property.properties.at(4).value<double>(),
|
material.specular = getVec3(property.properties, index);
|
||||||
property.properties.at(5).value<double>(),
|
|
||||||
property.properties.at(6).value<double>());
|
|
||||||
|
|
||||||
} else if (property.properties.at(0) == "Shininess") {
|
} else if (property.properties.at(0) == "Shininess") {
|
||||||
material.shininess = property.properties.at(4).value<double>();
|
material.shininess = property.properties.at(index).value<double>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -999,13 +965,21 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
glm::mat4 modelTransform = getGlobalTransform(parentMap, models, modelID);
|
glm::mat4 modelTransform = getGlobalTransform(parentMap, models, modelID);
|
||||||
|
|
||||||
// look for textures, material properties
|
// look for textures, material properties
|
||||||
int partIndex = 0;
|
int partIndex = mesh.parts.size() - 1;
|
||||||
foreach (const QString& childID, childMap.values(modelID)) {
|
foreach (const QString& childID, childMap.values(modelID)) {
|
||||||
if (!materials.contains(childID) || partIndex >= mesh.parts.size()) {
|
if (partIndex < 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
FBXMeshPart& part = mesh.parts[partIndex];
|
||||||
|
if (textureFilenames.contains(childID)) {
|
||||||
|
part.diffuseFilename = textureFilenames.value(childID);
|
||||||
|
qDebug() << "hello " << part.diffuseFilename << "\n";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!materials.contains(childID)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Material material = materials.value(childID);
|
Material material = materials.value(childID);
|
||||||
FBXMeshPart& part = mesh.parts[mesh.parts.size() - ++partIndex];
|
|
||||||
part.diffuseColor = material.diffuse;
|
part.diffuseColor = material.diffuse;
|
||||||
part.specularColor = material.specular;
|
part.specularColor = material.specular;
|
||||||
part.shininess = material.shininess;
|
part.shininess = material.shininess;
|
||||||
|
@ -1017,6 +991,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
||||||
if (!bumpTextureID.isNull()) {
|
if (!bumpTextureID.isNull()) {
|
||||||
part.normalFilename = textureFilenames.value(bumpTextureID);
|
part.normalFilename = textureFilenames.value(bumpTextureID);
|
||||||
}
|
}
|
||||||
|
partIndex--;
|
||||||
}
|
}
|
||||||
|
|
||||||
// find the clusters with which the mesh is associated
|
// find the clusters with which the mesh is associated
|
||||||
|
|
Loading…
Reference in a new issue