Skip to content

Commit

Permalink
Merge pull request #550 from alicevision/dev/coloredMeshViewer
Browse files Browse the repository at this point in the history
Viewer3D: add support for vertex-colored meshes
  • Loading branch information
fabiencastan authored Jul 16, 2019
2 parents 34d0b7f + 44fe4f7 commit d5dc83f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
21 changes: 14 additions & 7 deletions meshroom/nodes/aliceVision/Meshing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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=[],
),
]
7 changes: 7 additions & 0 deletions meshroom/ui/components/scene3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ def faceCount(self, entity):
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):
"""
Expand Down
11 changes: 10 additions & 1 deletion meshroom/ui/qml/Viewer3D/MaterialSwitcher.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
]
}
Expand All @@ -80,6 +84,11 @@ Entity {
diffuse: root.diffuseColor
}

PerVertexColorMaterial {
id: colored
objectName: "VertexColorMaterial"
}

DiffuseSpecularMaterial {
id: textured
objectName: "TexturedMaterial"
Expand Down

0 comments on commit d5dc83f

Please sign in to comment.