~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to release/scripts/modules/rigify/track_reverse.py

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# ##### BEGIN GPL LICENSE BLOCK #####
2
 
#
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.
7
 
#
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.
12
 
#
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.
16
 
#
17
 
# ##### END GPL LICENSE BLOCK #####
18
 
 
19
 
# <pep8 compliant>
20
 
 
21
 
import bpy
22
 
from rigify import RigifyError
23
 
from rigify_utils import copy_bone_simple
24
 
 
25
 
METARIG_NAMES = tuple()
26
 
RIG_TYPE = "track_reverse"
27
 
 
28
 
# TODO
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
33
 
#    arm = obj.data
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
37
 
#    bone.roll = 0.0000
38
 
#    bone.connected = False
39
 
#
40
 
#    bpy.ops.object.mode_set(mode='OBJECT')
41
 
#    pbone = obj.pose.bones['Bone']
42
 
#    pbone['type'] = 'copy'
43
 
 
44
 
bool_map = {0:False, 1:True,
45
 
            0.0:False, 1.0:True,
46
 
            "false":False, "true":True,
47
 
            "False":False, "True":True,
48
 
            "no":False, "yes":True,
49
 
            "No":False, "Yes":True}
50
 
 
51
 
def metarig_definition(obj, orig_bone_name):
52
 
    return (orig_bone_name,)
53
 
 
54
 
 
55
 
 
56
 
 
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).
61
 
    """
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]))
69
 
 
70
 
    eb = obj.data.edit_bones
71
 
    bb = obj.data.bones
72
 
    pb = obj.pose.bones
73
 
 
74
 
    bpy.ops.object.mode_set(mode='EDIT')
75
 
    arm = obj.data
76
 
 
77
 
    mbone1 = bone_definition[0]
78
 
    mbone2 = "ORG-" + options["to"]
79
 
 
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
84
 
    bone = bone_e.name
85
 
 
86
 
 
87
 
 
88
 
    bpy.ops.object.mode_set(mode='OBJECT')
89
 
 
90
 
    # Constraints
91
 
    con = pb[bone].constraints.new('COPY_LOCATION')
92
 
    con.target = obj
93
 
    con.subtarget = mbone2
94
 
 
95
 
    con = pb[bone].constraints.new('DAMPED_TRACK')
96
 
    con.target = obj
97
 
    con.subtarget = mbone1
98
 
 
99
 
 
100
 
    return tuple()