void ProxySurface::update_proxy_surface() { if(!_proxy_mesh) create_proxy_surface(); apply_xform(); while (grow_proxy_surface() > 0) ; trim_proxy_surface(); lod_update(); }
// Rotate model so that first principal axis is along +X (using // forward weighting), and the second is along +Y void pca_rotate(TriMesh *mesh) { point com = mesh_center_of_mass(mesh); trans(mesh, -com); float C[3][3]; mesh_covariance(mesh, C); float e[3]; eigdc<float,3>(C, e); // Sorted in order from smallest to largest, so grab third column vec first(C[0][2], C[1][2], C[2][2]); int npos = 0; int nv = mesh->vertices.size(); for (int i = 0; i < nv; i++) if ((mesh->vertices[i] DOT first) > 0.0f) npos++; if (npos < nv/2) first = -first; vec second(C[0][1], C[1][1], C[2][1]); npos = 0; for (int i = 0; i < nv; i++) if ((mesh->vertices[i] DOT second) > 0.0f) npos++; if (npos < nv/2) second = -second; vec third = first CROSS second; xform xf; xf[0] = first[0]; xf[1] = first[1]; xf[2] = first[2]; xf[4] = second[0]; xf[5] = second[1]; xf[6] = second[2]; xf[8] = third[0]; xf[9] = third[1]; xf[10] = third[2]; invert(xf); apply_xform(mesh, xf); trans(mesh, com); }
// Scale the mesh - isotropic void scale(TriMesh *mesh, float s) { apply_xform(mesh, xform::scale(s)); }
// Rotate the mesh by r radians void rot(TriMesh *mesh, float r, const vec &axis) { apply_xform(mesh, xform::rot(r, axis)); }
// Translate the mesh void trans(TriMesh *mesh, const vec &transvec) { apply_xform(mesh, xform::trans(transvec)); }
// Scale the mesh - anisotropic in an arbitrary direction void scale(TriMesh *mesh, float s, const vec &d) { apply_xform(mesh, xform::scale(s, d)); }
// Scale the mesh - anisotropic in X, Y, Z void scale(TriMesh *mesh, float sx, float sy, float sz) { apply_xform(mesh, xform::scale(sx, sy, sz)); }