Merge pull request #550 from alicevision/dev/coloredMeshViewer

Viewer3D: add support for vertex-colored meshes
This commit is contained in:
Fabien Castan 2019-07-16 19:25:38 +02:00 committed by GitHub
commit d5dc83f14e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 8 deletions

View file

@ -209,6 +209,13 @@ class Meshing(desc.CommandLineNode):
uid=[0],
advanced=True,
),
desc.BoolParam(
name='colorizeOutput',
label='Colorize Output',
description='Whether to colorize output dense point cloud and mesh.',
value=False,
uid=[0],
),
desc.BoolParam(
name='saveRawDensePointCloud',
label='Save Raw Dense Point Cloud',
@ -230,17 +237,17 @@ class Meshing(desc.CommandLineNode):
outputs = [
desc.File(
name="output",
label="Output Dense Point Cloud",
description="Output dense point cloud with visibilities (SfMData file format).",
value="{cache}/{nodeType}/{uid0}/densePointCloud.abc",
uid=[],
),
desc.File(
name="outputMesh",
label="Output Mesh",
description="Output mesh (OBJ file format).",
value="{cache}/{nodeType}/{uid0}/mesh.obj",
uid=[],
),
desc.File(
name="output",
label="Output Dense Point Cloud",
description="Output dense point cloud with visibilities (SfMData file format).",
value="{cache}/{nodeType}/{uid0}/densePointCloud.abc",
uid=[],
),
]

View file

@ -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):
"""

View file

@ -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"