Merge pull request #5526 from samcake/daft

Fix the multi part per mesh with various opacity level issue
This commit is contained in:
Brad Hefta-Gaub 2015-08-07 08:57:31 -07:00
commit a10d310403
4 changed files with 30 additions and 4 deletions

View file

@ -976,6 +976,8 @@ ExtractedMesh extractMesh(const FBXNode& object, unsigned int& meshIndex) {
data.extracted.mesh.meshIndex = meshIndex++;
QVector<int> materials;
QVector<int> textures;
bool isMaterialPerPolygon = false;
foreach (const FBXNode& child, object.children) {
if (child.name == "Vertices") {
data.vertices = createVec3Vector(getDoubleVector(child));
@ -1105,8 +1107,16 @@ ExtractedMesh extractMesh(const FBXNode& object, unsigned int& meshIndex) {
foreach (const FBXNode& subdata, child.children) {
if (subdata.name == "Materials") {
materials = getIntVector(subdata);
} else if (subdata.name == "MappingInformationType") {
if (subdata.properties.at(0) == "ByPolygon") {
isMaterialPerPolygon = true;
} else {
isMaterialPerPolygon = false;
}
}
}
} else if (child.name == "LayerElementTexture") {
foreach (const FBXNode& subdata, child.children) {
if (subdata.name == "TextureId") {
@ -1116,6 +1126,12 @@ ExtractedMesh extractMesh(const FBXNode& object, unsigned int& meshIndex) {
}
}
bool isMultiMaterial = false;
if (isMaterialPerPolygon) {
isMultiMaterial = true;
}
// convert the polygons to quads and triangles
int polygonIndex = 0;
QHash<QPair<int, int>, int> materialTextureParts;
@ -2104,6 +2120,9 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
if (type.contains("diffuse")) {
diffuseTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
} else if (type.contains("transparentcolor")) { // it should be TransparentColor...
// THis is how Maya assign a texture that affect diffuse color AND transparency ?
diffuseTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
} else if (type.contains("bump") || type.contains("normal")) {
bumpTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));

View file

@ -2239,10 +2239,17 @@ bool NetworkMeshPart::isTranslucent() const {
return diffuseTexture && diffuseTexture->isTranslucent();
}
bool NetworkMesh::isPartTranslucent(const FBXMesh& fbxMesh, int partIndex) const {
assert(partIndex >= 0);
assert(partIndex < parts.size());
return (parts.at(partIndex).isTranslucent() || fbxMesh.parts.at(partIndex).opacity != 1.0f);
}
int NetworkMesh::getTranslucentPartCount(const FBXMesh& fbxMesh) const {
int count = 0;
for (int i = 0; i < parts.size(); i++) {
if (parts.at(i).isTranslucent() || fbxMesh.parts.at(i).opacity != 1.0f) {
if (isPartTranslucent(fbxMesh, i)) {
count++;
}
}

View file

@ -398,6 +398,7 @@ public:
QVector<NetworkMeshPart> parts;
int getTranslucentPartCount(const FBXMesh& fbxMesh) const;
bool isPartTranslucent(const FBXMesh& fbxMesh, int partIndex) const;
};
#endif // hifi_GeometryCache_h

View file

@ -1824,11 +1824,10 @@ void Model::segregateMeshGroups() {
translucentMesh = hasTangents = hasSpecular = hasLightmap = isSkinned = false;
}
// Debug...
// Create the render payloads
int totalParts = mesh.parts.size();
for (int partIndex = 0; partIndex < totalParts; partIndex++) {
// this is a good place to create our renderPayloads
if (translucentMesh) {
if (networkMesh.isPartTranslucent(mesh, partIndex)) {
_transparentRenderItems << std::make_shared<MeshPartPayload>(true, this, i, partIndex);
} else {
_opaqueRenderItems << std::make_shared<MeshPartPayload>(false, this, i, partIndex);