2011 Software releases
Learn about the 2011 versions of some of Autodesk’s Digital Entertainment Creation tools.
Theme color:
  • 1/1
You are here: Homepage /  Blogs /  Everything in Real Time / Game-Mode Script v2
Game-Mode Script v2
Posted: Jul 13, 2007
Category: Misc
Social Media:
Bookmark and Share
 
I get a lot of long time MotionBuilder users that are unhappy with the removal of the “Game Mode” option for Characters. First off, I have to make sure that everyone understands this was a necessary move, not something we set out to remove. When we added the ability to set Degrees of Freedom (DOF) on objects, the “Game Mode” system was not at all compatible and caused some serious issues for the evaluation engine.

What was “Game Mode”? When this option was enabled on a character, the Z and Y axis of a characters elbows and knees were locked out, giving only X rotation animation, which is typically required for most game engines.
The following script will set the same limits on a character, locking out the Z and Y axis of your characters knees and elbows.

Special thanks to Haga-san! Dude, you kick-ass. Keep the Python scripts coming!

# Autodesk unsupported Python script
# Autoher: Hiroyuki Haga
# Last Update : 2007/ 6/ 18
#
# Usage : Select characterized characters which you want to limit joints, and execute this script.
#

from pyfbsdk import *

#----------------------------------------------------------------------
# A function to make the bone game mode
def SetDOF ( bone ):
bone.PropertyList.Find( 'RotationActive' ).Data = True
bone.PropertyList.Find( 'RotationMinX' ).Data = True
bone.PropertyList.Find( 'RotationMinY' ).Data = True
bone.PropertyList.Find( 'RotationMaxX' ).Data = True
bone.PropertyList.Find( 'RotationMaxY' ).Data = True


#----------------------------------------------------------------------
# List of characters that we have handled.
lAffectedCharacterList = []

# Needed to get to the list of characters in the scene.
lSystem = FBSystem()
lScene = lSystem.Scene

# Look at all the characters in the scene.
for lCharacter in lScene.Characters:

# And located those that are selected.
if lCharacter.Selected:

L_ElbowModel = lCharacter.GetModel( FBBodyNodeId.kFBLeftElbowNodeId )
R_ElbowModel = lCharacter.GetModel( FBBodyNodeId.kFBRightElbowNodeId )
L_KneeModel = lCharacter.GetModel( FBBodyNodeId.kFBLeftKneeNodeId )
R_KneeModel = lCharacter.GetModel( FBBodyNodeId.kFBRightKneeNodeId )

SetDOF( L_ElbowModel )
SetDOF( R_ElbowModel )
SetDOF( L_KneeModel )
SetDOF( R_KneeModel )

lAffectedCharacterList.append( lCharacter.Name )

#----------------------------------------------------------------------
if len( lAffectedCharacterList ) == 0:
FBMessageBox( 'Information', 'Could not set game mode. No character were selected', 'Ok' )
else:
FBMessageBox( 'Information', 'Set game mode for characters :%s' % lAffectedCharacterList, 'Ok' )

------[End of Script]----


And don't forget to sign up for the MotionBuilder MasterClasses at Siggraph this year!

Sign up here!


Cheers,

Curtis Garton
In order to post any comments, you must be logged in!