timmm
1
I have a question about Makie, when plotting triangulated mesh surfaces is it possible to colour with flat coloured patches?
Like: Triangular surface plot - MATLAB trisurf - MathWorks Deutschland
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
edljk
2
You can obtain flat coloured patches by a naive duplication of nodes to ensure that every triangle has different (eventually duplicated) vertices.
timmm
3
Do you have an example?
Tim
That seems like a hack. Sounds like something that should be easily implemented (if it isn’t already).
2 Likes
well this “hack” could be turned into a recipe 
2 Likes
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: MeshIO.jl/stl.jl at 69b58518a5ea41ab56b8d87bcae8bff220b34c5c · JuliaIO/MeshIO.jl · GitHub
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]
Any developments on this? I’m looking for the same feature right now.
I wrote some code to remove duplicate vertices from the meshes generated by Meshing.jl; now it seems like I have to implement the reverse operation?
The code is not complicated but I agree with @dpsanders, this should be a convenience method from the package
function _explode_vertices(vertices, faces)
new_vertices = similar(vertices, 0)
new_faces = similar(faces, 0)
for (i, face) in enumerate(faces)
for vertex in vertices[face]
push!(new_vertices, vertex)
end
push!(new_faces, Triangle(3i - 2:3i...))
end
return new_vertices, new_faces
end
newmesh = GLNormalMesh(_explode_vertices(oldmesh.vertices, oldmesh.faces)...)
feel free to upstream this code under current Meshing.jl license.
1 Like
Sorry to revive this, but is there a new (more built-in) approach to this ?
The viz
recipe in Meshes.jl handles colors per face or per vertex. It is all documented:
using Meshes
import GLMakie as Mke
g = CartesianGrid(10, 10)
viz(g, color = 1:10*10) # face colors
viz(g, color = 1:11*11) # vertex colors


1 Like
Thanks @juliohm, I knew that Meshes could do it, but I wonder if @sdanisch or another Makie developper can explain if this is a GLMakie (or OpenGL even) limitation that forbids having this built-in, or something else.
1 Like