mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 07:34:02 +02:00
SImple fix to the case of multiple material in a mesh with different opacity
This commit is contained in:
parent
0947bf2cd0
commit
f0f141a2b4
4 changed files with 39 additions and 3 deletions
|
@ -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,19 @@ ExtractedMesh extractMesh(const FBXNode& object, unsigned int& meshIndex) {
|
|||
foreach (const FBXNode& subdata, child.children) {
|
||||
if (subdata.name == "Materials") {
|
||||
materials = getIntVector(subdata);
|
||||
if (materials.size() > 1) {
|
||||
|
||||
}
|
||||
} 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 +1129,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 +2123,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));
|
||||
|
||||
|
|
|
@ -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++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1827,12 +1827,18 @@ void Model::segregateMeshGroups() {
|
|||
// Debug...
|
||||
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);
|
||||
}
|
||||
|
||||
// this is a good place to create our renderPayloads
|
||||
/* if (translucentMesh) {
|
||||
_transparentRenderItems << std::make_shared<MeshPartPayload>(true, this, i, partIndex);
|
||||
} else {
|
||||
_opaqueRenderItems << std::make_shared<MeshPartPayload>(false, this, i, partIndex);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
_meshGroupsKnown = true;
|
||||
|
|
Loading…
Reference in a new issue