my attempt at an 'unlimited clay' script

Lately I have been working on a script to subdivide a mesh only where it is needed, this could in turn be used as a suppliment to the sculpt tools in blender to allow for a largely quad dominant mesh that would update itself as you sculpted it.
NOTE** to use the script you must have the mesh in vertex select mode, and not be in edit mode.

as you can see in the links below, the majority of the faces are indeed quads, as opposed to triangles
http://www.4shared.com/photo/PbBJDQfI/Quaddom.html
http://www.4shared.com/photo/40TAjFdT/Mesh.htm

and here is the script:
http://www.4shared.com/file/sztdZOTh/RESOTEST.html

can ou make a short video to show how this is used < 3 Minutes
just to gie us an idea how to work with it !

Thanks and happy 2.5

and is it available in 2.5?

the script currently does not support 2.5, I still need to work out some issues with its integration with the blender tools (ie: so that the script will automatically update after each stroke in sculpt mode, and that it will only reference vertices effected by the brush) with the help of the blender community before I start working on getting it into an addon form :slight_smile:
as for the video, its uploading to youtube right now, I will post a link when it finishes

ok, and here, is a brief video of myself using the script in 2.49

don’t know how you can subdivide locally but it’s a good feature

hope you an make in 2.5 soon

can be very usefull!

did you see the Farharthey version for unlimited clay ?

keep up the good work

i tested it in 2.49 and works fine
very nice to subdivide localy

can this work with other type of brush - now it’s one type = inflate
but can it work with smooth pinch ect. ?

happy 2.5

well there are a couple of things I wanted to add in but they are limited by what I can do with the scripts. For example, I would like to make it so that the script updates each time you complete a stroke, and only references the verts that were moved by the brush. Do you have any idea how I can do that?

would be easier to do in 2.5

each time you change a var it should update the display !

i;ll ahve a look in sccript and see if hard to convert to 2.5

but might het help from IRC channel too

happy 2.5

here is the beginning of the ported script in 2.5 working in version 31197
and it is not an addons!

1- This add a new panel at bottom of the tool panel

Still need to add one or 2 properties for res

complete the subdivide and smooth function for the script

ti finalize this this panel

2 - Get some help to get the Selected vertices from the brush instead
might be much faster !

3 - Ideally would be nice to have all this in the operators’ pane instead of the too panel
easier to find and work with

so here is the script with some debugging lines you can read on the console


 
import bpy
import mathutils
from math import *
from bpy.props import *
 
 
 
def maintain_resolution(res,smooth,mesh=0):
 
 
    print ()
    objact=bpy.context.active_object
    print ('Active object =  =',objact )
    myMesh = objact.data
    print ('data  =',myMesh )
    print (' myMesh.vert sel  =',myMesh.total_vert_sel)
 
    print ()
 
    print ()
    print (' #### Edges    ####  ')
    print ()
 
 
 
    loc=0
 
    for ed in myMesh.edges:
 
#        if ed.selected or not bpy.context.scene.display_sel_only:
 
        v1, v2 = ed.verts
 
        print (' ed verts index =',ed.verts[0],'index =',ed.verts[1],'    v1=',v1,'v2=',v2)
 
        v3 = myMesh.verts[v1].co
        v4 = myMesh.verts[v2].co
        print ('v3=',v3,'v4=',v4)
 
 
    print ()
    print (' ####   Faces    ####  ')
    print ()
 
 
    fa=0
 
    for i in myMesh.faces:
        print('F=',fa,'Face verts =',i.verts[:],' Face.area = ', i.area,' qty Verts/ Face =',len(i.verts))
 
        for j in range(0,len(i.verts)):                            # List vertices  indices / Face
 
#            print('vert[',j,']=',i.verts[j],' Co =',myMesh.verts[j].co)
#            print ('j=',j,'Co =',myMesh.verts[j].co)
            vv1=myMesh.verts[j].co
#            print ('vv1=',vv1[0],'Y=',vv1[1],'Z=',vv1[2])
#            dist = sqrt(pow(vv1[0],2))
#            print ('dist=',dist)
 
            print()
 
 
            for k1 in range(0,len(i.verts)):
                vv2=myMesh.verts[k1].co
                print(' vv2 = vert[',k1,']=',i.verts[k1],' Co =',myMesh.verts[k1].co)
 
                dist1 = sqrt(pow(vv1[0]-vv2[0],2)+pow(vv1[1]-vv2[1],2)+pow(vv1[2]-vv2[2],2))
                print ('Dist =',dist1)
 
            print()
 
#    bpy.ops.mesh.quads_convert_to_tris()                 #    Operators
 
 
        fa+=1
 
 
 
 
"""
 
 
                    dist = math.sqrt(math.pow(v.co[0]-a.co[0],2)+math.pow(v.co[1]-a.co[1],2)+math.pow(v.co[2]-a.co[2],2))
                    if dist &gt; res:
                        v.sel = a.sel = 1
 
 
 
 
"""
 
bpy.types.Scene.StringProperty(name="file path",            # Define Text  Input   field
    attr="custompath",
    description="simple file path",
    maxlen= 1024,
    default= "")
 
class VIEW3D_PT_CustomMenuPanel(bpy.types.Panel):          # Define the New Panel
    bl_space_type = "VIEW_3D"
    bl_region_type = "TOOLS"
    bl_label = "Subdivide Local"
 
    def draw(self, context):
        layout = self.layout
        layout.label(text="custom text")                    # Add a new Text field on one line
        layout.label(text="Clay Local")                        # Add a new Text field on one line
        layout.operator("object.CustomButton")                # Add a new Label field on one line
        layout.label(text="Resolution")                        # Add a new Text field on one line
        layout.operator("object.CustomButton1")                # Add a new Label field on one line
 
 
 
 
class OBJECT_OT_CustomButton(bpy.types.Operator):        # Define First new button in  New Panel
    bl_idname = "OBJECT_OT_CustomButton"
    bl_label = "Subdivide Clay Local"
    __doc__ = "Subdivide  Clay Local"
 
    def invoke(self, context, event):
        print("Execute Clay Local")
 
 
        maintain_resolution(.1,5)
 
 
 
 
 
 
        return{'FINISHED'}    
 
 
class OBJECT_OT_CustomButton1(bpy.types.Operator):        # Define First new button in  New Panel
    bl_idname = "OBJECT_OT_CustomButton1"
    bl_label = "Clay Resolution"
    __doc__ = "Clay Resol"
 
    def invoke(self, context, event):
        print("Execute Clay Local")
 
 
 
        maintain_resolution(.1,5)
 
 
 
        return{'FINISHED'} 
 
 
 
 
def register():
    bpy.types.register(VIEW3D_PT_CustomMenuPanel)
    bpy.types.register(OBJECT_OT_CustomButton)
    bpy.types.register(OBJECT_OT_CustomButton1)
 
def unregister():
    bpy.types.unregister(VIEW3D_PT_CustomMenuPanel)
    bpy.types.unregister(OBJECT_OT_CustomButton)
    bpy.types.unregister(OBJECT_OT_CustomButton1)
 
if __name__ == "__main__":
    register()
 
 
 
 

might be able to get some helps at IRC python

Thanks and let us know how it goes
would definitively be nice to see this work in 2.5

You should contact Raul to share information about this method, maybe together can solve the individual problems that both of you has.

I already PM him but waiting for an answer

would be nice to hear form him!

don’t know what happenign with his Clay built!

i think it was put on hold till we get more tools in 2.5

happy 2.5

Thanks ricky for all your help, I definitely will keep you updated, well, I think the first thing I want to do is get the script to only check verts effected by the brush, then I will work on getting it to work automatically with each stroke :slight_smile: yet again thank you ricky :smiley: well I guess im off to the IRC to look for more answers

i’ll try to add the 2 variables in new panel
as soon as i find how to do it i’ll get back

but good idea for IRC
you migth get some help to get the list of vertices used by the brush

let us know how it goes

it will be an interesting script to locally subdivide and be able to use the brush in sculpt mode

happy 2.5