Exemple #1
0
def initAvatars(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawAvatar = vizconnect.getRawAvatarDict()

    #VC: initialize a new avatar
    _name = 'male_2'
    if vizconnect.isPendingInit('avatar', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: create the raw object
            avatar = viz.add('vcc_male2.cfg')
            avatar._bodyPartDict = {}
            avatar._handModelDict = {}
            rawAvatar[_name] = avatar

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addAvatar(rawAvatar[_name],
                                 _name,
                                 make='Complete Characters',
                                 model='Male 2')

        #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.CompleteCharactersHD(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(
                    'mouse_and_keyboard_walking').getNode3d(), None,
                                         vizconnect.DOF_6DOF),
                vizconnect.AVATAR_R_HAND:
                (vizconnect.getTracker('mouse_scroll_wheel').getNode3d(),
                 vizconnect.AVATAR_HEAD, vizconnect.DOF_POS),
            }

            #VC: create the raw object
            _rawAnimator = animator.InverseKinematics(rawAvatar[_name],
                                                      _skeleton,
                                                      _trackerAssignmentDict)

            #VC: set animator in wrapper (DO NOT EDIT)
            vizconnect.getAvatar(_name).setAnimator(_rawAnimator,
                                                    make='WorldViz',
                                                    model='Inverse Kinematics')

    #VC: return values can be modified here
    return None
Exemple #2
0
def initAvatars(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawAvatar = vizconnect.getRawAvatarDict()

	#VC: initialize a new avatar
	_name = 'main_avatar'
	if vizconnect.isPendingInit('avatar', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: set some parameters
			head = False
			rightHand = True
			leftHand = False
			torso = False
			lowerBody = False
			rightArm = False
			leftArm = False
			
			#VC: create the raw object
			# base avatar
			import vizfx
			avatar = vizfx.addChild('mark.cfg')
			avatar.disable(viz.LIGHTING)
			avatar._bodyPartDict = {}
			avatar._handModelDict = {}
			avatar.visible(head, r'mark_head.cmf')
			avatar.visible(rightHand, r'mark_hand_r.cmf')
			avatar.visible(leftHand, r'mark_hand_l.cmf')
			avatar.visible(torso, r'mark_torso.cmf')
			avatar.visible(lowerBody, r'mark_legs.cmf')
			avatar.visible(rightArm, r'mark_arm_r.cmf')
			avatar.visible(leftArm, r'mark_arm_l.cmf')
			rawAvatar[_name] = avatar
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addAvatar(rawAvatar[_name], _name, make='WorldViz', model='Mark')
	
		#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
			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['r_hand_input'].getState()&viz.MOUSEBUTTON_LEFT:# make=Generic, model=Mouse Buttons, name=r_hand_input, signal=Left Mouse Button
						return (hand.GESTURE_FIST, False, False)# GESTURE_FIST
					#VC: end gesture mappings
					return (hand.GESTURE_FLAT_HAND,False,False)
				sensor.getData = appliedGetData
				return hand.AvatarHandModel(rawAvatar[_name], left=False, type=hand.GLOVE_5DT, sensor=sensor)
			rightHand = initHand()
			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.CompleteCharactersHD(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('head_tracker').getNode3d(), None, vizconnect.DOF_6DOF),
				vizconnect.AVATAR_R_HAND:(vizconnect.getTracker('r_hand_tracker').getNode3d(), vizconnect.AVATAR_HEAD, vizconnect.DOF_POS),
			}
			
			#VC: create the raw object
			_rawAnimator = animator.Direct(rawAvatar[_name], _skeleton, _trackerAssignmentDict)
			
			#VC: set animator in wrapper (DO NOT EDIT)
			vizconnect.getAvatar(_name).setAnimator(_rawAnimator, make='Virtual', model='Direct')
	
		#VC: set the parent of the node
		if initFlag&vizconnect.INIT_PARENTS:
			vizconnect.getAvatar(_name).setParent(vizconnect.getTransport('main_transport'))

	#VC: set the name of the default
	vizconnect.setDefault('avatar', 'main_avatar')

	#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 = 'main_avatar'
    if vizconnect.isPendingInit('avatar', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set some parameters
            head = False
            rightHand = False
            leftHand = False
            torso = False
            lowerBody = False
            rightArm = False
            leftArm = False

            #VC: create the raw object
            # base avatar
            import vizfx
            avatar = vizfx.addChild('mark.cfg')
            avatar._bodyPartDict = {}
            avatar._handModelDict = {}
            avatar.visible(head, r'mark_head.cmf')
            avatar.visible(rightHand, r'mark_hand_r.cmf')
            avatar.visible(leftHand, r'mark_hand_l.cmf')
            avatar.visible(torso, r'mark_torso.cmf')
            avatar.visible(lowerBody, r'mark_legs.cmf')
            avatar.visible(rightArm, r'mark_arm_r.cmf')
            avatar.visible(leftArm, r'mark_arm_l.cmf')
            rawAvatar[_name] = avatar

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addAvatar(rawAvatar[_name],
                                 _name,
                                 make='WorldViz',
                                 model='Mark')

        #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.CompleteCharactersHD(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('head_tracker').getNode3d(), None,
                 vizconnect.DOF_POS),
                vizconnect.AVATAR_R_HAND:
                (vizconnect.getTracker('r_hand_tracker').getNode3d(), None,
                 vizconnect.DOF_POS),
            }

            #VC: create the raw object
            _rawAnimator = animator.Direct(rawAvatar[_name], _skeleton,
                                           _trackerAssignmentDict)

            #VC: set animator in wrapper (DO NOT EDIT)
            vizconnect.getAvatar(_name).setAnimator(_rawAnimator,
                                                    make='Virtual',
                                                    model='Direct')

        #VC: set the parent of the node
        if initFlag & vizconnect.INIT_PARENTS:
            vizconnect.getAvatar(_name).setParent(
                vizconnect.getGroup('main_display'))

    #VC: set the name of the default
    vizconnect.setDefault('avatar', 'main_avatar')

    #VC: return values can be modified here
    return None