def test_point2Joint_Motion(): mmFilePath = '../samples/physics2_WalkSameSame01.mm' pointMotion = yf.readMMFile(mmFilePath) frameTime = 1. / 30. pointMotion[0].pointMap['lFoot'][1] -= 0.1 # pointMotion = pointMotion[0:1] jointMotion = point2Joint_Motion(pointMotion, 'root') pointMotion2 = joint2Point_Motion(jointMotion) print 'pointMotion.skeleton', pointMotion[0].skeleton.links print pointMotion[0].pointMap.keys() print 'jointMotion.skeleton', jointMotion[0].skeleton.joints.keys() print 'pointMotion2.skeleton', pointMotion2[0].skeleton.links print pointMotion2[0].pointMap.keys() motionSystem = ym.MotionSystem() motionSystem.addMotion(pointMotion) motionSystem.addMotion(jointMotion) renderers = [] # renderers.append(yr.PointMotionRenderer(pointMotion)) renderers.append(yr.PointMotionRenderer(pointMotion2)) renderers.append( yr.JointMotionRenderer(jointMotion, (0, 255, 0), yr.LINK_LINE)) viewer = yv.Viewer2(100, 100, 800, 650, None, motionSystem, renderers) viewer.startTimer(frameTime) viewer.show() Fl.run()
def test_joint2Point_Motion(): bvhFilePath = '../samples/physics2_WalkSameSame00.bvh' jointMotion, frameTime = yf.readBvhFileAsJointMotion(bvhFilePath, .1) pointMotion = joint2Point_Motion(jointMotion) print 'jointMotion.skeleton', jointMotion[0].skeleton print 'pointMotion.skeleton', pointMotion[0].skeleton print 'jointMotion.skeleton - pointMotion.skeleton', set( jointMotion[0].skeleton.joints.keys( )) - pointMotion[0].skeleton.pointSet print 'pointMotion.skeleton - jointMotion.skeleton', pointMotion[ 0].skeleton.pointSet - set(jointMotion[0].skeleton.joints.keys()) motionSystem = ym.MotionSystem() motionSystem.addMotion(pointMotion) motionSystem.addMotion(jointMotion) renderers = [] renderers.append(yr.PointMotionRenderer(pointMotion)) renderers.append( yr.JointMotionRenderer(jointMotion, (0, 255, 0), yr.LINK_LINE)) viewer = yv.Viewer2(100, 100, 800, 650, None, motionSystem, renderers) viewer.startTimer(frameTime) viewer.show() Fl.run()
def test_joint2Point_Motion(): bvhFilePath = '../samples/physics2_WalkSameSame00.bvh' jointMotion, frameTime = yf.readBvhFileAsJointMotion(bvhFilePath, .1) # bvhFilePath = '../../../Walking/ppmotion/wd2_WalkForwardNormal00.bvh' # jointMotion = yf.readBvhFile(bvhFilePath) # frameTime = 1/jointMotion.fps pointMotion = joint2Point_Motion(jointMotion) # pointMotion = joint2mm_Motion(jointMotion) print('jointMotion.skeleton', jointMotion[0].skeleton) print('pointMotion.skeleton', pointMotion[0].skeleton) print('jointMotion.skeleton - pointMotion.skeleton', set(jointMotion[0].skeleton.joints.keys()) - pointMotion[0].skeleton.pointSet) print('pointMotion.skeleton - jointMotion.skeleton', pointMotion[0].skeleton.pointSet - set(jointMotion[0].skeleton.joints.keys())) motionSystem = ym.MotionSystem() motionSystem.addMotion(pointMotion) motionSystem.addMotion(jointMotion) renderers = [] renderers.append(yr.PointMotionRenderer(pointMotion)) renderers.append(yr.JointMotionRenderer(jointMotion, (0,255,0), yr.LINK_LINE)) viewer = yv.Viewer2(100, 100, 800, 650, None, motionSystem, renderers) # viewer = yv.MotionViewer(100, 100, 800, 650) viewer.setRenderers(renderers) viewer.setMotionSystem(motionSystem) viewer.startTimer(frameTime) viewer.show() Fl.run()
def test_readTrcFile(): trcMotion = readTrcFile('../samples/Day7_Session2_Take01_-_walk.trc', .01) print trcMotion[0].skeleton viewer = ysv.SimpleViewer() viewer.record(False) viewer.doc.addRenderer('trcMotion', yr.PointMotionRenderer(trcMotion, (0, 255, 0))) viewer.doc.addObject('trcMotion', trcMotion) viewer.startTimer(1 / trcMotion.fps) viewer.show() Fl.run()
def open(self, trcFilePath): fl_cursor(FL_CURSOR_WAIT) self.initialize() self.record(False) pointMotion = yf.readTrcFile(trcFilePath, .01) print(pointMotion[0].skeleton) self.doc.addRenderer('pointMotion', yr.PointMotionRenderer(pointMotion, (0,255,0))) self.doc.addObject('pointMotion', pointMotion) title = '%s - TrcViewer'%os.path.basename(trcFilePath) self.label(title) self.iconlabel(title) fl_cursor(FL_CURSOR_DEFAULT)
def test_SimpleViewer(): # mmFilePath = '../samples/physics2_WalkSameSame01.mm' # pointMotion1 = yf.readMMFile(mmFilePath) # mmFilePath = '../samples/physics2_WalkForwardFast00.mm' # pointMotion2 = yf.readMMFile(mmFilePath) # frameTime = 1./30. # # viewer = SimpleViewer() ## viewer = SimpleViewer((200,200,400,400)) # viewer.doc.addMotion(pointMotion1) # viewer.doc.addMotion(pointMotion2) # viewer.doc.addRenderer('WalkSameSame', yr.PointMotionRenderer(pointMotion1)) # viewer.doc.addRenderer('WalkForwardFast', yr.PointMotionRenderer(pointMotion2)) ## viewer.renderersWnd.when(FL_WHEN_CHANGED) ## print FL_WHEN_RELEASE ## print viewer.renderersWnd.when() # # viewer.startTimer(frameTime) # viewer.show() # Fl.run() pointMotion = yf.readTrcFile( '../samples/Day7_Session2_Take01_-_walk.trc', .01) jointMotion = yf.readBvhFile('../samples/wd2_WalkSameSame00.bvh', .01) print('pointSkeleton') print(pointMotion[0].skeleton) print('jointSkeleton') print(jointMotion[0].skeleton) viewer = SimpleViewer() viewer.record(False) viewer.doc.addRenderer( 'pointMotion', yr.PointMotionRenderer(pointMotion, (0, 255, 0))) viewer.doc.addObject('pointMotion', pointMotion) viewer.doc.addRenderer( 'jointMotion', yr.JointMotionRenderer(jointMotion, (0, 255, 0))) viewer.doc.addObject('jointMotion', jointMotion) viewer.startTimer(1 / pointMotion.fps) viewer.show() Fl.run()
def test_MotionViewer(): import Motion.ysMotion as ym import Resource.ysMotionLoader as yf import Renderer.ysRenderer as yr mmFilePath = '../samples/physics2_WalkSameSame01.mm' pointMotion = yf.readMMFile(mmFilePath) frameTime = 1. / 30. motionSystem = ym.MotionSystem() motionSystem.addMotion(pointMotion) renderers = [] renderers.append(yr.PointMotionRenderer(pointMotion)) viewer = MotionViewer(100, 100, 600, 400) # viewer = Viewer(100, 100, 800, 650, motionSystem, renderers) viewer.startTimer(frameTime) viewer.show() Fl.run()
def test_getCOMPos_Vel(): meshFilePath = '../samples/woody2_15.mesh.xml' skeletonFilePath = '../samples/woody2_15.skeleton.xml' mesh, js = yol.readOgreDataFiles(meshFilePath, .01, skeletonFilePath) bvhFilePath = '../samples/wd2_WalkSameSame00.bvh' motion = yf.readBvhFile(bvhFilePath, .01) meshMotion = meshAnimation2PointMotion(mesh, motion) vertexMasses = getDistributedVertexMasses(mesh, massMap) upperIndices = getSubmeshVertexIndicesEx(mesh, 'UPPER') totalMass = getTotalMass(vertexMasses) upperMass = getTotalMass(vertexMasses, upperIndices) viewer = ysv.SimpleViewer() viewer.record(False) viewer.doc.addRenderer('mesh', yr.MeshRenderer(mesh)) viewer.doc.addObject('mesh', mesh) viewer.doc.addRenderer('meshMotion', yr.PointMotionRenderer(meshMotion)) viewer.doc.addObject('meshMotion', meshMotion) def extraDrawCallback(): frame = viewer.getCurrentFrame() positions = meshMotion[frame].getPositions() COM = getCOMPos(positions, vertexMasses, totalMass) upperCOM = getCOMPos(positions, vertexMasses, upperMass, upperIndices) if frame > 0: velocities = meshMotion.getVelocities(frame) ygh.drawVector(getCOMVel(velocities, vertexMasses, totalMass), COM, (255,255,0)) ygh.drawVector(getCOMVel(velocities, vertexMasses, upperMass, upperIndices), upperCOM, (0,255,0)) viewer.setExtraDrawCallback(extraDrawCallback) viewer.startTimer(1/30.) viewer.show() Fl.run()
def test_mesh2PointPosture(): meshFilePath = '../samples/woody2_15.mesh.xml' skeletonFilePath = '../samples/woody2_15.skeleton.xml' skinMesh, js = yol.readOgreDataFiles(meshFilePath, .01, skeletonFilePath) bvhFilePath = '../samples/wd2_WalkSameSame00.bvh' jointMotion = yf.readBvhFile(bvhFilePath, .01) meshPointMotion = meshAnimation2PointMotion(skinMesh, jointMotion) viewer = ysv.SimpleViewer() viewer.record(False) viewer.doc.addRenderer('skinMesh', yr.MeshRenderer(skinMesh)) viewer.doc.addObject('skinMesh', skinMesh) viewer.doc.addRenderer('meshPointMotion', yr.PointMotionRenderer(meshPointMotion)) viewer.doc.addObject('meshPointMotion', meshPointMotion) def preFrameCallback(frame): skinMesh.update(jointMotion[frame]) viewer.setPreFrameCallback(preFrameCallback) viewer.startTimer(1/30.) viewer.show() Fl.run()
# motion, f = yf.readBvhFileAsJointMotion('Data/wd2_WalkLean00.bvh', .01) # motion, f = yf.readBvhFileAsJointMotion('Data/wd2_WalkSukiko00.bvh', .01) # motion, f = yf.readBvhFileAsJointMotion('Data/wd2_2foot_walk_turn2.bvh', .01) # motion, f = yf.readBvhFileAsJointMotion('Data/wd2_2foot_walk_turn.bvh', .01) motion = yf.readBvhFile('../samples/wd2_WalkSameSame00.bvh', .01) meshMotion = ysu.meshAnimation2PointMotion(mesh, motion) vertexMasses = ysu.getDistributedVertexMasses(mesh, massMap) upperVertexIndices, upperMass = ysu.getUpperInfo(mesh, vertexMasses) totalMass = ysu.getTotalMass(vertexMasses) viewer = ysv.SimpleViewer() viewer.record(False) viewer.doc.addRenderer('mesh', yr.MeshRenderer(mesh)) viewer.doc.addObject('mesh', mesh) viewer.doc.addRenderer('meshMotion', yr.PointMotionRenderer(meshMotion)) viewer.doc.addObject('meshMotion', meshMotion) def preFrameCallback(frame): mesh.update(motion[frame]) def extraDrawCallback(): frame = viewer.getCurrentFrame() meshPositions = meshMotion[frame].getPointPositions() ygh.drawPoint( ysu.getUpperCOMPos(meshPositions, vertexMasses, upperVertexIndices, upperMass)) ygh.drawPoint(ysu.getCOMPos(meshPositions, vertexMasses, totalMass), (255, 255, 0)) if frame > 0: meshVelocities = meshMotion.getPointVelocities(frame, frame - 1)