def init(self): #load the agent and parent it to the world #The joints of this agent will reference Panda NodePaths, it will be possible to play animations on it self.animationAgent = Actor(self.modelFileName, self.animationFileNames) self.agent = Actor(self.modelFileName, self.morphTargetsFileName) self.targets = { #'Basis':[], 'ExpSmileClosed': [], 'ExpAnger': [], 'ExpDisgust': [], 'ExpFear': [], 'ExpSad': [], 'ExpSurprise': [], 'ExpSmileOpen': [], 'ModBlinkLeft': [], 'ModBlinkRight': [], 'ModBrowDownLeft': [], 'ModBrowDownRight': [], 'ModBlinkRight': [], 'ModBrowInRight': [], 'ModBrowInLeft': [], 'ModBrowUpLeft': [], 'ModBrowUpRight': [], 'ModEarsOut': [], 'ModEyeSquintLeft': [], 'ModEyeSquintRight': [], 'ModLookDown': [], 'ModLookLeft': [], 'ModLookRight': [], 'ModLookUp': [], 'ModBlinkLeft': [], 'Phonaah': [], 'PhonB,M,P': [], 'Phonbigaah': [], 'Phonch,J,sh': [], 'PhonD,S,T': [], 'Phonee': [], 'Phoneh': [], 'PhonF,V': [], 'Phoni': [], 'PhonK': [], 'PhonN': [], 'Phonoh': [], 'Phonooh,Q': [], 'PhonR': [], 'Phonth': [], 'PhonW': [] } iter = self.targets.iteritems() while True: try: morphsItem = iter.next() except StopIteration: break for i in range(2, 7): #print (str(i)+'_'+morphsItem[0]) blendShape = self.agent.controlJoint( None, 'modelRoot', str(i) + '_' + morphsItem[0]) if (blendShape): morphsItem[1].append(blendShape) self.targets['inspire'] = [ self.agent.controlJoint(None, 'modelRoot', 'inspire') ] #instanciate a list in order to keep track of kinematic joints joints #in python runtime #if nothing points towards those joints, they get flushed by #python's garbage collector self.jointList = [] self.jointFKList = [] self.agentControlJoints = [] self.agentNodePaths = [] self.agentSMRSkel = SMRPy.SMRSkeleton(True, True, 'agent') self.createSkel(self.agent, self.agentSMRSkel, 'root', '') #SMRPy.exportSkeletonToBvh('exportedPose.bvh',self.agentSMRSkel); self.newSkeleton = SMRPy.SMRSkeleton(True, True, 'pose') self.createFKSkel(self.animationAgent, self.newSkeleton, "root", '') self.realizer.addCharacter(self.name, self.agentSMRSkel) for key in self.targets.keys(): self.realizer.addMorphTarget(self.name, key) self.realizer.addShaderParameter(self.name, 'blushing') self.addAnimation(self.name, 'breathing') self.addAnimation(self.name, 'hands_claw') self.addAnimation(self.name, 'hands_fist') self.addAnimation(self.name, 'hands_index') self.addAnimation(self.name, 'hands_open-relaxed') self.addAnimation(self.name, 'hands_open-spread') self.addAnimation(self.name, 'hands_open-straight') self.addAnimation(self.name, 'hands_purse') self.addAnimation(self.name, 'hands_ring') self.addAnimation(self.name, 'poseNeutral') #self.addAnimation(self.name,'endian') if 'default' in self.animationFileNames: self.addAnimation(self.name, 'default') #self.realizer.addCharacterSkeleton( self.name, ); self.agent.reparentTo(render) self.agent.hide(BitMask32.bit(self.cameraMask)) #set lighting ambientColor = Vec4(0.0, 0.0, 0.0, 0.0) self.lighting = shaders.Lighting(ambientColor, self.agent) if self.loadLightingFromConfig == 1: self.lighting.loadFromConfig(self.lightingConfig, self.lightingConfigName) #shadow map if self.createShadowMap == 1: self.shadowMap = shadowmap.ShadowMap(self.shadowMapIndex, self.dataPath)
def __init__(self): #This code puts the standard title and instuction text on screen self.title = OnscreenText(text="", style=1, fg=(1, 1, 1, 1), pos=(0.8, -0.95), scale=.07) #setup key input self.accept('escape', sys.exit) self.agent = Actor( 'models/amber/amber.bam', {"morph": "models/amber/animations/amber-morphTargets.bam"}) self.agent2 = Actor( 'models/amber/amber.bam', {"morph": "models/amber/animations/amber-morphTargets.bam"}) self.agent.reparentTo(render) self.agent.setPos(7, 0, 0) self.agent.setScale(10) self.agent2.reparentTo(render) self.agent2.setPos(-7, 0, 0) self.agent2.setScale(10) self.agent2.hide(BitMask32.bit(1)) #self.agent2.setHpr(100,90,60) #self.agent.setAntialias(AntialiasAttrib.MMultisample, AntialiasAttrib.MBetter) ambientColor = Vec4(1.0, 1.0, 1.0, 1.0) #lighting 1 self.lighting = shaders.Lighting(ambientColor) self.lighting.directionalLights[2].color = Vec4(1, 0, 0, 0) #lighting 2 self.lighting2 = shaders.Lighting(ambientColor) self.lighting2.directionalLights[2].color = Vec4(1, 1, 1, 0) #set up shaders for amber model self.amberModel = shaders.AmberModel(self.agent, self.lighting) self.amberModel2 = shaders.AmberModel(self.agent2, self.lighting2) self.time = 0 self.amberModel.update() self.amberModel2.update() #load lamp self.addLamps() #materials[1].setDiffuse( Vec4(1,0,0,0) ) #self.lamp.setMaterial( materials[0] ) #self.lamp.setMaterial( materials[1] ) #print self.lamp.findAllMaterials() taskMgr.doMethodLater(0.02, self.refreshSkels, "refreshSkels") base.disableMouse() #Disable mouse-based camera-control base.camera.setPos(0, -100, 0) #Position the camera base.camera.setHpr(0, 0, 0) base.camLens.setFilmSize(24, 36) # 35 mm film base.camLens.setFocalLength(70) # 70 mm focalLength #base.camera.node().setCameraMask(BitMask32.bit(0)) #base.oobe() #base.useDrive() base.useTrackball() base.setFrameRateMeter(True) base.setBackgroundColor(0, 0, 0) base.disableAllAudio() #self.initShadowMapping() self.shadowMap = shadowmap.ShadowMap() self.addGUI()