Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® MotionBuilder® / Python / namespaces, model selection, inconsistencies: it's driving me crazy
  RSS 2.0 ATOM  

namespaces, model selection, inconsistencies: it's driving me crazy
Rate this thread
 
22706
 
Permlink of this thread  
avatar
  • steebu
  • Posted: 12 February 2009 08:50 PM
  • Total Posts: 44
  • Joined: 09 January 2007 01:40 PM

So I’m trying to build a script that does some smart, automatic plotting.  Here’s the setup:

- there is a setup file that can contain anywhere from 1-6 characters (using custom char->char solve, not actor->char solver)
- .c3d data is imported into the setup file, so you could potentially have 1-150 takes
- we need to plot TR on various bones and only R on others.  The bones all have the same name and are differentiated with namespaces

So algorithmically it’s not that difficult to put together, but I’m having problems with the “smart” portion of the script (how ironic):

Since I’m trying to make a generic script that can run on any setup file, it doesn’t make sense to plot data on a bone that doesn’t need it

For example, since we’re using namespaces to separate out the various characters, you could have ply1:root, ply2:root, ply3:root, etc.  The thing is, we don’t know how many characters are in a setup file.  What’s worse, there is no consistency between the # of characters and the “namespace number”.  Thus, we could have 4 guys in the scene and they could be named “ply1:root, ply2:root, ply5:root, ply19:root”.

The “smart” portion of the script would check to see if the root node has a global translation value that changes over time; if it does, the character has data that needs to get plotted.  If not, there’s no mocap data driving the character so we don’t need to plot him. 

I can’t seem to iterate over items that start with “ply” (the namespace name), so I’m not sure how I can go about this.  Meaning, how can I find all the ply*:root in the scene?  Ideally, I’d want to do something like:

for every matching item named ply*:root:
if you have data
plot it

Any suggestions?



Replies: 0
avatar

I assume these characters have been characterized ?

If so you could iterate through the character objects in the scene, checking along the way to see if the character object has an active input type of another character object.

Might be easier than worrying about namespace formatting

If you want to organize the plotting you can always use groups.  Bones with rotation only in one group and bones that will need plotting to trans and rots in another.  I usually just give the groups the same prefix as my character if I am going to process multiple characters.

Brett



Replies: 0
avatar
  • steebu
  • Posted: 13 February 2009 12:56 PM

Hi Brett,

Brett Ineson 13 February 2009 12:50 AM

I assume these characters have been characterized ?

No, I incorrectly stated that we’re doing a char->char solve.  We are not using the built-in char->char solver, either.  We are using a completely done-from-scratch, constraints-based solver.

Brett Ineson 13 February 2009 12:50 AM

If you want to organize the plotting you can always use groups.  Bones with rotation only in one group and bones that will need plotting to trans and rots in another.  I usually just give the groups the same prefix as my character if I am going to process multiple characters.

The problem with the groups is that they are set up by someone else and again, may not share any consistency with the namespace.  Thus, you could have skeletons for ply1:root, ply2:root, ply4:root, ply17:root, but the groups associated with them are the actor initials, thus, DM, AC, BR, JJ.  How do you make the association between the group name and the actual skeletons without traversing thru the group to find it?  I’ve requested that if there’s a skeleton ply1:root (they have to be named plyx:<bonename>), the group associated with that bone hierarchy should be something like JJ:ply1, but that can’t be guaranteed.  Basically, I have to write a bunch of CYA type stuff for bad setups.  :-)

As an aside, how can you plot only rotations on bones that only need rotations?  I’ve found that the PlotTakeOnSelected and PlotAllTakesOnSelected functions will plot T and R, even if you set the plot options to only plot on the root.  The only other way is to manually iterate, frame-by-frame, and plot an R on a bone that only needs R, and that takes like 2 minutes per skeleton (vs. 5 seconds to plot the whole everything).  What I’ve done is plotted TR on everything, then remove T keys on the bones that only get R keys.



Replies: 0
avatar

oh ok ... try this to find all your Root nodes with namespace ply*

from pyfbsdk import *
      
for 
lComp in FBSystem().Scene.Components


    if 
lComp != None and lComp.Is(FBModel_TypeInfo()):
                       
            
lname lComp.LongName 
            
if lname.startswith('ply') and lname.endswith(':Root'):
                  
                
# put your plot instructions here
                
print 'plotting %s' % (lname)

Brett



Replies: 0
avatar
  • hansen.ck
  • Posted: 25 February 2009 06:07 PM

I pretty much made a class for the skeleton that i tokenized the name and seperated out the namespace, in that class i also gathered all data i wanted about the skeleton such as: children, constraints, prefixes, characters and so on.  that way when i needed anything all i had to do was use skeleton.namespace to get the namespace or skeleton.child to get any of the children of my root joint.  I used this to plot constraints from a mo-capped skeleton of a horse onto our in-game skeleton of a horse.



Replies: 0