I wanted to make a script to shrinkwrap one mesh around another … but I need to try to do it another way, because this method causes some of the vertices to not move.
Basically, a ray is cast from a vertices in the inverse direction of the normal, and then the vertices is moved to the closest point where the ray intersects one of the triangles. A better way would be to find the shortest distance from a point to a triangle, and then move the vertice onto the triangle. I don’t think I am explaining it very well … oh well.
To use this, first select the mesh to shrink around, then also select the mesh that would be doing the shrinking. Then run the script. A Better version may come about later.
The idea was to allow people to focus on shapes and proportions, without having to worry about vertice placement, then afterwards work on better verice placement. I found that this was rather hard to do with this script, because rays cast from some of the vertices do not intersect with any triangles (the inverse of the normal points slightly off). Maybe somebody might find it interesting though.
# shrink-wrap - Nov. 7, 2004 # Created by: Nathan Moore # Ray Triangle Intersection found at: http://www.cs.virginia.edu/~gfx/Courses/2003/ImageSynthesis/papers/Acceleration/Fast%20MinimumStorage%20RayTriangle%20Intersection.pdf import Blender print " ########## Shrink-Wrap ##########" shrinkObj = Blender.Object.GetSelected() wrapObj = Blender.Object.GetSelected() shrinkMesh = Blender.NMesh.GetRaw(shrinkObj.data.name) epsilon = 0.000001 def cross(v1,v2): dest =  dest.append(v1*v2-v1*v2) dest.append(v1*v2-v1*v2) dest.append(v1*v2-v1*v2) return dest def dot(v1,v2): return v1*v2+v1*v2+v1*v2 def sub(v1,v2): dest =  dest.append(v1-v2) dest.append(v1-v2) dest.append(v1-v2) return dest def intersectTriangle(orig, dir, v0, v1, v2): edge1 =  edge2 =  tvec =  qvec =  edge1 = sub(v1,v0) edge2 = sub(v2,v0) pvec = cross(dir, edge2) det = dot(edge1, pvec) if det<epsilon: return 0 tvec = sub(orig, v0) u = dot(tvec, pvec) if (u<0.0 or u>det): return 0 qvec = cross(tvec, edge1) v = dot(dir, qvec) if(v<0.0 or u+v>det): return 0 t = dot(edge2, qvec) inv_det = 1.0/det t = t * inv_det u = u * inv_det v = v * inv_det r =  r.append(t) r.append(u) r.append(v) return r def shrinkwrap(): global shrinkMesh, wrapObj, shrinkObj c=0 for v in shrinkMesh.verts: d = 500000.0 ntmp = [-v.no, -v.no, -v.no] for f in wrapObj.getData().faces: tmp = intersectTriangle(v.co, ntmp, f.v, f.v, f.v) if tmp != 0: if tmp<d: d = tmp if len(f.v) > 3: tmp = intersectTriangle(v.co, ntmp, f.v, f.v, f.v) if tmp != 0: if tmp<d: d = tmp if d != 500000.0: shrinkMesh.verts[v.index].co = v.co+ntmp*d shrinkMesh.verts[v.index].co = v.co+ntmp*d shrinkMesh.verts[v.index].co = v.co+ntmp*d c = c+1 print c,"/",len(shrinkMesh.verts) shrinkMesh.update(1) shrinkwrap() print "done"