Mesh Relax Script?

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)

What about the smooth vertex operator?

what about the decimator

i think it’s doing what your saying !

salutations

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.

It’s already hard coded into blender… -> here: http://wiki.blender.org/index.php/Doc:Manual/Modifiers/Mesh/Smooth

the smooth modifier does not preserve the volume of the mesh

Loolarge and Waylow are correct.

Basically, it would take messy edges such as these:

and relax them into clean, evenly spaced edges like these:

While preserving the shape and volume as much as possible.

hmm your examples are not before and after, and don’t actually use the relax tool…

http://designreform.net/2007/05/mesh-relaxation/
The above link is the only real example I found of the modifier in action. Is this what you’re referring too?

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.

You may want to look into the re-topology tools.

The closest you can get right now is probably duplicate -> shrinkwrap -> smooth (-> delete duplicate).

0knowledge: This is also something different than what has been asked for but none the less quite useful.

Select mesh > tab into edit mode > select mesh > w > smooth.

If this is the case, maybe you have to take a look at this:
http://blenderartists.org/forum/showthread.php?t=148728

Using Smoth modifier applied to a vertex group.

http://www.pasteall.org/pic/show.php?id=1673

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.

http://frigi.designdevil.de/Scripts/Relax/relax_anim.gif

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.

Hi,

my name ist Hakan and i´m a collegue of Loolarge. I will first excuse for my bad english :slight_smile:
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 :smiley: Everyone were suprised about my decision to use blender. I´d alot to explain why i use it for modeling …an opensource program :smiley: 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.

please look at this video http://www.youtube.com/watch?v=rK5TZljG1gs at 2:27 the guy will explain the relax brush and how comfortable it is in use.

it would be soooo awesome to see a relax like brush in the sculpting-brush-presets in blender.

again…i´m sorry for my bad english… :smiley:

The most recent version is in the tracker now: http://projects.blender.org/tracker/index.php?func=detail&aid=21421&group_id=153&atid=467
Or it can also be downloaded here: http://frigi.designdevil.de/Scripts/Relax/mesh_relax.py

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.

http://img30.imageshack.us/img30/2328/blender.jpg

Uploaded with ImageShack.us

That script is for blender 2.5, not for 2.4x

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.

OK. Thank you guys!