Announcement

Collapse
No announcement yet.

Tool to convert opacity mapped faces into geometry leaves

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #61
    Here is zee old one:

    Code:
    macroScript LeafConvert category:"John O'Connell Tools"
    
    /*
    
    This script is provded as is and is in no way to be considered a bug free utility.
    Any loss of time or information as a result of using this script is not the responsibility
    of John O'Connell so use it at your own risk!
    
    To be done:
    
    1. Add random scaling and rotation offsets
    2. Add in the option to use more than one type of leaf
    3. Add the ability to convert multiple objects and have automatic conversion of objects into editable poly
    4. Add in stability and more error checking
    
    The latest version of this should always be available in the stuff section of
    http://www.joconnell.com so check back often
    
    */
    
    (
    
       rollout LeafConvert "AEC Leaf convertor"
       (
          fn polyFilter obj = superclassof obj == GeometryClass
          
          Spinner replaceID "Replace Mat ID" type:#integer range:[-1000,1000,5]
          pickbutton LeafObject "Pick leaf Object" width:200 align:#right filter:polyfilter
          button MakeLeaves "Make Leaves" width:200 align:#right
       
          on LeafObject picked obj do
          (
             leafobject.text = LeafObject.object.name
          )
          
          on makeleaves pressed do
          (
       
             the_sel = selection as array
             
             copy_obj = leafobject.object
             
             mat_id = replaceID.value
             
             for o = 1 to the_sel.count do
             (
             
                
                
                try(convertToPoly the_sel[o])catch()
                face_count = getnumfaces the_sel[o]
                print face_count
                face_array = #()
                
                -- Get faces with the specified mat id
                
                for i = 1 to face_count do
                (
                   if (polyop.getfaceMatId the_sel[o] i == mat_id) then
                   (
                      append face_array i
                   )
                )
                
                copy_obj_mesh = editable_mesh()
                copy_obj_mesh.name = (the_sel[o].name + "_leaves")
                copy_obj_mesh.pos = the_sel[o].pos
                
                disableSceneRedraw()
                
                -- Begin progress bar
                
                progressStart "Making leaves"
                escapeEnable = false
                itemnum = face_count
                curitem = 0
                
                for f = 1 to face_array.count do
                (
                   curitem += 1
                   the_pos = polyop.getfacecenter the_sel[o] (face_array[f])
                   the_dir = polyop.getfacenormal the_sel[o] (face_array[f])
                   the_dist_obj = copy copy_obj
                   the_dist_obj.pos = the_pos
                   the_dist_obj.dir = the_dir
                   attach copy_obj_mesh the_dist_obj
                   
                   -- Update progress bar
                   
                   total_progress = ((curitem as float)/(itemnum as float))*100
                   
                   gc()
                   progressUpdate total_progress
                )
                
                progressEnd()
                
                enableSceneRedraw()         
                completeRedraw()
             )
          )
       
       )
       
       createdialog LeafConvert width:360
    
    )

    Comment


    • #62
      Thanks a million !
      http://mikebracken.cgsociety.org/gallery/

      Comment


      • #63
        Thanks joconnell!!!!!!!

        I found I guess the original version in a different thread, will give it a try.

        Thanks again!

        Comment


        • #64
          Seems like I am somewhat behind-the-times on this thread! Oh well, lets resurrect it! Is there a version of this script available anywhere? From reading this thread, it seems pretty ideal for my workflow. Pesky opacity mapped geometry!!!!
          Kind Regards,
          Richard Birket
          ----------------------------------->
          http://www.blinkimage.com

          ----------------------------------->

          Comment


          • #65
            I see you found this thread tricky!

            I think the one I have is newer than the one in joconnell's last post. As far as i remember i found it at evermotion and had to clean it up to remove smileys. Not sure what version it is.

            (rename it to .ms and stick it in scripts/startup)
            Attached Files
            www.peterguthrie.net
            www.peterguthrie.net/blog/
            www.pg-skies.net/

            Comment


            • #66
              Nice one mate. Much appreciated! Have yourself a beer on me!
              Kind Regards,
              Richard Birket
              ----------------------------------->
              http://www.blinkimage.com

              ----------------------------------->

              Comment


              • #67
                no probs mate. Think I'll go for a pint of IPA if I can find it down here in lahndan.

                One thing about this script is that it can take bloomin ages since it (maxscript) isnt multithreaded, so go and make yourself a cuppa while its working! I normally detach (clone) a few leaves first so that you can test that you have pivot points in the right place.

                While I'm at it heres a bit of a workflow:

                -export tree from onyx as 3ds with leaves as planes (simple rectangles, no curvature or anything, '0' resolution in the leaf plates dialogue box), plus i make 2 types of leaf (2 p-objects)
                -import 3ds file into max
                -detach the 2 types of leaves to separate editable meshes using mat id
                -make a plane oject about the size of a leaf, give it your new leaf material and trace over it to make a new leaf
                -add bend modifier so it looks leafish, then collapse
                -pivot point should normally be in the middle
                -detach a few leaves as clones from the imported geometry and test the leaf replacer script so you can check pivot point and orientation is correct
                -run script for both sets of leaves (i make the 2nd leaf a bit different to the first and with a slightly different material)
                -check resultant leaves have the right mat id and attach them back to the main tree
                -set up materials for leaves (2sided) and trunk/branches etc
                -export vrayproxy
                www.peterguthrie.net
                www.peterguthrie.net/blog/
                www.pg-skies.net/

                Comment


                • #68
                  Stunning - and an ale drinker as well! Even better! Why did I go and mention a pint? Now I neeeeeEEED a beer!
                  Kind Regards,
                  Richard Birket
                  ----------------------------------->
                  http://www.blinkimage.com

                  ----------------------------------->

                  Comment


                  • #69
                    forgot a step:

                    if you find you are getting 2 new leaves for every square leaf from onyx, then go into the detached editable mesh, change to edge, select all edges then click 'auto edge'.

                    that trick is probably from someone else on this forum btw!
                    www.peterguthrie.net
                    www.peterguthrie.net/blog/
                    www.pg-skies.net/

                    Comment


                    • #70
                      Ha ha this is still going

                      Gotta give lele a shout and resurrect some of our gardening tools since we're coming into the season

                      Comment


                      • #71
                        Originally posted by joconnell View Post
                        Ha ha this is still going

                        Gotta give lele a shout and resurrect some of our gardening tools since we're coming into the season
                        Good old search utility!!!
                        Kind Regards,
                        Richard Birket
                        ----------------------------------->
                        http://www.blinkimage.com

                        ----------------------------------->

                        Comment


                        • #72
                          It does seem rather slow, but it does work. Very clever little script. Did I read somewhere in this/another thread that maxscript is only single-threaded which is the cause of its lack of speed?
                          Kind Regards,
                          Richard Birket
                          ----------------------------------->
                          http://www.blinkimage.com

                          ----------------------------------->

                          Comment


                          • #73
                            Yep, that'd be it alright. Another thing is that it's very memory intensive to run on high poly meshes so I get max to flush its ram after each leaf - it's not an efficient way to do it but it was the only way to guarantee stability on large amounts of leaves.

                            Comment


                            • #74
                              The reason it runs out of memory is the undo system gets overwhelmed trying to keep a copy of the mesh as each leaf is attached. Lose the garbage collection in the main loop, as thats going to be very slow. Instead put an 'undo off ()' around the main loop. Memory stays low this way and there's a fair speed increase.

                              It's worth noting that the attaching gets slower as polycount increases, you might notice the progress bar seems to slow down as it goes on. One way round this is to attach the leaves into clumps, then attach the clumps at the end. There was some discussion here about that.

                              Comment


                              • #75
                                Thanks Matt, will give this a try
                                www.peterguthrie.net
                                www.peterguthrie.net/blog/
                                www.pg-skies.net/

                                Comment

                                Working...
                                X