Last active
October 1, 2022 16:49
-
-
Save kergalym/b5117d5de3fc4c6c6e8417ebcad4b416 to your computer and use it in GitHub Desktop.
Panda3D: Cloak Pinning Fragment Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pin the cloak down | |
spine_bone = actor.expose_joint(None, 'modelRoot', 'Korlan:Spine2') | |
self.spine_bones[name] = spine_bone | |
pin = spine_bone.attach_new_node(BulletRigidBodyNode('pin')) | |
self.cloth_pins[name] = pin | |
# Position of the cloak get's shifted, fix it | |
pin.set_z(0) | |
# Cloak geom vertices integer numbers contain in the textual format | |
raw_txt = cloth.find('**/=ClothPin').getTag('ClothPin') | |
vtx_list = raw_txt.strip().split() | |
vec3_list = [] | |
# Convert them into numbers and append as nested 3-component vector list | |
for s_vtx in range(0, len(vtx_list), 3): | |
i_vtx = int(s_vtx) | |
vec3_list.append(vtx_list[i_vtx:i_vtx+3]) | |
# Append fixed (non-movable) part of the cloak to the pin node | |
for idx in vec3_list: | |
soft_np.node().append_anchor( | |
soft_np.node().get_closest_node_index(Vec3(*idx), True), pin.node()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment