Example #1
0
inline bool
create_sides(
   CBface_list& faces,
   CVertMapper& tmap,
   CVertMapper& bmap,
   Primitive* p
   )
{
   assert(p && tmap.is_valid() && bmap.is_valid());
   Bface_list ret;

   EdgeStrip boundary = faces.get_boundary();
   assert(!boundary.empty());

   EdgeStrip top_strip = tmap.a_to_b(boundary);
   EdgeStrip bot_strip = bmap.a_to_b(boundary);
   assert(!(top_strip.empty() || bot_strip.empty()));

   UVpt a, b, c, d;
   Bedge *top_e, *bot_e;
   Bface *top_f, *bot_f;
   Bvert *v1, *v2, *v3, *v4;
   for (int i = 0; i < top_strip.num(); i++) {
      top_e = top_strip.edge(i);
      bot_e = bot_strip.edge(i);
      top_f = top_e->get_face();
      bot_f = bot_e->get_face();
      v1 = top_strip.vert(i);
      v2 = top_e->other_vertex(v1);
      v3 = bot_strip.vert(i);
      v4 = bot_e->other_vertex(v3);
      bool has_uv = UVdata::get_uvs(top_f, a, b, c);
      if (has_uv) {
         assert(top_f->is_quad() && bot_f->is_quad());
         a = UVdata::get_uv(v1, top_f);
         b = UVdata::get_uv(v2, top_f);
         c = UVdata::get_uv(v3, bot_f);
         d = UVdata::get_uv(v4, bot_f);
         if (c[0]==0 && d[0]==0) 
            c[0] = d[0] = a[0]+abs((UVdata::get_uv(top_f->other_vertex(v1, v2), top_f))[0]-a[0]);
         if (top_f->other_vertex(top_f->weak_edge()) == v1)
            p->add_quad(v1, v3, v4, v2, a, c, d, b);
         else {
            assert(top_f->other_vertex(top_f->weak_edge()) == v2);
            p->add_quad(v3, v4, v2, v1, c, d, b, a);
         }
      } else {
         p->add_quad(v1, v3, v4, v2);
      }
   }

   return true;
}
Example #2
0
inline void
define_offsets(
   CBvert_list& verts,
   CVertMapper& tmap,
   CVertMapper& bmap,
   CWvec& n,
   Primitive* p
   )
{
   assert(tmap.is_valid() && bmap.is_valid());

   for (Bvert_list::size_type i=0; i<verts.size(); i++) {
      define_offset(verts[i], tmap, bmap, n, p);
   }
}
Example #3
0
inline Bface_list
copy_faces(CBface_list& faces, CVertMapper& vmap, Primitive* p, bool reverse=false)
{
   assert(p && vmap.is_valid());
   Bface_list ret;

   for (Bface_list::size_type i=0; i<faces.size(); i++) {
      ret.push_back(copy_face(faces[i], vmap, p, reverse));
   }
   copy_edges(faces.get_edges(), vmap);
   return ret;
}