Home Technical Talk

Working normal thief for 3ds max 2018 ?

HashBrownHamish
polycounter lvl 5
Offline / Send Message
HashBrownHamish polycounter lvl 5
I've tried some of the normal thief scripts with 3ds max 2018 but some don't work and others cause crashes. Has anybody got a script that works with 3ds max 2018 that i can use to transfer normals from a sphere to my tree branches ?

Replies

  • Swordslayer
    Offline / Send Message
    Swordslayer interpolator
    From a sphere? In that case, you don't need a mesh to transfer the normals from at all, just a center point position. Assuming the selected object is an editable mesh, something like this should do the trick (probably with a different centerPos value):

    centerPos = $.center
    for vert in $.vertices do setNormal $ vert.index (vert.pos - centerPos)
    update $<br>
  • cptSwing
    Offline / Send Message
    cptSwing polycounter lvl 11
    That's pretty genius ^

    I found this one here a while ago, uses the working pivot instead of $.center - which I found quite smart - and works on Editable Poly instead (no modifier stacks unfortunately, though):

    https://mixescript.blogspot.com/2013/04/foliage-models-often-require-edited.html



  • Eric Chadwick
  • cptSwing
    Offline / Send Message
    cptSwing polycounter lvl 11
    It works fine on simpler modifier stacks (albeit with script errors) yeah, but has been regularly crapping out on me when confronted with more "unorthodox" usecases. For instance, I'm playing around with the "Mesh Mixer" MCG included herein , which can combine several existing meshes in order to make them appear as a single mesh to Max - which makes more procedural stuff a bit easier - but all of the NormalThief scripts stumble over its Meshtype I guess (crashing my viewport in the process ;) ) ..
  • Noors
    Offline / Send Message
    Noors greentooth
    @cptSwing Not that i'm taking offence, but i'm not a developper, and i've made this script 5 years ago, for a specific case. And true, it's barely protected against crashes.
    Would you mind to share a simple scene with your mcg setup ? With the source object and the target object.
  • cptSwing
    Offline / Send Message
    cptSwing polycounter lvl 11
    Hey, absolutely no offense meant. My programming skill is at least a couple of notches below yours and I'm grateful for the script either way!

    Will update this post with a link in a bit, hang on

    EDIT: here it is  (wetransfer) - max 2018, and the MCG Mesh Mixer from the sample pack I linked above is needed, obv
  • Noors
    Offline / Send Message
    Noors greentooth
    Ok thanks !
    Weird things going on.
    I've made a temporary ugly fix linked below, looks like it's working. Atleast it shouldnt crash the viewport :p
    but i should retake that script entirely, or see if there are smarter solution than maxscript now (maxplus). I can't believe it's still not included. AD nonsense once more.
    I guess you'd use meshmixer to make the leaves mesh from solo cards ? Because the trunk certainly shoudnt be included in the normals projection.
    This might worth a look maybe ? : https://gumroad.com/l/VertexNormalToolkit
    I should make an option to transfer on selected faces only.

  • cptSwing
    Offline / Send Message
    cptSwing polycounter lvl 11
     It worked like a charm - you are a star!


    And yeah, having it work on select geometry only would be the logical next step I guess. The script on mixescript[...] uses
    subobjectLevel = 1
    vertarray = #{}
    vertarray = polyop.getVertSelection obj
    if vertarray.numberSet == 0 then -- no selection, select all
    (
     polyop.setVertSelection obj #all
     vertarray = polyop.getVertSelection obj
    )
    

    and so forth. Might be fairly easy? Not sure how it'd work for Meshes with a modifier stack though, one would add a Meshselect/VolSelect beforehand?

  • Noors
    Offline / Send Message
    Noors greentooth
    i feel ashamed to script when i see an algo by denisT, Polytools,Klvnk... :#

    i'd use snapshot function. It creates a snapshot of the top level mesh, and preserve the highest level selection. I can perform operations on those without messing with original objects/stack.
    By then i was only replicating normal thief behaviour, which finds the normal of the closest vert coz i didn't want people to get a different result.
    But it would be more accurate to get the normal of the closest point on face.

  • Noors
    Offline / Send Message
    Noors greentooth
    So i basically rewrote it.
    The script project normals only on selected faces. Or all faces if none selected.
    I use the closest whatever point normal on the source object, and not the closest vertex normal anymore, which gives as expected a much better result. It's fast and compatible with mesh and poly.
    Yes edit normals is a massive pain.
    I'll ran some more tests before releasing on scriptspot but i'm fairly happy, so posting a pic !
    Happy new year !


  • cptSwing
    Offline / Send Message
    cptSwing polycounter lvl 11
    Wow, I r excite!
  • Noors
  • cptSwing
    Offline / Send Message
    cptSwing polycounter lvl 11
    Late feedback, sorry: It works really well. No more crashes, using a Mesh Select modifier in conjunction with the script is a breeze.. thanks Noors!
  • Noors
    Offline / Send Message
    Noors greentooth
    Thanks. I know i have a bug when projecting a second time on a different set of faces.
    I'll try to fix this over the week-end.
  • gnoop
    Offline / Send Message
    gnoop polycounter
    Would love to see same thing for Blender.   Maybe as a paid addon on Blender market.
      Blenders native Data Transfer modifier could do same but kind of less reliably with normals sometimes split  and not exactly same direction as in  source object. 
    It's one rare thing I had to switch back to Max sometimes
  • Noors
    Offline / Send Message
    Noors greentooth
    To my knowledge there weren't tool doing this properly in Max. Except VertexNormalToolkit but it's very new, and while it has good ideas, it feels lil clunky and it does stuff i'm not sure to like (like collapsing the stack).

    I've updated the script to 1.1.1 with a small bug fix when source objects have transformations (which was in fact the cause of my earlier post bug)

    One thing i didn't address tho, is that i don't split normals per vertex during projection. If you need several normals per vertex (for instance on my picture above, verts between the sphere surface and the cylinders surfaces) you have to use 2 different smoothing groups on your object. (Could be a modifier.)
    If you use only 1 smoothing goup on base object, even with 2 projections on adjacent faces, you'll get only 1 normal per vert.
    Hope i'm making sense...
    I'll add normal split eventually, but atleast there is a workaround.
  • Michael Knubben
    gnoop said:
    Would love to see same thing for Blender.   Maybe as a paid addon on Blender market.
      Blenders native Data Transfer modifier could do same but kind of less reliably with normals sometimes split  and not exactly same direction as in  source object. 
    It's one rare thing I had to switch back to Max sometimes
    if it doesn't work well, you should really let the devs know! Ideally with some examples to prove your point.
  • gnoop
    Offline / Send Message
    gnoop polycounter
    gnoop said:
    Would love to see same thing for Blender.   Maybe as a paid addon on Blender market.
      Blenders native Data Transfer modifier could do same but kind of less reliably with normals sometimes split  and not exactly same direction as in  source object. 
    It's one rare thing I had to switch back to Max sometimes
    if it doesn't work well, you should really let the devs know! Ideally with some examples to prove your point.
    Sorry for the misinformation. Looks like it works just fine in current version of Blender. I couldn't recreate the issues I had before anymore. 
Sign In or Register to comment.