// // Written by Andrew Chapman - Oct 2002 - chapman@technolumiere.com // // Moves all the points in the 'deformThisMesh' object to match the positions // of the points in the 'sourceShapeMesh' object. Kind of a shortcut for doing a // blendshape between the objects, moving the slider up, then deleting the blend shape // // Both meshes should have the same number of points, but if they don't then the first // N points of the object being deformed will move to match the first M points of the // source shape. If M is less than N, then only the first M points in the deforming // object will be moved. If N and M are not equal a warning will be shown. // // Deleting a vertex from an object will normally re-order the vertices though, so the // results will most likely not be what you're after in these cases. Thought: could write // a vertex re-ordering script that makes sure the vertices of two meshes have the same // order, based on matchin point locations. global proc conformMeshToMesh(string $deformThisMesh, string $sourceShapeMesh) { int $nVerts[] = `polyEvaluate -vertex $deformThisMesh`; int $nVertsSrc[] = `polyEvaluate -vertex $sourceShapeMesh`; if ($nVerts[0] < $nVertsSrc[0]) { warning "conformMeshToMesh: deforming mesh has less points than source mesh"; } if ($nVerts[0] > $nVertsSrc[0]) { warning "conformMeshToMesh: deforming mesh has more points than source mesh"; } int $i; int $nPointsToMove = min($nVerts[0], $nVertsSrc[0]); for($i=0; $i<$nPointsToMove; $i++) { float $pts[] = `xform -objectSpace -q -translation ($sourceShapeMesh + ".vtx[" + $i + "]")`; xform -objectSpace -translation $pts[0] $pts[1] $pts[2] ($deformThisMesh + ".vtx[" + $i + "]"); } }