# Color each triangle on a ConvexHullMesh

I'm using this code to show the convex hull of some points in 3D:

ClearAll["Global*"]
p = {{6, 0, 0}, {0, 6, 4}, {1, 1, 1}, {0, 3, 0}, {0, 0, 5}, {9, 6, 0}, {3, 0, 7}};

chull = ConvexHullMesh[p];
Show[HighlightMesh[chull, Labeled[1, "Index"]],
Graphics3D[{Red, Sphere[p, 0.05], Blue,
Map[Text[#, # + {0., 0, 0.001}] &, p]}], Axes -> True,
Boxed -> True, AxesLabel -> {x, y, z}]


I need to give every triangle a color or number so I can know it when I change the convex hull.

colors = ColorData[97, "ColorList"][[;; MeshCellCount[chull,2]]];
styledfaces = Style[{2, #}, colors[[#]]]& /@ Range[MeshCellCount[chull, 2]];

Show[HighlightMesh[chull, {Labeled[1, "Index"], styledfaces}],
Graphics3D[{Red, Sphere[p, 0.05], Blue, Map[Text[#, # + {0., 0, 0.001}] &, p]}],
Axes -> True, Boxed -> True, AxesLabel -> {x, y, z}]


To get face colors with Opacity[1] use

colors = Opacity[1, #]& /@ ColorData[97, "ColorList"][[;; MeshCellCount[chull,2]]];
`

• Thanks, Can you help me to make every triangle not transparent such that when I see one I can not see the one behind it. I hope i explain it well. – Ateq Alsaadi Feb 10 '18 at 22:09
• @Ateq, please see the updated version. – kglr Feb 10 '18 at 22:21
• Got it, thanks :) – Ateq Alsaadi Feb 10 '18 at 22:25