How to use the payton.scene.geometry.ragdoll.Bone function in Payton

To help you get started, we’ve selected a few Payton examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sinanislekdemir / payton / payton / scene / geometry / ragdoll.py View on Github external
root_joint = Joint(name=root_joint_name)
        end_joint = Joint(name=end_joint_name)
        self.add_child(root_joint_name, root_joint)
        self.root = self.children[root_joint_name]
        self.root.add_child(end_joint_name, end_joint)
        self.end = self.root.children[end_joint_name]
        self.end.position = [0.0, 0.0, length]

    def connect_to_root(self, joint: Joint):
        self.root.add_child(joint.name, joint)

    def connect_to_end(self, joint: Joint):
        self.end.add_child(joint.name, joint)


class RagDoll(Bone):
    def __init__(self, **kwargs: Any) -> None:
        kwargs["root_joint_name"] = "lower_spine"
        kwargs["end_joint_name"] = "higher_spine"
        kwargs["length"] = 1.0
        super().__init__(**kwargs)
        self.joints: Dict[str, Joint] = {}
        self.position = [0.0, 0.0, 2.0]
        self.setup_joints()
        self.setup_geometry()

    def setup_geometry(self):
        self.joints[HEAD].add_child(
            "mesh", Cube(from_corner=[-0.2, -0.2, 0], to_corner=[0.2, 0.2, 0.4]),
        )
        self.joints[NECK].add_child(
            "mesh", Cube(from_corner=[-0.1, -0.1, 0], to_corner=[0.1, 0.1, 0.2]),
github sinanislekdemir / payton / payton / scene / geometry / ragdoll.py View on Github external
left_upper_arm.connect_to_end(left_lower_arm.root)

        right_hand = Bone(root_joint_name="r_wrist", end_joint_name="r_hand", length=0.2)
        right_lower_arm.connect_to_end(right_hand.root)
        left_hand = Bone(root_joint_name="l_wrist", end_joint_name="l_hand", length=0.2)
        left_lower_arm.connect_to_end(left_hand.root)

        right_upper_leg = Bone(root_joint_name="r_hip", end_joint_name="r_knee", length=1.0)
        self.connect_to_root(right_upper_leg.root)
        right_upper_leg.root.rotate_around_y(math.radians(160))

        left_upper_leg = Bone(root_joint_name="l_hip", end_joint_name="l_knee", length=1.0)
        self.connect_to_root(left_upper_leg.root)
        left_upper_leg.root.rotate_around_y(math.radians(-160))

        right_lower_leg = Bone(root_joint_name="r_knee", end_joint_name="r_foot", length=1.0)
        right_upper_leg.connect_to_end(right_lower_leg.root)
        left_lower_leg = Bone(root_joint_name="l_knee", end_joint_name="l_foot", length=1.0)
        left_upper_leg.connect_to_end(left_lower_leg.root)
        right_foot = Bone(root_joint_name="r_foot", end_joint_name="r_toe", length=0.3)
        right_lower_leg.connect_to_end(right_foot.root)
        right_foot.root.rotate_around_x(math.radians(90))

        left_foot = Bone(root_joint_name="l_foot", end_joint_name="l_toe", length=0.3)
        left_lower_leg.connect_to_end(left_foot.root)
        left_foot.root.rotate_around_x(math.radians(90))

        self.joints[NECK] = neck.root
        self.joints[HEAD] = head.root
        self.joints[R_COLLAR] = right_collar.root
        self.joints[L_COLLAR] = left_collar.root
        self.joints[R_SHOULDER] = right_upper_arm.root
github sinanislekdemir / payton / payton / scene / geometry / ragdoll.py View on Github external
def setup_joints(self):
        neck = Bone(root_joint_name="lower_neck", end_joint_name="head", length=0.2)
        self.connect_to_end(neck.root)
        head = Bone(root_joint_name="head", end_joint_name="head_top", length=0.4)
        neck.connect_to_end(head.root)
        left_collar = Bone(root_joint_name="l_collar_joint", end_joint_name="l_shoulder", length=0.5,)
        self.connect_to_end(left_collar.root)

        right_collar = Bone(root_joint_name="r_collar_joint", end_joint_name="r_shoulder", length=0.5,)
        self.connect_to_end(right_collar.root)

        right_collar.root.rotate_around_y(math.radians(100))
        left_collar.root.rotate_around_y(math.radians(-100))

        right_upper_arm = Bone(root_joint_name="r_shoulder", end_joint_name="r_elbow", length=0.5)
        right_collar.connect_to_end(right_upper_arm.root)
        right_upper_arm.rotate_around_y(math.radians(20))

        left_upper_arm = Bone(root_joint_name="l_shoulder", end_joint_name="l_elbow", length=0.5)
        left_collar.connect_to_end(left_upper_arm.root)
github sinanislekdemir / payton / payton / scene / geometry / ragdoll.py View on Github external
def setup_joints(self):
        neck = Bone(root_joint_name="lower_neck", end_joint_name="head", length=0.2)
        self.connect_to_end(neck.root)
        head = Bone(root_joint_name="head", end_joint_name="head_top", length=0.4)
        neck.connect_to_end(head.root)
        left_collar = Bone(root_joint_name="l_collar_joint", end_joint_name="l_shoulder", length=0.5,)
        self.connect_to_end(left_collar.root)

        right_collar = Bone(root_joint_name="r_collar_joint", end_joint_name="r_shoulder", length=0.5,)
        self.connect_to_end(right_collar.root)

        right_collar.root.rotate_around_y(math.radians(100))
        left_collar.root.rotate_around_y(math.radians(-100))

        right_upper_arm = Bone(root_joint_name="r_shoulder", end_joint_name="r_elbow", length=0.5)
        right_collar.connect_to_end(right_upper_arm.root)
        right_upper_arm.rotate_around_y(math.radians(20))
github sinanislekdemir / payton / payton / scene / geometry / ragdoll.py View on Github external
def setup_joints(self):
        neck = Bone(root_joint_name="lower_neck", end_joint_name="head", length=0.2)
        self.connect_to_end(neck.root)
        head = Bone(root_joint_name="head", end_joint_name="head_top", length=0.4)
        neck.connect_to_end(head.root)
        left_collar = Bone(root_joint_name="l_collar_joint", end_joint_name="l_shoulder", length=0.5,)
        self.connect_to_end(left_collar.root)

        right_collar = Bone(root_joint_name="r_collar_joint", end_joint_name="r_shoulder", length=0.5,)
        self.connect_to_end(right_collar.root)

        right_collar.root.rotate_around_y(math.radians(100))
        left_collar.root.rotate_around_y(math.radians(-100))

        right_upper_arm = Bone(root_joint_name="r_shoulder", end_joint_name="r_elbow", length=0.5)
        right_collar.connect_to_end(right_upper_arm.root)
        right_upper_arm.rotate_around_y(math.radians(20))

        left_upper_arm = Bone(root_joint_name="l_shoulder", end_joint_name="l_elbow", length=0.5)
        left_collar.connect_to_end(left_upper_arm.root)
        left_upper_arm.rotate_around_y(math.radians(-20))

        right_lower_arm = Bone(root_joint_name="r_elbow", end_joint_name="r_wrist", length=0.5)
        right_upper_arm.connect_to_end(right_lower_arm.root)
        left_lower_arm = Bone(root_joint_name="l_elbow", end_joint_name="l_wrist", length=0.5)
github sinanislekdemir / payton / payton / scene / geometry / ragdoll.py View on Github external
right_upper_arm = Bone(root_joint_name="r_shoulder", end_joint_name="r_elbow", length=0.5)
        right_collar.connect_to_end(right_upper_arm.root)
        right_upper_arm.rotate_around_y(math.radians(20))

        left_upper_arm = Bone(root_joint_name="l_shoulder", end_joint_name="l_elbow", length=0.5)
        left_collar.connect_to_end(left_upper_arm.root)
        left_upper_arm.rotate_around_y(math.radians(-20))

        right_lower_arm = Bone(root_joint_name="r_elbow", end_joint_name="r_wrist", length=0.5)
        right_upper_arm.connect_to_end(right_lower_arm.root)
        left_lower_arm = Bone(root_joint_name="l_elbow", end_joint_name="l_wrist", length=0.5)
        left_upper_arm.connect_to_end(left_lower_arm.root)

        right_hand = Bone(root_joint_name="r_wrist", end_joint_name="r_hand", length=0.2)
        right_lower_arm.connect_to_end(right_hand.root)
        left_hand = Bone(root_joint_name="l_wrist", end_joint_name="l_hand", length=0.2)
        left_lower_arm.connect_to_end(left_hand.root)

        right_upper_leg = Bone(root_joint_name="r_hip", end_joint_name="r_knee", length=1.0)
        self.connect_to_root(right_upper_leg.root)
        right_upper_leg.root.rotate_around_y(math.radians(160))

        left_upper_leg = Bone(root_joint_name="l_hip", end_joint_name="l_knee", length=1.0)
        self.connect_to_root(left_upper_leg.root)
        left_upper_leg.root.rotate_around_y(math.radians(-160))

        right_lower_leg = Bone(root_joint_name="r_knee", end_joint_name="r_foot", length=1.0)
        right_upper_leg.connect_to_end(right_lower_leg.root)
        left_lower_leg = Bone(root_joint_name="l_knee", end_joint_name="l_foot", length=1.0)
        left_upper_leg.connect_to_end(left_lower_leg.root)
        right_foot = Bone(root_joint_name="r_foot", end_joint_name="r_toe", length=0.3)
        right_lower_leg.connect_to_end(right_foot.root)
github sinanislekdemir / payton / payton / scene / geometry / ragdoll.py View on Github external
self.connect_to_root(right_upper_leg.root)
        right_upper_leg.root.rotate_around_y(math.radians(160))

        left_upper_leg = Bone(root_joint_name="l_hip", end_joint_name="l_knee", length=1.0)
        self.connect_to_root(left_upper_leg.root)
        left_upper_leg.root.rotate_around_y(math.radians(-160))

        right_lower_leg = Bone(root_joint_name="r_knee", end_joint_name="r_foot", length=1.0)
        right_upper_leg.connect_to_end(right_lower_leg.root)
        left_lower_leg = Bone(root_joint_name="l_knee", end_joint_name="l_foot", length=1.0)
        left_upper_leg.connect_to_end(left_lower_leg.root)
        right_foot = Bone(root_joint_name="r_foot", end_joint_name="r_toe", length=0.3)
        right_lower_leg.connect_to_end(right_foot.root)
        right_foot.root.rotate_around_x(math.radians(90))

        left_foot = Bone(root_joint_name="l_foot", end_joint_name="l_toe", length=0.3)
        left_lower_leg.connect_to_end(left_foot.root)
        left_foot.root.rotate_around_x(math.radians(90))

        self.joints[NECK] = neck.root
        self.joints[HEAD] = head.root
        self.joints[R_COLLAR] = right_collar.root
        self.joints[L_COLLAR] = left_collar.root
        self.joints[R_SHOULDER] = right_upper_arm.root
        self.joints[L_SHOULDER] = left_upper_arm.root
        self.joints[R_ELBOW] = right_lower_arm.root
        self.joints[L_ELBOW] = left_lower_arm.root
        self.joints[R_WRIST] = right_hand.root
        self.joints[L_WRIST] = left_hand.root
        self.joints[R_HIP] = right_upper_leg.root
        self.joints[L_HIP] = left_upper_leg.root
        self.joints[R_KNEE] = right_lower_leg.root
github sinanislekdemir / payton / payton / scene / geometry / ragdoll.py View on Github external
right_hand = Bone(root_joint_name="r_wrist", end_joint_name="r_hand", length=0.2)
        right_lower_arm.connect_to_end(right_hand.root)
        left_hand = Bone(root_joint_name="l_wrist", end_joint_name="l_hand", length=0.2)
        left_lower_arm.connect_to_end(left_hand.root)

        right_upper_leg = Bone(root_joint_name="r_hip", end_joint_name="r_knee", length=1.0)
        self.connect_to_root(right_upper_leg.root)
        right_upper_leg.root.rotate_around_y(math.radians(160))

        left_upper_leg = Bone(root_joint_name="l_hip", end_joint_name="l_knee", length=1.0)
        self.connect_to_root(left_upper_leg.root)
        left_upper_leg.root.rotate_around_y(math.radians(-160))

        right_lower_leg = Bone(root_joint_name="r_knee", end_joint_name="r_foot", length=1.0)
        right_upper_leg.connect_to_end(right_lower_leg.root)
        left_lower_leg = Bone(root_joint_name="l_knee", end_joint_name="l_foot", length=1.0)
        left_upper_leg.connect_to_end(left_lower_leg.root)
        right_foot = Bone(root_joint_name="r_foot", end_joint_name="r_toe", length=0.3)
        right_lower_leg.connect_to_end(right_foot.root)
        right_foot.root.rotate_around_x(math.radians(90))

        left_foot = Bone(root_joint_name="l_foot", end_joint_name="l_toe", length=0.3)
        left_lower_leg.connect_to_end(left_foot.root)
        left_foot.root.rotate_around_x(math.radians(90))

        self.joints[NECK] = neck.root
        self.joints[HEAD] = head.root
        self.joints[R_COLLAR] = right_collar.root
        self.joints[L_COLLAR] = left_collar.root
        self.joints[R_SHOULDER] = right_upper_arm.root
        self.joints[L_SHOULDER] = left_upper_arm.root
        self.joints[R_ELBOW] = right_lower_arm.root
github sinanislekdemir / payton / payton / scene / geometry / ragdoll.py View on Github external
head = Bone(root_joint_name="head", end_joint_name="head_top", length=0.4)
        neck.connect_to_end(head.root)
        left_collar = Bone(root_joint_name="l_collar_joint", end_joint_name="l_shoulder", length=0.5,)
        self.connect_to_end(left_collar.root)

        right_collar = Bone(root_joint_name="r_collar_joint", end_joint_name="r_shoulder", length=0.5,)
        self.connect_to_end(right_collar.root)

        right_collar.root.rotate_around_y(math.radians(100))
        left_collar.root.rotate_around_y(math.radians(-100))

        right_upper_arm = Bone(root_joint_name="r_shoulder", end_joint_name="r_elbow", length=0.5)
        right_collar.connect_to_end(right_upper_arm.root)
        right_upper_arm.rotate_around_y(math.radians(20))

        left_upper_arm = Bone(root_joint_name="l_shoulder", end_joint_name="l_elbow", length=0.5)
        left_collar.connect_to_end(left_upper_arm.root)
        left_upper_arm.rotate_around_y(math.radians(-20))

        right_lower_arm = Bone(root_joint_name="r_elbow", end_joint_name="r_wrist", length=0.5)
        right_upper_arm.connect_to_end(right_lower_arm.root)
        left_lower_arm = Bone(root_joint_name="l_elbow", end_joint_name="l_wrist", length=0.5)
        left_upper_arm.connect_to_end(left_lower_arm.root)

        right_hand = Bone(root_joint_name="r_wrist", end_joint_name="r_hand", length=0.2)
        right_lower_arm.connect_to_end(right_hand.root)
        left_hand = Bone(root_joint_name="l_wrist", end_joint_name="l_hand", length=0.2)
        left_lower_arm.connect_to_end(left_hand.root)

        right_upper_leg = Bone(root_joint_name="r_hip", end_joint_name="r_knee", length=1.0)
        self.connect_to_root(right_upper_leg.root)
        right_upper_leg.root.rotate_around_y(math.radians(160))
github sinanislekdemir / payton / payton / scene / geometry / ragdoll.py View on Github external
left_upper_arm = Bone(root_joint_name="l_shoulder", end_joint_name="l_elbow", length=0.5)
        left_collar.connect_to_end(left_upper_arm.root)
        left_upper_arm.rotate_around_y(math.radians(-20))

        right_lower_arm = Bone(root_joint_name="r_elbow", end_joint_name="r_wrist", length=0.5)
        right_upper_arm.connect_to_end(right_lower_arm.root)
        left_lower_arm = Bone(root_joint_name="l_elbow", end_joint_name="l_wrist", length=0.5)
        left_upper_arm.connect_to_end(left_lower_arm.root)

        right_hand = Bone(root_joint_name="r_wrist", end_joint_name="r_hand", length=0.2)
        right_lower_arm.connect_to_end(right_hand.root)
        left_hand = Bone(root_joint_name="l_wrist", end_joint_name="l_hand", length=0.2)
        left_lower_arm.connect_to_end(left_hand.root)

        right_upper_leg = Bone(root_joint_name="r_hip", end_joint_name="r_knee", length=1.0)
        self.connect_to_root(right_upper_leg.root)
        right_upper_leg.root.rotate_around_y(math.radians(160))

        left_upper_leg = Bone(root_joint_name="l_hip", end_joint_name="l_knee", length=1.0)
        self.connect_to_root(left_upper_leg.root)
        left_upper_leg.root.rotate_around_y(math.radians(-160))

        right_lower_leg = Bone(root_joint_name="r_knee", end_joint_name="r_foot", length=1.0)
        right_upper_leg.connect_to_end(right_lower_leg.root)
        left_lower_leg = Bone(root_joint_name="l_knee", end_joint_name="l_foot", length=1.0)
        left_upper_leg.connect_to_end(left_lower_leg.root)
        right_foot = Bone(root_joint_name="r_foot", end_joint_name="r_toe", length=0.3)
        right_lower_leg.connect_to_end(right_foot.root)
        right_foot.root.rotate_around_x(math.radians(90))

        left_foot = Bone(root_joint_name="l_foot", end_joint_name="l_toe", length=0.3)