def LoadMotionGraph(self, e): motions = [] if self.selectedTrack != None: splits = self.tracks[self.selectedTrack].GetSplits() if splits != []: for split in splits: motions.append(split.GetSubMotion()) else: motions.append(self.motion) self.motiongraph = Piavca.MotionGraph(motions) self.motiongraph.loadGraph("motiongraph.txt") # load the Motion Graph into the avatar to play them Piavca.Core.getCore().setCurrentTime(0) self.avatar.playMotionDirect(self.motiongraph) Piavca.Core.getCore().setCurrentTime(self.time)
def MotionGraph(self, e): weights = [] file = open("TrackWeights.txt", "r") for line in file.readlines(): for joint in line.split(): joint = joint.split("=") weight = float(joint[1]) joint = joint[0] jointid = Piavca.Core.getCore().getJointId(joint) print joint, jointid, weight if (not self.motion.isNull(jointid)): weights.append((jointid, float(1.0))) #distancemeasure = MotionGraph.DistanceMeasure(10, weights) print "creating distance measure" distancemeasure = Piavca.DistanceMeasure(weights) #loading motions motions = [] if self.selectedTrack != None: splits = self.tracks[self.selectedTrack].GetSplits() if splits != []: for split in splits: motions.append(split.GetSubMotion()) else: motions.append(self.motion) print "creating graph" self.motiongraph = Piavca.MotionGraph(motions) val = 4.0 #None #dialog = wxTextEntryDialog ( None, message="enter same motion threshold" ) #dialog.SetValue("4") # The user pressed the "OK" button in the dialog #if dialog.ShowModal() == wxID_OK: # print 'Position of selection:', dialog.GetValue() # val = float(dialog.GetValue()) # print val #else: # path = None # print 'You did not select anything.' #dialog.Destroy() if val != None: self.motiongraph.setThresholdSame(val) val = 4.0 #None #dialog = wxTextEntryDialog ( None, message="enter different motion threshold" ) #dialog.SetValue("4") # The user pressed the "OK" button in the dialog #if dialog.ShowModal() == wxID_OK: # print 'Position of selection:', dialog.GetValue() # val = float(dialog.GetValue()) # print val #else: # path = None # print 'You did not select anything.' #dialog.Destroy() if val != None: self.motiongraph.setThresholdDiff(val) #self.motiongraph.constructGraph(distancemeasure, 12, 20, 10) self.motiongraph.setJointWeightsFile("TrackWeights.txt") self.motiongraph.setFPS(10) self.motiongraph.create() # load the Motion Graph into the avatar to play them Piavca.Core.getCore().setCurrentTime(0) self.avatar.playMotionDirect(self.motiongraph) Piavca.Core.getCore().setCurrentTime(self.time)