Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def pass_joint_to_scene(amt, part, parent, rotation):
- #Already in edit mode
- #I can create the bone normally
- part_name = part['info']['name']
- part_type = part['info']['type']
- #Make bone to Center of Axes
- loc = Vector(part['options']['transmat'][0:3])
- bonevec = Vector((loc[0], loc[1], loc[2]))
- if bonevec[0]==bonevec[1]==bonevec[2]==0:
- bonevec = Vector((0,0,0.01))
- print("Empty bone:",part_name)
- localrot = part['options']['transmat'][3:6]
- localscale = part['options']['transmat'][6:9]
- localrot = Euler((math.radians(localrot[0]),
- math.radians(localrot[1]),
- math.radians(localrot[2])),"XYZ")
- #Update rotation
- newrot = Euler((0,0,0),'XYZ')
- newrot[0] = rotation[0] + localrot[0]
- newrot[1] = rotation[1] + localrot[1]
- newrot[2] = rotation[2] + localrot[2]
- #Scale before rotating
- #bonevec[0] *= localscale[0]
- #bonevec[1] *= localscale[1]
- #bonevec[2] *= localscale[2]
- #Rotate vector on center
- bonevec.rotate(rotation)
- #Add vector to bone
- bone = amt.edit_bones.new(part_name)
- if parent:
- bone.parent = parent
- bone.head = parent.tail;
- bone.tail = bone.head + bonevec
- #bone.use_connect
- if part['children']:
- for e in part['children']:
- pass_joint_to_scene(amt,e, bone, newrot)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement