mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-29 10:59:55 +02:00
Merge pull request #5526 from samcake/daft
Fix the multi part per mesh with various opacity level issue
This commit is contained in:
commit
a10d310403
4 changed files with 30 additions and 4 deletions
|
@ -976,6 +976,8 @@ ExtractedMesh extractMesh(const FBXNode& object, unsigned int& meshIndex) {
|
||||||
data.extracted.mesh.meshIndex = meshIndex++;
|
data.extracted.mesh.meshIndex = meshIndex++;
|
||||||
QVector<int> materials;
|
QVector<int> materials;
|
||||||
QVector<int> textures;
|
QVector<int> textures;
|
||||||
|
bool isMaterialPerPolygon = false;
|
||||||
|
|
||||||
foreach (const FBXNode& child, object.children) {
|
foreach (const FBXNode& child, object.children) {
|
||||||
if (child.name == "Vertices") {
|
if (child.name == "Vertices") {
|
||||||
data.vertices = createVec3Vector(getDoubleVector(child));
|
data.vertices = createVec3Vector(getDoubleVector(child));
|
||||||
|
@ -1105,8 +1107,16 @@ ExtractedMesh extractMesh(const FBXNode& object, unsigned int& meshIndex) {
|
||||||
foreach (const FBXNode& subdata, child.children) {
|
foreach (const FBXNode& subdata, child.children) {
|
||||||
if (subdata.name == "Materials") {
|
if (subdata.name == "Materials") {
|
||||||
materials = getIntVector(subdata);
|
materials = getIntVector(subdata);
|
||||||
|
} else if (subdata.name == "MappingInformationType") {
|
||||||
|
if (subdata.properties.at(0) == "ByPolygon") {
|
||||||
|
isMaterialPerPolygon = true;
|
||||||
|
} else {
|
||||||
|
isMaterialPerPolygon = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else if (child.name == "LayerElementTexture") {
|
} else if (child.name == "LayerElementTexture") {
|
||||||
foreach (const FBXNode& subdata, child.children) {
|
foreach (const FBXNode& subdata, child.children) {
|
||||||
if (subdata.name == "TextureId") {
|
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
|
// convert the polygons to quads and triangles
|
||||||
int polygonIndex = 0;
|
int polygonIndex = 0;
|
||||||
QHash<QPair<int, int>, int> materialTextureParts;
|
QHash<QPair<int, int>, int> materialTextureParts;
|
||||||
|
@ -2104,6 +2120,9 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping,
|
||||||
if (type.contains("diffuse")) {
|
if (type.contains("diffuse")) {
|
||||||
diffuseTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
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")) {
|
} else if (type.contains("bump") || type.contains("normal")) {
|
||||||
bumpTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
bumpTextures.insert(getID(connection.properties, 2), getID(connection.properties, 1));
|
||||||
|
|
||||||
|
|
|
@ -2239,10 +2239,17 @@ bool NetworkMeshPart::isTranslucent() const {
|
||||||
return diffuseTexture && diffuseTexture->isTranslucent();
|
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 NetworkMesh::getTranslucentPartCount(const FBXMesh& fbxMesh) const {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < parts.size(); i++) {
|
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++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -398,6 +398,7 @@ public:
|
||||||
QVector<NetworkMeshPart> parts;
|
QVector<NetworkMeshPart> parts;
|
||||||
|
|
||||||
int getTranslucentPartCount(const FBXMesh& fbxMesh) const;
|
int getTranslucentPartCount(const FBXMesh& fbxMesh) const;
|
||||||
|
bool isPartTranslucent(const FBXMesh& fbxMesh, int partIndex) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_GeometryCache_h
|
#endif // hifi_GeometryCache_h
|
||||||
|
|
|
@ -1824,11 +1824,10 @@ void Model::segregateMeshGroups() {
|
||||||
translucentMesh = hasTangents = hasSpecular = hasLightmap = isSkinned = false;
|
translucentMesh = hasTangents = hasSpecular = hasLightmap = isSkinned = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debug...
|
// Create the render payloads
|
||||||
int totalParts = mesh.parts.size();
|
int totalParts = mesh.parts.size();
|
||||||
for (int partIndex = 0; partIndex < totalParts; partIndex++) {
|
for (int partIndex = 0; partIndex < totalParts; partIndex++) {
|
||||||
// this is a good place to create our renderPayloads
|
if (networkMesh.isPartTranslucent(mesh, partIndex)) {
|
||||||
if (translucentMesh) {
|
|
||||||
_transparentRenderItems << std::make_shared<MeshPartPayload>(true, this, i, partIndex);
|
_transparentRenderItems << std::make_shared<MeshPartPayload>(true, this, i, partIndex);
|
||||||
} else {
|
} else {
|
||||||
_opaqueRenderItems << std::make_shared<MeshPartPayload>(false, this, i, partIndex);
|
_opaqueRenderItems << std::make_shared<MeshPartPayload>(false, this, i, partIndex);
|
||||||
|
|
Loading…
Reference in a new issue