Home Technical Talk

MaxScript to move pivot to farthest corner of mesh.

polycounter lvl 5
Offline / Send Message
deohboeh polycounter lvl 5
I am working on a game which is tiled based and the mesh needs to snap to the grid. With centre pivot the pivot sometimes moves to the centre of the grid and causes misalignment. I need a script that moves the pivot to the farthest corner of the mesh( all corner verts are on grid for snapping purposes) or the farthest corner of the bounding box.

Any help is much appreciated.

Thanks!

Dev

Replies

  • NuggetOG
    Options
    Offline / Send Message
    Hey Have you tried using the putPivot script that is part of the Soulburn Scripts package?


    http://www.neilblevins.com/cg_tools/soulburnscripts/soulburnscripts.htm

    "
    putPivot

    Places the pivot of the selected objects in one of 27 spots such as center, bottom, top, high left side, etc. You can also align pivot to currently selected vert, edge or face.

    "
  • tadpole3159
    Options
    Offline / Send Message
    tadpole3159 polycounter lvl 12
    I may be confused here but can't you just align pivot to maximum? Click on the move pivot button (can't remember the name, on an iPad) press Alt+A to pick the allign tool and just click on the original mess then choose maximum. Does that work?
  • deohboeh
    Options
    Offline / Send Message
    deohboeh polycounter lvl 5
    Thanks for the help guys! :) It's night time now will post updates tomorrow.
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    Soulburn scirpts is definitely something that you might want to check out, but most of them linked to one another, so sometime you cant simply extract one that you need (if you don't want to install all of the collection)

    What about just using simple script like this?
    (
        xPvt = $.min.x -- can change to: $.min.x / $.max.x / $.center.x depending on needs
        yPvt = $.min.y -- same thing here..
        zPvt = $.min.z -- and here too..
        
        $.pivot = [xPvt, yPvt, zPvt] -- move the pivot
        resetXform $ -- reset xform the object
        collapseStack $ -- collapse modifier stack
    )
    
  • deohboeh
    Options
    Offline / Send Message
    deohboeh polycounter lvl 5
    Revel wrote: »
    Soulburn scirpts is definitely something that you might want to check out, but most of them linked to one another, so sometime you cant simply extract one that you need (if you don't want to install all of the collection)

    What about just using simple script like this?
    (
        xPvt = $.min.x -- can change to: $.min.x / $.max.x / $.center.x depending on needs
        yPvt = $.min.y -- same thing here..
        zPvt = $.min.z -- and here too..
        
        $.pivot = [xPvt, yPvt, zPvt] -- move the pivot
        resetXform $ -- reset xform the object
        collapseStack $ -- collapse modifier stack
    )
    

    Thanks for the advice and the script Revel. Putpivot is doing the job correctly now only problem is the sub object pivot is not in global anymore and is now according to the local normal which is causing me problems. :\

    Any idea what to do?
  • Revel
    Options
    Offline / Send Message
    Revel interpolator
    What do you mean by "not global anymore"? I haven't use soulburn script myself, but from what you mention seems like the script changing the coodsys to local?
  • deohboeh
    Options
    Offline / Send Message
    deohboeh polycounter lvl 5
    Revel wrote: »
    What do you mean by "not global anymore"? I haven't use soulburn script myself, but from what you mention seems like the script changing the coodsys to local?

    Thanks for the script Revel! You the man! Sorry for the late reply. This new city and job are really taking my time. :/ You are right! Every time I use Soulburn's script it changes the reference coordinate system to local.
Sign In or Register to comment.