0
votes

I'm trying to visualize a mesh using the "patch" function in matlab R2016b.

My mesh data is a simple sphere consisting of a faces matrix 512x3 and a vertices matrix 258x3 structured like in the following figure (but with 3 vertices per face):

enter image description here

When I'm visualizing the mesh with a single solid color with the following command:

patch('Faces', mesh.sharedVert, 'Vertices', mesh.vertices, ...
      'FaceColor', [0.9290 0.6940 0.1250])

There are no problems:

enter image description here

However, when I try to visualize different a color per face or per vertex, I get the following result:

enter image description here

This is the script for the failed attempts:

patch('Faces', mesh.sharedVert, 'Vertices', mesh.vertices, ...
      'FaceVertexCData', colors)

My colors variable is either a column vector of 512x1 (for faces) or 258x1 for vertices (for now I'm using random numbers in it). According to matlab's "patch" documentation, under the "FaceVertexCData" section, it should work in both cases, but it doesn't...

1

1 Answers

1
votes

According to Matlab staff, you must set the FaceColor property to be either 'flat' (if using per-face colors) or 'interp' (if using per-vertex colors), because the default value of [0 0 0] over-writes the per-face/vertex values.

It's interesting that they didn't bother adding that information to the man page.