from pyfbsdk import *
lBonesName = ( 'LeftForeArm', 'RightForeArm', 'LeftLeg', 'RightLeg' )
lAffectedCharacterList = []
lSystem = FBSystem()
lScene = lSystem.Scene
def SetGameModeOnSelectedCharacters(pCharacter, pState = True):
print 'Setting game mode for character \'%s\'' % pCharacter.Name
lBones = []
global lBonesName
for lBoneName in lBonesName:
lBone = FBFindModelByName( '%s:%s' % ( pCharacter.Name, lBoneName ))
if lBone: lBones.append( lBone )
if len( lBonesName ) == len( lBones ):
for lBone in lBones:
lBone.PropertyList.Find( 'RotationActive' ).Data = pState
lBone.PropertyList.Find( 'RotationMinX' ).Data = pState
lBone.PropertyList.Find( 'RotationMinY' ).Data = pState
lBone.PropertyList.Find( 'RotationMaxX' ).Data = pState
lBone.PropertyList.Find( 'RotationMaxY' ).Data = pState
lAffectedCharacterList.append( lCharacter.Name )
else:
FBMessageBox( 'Warning', 'Unable to set game mode for character \'%s\'' % lCharacter.Name, "Ok" )
for lCharacter in lScene.Characters:
if lCharacter.Selected:
SetGameModeOnSelectedCharacters(lCharacter)
if len( lAffectedCharacterList ) == 0:
if FBApplication().CurrentCharacter !=None:
if FBMessageBox( 'Information', 'Could not set Game Mode. No character is selected. \n Do you want to enable Game Mode on the current Character?', 'Yes', 'No' )==1:
SetGameModeOnSelectedCharacters(FBApplication().CurrentCharacter)
else:
FBMessageBox( 'Information', 'Could not set game mode. No character were selected.', 'Ok' )
else:
FBMessageBox( 'Information', 'Set game mode for characters :%s' % lAffectedCharacterList, 'Ok' )