Makie: Triangle face colour, mesh


#1

I have a question about Makie, when plotting triangulated mesh surfaces is it possible to colour with flat coloured patches?
Like: https://de.mathworks.com/help/matlab/ref/trisurf.html
Compared to the example in: http://makie.juliaplots.org/stable/examples-mesh.html
I.e. the colour vector defines the colour of each triangles face and not each triangle’s edge points.

Cheers,
Tim


#2

You can obtain flat coloured patches by a naive duplication of nodes to ensure that every triangle has different (eventually duplicated) vertices.


#3

Do you have an example?
Tim


#4

That seems like a hack. Sounds like something that should be easily implemented (if it isn’t already).


#5

well this “hack” could be turned into a recipe :wink:


#6

Does the problem start because the mesh objects don’t support per-face attributes? I’m not sure if that’s actually the case, but I remember reading this comment: https://github.com/JuliaIO/MeshIO.jl/blob/69b58518a5ea41ab56b8d87bcae8bff220b34c5c/src/io/stl.jl#L83

normals[i*3+1] = NormalType(normal...)
normals[i*3+2] = normals[i*3+1] # hurts, but we need per vertex normals
normals[i*3+3] = normals[i*3+1]