1

A simplified specification of what I am trying to accomplish would be to construct a cube each face with a different color and each face having a text label that can be seen only when viewing from the front direction of the face (I do not want the labels on the back and side faces to show through the cube.) I also want the labels to be in the plane of the face and to remain in the plane of the face as I rotate the cube.

Ron Burns
  • 451
  • 3
  • 6

2 Answers2

4
Graphics3D[
 GraphicsComplex[
  Tuples[{0, 1}, 3],
   MapThread[
    {Texture[
       Graphics[ImportString[ExportString[#1, "PDF"], "PDF"][[1, 1]], Background -> #3]],
     Polygon[#2, VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}]} &,
    {Characters["ABCDEF"],
     {{1, 2, 4, 3}, {1, 5, 6, 2}, {1, 3, 7, 5}, {8, 6, 5, 7}, {8, 7, 
       3, 4}, {8, 4, 2, 6}},
     Table[Hue[i/6], {i, 6}]}
    ]
   ],
 Lighting -> "Neutral"]

Mathematica graphics

Note that this extracts a FilledCurve from the list of Graphics returned by ImportString (see also this question):

ImportString[ExportString[#1, "PDF"], "PDF"][[1, 1]]
Michael E2
  • 235,386
  • 17
  • 334
  • 747
0
vtc    =  {{0, 0}, {1, 0}, {1, 1}, {0, 1}};
coords = {{{0, 0, 0}, {0, 1, 0}, {1, 1, 0}, {1, 0, 0}}, 
          {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}}, 
          {{1, 0, 0}, {1, 1, 0}, {1, 1, 1}, {1, 0, 1}}, 
          {{1, 1, 0}, {0, 1, 0}, {0, 1, 1}, {1, 1, 1}}, 
          {{0, 1, 0}, {0, 0, 0}, {0, 0, 1}, {0, 1, 1}}, 
          {{0, 0, 1}, {1, 0, 1}, {1, 1, 1}, {0, 1, 1}}};

tt = Table[Texture@Image[Rasterize@Style[RandomInteger@10, 30]], {i, 6}];
Graphics3D[Table[{tt[[i]], Polygon[coords[[i]],
           VertexTextureCoordinates -> vtc]}, {i, 6}]]

Mathematica graphics

Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453