Вход/Регистрация
Введение в написание скриптов на Питоне для Блендера 2.5x. Примеры кода
вернуться

Larsson Thomas

Шрифт:

status = Frames

frame = 0

t = 0

bpy.ops.object.mode_set(mode='POSE')

pbones = rig.pose.bones

for pb in pbones:

pb.rotation_mode = 'QUATERNION'

elif status == Frames:

addFrame(words, frame, nodes, pbones, scale)

t += frameTime

frame += 1

fp.close

time2 = time.clock

print("Bvh file loaded in %.3f s" % (time2-time1))

return rig 

#

# channelYup(word):

# channelZup(word):

#

def channelYup(word):

if word == 'Xrotation':

return ('X', Rotation, +1)

elif word == 'Yrotation':

return ('Y', Rotation, +1)

elif word == 'Zrotation':

return ('Z', Rotation, +1)

elif word == 'Xposition':

return (0, Location, +1)

elif word == 'Yposition':

return (1, Location, +1)

elif word == 'Zposition':

return (2, Location, +1)

def channelZup(word):

if word == 'Xrotation':

return ('X', Rotation, +1)

elif word == 'Yrotation':

return ('Z', Rotation, +1)

elif word == 'Zrotation':

return ('Y', Rotation, -1)

elif word == 'Xposition':

return (0, Location, +1)

elif word == 'Yposition':

return (2, Location, +1)

elif word == 'Zposition':

return (1, Location, -1)

#

# addFrame(words, frame, nodes, pbones, scale):

#

def addFrame(words, frame, nodes, pbones, scale):

m = 0

for node in nodes:

name = node.name

try:

pb = pbones[name]

except:

pb = None

if pb:

for (mode, indices) in node.channels:

if mode == Location:

vec = Vector((0,0,0))

for (index, sign) in indices:

vec[index] = sign*float(words[m])

m += 1

pb.location = (scale * vec - node.head) * node.inverse

for n in range(3):

pb.keyframe_insert('location', index=n, frame=frame, group=name)

elif mode == Rotation:

mats = []

for (axis, sign) in indices:

angle = sign*float(words[m])*Deg2Rad

mats.append(Matrix.Rotation(angle, 3, axis))

m += 1

mat = node.inverse * mats[0] * mats[1] * mats[2] * node.matrix

pb.rotation_quaternion = mat.to_quaternion

for n in range(4):

pb.keyframe_insert('rotation_quaternion',

index=n, frame=frame, group=name)

  • Читать дальше
  • 1
  • ...
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • ...

Ебукер (ebooker) – онлайн-библиотека на русском языке. Книги доступны онлайн, без утомительной регистрации. Огромный выбор и удобный дизайн, позволяющий читать без проблем. Добавляйте сайт в закладки! Все произведения загружаются пользователями: если считаете, что ваши авторские права нарушены – используйте форму обратной связи.

Полезные ссылки

  • Моя полка

Контакты

  • chitat.ebooker@gmail.com

Подпишитесь на рассылку: