Beispiel #1
0
inline Bface*
copy_face(Bface* f, CVertMapper& vmap, Primitive* p, bool reverse)
{
   assert(f && p && vmap.is_valid());

   Bvert* v1 = vmap.a_to_b(f->v1());
   Bvert* v2 = vmap.a_to_b(f->v2());
   Bvert* v3 = vmap.a_to_b(f->v3());
   assert(v1 && v2 && v3);

   FaceMeme* fm = nullptr;
   UVpt a, b, c;
   if (UVdata::get_uvs(f, a, b, c)) {
      Panel* r = dynamic_cast<Panel*>(Bsurface::find_controller(f));
      assert(r && r->curves().num()==4);
      int n = min(r->curves()[0]->num_edges(), r->curves()[1]->num_edges());
      if (reverse) {
         fm = p->add_face(v1, v3, v2, a, c, b);
      } else {
         a = UVpt(2+1.0/n-a[0], a[1]);
         b = UVpt(2+1.0/n-b[0], b[1]);
         c = UVpt(2+1.0/n-c[0], c[1]);
         fm = p->add_face(v1, v2, v3, a, b, c);
      }
   } else {
      if (reverse)
         fm = p->add_face(v1, v3, v2);
      else
         fm = p->add_face(v1, v2, v3);
   }
   return fm ? fm->face() : nullptr;
   
}
Beispiel #2
0
Lface*
Skin::gen_face(Bface* f)
{
   if (!f) {
      err_adv(debug, "Skin::gen_face: null face");
      return 0;
   }
   Bvert* v1 = _mapper.a_to_b(f->v1());
   Bvert* v2 = _mapper.a_to_b(f->v2());
   Bvert* v3 = _mapper.a_to_b(f->v3());

   FaceMeme* fm = 0;
   UVpt a, b, c;

   // if the new face exists, the following does not re-create it:
   if (UVdata::get_uvs(f, a, b, c)) {
      if (_reverse)
         fm = add_face(v1, v3, v2, a, c, b);
      else
         fm = add_face(v1, v2, v3, a, b, c);
   } else {
      if (_reverse)
         fm = add_face(v1, v3, v2);
      else
         fm = add_face(v1, v2, v3);
   }
   return fm ? fm->face() : 0;
}