I regularly use the VertexColors option with GraphicsComplex[] to render images of objects with certain attributes at the vertices.

For example,

  GraphicsComplex[PolyhedronData["Cuboctahedron", "VertexCoordinates"],
   Polygon[PolyhedronData["Cuboctahedron", "FaceIndices"]],
   VertexColors -> 
      Glow[Hue[Random[]]]}, {PolyhedronData["Cuboctahedron", 
 Boxed -> False, Lighting -> None]

gives something like:

Mathematica graphics

I have been experimenting with MeshRegions for a few things (Somewhat related to this question: Differential Geometry on a MeshRegion) since they allow me to attach attributes to the vertices in a more generic manner.

Sadly, RegionPlot3D[] doesn't seem to respect or use the MeshCellStyle directive:

bmr = BoundaryMeshRegion[
  PolyhedronData["Cuboctahedron", "VertexCoordinates"], 
  Polygon[PolyhedronData["Cuboctahedron", "FaceIndices"]], 
  MeshCellStyle -> {0 -> {PointSize[Large], Black}, 
    1 -> {Dashed, Thick, Blue}, 2 -> Opacity[0.5, Green]}]

Mathematica graphics


RegionPlot3D[bmr, Boxed -> False]

Mathematica graphics

It isn't precisely clear to me what is available to RegionPlot3D[region] from the supplied region at render time. Any thoughts here?

(nb- I realize I could use the BoundaryMeshRegion[] output (bmr above) and just use Show[] to get the various camera angles, etc that I need. Like

Show[bmr, ViewPoint -> Front, Lighting -> {{"Directional", White, {1, - 2, 3}}}]]

Mathematica graphics

but I suppose I'd like to understand a little bit about how RegionPlot3D[] does what it does with respect to MeshRegions a little better)

  • $\begingroup$ I would guess that mathematically RegionPlot3D uses only the region defined by the mesh region and programmatically that means it uses only the polygons of the boundary. Compare First@Show@bmr and First@RegionPlot3D@bmr. $\endgroup$ – Michael E2 May 7 '15 at 15:01
  • 1
    $\begingroup$ You can post-process the RegionPlot3D output to add VertexColors to Polygons:, e.g. rp=RegionPlot3D[bmr, Boxed -> False,Lighting -> "Neutral"]; rp /. Polygon[x_]:> ( Polygon[#,VertexColors->(RandomColor[Hue[_, 1, 1,RandomReal[{.5,1}]], Length@#, ColorSpace -> "RGB"] )] &/@x) $\endgroup$ – kglr May 7 '15 at 17:13
  • $\begingroup$ Ah- also a good idea. I'm interested in the 'general solution' to this (if possible) since it would be cool to attach a bunch of qualia to the vertices / faces in the region and have the renderer be able to do things with that stuff 'on the fly' (I've been doing that with RenderMan shaders for eons, but would like to be able to do that in MMa, of course, GLSL shaders would be nice to add to MMa at some point too :) $\endgroup$ – flip May 7 '15 at 20:14

Coloring vertices can be colored by adding VertexColors after RegionPlot:

rplot = RegionPlot3D[bmr, Boxed -> False];

rplot /. GraphicsComplex[p_, rest__] :> 
  GraphicsComplex[p, rest, VertexColors -> ColorData["Rainbow"] /@ Rescale[p[[All, 1]]]]

Mathematica graphics


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.