Set Mesh Vertex Color

I would like to change the color of a mesh vertex. I tried to see if I could turn a meshes points on to see the vertices, and then click on one, but from there I couldn’t find any setting for color.

Alternatively, I tried to do it programatically by setting certain index vertices’ color. But while I was able to change all of the vertex colors, it doesn’t seem to work when I do it selectively as I show below. Any suggestions?

Thanks,
Sam

For i = 0 To MyMesh.Vertices.Count - 1
  If i < 20 Then
      MyMesh.VertexColors.SetColor(i, Drawing.Color.Green)
   End If
Next

If you are going to set mesh vertex colors, you need to set all of them. It’s an all or nothing deal.

Does this help?

– Dale

That explains the issues I was having.

I’m trying to add landmark dots to a mesh model of the human body. I don’t like how it looks when I color all the vertices though, becomes quite flat in rendered view. So I’m thinking rather than set vertex colors, I want to create a texture mapping from a jpg that has the dots marked.

Any suggestions on how to create this texture mapping? Ideally, I could ‘paint’ the dots onto the mesh by clicking on certain regions. Is there a way to do this with Rhino? If not, perhaps there is another software that could do it (preferably free)?

Thanks,
Sam

Create points at the desired mesh vertices using Point or Points with the Vertex OSnap active. Or to create points at a group of vertices. Put the points on a different layer than the mesh and you can control the color of the points by changing the color of the layer. To change the color of individual points select the points and use Properties.

Another approach would be to use ExtractPts to create a point at each vertex. Then select the desired points and change their color using Properties.

I need the landmarks dots to actually be part of the mesh, not separate points in the file. Any other suggestions?

Thanks,
Sam

You can Group the landmark points with the mesh.

Good thought, but that won’t work for my current application. What I require is a way to paint dots on model, and have that applied to a jpg texture file for the model.

Thanks,
Sam

I don’t work with textures, so can’t comment on the

and have that applied to a jpg texture file

bit. But if you want to change vertex colours, you could try something like this:

  1. place actual rhino dots where you want to generate the vertex colour dots
  2. colours = []
  3. define default_colour and landmark_colour, both as rgb triplets
  4. loop over all mesh verts extracted with rs.MeshVertices(mesh)
  5. for each vertex, test whether its xyz is close to (or identical to) one of the landmark points
  6. if so: colours.append(default_colour); if not: colours.append(landmark_colour)
  7. once the loop over all mesh verts is done, simply call rs.MeshVertexColors(mesh, colours)

This is probably quite inefficient, but should work.

To get textures from vertex colors, I usually use meshlab. I export a vrml 2.0 file from rhino (though any mesh format that supports vertex colors should work), import that into meshlab, and run a texture filter per triangle parameterization, finally I use the texture filter vertex color to texture.

1 Like

That sounds like what I’m after, fraguada. I’m hoping not to have to use matlab for this though. Can anyone think of a way to do this natively in Rhino, or perhaps with a plugin?

Thanks,
Sam

I said MeshLab, not matlab. Meshlab is a free, opensource, program. Suggested because there are no ways to do this in Rhino. There are some older discussions on the gh forum on this, with @visose discussing a few techniques to script this.

Whoops, I just saw the M and Lab and brain did the rest :frowning:

I will give that a try, thanks!
Sam