Forum: Poser Technical


Subject: Antonia Technical

odf opened this issue on Aug 20, 2009 · 49 posts


odf posted Sun, 30 August 2009 at 3:53 AM

The script for moving actors together with their descendants is only slightly longer. The following is what I did to adjust the rigging after changing the default upper arm length on Antonia:

#!/usr/bin/env
python<br></br><br></br>
import sys<br></br>
from poserFile import PoserFile<br></br><br></br>
def shiftPoint(node, v):<br></br>
    for i in range(1, len(node.fields)):<br></br>
        node.fields[i] =
str(float(node.fields[i]) + v[i-1])<br></br><br></br>
def shiftChannel(node, v):<br></br>
    inSpheres = False<br></br>
    for child in node.children:<br></br>
        if child.firstField ==
'center':<br></br>
           
shiftPoint(child, v)<br></br>
        elif child.firstField ==
'sphereMatsRaw':<br></br>
           
inSpheres = True<br></br>
        elif inSpheres:<br></br>
           
try:<br></br>
               
w = map(float, child.fields)<br></br>
           
except ValueError:<br></br>
               
inSpheres = False<br></br>
           
else:<br></br>
               
if w and w[-1] == 1:<br></br>
                   
for i in range(len(v)):<br></br>
                       
child.fields[i] = str(float(w[i]) + v[i])<br></br><br></br>
def shiftActor(actor, v):<br></br>
    parent = actor.parent<br></br>
    for channels in
actor.content.select('channels'):<br></br>
        for channel in
channels.children:<br></br>
           
if channel.get('otherActor') == parent.name:<br></br>
               
shiftChannel(channel, v)<br></br>
    for channels in
parent.content.select('channels'):<br></br>
        for channel in
channels.children:<br></br>
           
if channel.get('otherActor') == actor.name:<br></br>
               
shiftChannel(channel, v)<br></br>
    for node in actor.content.select('origin'):<br></br>
        shiftPoint(node, v)<br></br>
    for node in
actor.content.select('endPoint'):<br></br>
        shiftPoint(node, v)<br></br><br></br>
def shiftActorAndDescendants(actor, v):<br></br>
    for node in actor.subtree:<br></br>
        shiftActor(node, v)<br></br><br></br><br></br>
if __name__ == "__main__":<br></br>
    tree = PoserFile(file(sys.argv[1]))<br></br><br></br>
   
shiftActorAndDescendants(tree.actor('rForeArm:1'),<br></br>
                            
[-0.013467, -0.001708, 0.000797])<br></br>
   
shiftActorAndDescendants(tree.actor('lForeArm:1'),<br></br>
                            
[0.013467, -0.001708, 0.000797])<br></br><br></br>
    tree.writeTo(file(sys.argv[2],
'w'))<br></br>

-- I'm not mad at you, just Westphalian.