【问题标题】:Fix object position on frames to animate it修复帧上的对象位置以对其进行动画处理
【发布时间】:2022-01-02 06:26:28
【问题描述】:

我想根据帧数将对象(例如 Ocube)固定在不同的位置。

这是我的代码,灵感来自我找到的教程 (https://github.com/PluginCafe/cinema4d_py_sdk_extended)


    # Creates the object in memory
    obj = c4d.BaseObject(c4d.Ocube)
    
    # Retrieves BaseTime of frame 0, 20
    start = 0
    end = 20

    # Loops through the frames
    for frame in range(start, end + 1):
    
        # Move the cube to some position
        obj.SetRelPos(c4d.Vector(20+frame*20))

        # Creates the track in memory. Defined by it's DescID
        trackY = c4d.CTrack(obj, c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_REL_POSITION, c4d.DTYPE_VECTOR, 0),
                                            c4d.DescLevel(c4d.VECTOR_Y, c4d.DTYPE_REAL, 0)))
                                           
        # Inserts the track 
        obj.InsertTrackSorted(trackY)

    # Inserts the object in document
    doc.InsertObject(obj)

    # Pushes an update event to Cinema 4D
    c4d.EventAdd()

问题

此代码不会修复帧中的对象。立方体在每次循环迭代时改变位置,但它不是逐帧固定的。我想我需要将轨道与帧相关联,但我还没有找到相关文档。

我想要什么

在每次循环迭代中,我想像“记录活动对象”那样记录对象位置。

并自动创建出现在时间线上的轨道:

问题

  • 如何将轨道链接到帧号?
  • 是逐帧动画立方体的好方法吗?
  • 您是否有示例链接可以指导我在 python 中逐帧动画对象?

谢谢

【问题讨论】:

    标签: python cinema-4d


    【解决方案1】:

    我在阅读文档时遗漏了一些东西,但我终于在此链接上找到了适合我需要的答案:

    https://github.com/PluginCafe/cinema4d_py_sdk_extended/blob/master/scripts/04_3d_concepts/scene_elements/animation/ctrack_create_keys_r13.py

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-09
      • 1970-01-01
      • 2017-04-10
      • 1970-01-01
      相关资源
      最近更新 更多