mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-08-06 10:18:42 +02:00
[ui] Viewer3D: add support for vertex-colored meshes
Use PerVertexColorMaterial if any vertex color data is available on a mesh without textures.
This commit is contained in:
parent
d30b2364eb
commit
cee8d1b612
2 changed files with 17 additions and 1 deletions
|
@ -45,6 +45,13 @@ class Scene3DHelper(QObject):
|
|||
count += sum([attr.count() for attr in geo.attributes() if attr.name() == "vertexPosition"])
|
||||
return count / 3
|
||||
|
||||
@Slot(Qt3DCore.QEntity, result=int)
|
||||
def vertexColorCount(self, entity):
|
||||
count = 0
|
||||
for geo in entity.findChildren(Qt3DRender.QGeometry):
|
||||
count += sum([attr.count() for attr in geo.attributes() if attr.name() == "vertexColor"])
|
||||
return count
|
||||
|
||||
|
||||
class TrackballController(QObject):
|
||||
"""
|
||||
|
|
|
@ -62,7 +62,11 @@ Entity {
|
|||
},
|
||||
State {
|
||||
name: "Textured"
|
||||
PropertyChanges { target: m; material: diffuseMap ? textured : solid }
|
||||
PropertyChanges {
|
||||
target: m;
|
||||
// "textured" material resolution order: diffuse map > vertex color data > no color info
|
||||
material: diffuseMap ? textured : (Scene3DHelper.vertexColorCount(root.parent) ? colored : solid)
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -80,6 +84,11 @@ Entity {
|
|||
diffuse: root.diffuseColor
|
||||
}
|
||||
|
||||
PerVertexColorMaterial {
|
||||
id: colored
|
||||
objectName: "VertexColorMaterial"
|
||||
}
|
||||
|
||||
DiffuseSpecularMaterial {
|
||||
id: textured
|
||||
objectName: "TexturedMaterial"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue