Difference between revisions of "Talk:SFM/Python script commands"

From Valve Developer Community
Jump to: navigation, search
(Working on figuring this stuff out, may merge this into the main section eventually: new section)
 
Line 1: Line 1:
 
Thanks immensely for these commands! The documentation is going to make some tricky rigging shenanigans easier to accomplish. --[[User:Mystfit|Mystfit]] 08:42, 29 July 2012 (PDT)
 
Thanks immensely for these commands! The documentation is going to make some tricky rigging shenanigans easier to accomplish. --[[User:Mystfit|Mystfit]] 08:42, 29 July 2012 (PDT)
 +
 +
== Working on figuring this stuff out, may merge this into the main section eventually ==
 +
 +
So, I'm new to Source modding and animation and everything, and I'm just writing this to try and put my current lessons learned in a single useful place so that at the least, I can go back to it and remember some stuff. FYI, I'm working on a tool to use the Kinect to do facial animation in SFM, so I'm working on using Python to mess with controls and animation curves
 +
 +
 +
Lesson 1: The Element Viewer is your friend. It will give you the names and structure of the model data
 +
 +
Lesson 2: Controls modify the underlying gameModel, and you can get them programatically with
 +
 +
rootGroup = animSet.GetRootControlGroup()
 +
 +
controlNameYouWant = rootGroup.FindControlByName( 'canonical name of control in the hierarchy', True )
 +
 +
Once you have it stored in a variable, you can access all the data (read-only data is a darker grey text in the Element Viewer) with dot notation, like controlNameYouWant.name
 +
 +
Lesson 3: Read the code in sfmUtils.py and the example code, since the API is not completely described by a long shot.
 +
 +
 +
Notes: I'm still having no luck trying to script changes in the slider controls. If I try and change the fromElement values on a control channel, the control slider value seems to override any changes made to that script-set element.  On the other hand, if I make my own control, for whatever reason, the control bar doesn't retain its value once set.
 +
 +
I also don't know the difference between the 'controls' and 'rootControlGroup' sections of the models. Maybe this is where I'm screwing up, or maybe one is just a pointer to the other?

Latest revision as of 04:07, 12 November 2012

Thanks immensely for these commands! The documentation is going to make some tricky rigging shenanigans easier to accomplish. --Mystfit 08:42, 29 July 2012 (PDT)

Working on figuring this stuff out, may merge this into the main section eventually

So, I'm new to Source modding and animation and everything, and I'm just writing this to try and put my current lessons learned in a single useful place so that at the least, I can go back to it and remember some stuff. FYI, I'm working on a tool to use the Kinect to do facial animation in SFM, so I'm working on using Python to mess with controls and animation curves


Lesson 1: The Element Viewer is your friend. It will give you the names and structure of the model data

Lesson 2: Controls modify the underlying gameModel, and you can get them programatically with

rootGroup = animSet.GetRootControlGroup()

controlNameYouWant = rootGroup.FindControlByName( 'canonical name of control in the hierarchy', True )

Once you have it stored in a variable, you can access all the data (read-only data is a darker grey text in the Element Viewer) with dot notation, like controlNameYouWant.name

Lesson 3: Read the code in sfmUtils.py and the example code, since the API is not completely described by a long shot.


Notes: I'm still having no luck trying to script changes in the slider controls. If I try and change the fromElement values on a control channel, the control slider value seems to override any changes made to that script-set element. On the other hand, if I make my own control, for whatever reason, the control bar doesn't retain its value once set.

I also don't know the difference between the 'controls' and 'rootControlGroup' sections of the models. Maybe this is where I'm screwing up, or maybe one is just a pointer to the other?