1
# ##### BEGIN GPL LICENSE BLOCK #####
3
# This program is free software; you can redistribute it and/or
4
# modify it under the terms of the GNU General Public License
5
# as published by the Free Software Foundation; either version 2
6
# of the License, or (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software Foundation,
15
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
# ##### END GPL LICENSE BLOCK #####
22
from rigify import RigifyError
23
from rigify_utils import copy_bone_simple
25
METARIG_NAMES = tuple()
26
RIG_TYPE = "track_reverse"
29
#def metarig_template():
30
# # generated by rigify.write_meta_rig
31
# bpy.ops.object.mode_set(mode='EDIT')
32
# obj = bpy.context.active_object
34
# bone = arm.edit_bones.new('Bone')
35
# bone.head[:] = 0.0000, 0.0000, 0.0000
36
# bone.tail[:] = 0.0000, 0.0000, 1.0000
38
# bone.connected = False
40
# bpy.ops.object.mode_set(mode='OBJECT')
41
# pbone = obj.pose.bones['Bone']
42
# pbone['type'] = 'copy'
44
bool_map = {0:False, 1:True,
46
"false":False, "true":True,
47
"False":False, "True":True,
48
"no":False, "yes":True,
49
"No":False, "Yes":True}
51
def metarig_definition(obj, orig_bone_name):
52
return (orig_bone_name,)
57
def main(obj, bone_definition, base_names, options):
58
""" A bone that tracks bakwards towards its parent, while copying the
59
location of it's target.
60
Deformation only (no controls).
62
# Verify required parameter
63
if "to" not in options:
64
raise RigifyError("'%s' rig type requires a 'to' parameter (bone: %s)" % (RIG_TYPE, base_names[0]))
65
if type(options["to"]) is not str:
66
raise RigifyError("'%s' rig type 'to' parameter must be a string (bone: %s)" % (RIG_TYPE, base_names[0]))
67
if ("ORG-" + options["to"]) not in obj.data.bones:
68
raise RigifyError("'%s' rig type 'to' parameter must name a bone in the metarig (bone: %s)" % (RIG_TYPE, base_names[0]))
70
eb = obj.data.edit_bones
74
bpy.ops.object.mode_set(mode='EDIT')
77
mbone1 = bone_definition[0]
78
mbone2 = "ORG-" + options["to"]
80
bone_e = copy_bone_simple(obj.data, mbone2, "DEF-%s.02" % base_names[bone_definition[0]])
81
bone_e.connected = False
82
bone_e.parent = eb[mbone1]
83
bone_e.tail = eb[mbone1].head
88
bpy.ops.object.mode_set(mode='OBJECT')
91
con = pb[bone].constraints.new('COPY_LOCATION')
93
con.subtarget = mbone2
95
con = pb[bone].constraints.new('DAMPED_TRACK')
97
con.subtarget = mbone1