def initAvatars(initFlag=vizconnect.INIT_INDEPENDENT, initList=None): #VC: place any general initialization code here rawAvatar = vizconnect.getRawAvatarDict() #VC: initialize a new avatar _name = 'head_and_hand' if vizconnect.isPendingInit('avatar', _name, initFlag, initList): #VC: init the raw object if initFlag & vizconnect.INIT_RAW: #VC: set some parameters # rightHandFilename = 'glove.cfg' rightHandFilename = '' leftHandFilename = '' #VC: create the raw object # base avatar avatar = viz.addGroup() avatar._bodyPartDict = {} avatar._handModelDict = {} # head head = viz.addGroup() head.setParent(avatar) avatar._bodyPartDict[vizconnect.AVATAR_HEAD] = head # left hand if leftHandFilename: leftHand = avatar.add(leftHandFilename) avatar.leftHandFilename = leftHandFilename else: leftHand = viz.addGroup() avatar.leftHandFilename = None leftHand.setParent(avatar) avatar._bodyPartDict[vizconnect.AVATAR_L_HAND] = leftHand # right hand if rightHandFilename: rightHand = avatar.add(rightHandFilename) avatar.rightHandFilename = rightHandFilename else: rightHand = viz.addGroup() avatar.rightHandFilename = None rightHand.setParent(avatar) avatar._bodyPartDict[vizconnect.AVATAR_R_HAND] = rightHand # done rawAvatar[_name] = avatar #VC: init the wrapper (DO NOT EDIT) if initFlag & vizconnect.INIT_WRAPPERS: vizconnect.addAvatar(rawAvatar[_name], _name, make='Generic', model='Head and Hand') #VC: init the gestures if initFlag & vizconnect.INIT_GESTURES: #VC: need to get the raw input dict so we have access to signals import vizact rawInput = vizconnect.getConfiguration().getRawDict('input') #VC: gestures for the avatar's r_hand import hand # remove the old hand rightHand = rawAvatar[_name]._bodyPartDict[ vizconnect.AVATAR_R_HAND] if rightHand: rightHand.remove() # add a new hand def initHand(): sensor = hand.InputSensor() rawAvatar[_name].handSensor = sensor sensor.createHandRenderer = lambda *args, **kw: hand._InputDeviceRenderer( *args, **kw) def appliedGetData(): #VC: set the mappings for the gestures if rawInput['flystick'].isButtonDown( 0 ): # make=ART, model=Flystick, name=flystick, signal=Button 0 return (hand.GESTURE_FIST, False, False ) # GESTURE_FIST #VC: end gesture mappings return (hand.GESTURE_FLAT_HAND, False, False) sensor.getData = appliedGetData file = None if hasattr(rawAvatar[_name], "rightHandFilename"): file = rawAvatar[_name].rightHandFilename return hand.HandModel(left=False, type=hand.GLOVE_5DT, file=file, sensor=sensor) rightHand = initHand() rightHand.setParent(rawAvatar[_name]) rawAvatar[_name]._bodyPartDict[ vizconnect.AVATAR_R_HAND] = rightHand rawAvatar[_name]._handModelDict[ vizconnect.AVATAR_R_HAND] = rightHand #VC: gestures may change the raw avatar, so refresh the raw in the wrapper vizconnect.getAvatar(_name).setRaw(rawAvatar[_name]) #VC: init the animator if initFlag & vizconnect.INIT_ANIMATOR: # need to get the raw tracker dict for animating the avatars from vizconnect.util.avatar import animator from vizconnect.util.avatar import skeleton # get the skeleton from the avatar _skeleton = skeleton.Disembodied(rawAvatar[_name]) #VC: set which trackers animate which body part # format is: bone: (tracker, parent, degrees of freedom used) _trackerAssignmentDict = { vizconnect.AVATAR_HEAD: (vizconnect.getTracker('dtrack_head').getNode3d(), None, vizconnect.DOF_6DOF), vizconnect.AVATAR_R_HAND: (vizconnect.getTracker('dtrack_flystick').getNode3d(), None, vizconnect.DOF_6DOF), } #VC: create the raw object _rawAnimator = animator.Disembodied(rawAvatar[_name], _skeleton, _trackerAssignmentDict) #VC: set animator in wrapper (DO NOT EDIT) vizconnect.getAvatar(_name).setAnimator(_rawAnimator, make='Virtual', model='Disembodied') #VC: set the parent of the node if initFlag & vizconnect.INIT_PARENTS: vizconnect.getAvatar(_name).setParent( vizconnect.getGroup('cave_manual_configuration')) #VC: set the name of the default vizconnect.setDefault('avatar', 'head_and_hand') #VC: return values can be modified here return None
def initAvatars(initFlag=vizconnect.INIT_INDEPENDENT, initList=None): #VC: place any general initialization code here rawAvatar = vizconnect.getRawAvatarDict() #VC: initialize a new avatar _name = 'head_and_hand' if vizconnect.isPendingInit('avatar', _name, initFlag, initList): #VC: init the raw object if initFlag&vizconnect.INIT_RAW: #VC: set some parameters rightHandFilename = 'glove.cfg' leftHandFilename = '' #VC: create the raw object # base avatar avatar = viz.addGroup() avatar._bodyPartDict = {} avatar._handModelDict = {} # head head = viz.addGroup() head.setParent(avatar) avatar._bodyPartDict[vizconnect.AVATAR_HEAD] = head # left hand if leftHandFilename: leftHand = avatar.add(leftHandFilename) avatar.leftHandFilename = leftHandFilename else: leftHand = viz.addGroup() avatar.leftHandFilename = None leftHand.setParent(avatar) avatar._bodyPartDict[vizconnect.AVATAR_L_HAND] = leftHand # right hand if rightHandFilename: rightHand = avatar.add(rightHandFilename) avatar.rightHandFilename = rightHandFilename else: rightHand = viz.addGroup() avatar.rightHandFilename = None rightHand.setParent(avatar) avatar._bodyPartDict[vizconnect.AVATAR_R_HAND] = rightHand # done rawAvatar[_name] = avatar #VC: init the wrapper (DO NOT EDIT) if initFlag&vizconnect.INIT_WRAPPERS: vizconnect.addAvatar(rawAvatar[_name], _name, make='Generic', model='Head and Hand') #VC: init the animator if initFlag&vizconnect.INIT_ANIMATOR: # need to get the raw tracker dict for animating the avatars from vizconnect.util.avatar import animator from vizconnect.util.avatar import skeleton # get the skeleton from the avatar _skeleton = skeleton.Disembodied(rawAvatar[_name]) #VC: set which trackers animate which body part # format is: bone: (tracker, parent, degrees of freedom used) _trackerAssignmentDict = { vizconnect.AVATAR_HEAD:(vizconnect.getTracker('headtracker').getNode3d(), None, vizconnect.DOF_6DOF), vizconnect.AVATAR_R_HAND:(vizconnect.getTracker('wandtracker').getNode3d(), None, vizconnect.DOF_6DOF), } #VC: create the raw object _rawAnimator = animator.Disembodied(rawAvatar[_name], _skeleton, _trackerAssignmentDict) #VC: set animator in wrapper (DO NOT EDIT) vizconnect.getAvatar(_name).setAnimator(_rawAnimator, make='Virtual', model='Disembodied') #VC: set the parent of the node if initFlag&vizconnect.INIT_PARENTS: vizconnect.getAvatar(_name).setParent(vizconnect.getGroup('cave_manual_configuration')) #VC: return values can be modified here return None