///////////////////////////////////// // get_visibility() ///////////////////////////////////// void HatchingGroupFixed::get_visibility(TAGformat &d) { err_mesg(ERR_LEV_SPAM, "HatchingGroupFixed::get_visibility()"); BMESH *m = _patch->mesh(); if (LMESH::isa(m)) m = ((LMESH*)m)->cur_mesh(); int k, ctr=0; ARRAY<int> indices; CBface_list& faces = m->faces(); *d >> indices; for (k=0; k<indices.num(); k++) { HatchingSimplexDataFixed *hsdf = HatchingSimplexDataFixed::find(faces[indices[k]]); if (!hsdf) { hsdf = new HatchingSimplexDataFixed(faces[indices[k]]); ctr++; } hsdf->add(this); } err_mesg(ERR_LEV_SPAM, "HatchingGroupFixed::get_visibility() - Flagged %d tris and added %d new simplex data.", indices.num(), ctr); }
///////////////////////////////////// // put_visibility() ///////////////////////////////////// void HatchingGroupFixed::put_visibility(TAGformat &d) const { err_mesg(ERR_LEV_SPAM, "HatchingGroupFixed::put_visibility()"); BMESH *m = _patch->mesh(); if (LMESH::isa(m)) m = ((LMESH*)m)->cur_mesh(); int k; ARRAY<int> indices; CBface_list& faces = m->faces(); for (k=0; k< faces.num(); k++) { HatchingSimplexDataFixed *hsdf = HatchingSimplexDataFixed::find(faces[k]); if (hsdf) { if(hsdf->hack_exists(this)) indices += faces[k]->index(); } } err_mesg(ERR_LEV_SPAM, "HatchingGroupFixed::put_visibility() - Stored %d tri indices.", indices.num()); d.id(); *d << indices; d.end_id(); }
void init_strips(const BMESH &mesh) { // VIEWptr view = new VIEWsimp; // VIEW::push(view); ((BMESH &) mesh).make_patch_if_needed(); for (int p = 0; p < mesh.patches().num(); p++) { mesh.patches()[p]->build_tri_strips(); } // VIEW::pop(); }
void write_normals(const BMESH &mesh, ostream &os) { Formatter out(&os, 77); out.write(" normal ["); IVNormalIterator iter(&out); for (int p = 0; p < mesh.patches().num(); p++) { Patch *patch = mesh.patches()[p]; patch->draw_tri_strips(&iter); } os << "]" << endl; os << " normalBinding PER_FACE" << endl; }
void write_verts(const BMESH &mesh, ostream &os) { const int num = mesh.nverts(); int i; for (i = 0; i < num; i++) { CWpt &loc = mesh.bv(i)->loc(); os << "v " << loc[0] << " " << loc[1] << " " << loc[2] << endl; } for (i = 0; i < num; i++) { Wvec n = mesh.bv(i)->norm(); os << "vn " << n[0] << " " << n[1] << " " << n[2] << endl; } }
void write_verts(const BMESH &mesh, ostream &os) { os << " vertex ["; const int num = mesh.nverts(); for (int i = 0; i < num; i++) { CWpt &loc = mesh.bv(i)->loc(); if (i != 0) { os << " "; } os << loc[0] << " " << loc[1] << " " << loc[2]; if (i != num - 1) os << "," << endl; } os << "]" << endl; }
void write_faces(const BMESH &mesh, ostream &os, bool do_simple=false) { const int num = mesh.nfaces(); for (int i = 0; i < num; i++) { os << "f "; for (int v = 1; v <= 3; v++) { int k = mesh.bf(i)->v(v)->index()+1; os << k; if (!do_simple) os << "//" << k; os << ((v==3) ? "" : " "); } os << endl; } }
void write_strips(const BMESH &mesh, ostream &os) { const str_ptr intro(" coordIndex ["); Formatter out(&os, 77); out.write(intro); IVTriStripIterator iter(&out); // from Bface::draw_strips() for (int p = 0; p < mesh.patches().num(); p++) { Patch *patch = mesh.patches()[p]; iter.set_left(patch->num_tri_strips()); patch->draw_tri_strips(&iter); // If there are more patches, write out ", " if (p < mesh.patches().num() - 1) os << ", "; } os << "]" << endl; }
void XToonStripCB::faceCB(CBvert* v, CBface* f) { assert(v && f); Wvec bNorm; //Blended Normal //first calculate the abstract(blended) normal switch(_blend_type) { case XToonStripCB::SMOOTH: { // Note: doesn't work bNorm = v->get_all_faces().n_ring_faces(3).avg_normal(); } break; case XToonStripCB::SPHERIC: { BMESH* mesh = v->mesh(); Wpt c = mesh->get_bb().center(); bNorm = (v->loc()-c).normalized(); } break; case XToonStripCB::ELLIPTIC: { BMESH* mesh = v->mesh(); Wvec c_to_v = v->loc() - mesh->get_bb().center(); Wvec dim = mesh->get_bb().dim(); double a = dim[0]*0.5; double b = dim[1]*0.5; double c = dim[2]*0.5; bNorm = Wvec(c_to_v[0]/a, c_to_v[1]/b, c_to_v[2]/c).normalized(); } break; case XToonStripCB::CYLINDRIC: { BMESH* mesh = v->mesh(); Wpt c = mesh->get_bb().center(); Wvec axis; Wvec dim = mesh->get_bb().dim(); if (dim[0]>dim[1] && dim[0]>dim[2]) axis = dim.X(); else if (dim[1]>dim[0] && dim[1]>dim[2]) axis = dim.Y(); else axis = dim.Z(); Wpt v_proj = c + ((v->loc()-c)*axis) * axis; bNorm = (v->loc()-v_proj).normalized(); } break; default: assert(0); } //set the blended normal, the regular normal and the vertex point glVertexAttrib3f(_loc, bNorm[0], bNorm[1], bNorm[2]); glNormal3dv(f->vert_normal(v).data()); glVertex3dv(v->loc().data()); }