def drawSkeleton(self, skel): if self.skelObj: # Remove old skeleton mesh self.removeObject(self.skelObj) self.human.removeBoundMesh(self.skelObj.name) self.skelObj = None self.skelMesh = None if not skel: return # Create a mesh from the skeleton in rest pose skel.setToRestPose() # Make sure skeleton is in rest pose when constructing the skeleton mesh self.skelMesh = skeleton_drawing.meshFromSkeleton(skel, "Prism") self.skelMesh.priority = 100 self.skelMesh.setPickable(False) self.skelObj = self.addObject(gui3d.Object(self.skelMesh, self.human.getPosition()) ) self.skelObj.setShadeless(0) self.skelObj.setSolid(0) self.skelObj.setRotation(self.human.getRotation()) # Add the skeleton mesh to the human AnimatedMesh so it animates together with the skeleton # The skeleton mesh is supposed to be constructed from the skeleton in rest and receives # rigid vertex-bone weights (for each vertex exactly one weight of 1 to one bone) mapping = skeleton_drawing.getVertBoneMapping(skel, self.skelMesh) self.human.addBoundMesh(self.skelMesh, mapping) mh.redraw()
def loadBVHRig(self, bvhRig): global SPARSIFY # Draw BVH skeleton if it does not exist yet if not self.bvhMesh: self.bvhSkel = bvhRig.createSkeleton() self.bvhMesh = skeleton_drawing.meshFromSkeleton(self.bvhSkel, "Prism") self.bvhMesh.priority = 100 self.bvhMesh.setColor([0, 255, 0, 255]) self.bvhObj = self.addObject(gui3d.Object(self.human.getPosition(), self.bvhMesh) ) self.bvhObj.setRotation(self.human.getRotation()) # Get rigid weights for skeleton mesh boneWeights = skeleton_drawing.getVertBoneMapping(self.bvhSkel, self.bvhMesh) self.bvhAnimated = animation.AnimatedMesh(self.bvhSkel, self.bvhMesh, boneWeights) # Load animation to BVH rig animName = unicode(os.path.splitext(os.path.basename(bvhRig.filename))[0]) trivialMap = [bone.name for bone in self.bvhSkel.getBones()] animTrack = bvhRig.createAnimationTrack(trivialMap, animName) animTrack.interpolationType = 0 if animTrack.frameRate > 30: animTrack.sparsify(30) self.bvhAnimated.addAnimation(animTrack)
def drawSkeleton(self): self._unloadSkeletonMesh() skel = self.human.getSkeleton() if not skel: return # Create a mesh from the skeleton in rest pose skel.setToRestPose( ) # Make sure skeleton is in rest pose when constructing the skeleton mesh self.skelMesh = skeleton_drawing.meshFromSkeleton(skel, "Prism") self.skelMesh.name = self.skelMesh.name + '-skeletonDebug' self.skelMesh.priority = 100 self.skelMesh.setPickable(False) self.skelObj = self.addObject( gui3d.Object(self.skelMesh, self.human.getPosition())) self.skelObj.setShadeless(0) self.skelObj.setSolid(0) self.skelObj.setRotation(self.human.getRotation()) # Add the skeleton mesh to the human AnimatedMesh so it animates together with the skeleton # The skeleton mesh is supposed to be constructed from the skeleton in rest and receives # rigid vertex-bone weights (for each vertex exactly one weight of 1 to one bone) mapping = skeleton_drawing.getVertBoneMapping(skel, self.skelMesh) self.human.addBoundMesh(self.skelMesh, mapping) self.human.refreshPose() # Pose drawn skeleton if human is posed mh.redraw()
def drawSkeleton(self, skel): if self.skelObj: # Remove old skeleton mesh self.removeObject(self.skelObj) self.human.removeBoundMesh(self.skelObj.name) self.skelObj = None self.skelMesh = None self.selectedBone = None if not skel: return # Create a mesh from the skeleton in rest pose skel.setToRestPose( ) # Make sure skeleton is in rest pose when constructing the skeleton mesh self.skelMesh = skeleton_drawing.meshFromSkeleton(skel, "Prism") self.skelMesh.name = 'SkeletonMesh-poseLibrary' self.skelMesh.priority = 100 self.skelMesh.setPickable(False) self.skelObj = self.addObject( gui3d.Object(self.skelMesh, self.human.getPosition())) self.skelObj.setShadeless(0) self.skelObj.setSolid(0) self.skelObj.setRotation(self.human.getRotation()) # Add the skeleton mesh to the human AnimatedMesh so it animates together with the skeleton # The skeleton mesh is supposed to be constructed from the skeleton in rest and receives # rigid vertex-bone weights (for each vertex exactly one weight of 1 to one bone) mapping = skeleton_drawing.getVertBoneMapping(skel, self.skelMesh) self.human.addBoundMesh(self.skelMesh, mapping) # Store a reference to the skeleton mesh object for other plugins self.human.getSkeleton().object = self.skelObj mh.redraw()
def drawSkeleton(self, skel): if self.skelObj: # Remove old skeleton mesh gui3d.app.removeObject(self.skelObj) self.skelObj = None self.skelMesh = None self.selectedBone = None # Create a mesh from the skeleton in rest pose skel.setToRestPose() # Make sure skeleton is in rest pose when constructing the skeleton mesh self.skelMesh = skeleton_drawing.meshFromSkeleton(skel, "Prism") self.skelMesh.priority = 100 self.skelMesh.setPickable(True) mh.updatePickingBuffer() self.skelObj = gui3d.app.addObject(gui3d.Object(self.human.getPosition(), self.skelMesh) ) self.skelObj.setRotation(self.human.getRotation()) # Add the skeleton mesh to the human AnimatedMesh so it animates together with the skeleton # The skeleton mesh is supposed to be constructed from the skeleton in rest and receives # rigid vertex-bone weights (for each vertex exactly one weight of 1 to one bone) mapping = skeleton_drawing.getVertBoneMapping(skel, self.skelMesh) self.human.animated.addMesh(self.skelMesh, mapping) # Store a reference to the skeleton mesh object for other plugins self.human._skeleton.object = self.skelObj '''
def drawSkeleton(self, skel): if self.skelObj: # Remove old skeleton mesh gui3d.app.removeObject(self.skelObj) self.skelObj = None self.skelMesh = None self.selectedBone = None # Create a mesh from the skeleton in rest pose skel.setToRestPose( ) # Make sure skeleton is in rest pose when constructing the skeleton mesh self.skelMesh = skeleton_drawing.meshFromSkeleton(skel, "Prism") self.skelMesh.priority = 100 self.skelMesh.setPickable(True) mh.updatePickingBuffer() self.skelObj = gui3d.app.addObject( gui3d.Object(self.human.getPosition(), self.skelMesh)) self.skelObj.setRotation(self.human.getRotation()) # Add the skeleton mesh to the human AnimatedMesh so it animates together with the skeleton # The skeleton mesh is supposed to be constructed from the skeleton in rest and receives # rigid vertex-bone weights (for each vertex exactly one weight of 1 to one bone) mapping = skeleton_drawing.getVertBoneMapping(skel, self.skelMesh) self.human.animated.addMesh(self.skelMesh, mapping) # Store a reference to the skeleton mesh object for other plugins self.human._skeleton.object = self.skelObj # Add event listeners to skeleton mesh for bone highlighting @self.skelObj.mhEvent def onMouseEntered(event): """ Event fired when mouse hovers over a skeleton mesh facegroup """ gui3d.TaskView.onMouseEntered(self, event) try: self.removeBoneHighlights() except: pass self.highlightBone(event.group.name) @self.skelObj.mhEvent def onMouseExited(event): """ Event fired when mouse hovers off of a skeleton mesh facegroup """ gui3d.TaskView.onMouseExited(self, event) try: self.removeBoneHighlights() except: pass # Highlight bone selected in bone explorer again for rdio in self.boneSelector: if rdio.selected: self.clearBoneWeights() self.highlightBone(str(rdio.text()))
def drawSkeleton(self, skel): if self.skelObj: # Remove old skeleton mesh gui3d.app.removeObject(self.skelObj) self.skelObj = None self.skelMesh = None self.selectedBone = None # Create a mesh from the skeleton in rest pose skel.setToRestPose() # Make sure skeleton is in rest pose when constructing the skeleton mesh self.skelMesh = skeleton_drawing.meshFromSkeleton(skel, "Prism") self.skelMesh.priority = 100 self.skelMesh.setPickable(True) mh.updatePickingBuffer() self.skelObj = gui3d.app.addObject(gui3d.Object(self.human.getPosition(), self.skelMesh) ) self.skelObj.setRotation(self.human.getRotation()) # Add the skeleton mesh to the human AnimatedMesh so it animates together with the skeleton # The skeleton mesh is supposed to be constructed from the skeleton in rest and receives # rigid vertex-bone weights (for each vertex exactly one weight of 1 to one bone) mapping = skeleton_drawing.getVertBoneMapping(skel, self.skelMesh) self.human.animated.addMesh(self.skelMesh, mapping) # Store a reference to the skeleton mesh object for other plugins self.human._skeleton.object = self.skelObj # Add event listeners to skeleton mesh for bone highlighting @self.skelObj.mhEvent def onMouseEntered(event): """ Event fired when mouse hovers over a skeleton mesh facegroup """ gui3d.TaskView.onMouseEntered(self, event) try: self.removeBoneHighlights() except: pass self.highlightBone(event.group.name) @self.skelObj.mhEvent def onMouseExited(event): """ Event fired when mouse hovers off of a skeleton mesh facegroup """ gui3d.TaskView.onMouseExited(self, event) try: self.removeBoneHighlights() except: pass # Highlight bone selected in bone explorer again for rdio in self.boneSelector: if rdio.selected: self.clearBoneWeights() self.highlightBone(str(rdio.text()))
def drawSkeleton(self): self._unloadSkeletonMesh() skel = self.human.getSkeleton() if not skel: return # Create a mesh from the skeleton in rest pose skel.setToRestPose() # Make sure skeleton is in rest pose when constructing the skeleton mesh self.skelMesh = skeleton_drawing.meshFromSkeleton(skel, "Prism") self.skelMesh.name = self.skelMesh.name + '-skeletonDebug' self.skelMesh.priority = 100 self.skelMesh.setPickable(False) self.skelObj = self.addObject(gui3d.Object(self.skelMesh, self.human.getPosition()) ) self.skelObj.setShadeless(0) self.skelObj.setSolid(0) self.skelObj.setRotation(self.human.getRotation()) self.axisMesh = skeleton_drawing.meshFromSkeleton(skel, "axis") self.axisMesh.name = self.axisMesh.name + '-axis-skeletonDebug' self.axisMesh.priority = 100 self.axisMesh.setPickable(False) self.axisObj = self.addObject(gui3d.Object(self.axisMesh, self.human.getPosition()) ) self.axisObj.material.ambientColor = [0.2, 0.2, 0.2] self.axisObj.material.configureShading(vertexColors=True) self.axisObj.material.depthless = True self.axisObj.setRotation(self.human.getRotation()) # Add the skeleton mesh to the human AnimatedMesh so it animates together with the skeleton # The skeleton mesh is supposed to be constructed from the skeleton in rest and receives # rigid vertex-bone weights (for each vertex exactly one weight of 1 to one bone) mapping = skeleton_drawing.getVertBoneMapping(skel, self.skelMesh) self.human.addBoundMesh(self.skelMesh, mapping) mapping = skeleton_drawing.getVertBoneMapping(skel, self.axisMesh) self.human.addBoundMesh(self.axisMesh, mapping) self.human.refreshPose() # Pose drawn skeleton if human is posed mh.redraw()
def drawSkeleton(self, skel): # Create a mesh from the skeleton in rest pose skel.setToRestPose() # Make sure skeleton is in rest pose when constructing the skeleton mesh self.skelMesh = skeleton_drawing.meshFromSkeleton(skel, "Prism") self.skelMesh.priority = 100 self.skelObj = self.addObject(gui3d.Object(self.human.getPosition(), self.skelMesh) ) self.skelObj.setRotation(self.human.getRotation()) # Add the skeleton mesh to the human AnimatedMesh so it animates together with the skeleton # The skeleton mesh is supposed to be constructed from the skeleton in rest and receives # rigid vertex-bone weights (for each vertex exactly one weight of 1 to one bone) mapping = skeleton_drawing.getVertBoneMapping(skel, self.skelMesh) self.animated.addMesh(self.skelMesh, mapping) self.setShowRig(self.showMHXRigTggl.selected)