i was sort of right :)
quick port of the ppg logic ->
[code]
#port of reset pivot button code
vec = XSIMath.CreateVector3()
xfmPC = XSIMath.CreateTransform()
xfmL = XSIMath.CreateTransform()
xfmN = XSIMath.CreateTransform()
matN = XSIMath.CreateMatrix4()

params = []
values = []

def resetPivot(kineObj):

    # neutral pose
    v = setVec(kineObj, 'nscl')
    xfmN.SetScaling(v)

    v =  setVec(kineObj, 'nrot', True)
    xfmN.SetRotationFromXYZAngles(v)

    v =  setVec(kineObj, 'npos')
    xfmN.SetTranslation(v)

    v =  setVec(kineObj, 'scl')
    xfmL.SetScaling(v)

    v =  setVec(kineObj, 'rot', True)
    xfmL.SetRotationFromXYZAngles(v)

    v =  setVec(kineObj, 'pos')
    xfmL.SetTranslation(v)

    xfmN.GetMatrix4(matN)
    matN.InvertInPlace()
    xfmN.SetMatrix4(matN)
    xfmL.Mul( kineObj.Transform, xfmN )

    params.append( str(kineObj) + '.sclx' )
    params.append( str(kineObj) + '.scly' )
    params.append( str(kineObj) + '.sclz' )

    params.append( str(kineObj) + '.rotx' )
    params.append( str(kineObj) + '.roty' )
    params.append( str(kineObj) + '.rotz' )

    params.append( str(kineObj) + '.posx' )
    params.append( str(kineObj) + '.posy' )
    params.append( str(kineObj) + '.posz' )

    xfmL.GetScaling(vec) # comp scaling vec
    values.append(vec.X)
    values.append(vec.Y)
    values.append(vec.Z)

    xfmL.GetRotationXYZAngles(vec) # comp rotation vec
    vec.ScaleInPlace( XSIMath.RadiansToDegrees(1) )
    values.append(vec.X)
    values.append(vec.Y)
    values.append(vec.Z)

    xfmL.GetTranslation(vec) # comp trans
    values.append(vec.X)
    values.append(vec.Y)
    values.append(vec.Z)

    params.append( str(kineObj) + '.psclx' )
    params.append( str(kineObj) + '.pscly' )
    params.append( str(kineObj) + '.psclz' )

    params.append( str(kineObj) + '.protx' )
    params.append( str(kineObj) + '.proty' )
    params.append( str(kineObj) + '.protz' )

    params.append( str(kineObj) + '.pposx' )
    params.append( str(kineObj) + '.pposy' )
    params.append( str(kineObj) + '.pposz' )

    params.append( str(kineObj) + '.pcsclx' )
    params.append( str(kineObj) + '.pcscly' )
    params.append( str(kineObj) + '.pcsclz' )

    params.append( str(kineObj) + '.pcrotx' )
    params.append( str(kineObj) + '.pcroty' )
    params.append( str(kineObj) + '.pcrotz' )

    params.append( str(kineObj) + '.pcposx' )
    params.append( str(kineObj) + '.pcposy' )
    params.append( str(kineObj) + '.pcposz' )

    #nope
    for p in range(2):
        for s in range(3):
            values.append(1.0)
        for pr in range(6):
            values.append(0.0)


#__repr__
def formatVector(v):
    return ' [{0}, {1}, {2}] '.format(v.X, v.Y, v.Z)

# needs &vec
def setVec(kineObj, prefix, d2r=False):
    _xn = prefix + 'x'
    _yn = prefix + 'y'
    _zn = prefix + 'z'
    _x = kineObj.Parameters(_xn).Value
    _y = kineObj.Parameters(_yn).Value
    _z = kineObj.Parameters(_zn).Value
    if d2r:
        _x = XSIMath.DegreesToRadians(_x)
        _y = XSIMath.DegreesToRadians(_y)
        _z = XSIMath.DegreesToRadians(_z)
        vec.Set(_x, _y, _z)
    else:
        vec.Set(_x, _y, _z)

    return vec # copy


##-------------------------main
for i,each in enumerate(Application.Selection):
    #print 'resetting pivot for object: {0} - {1}'.format(i, each.name)
    resetPivot(each.Kinematics.Local)

Application.SetValue(params, values)
[/code]




On 12 October 2013 07:13, Jon Swindells <[email protected]> wrote:

>
>
> If i recall correctly, you need to invMul your pivot against the neutral
> pose so it's compensated then zero out the pivot params
>
> memory is a fickle thing though so i could be way off. :)
>
>
> On 12 October 2013 06:37, Matt Lind <[email protected]> wrote:
>
>> Anybody know how the pivot and pivot compensation values are computed for
>> an object?****
>>
>> ** **
>>
>> I’m trying to write a tool to freeze scaling, reset pivot, reset neutral
>> pose, and so on for an entire scene.  I’ve got everything working except
>> resetting the pivot only because I don’t know what the order operations are
>> and whether neutral pose is factored in.****
>>
>> ** **
>>
>> When I click the ‘reset pivot’ button in the object’s Pivot tab in its
>> PPG, it logs as a SetValue() with 27 parameters and associated values.  The
>> last 18 numbers are the values to be assigned for the pivot and pivot
>> compensation respectively (identity), but the first 9 numbers are a
>> mystery.  At first glance they appear to be the object’s local transform as
>> those are the parameter values logged, but upon closer inspection that is
>> not the case because when I apply the same values from code using
>> SetValue(), I get different results.  I’ve also tried applying an inverse
>> transform thinking it would be a local transform from the pivot location to
>> put the object back into the proper global transform, but that isn’t it
>> either.****
>>
>> ** **
>>
>> Anybody?****
>>
>> ** **
>>
>> ** **
>>
>> Thanks,****
>>
>> ** **
>>
>> Matt****
>>
>
>
>
> --
> Jon Swindells
> [email protected]
>



-- 
Jon Swindells
[email protected]

Reply via email to