Is there a mesh relax script available for Blender? If not, I’d like to suggest it as an addition for 2.5. It would be nice to have a script for this and even nicer to have a button integrated into the UI.
(Mesh relax is a function in other 3d software [XSI, Maya] that cleans up a mesh by evening out the spacing between edges while maintaining the shape of the object as much as possible)
RickyBlender: I think that is totally different from what he wants. He wants the existing points to be moved along the existing edges, so the overall distances between the points is more uniform but the overeall shape is kept.
This seems to work just like the smooth modifier and operators in blender (I tried it and got the same results). The only difference is there is not equivalent “Keep boundry points fixed”, and “Save outer corners” options in blender. I don’t know what they do, so I perhaps those are the missing options you need, in which case… they are missing.
Ok, I gave it a try today and it works pretty well. Definitely not perfect but easyly good enough to be useful in many cases.
def relax_mesh(context):
# get active object and remember some of its mesh info
obj = context.active_object
me_old = obj.data
me_name = me_old.name
# duplicate the object so it can be used as a target for the shrinkwrap modifier
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.duplicate()
target = context.active_object
bpy.context.scene.objects.active = obj
sw = obj.modifiers.new(type='SHRINKWRAP', name='target')
sw.target = target
# run smooth operator to relax the mesh
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.vertices_smooth()
bpy.ops.object.mode_set(mode='OBJECT')
# apply and remove the modifier (ugly...)
me = obj.create_mesh(True, 'PREVIEW')
obj.data = me
obj.modifiers.remove(sw)
# clean up the old mesh and rename the new one
bpy.data.meshes.remove(me_old)
obj.data.name = me_name
# delete the target object
obj.selected = False
target.selected = True
bpy.ops.object.delete()
obj.selected = True
bpy.ops.object.mode_set(mode='EDIT')
class Relax(bpy.types.Operator):
'''Relaxes selected vertices while retaining the shape'''
bl_idname = 'mesh.relax'
bl_label = 'Relax'
bl_options = {'REGISTER', 'UNDO'}
def poll(self, context):
obj = context.active_object
return (obj and obj.type == 'MESH')
def execute(self, context):
relax_mesh(context)
return {'FINISHED'}
bpy.types.register(Relax)
if __name__ == '__main__':
bpy.ops.mesh.relax()
The implementation has some flaws (concerning the method to apply the modifier), I will further look into this.
my name ist Hakan and i´m a collegue of Loolarge. I will first excuse for my bad english
We´ve worked together at Ambient-Entertainmen on the coming german 3D Feature-Film “Konferenz der Tiere / Animals United”. I´m a blender user about 2 years now and i love it! My first job at AE was to model with my Supervisor the whole Characters. Our main-tool is Maya but i modelled all my Characters in blender Everyone were suprised about my decision to use blender. I´d alot to explain why i use it for modeling …an opensource program Well it was funny to see how the jaws get drop when i began to model from scratch so fast and intuitiv with the mindblowing artist-friendly tools in blender. ;D
Well back to the topic. And the end of my workingprogress i did the final touch in maya! Sadly…(of course maya has also a really good modelling-workflow) but i missed a tool like the Relax-Brush in Maya. You have some basic Sculptingtools called Sculpting-Geometry-Tools but very primitive not compareible to blender´s sculpting tool. Except the Relax-Brush!
You can do really fast cleanup your mesh! This is for the facials really important. You will get clean results of your mesh… like it were smoothed without a smoothmodifier. But the volume isn´t lost.
Install and enable it using the Add-On page in the user prefs,
afterwards it’s accessible either through the “w-menu” or through “Mesh -> Vertices -> Relax”.
@0knowledge - Yes, the example’s were bad, but I was at work and did not have access to a good example. The video you sent me isn’t exactly what I’m looking for, but thanks much for the assistance.
@mr_archano - wow, those loop tools are very useful and appear to be a good solution, thanks for pointing me to them!
@frigi - That’s amazing! Exactly what I am looking for, thank you for writing the script!
Frigi - man thanx a lot for the script. It is just what i need now, but can u help. It can’t be executed due to an error. See the pic and please tell me what should i do.
I encountered a similar error when I tried to run the script. I contacted Frigi about it and he said it was written for 2.5 (I am running 2.49 and it looks like you are too). I tried running it on 2.5, but it still didn’t work for me. I didn’t really install 2.5 properly though. So I haven’t actually gotten it to work yet, I just assume it will because he shows it working. I am waiting for a stable release with all of 2.49’s features to switch over to 2.5 (hopefully that means Beta 1?). Then I’ll get to try this out.