def restBones(self): animated = self.getAnimatedBoneNames() bones = self.context.renderer.getBones() target = skin.SkinningBone(None) for name in bones: if not name in animated: self.restBone(bones[name], target)
def apply(self, editor): bones = editor.context.renderer.bones parent = bones[self.bone.name] baseName = parent.name.replace("\\", "/").rsplit("/")[-1] parts = baseName.strip().split(" ") if parts[-1].isdigit(): parts = parts[:-1] newName = self.findNextFreeBoneName(bones, " ".join(parts)) bone = skin.SkinningBone(newName) bone.pivot = editor.getBoneInverseTranslation(bones[self.bone.name], editor.mouse, False) bone.zOrder = self.findNextZOrder(parent, bones) bones[bone.name] = bone editor.connectBone(bone.name, parent.name) editor.setActiveBone(bone)
def createImageBone(self, surface, boneName, fileName, placement, zOrder): originalWidth, originalHeight = surface.get_size() crop = surface.get_bounding_rect() crop.inflate_ip(10, 10) #TODO For testing surface = self.cropSurface(surface, crop) x = placement[0] + crop[0] y = placement[1] + crop[1] bone = skin.SkinningBone(boneName) bone.parent = self.root.name bone.image = skin.SkinnedImage(fileName, crop[0], crop[1], surface.get_width(), surface.get_height(), originalWidth, originalHeight) bone.pos = (x, y) bone.pivot = (bone.pos[0] + bone.image.width / 2.0, bone.pos[1] + bone.image.height / 2.0) bone.zOrder = zOrder bone.updatePoints(surface, self.pointResolution) self.bones[bone.parent].children.append(boneName) self.bones[boneName] = bone self.skinTextures.setTexture(bone.image.name, surface)
def createRootBone(self): root = skin.SkinningBone("root") root.pivot = (self.size[0] * 0.5, self.size[1] * 0.75) self.bones = {root.name: root} return root