【问题标题】:Exporting keyframes in blender python在搅拌机python中导出关键帧
【发布时间】:2010-11-19 09:41:47
【问题描述】:

我正在尝试从搅拌机中导出动画,这是我目前所做的:
--- 这只是为了让您了解我在做什么,为了简短起见,我遗漏了很多内容。
--- 如果它太混乱或者如果需要,我可以发布整个源代码。

# Get the armature  
arm = ob.getData()  
# Start at the root bone  
for bone in bones:  
    if not bone.parent:  
        traceBone(bone)  

def traceBone(bone):
  # Get the channel for this bone
  channel=action.getChannelIpo(bone.name);

  # Get the loc x, y, z channels
  c_locx=channel[Ipo.OB_LOCX].bezierPoints
  frameCount=len(c_locx)

  # Write each location frame
  for frameIndex in  range(frameCount):
    frame_x=c_locx[frameIndex].pt
    frameTime=int(frame_x[0]-1)
    # Write the time of the frame
    writeInt(frameTime)
    # Write the x, y and z coordinates
    writeFloats(frame_x[1], frame_z[1], frame_y[1])

  # Iv'e done the same for rotation
  c_quatx=channel[Ipo.PO_QUATX].bezierPoints
  # Write the quaternion w, x, y and z values
  writeFloats(frame_w[1], frame_x[1], frame_z[1], frame_y[1])

  # Go through the children
  for child in bone.children:
    traceBone(child)  

据我所知,这一切正常,问题是这些值是偏移量, 表示变化,但我需要的是表示骨骼相对于其父级的位置和旋转值的绝对值。

如何获得相对于其父级的位置和旋转?

【问题讨论】:

  • 哇,我有一段时间没看到搅拌机代码了。你在blenderartists.org/forum 可能会比这里更成功。
  • 您拥有的邮政编码。或者如果您解决了问题,则可以使用工作代码。

标签: python 3d blender


【解决方案1】:

通道数据应应用在绑定姿势矩阵之上。

完整的公式如下:

先生 = 女士 * B0*P0 * B1*P1 ... Bn*Pn

地点:

Mr = 骨骼“n”的结果矩阵

Ms = 骨架->世界矩阵

Bi = 绑定骨骼“i”的姿势矩阵

Pi = 构成从存储通道(您正在导出的通道)构造的实际矩阵

“n-1”是“n”的父骨骼,“n-2”是“n-1”的父骨骼,...,“0”是“1”的父骨骼

【讨论】:

    猜你喜欢
    • 2012-02-07
    • 2018-09-25
    • 2016-08-17
    • 1970-01-01
    • 2012-02-02
    • 1970-01-01
    • 2017-09-03
    • 2020-01-06
    • 2017-06-15
    相关资源
    最近更新 更多