Face-Mapped Materials
 
 
 

Face-mapped materials require no application of mapping coordinates by the user. The user can create a face-mapped material in the 3ds Max Materials Editor. When a face-mapped material is applied to an object, the map is automatically applied to each facet of the object. Below is the code used internally by 3ds Max that computes the texture coordinates for face mapping:

static Point3 basic_tva[3] = {
   Point3(0.0,0.0,0.0),
   Point3(1.0,0.0,0.0),
   Point3(1.0,1.0,0.0)};
 
static Point3 basic_tvb[3] = {
   Point3(1.0,1.0,0.0),
   Point3(0.0,1.0,0.0),
   Point3(0.0,0.0,0.0)};
 
static int nextpt[3] = {1,2,0};
static int prevpt[3] = {2,0,1};
 
static void make_face_uv(Face *f, Point3 *tv)
{
   intna,nhid,i;
   Point3 *basetv;
 
   /* makethe invisibleedge be2->0 */
   nhid = 2;
   if (!(f->flags&EDGE_A)) nhid=0;
   elseif (!(f->flags&EDGE_B)) nhid = 1;
   elseif (!(f->flags&EDGE_C)) nhid = 2;
   na = 2-nhid;
   basetv = (f->v[prevpt[nhid]]<f->v[nhid]) ? basic_tva : basic_tvb;
   for (i=0; i<3; i++)
   {
     tv[i] = basetv[na];
     na = nextpt[na];
   }
}