Home Technical Talk

Query Object position at pivot?

Pola
polycounter lvl 6
Offline / Send Message
Pola polycounter lvl 6
I'm doing a script where I need to get transform values such as translation from an object. I've noticed the pivot can be moved around but that won't update the transforms correctly, If I have a cube say and the pivot is at the center, I duplicate the cube and move the pivot to a corner of the cube and rotate it 90 degrees and translate it along an axis applying the same values won't place the original cube at the duplicated ones position.

I'm figuring the best way to do this is center the pivot, point/orient/scale constrain a locator to the object to snap to its centered pivot, remove the history and get the locators transforms which can then be applied to the original cube to position it the same as the duplicate version.

Is there a better way to do this?

Replies

  • m4dcow
    Options
    Offline / Send Message
    m4dcow interpolator
    If this is in Maya you can query your pivot positions, and then figure out the differences in object transforms vs Scale transforms.

    xform -q -ws -t pCube.scalePivot
    

    Gets the position of the scale Pivot in world space.
  • bk3d
    Options
    Offline / Send Message
    bk3d polycounter lvl 5
    assuming you are using Mel. This will get the world space location of and object
    xform -q -rp -ws $ObjectName;
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    man people are fast haha, had to go back to look some of the flags up.
  • Pola
    Options
    Offline / Send Message
    Pola polycounter lvl 6
    Wow you guys responded alot faster then I expected :D Thanks!

    I forgot to mention that I was using maya and the language was python, I've come up with this long method:
      cmds.xform('pCube6',cp=True) 
      test = cmds.spaceLocator()
      cmds.pointConstraint('pCube6',test)
      cmds.orientConstraint('pCube6',test)
      cmds.scaleConstraint('pCube6',test)
      locatorT = cmds.xform(test,query=True,t=True,worldSpace=True)
      print locatorT
    
    I wasn't able to make complete sense of m4dcows solution (not too experienced with scripting). But bk3d's solution got the same translate values as my method above which is great, applying those values and the duplicateds rotation/scale values seems to work perfectly. Should I be concerned about the scale pivot?

    The aim is to import an asset (which had its pivot centered and exported from being snapped to the origin), then manipulate various copies in maya and through a script get the correct transform values to use in a game engine to build levels through modular pieces. Level iteration through the engines editor is very slow thought this would make more sense.
  • Pola
    Options
    Offline / Send Message
    Pola polycounter lvl 6
    Tested it with writing the string to clipboard for UDK to paste my maya layout and it works perfectly :) Can manipulate the pivot with the cube mesh getting the correct transforms in engine. Sadly we're not able to use UDK for the project :(

    mayatoudk.png
Sign In or Register to comment.