1
$\begingroup$

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.

$\endgroup$
5

2 Answers 2

4
$\begingroup$
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]]
$\endgroup$
1
  • $\begingroup$ +1 Very clean. The use to which Tuples was put was especially clever! $\endgroup$
    – DavidC
    Commented Jul 14, 2013 at 6:44
0
$\begingroup$
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

$\endgroup$
2
  • $\begingroup$ Thank you for the example. As posted vtc is not defined, but I am beginning to get the idea anyway. $\endgroup$
    – Ron Burns
    Commented Jul 14, 2013 at 4:57
  • $\begingroup$ @RonBurns Sorry, I forgot to paste it. Corrected $\endgroup$ Commented Jul 14, 2013 at 5:01

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