簡體   English   中英

修復幀上的 object position 以對其進行動畫處理

[英]Fix object position on frames to animate it

我想根據幀號在不同位置修復 object(例如 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()

問題

此代碼無法修復幀中的 object。 立方體在每次循環迭代時更改 position 但它不是逐幀固定的。 我想我需要將軌道與框架相關聯,但我還沒有找到執行此操作的文檔。

我想要的是

在每次循環迭代中,我想記錄一個 object position 作為“記錄活動對象”。

錄制按鈕

並自動創建出現在時間線上的軌道:

按時間線追蹤

問題

  • 如何將軌道鏈接到幀號?
  • 這是逐幀動畫立方體的好方法嗎?
  • 您是否有示例鏈接可以指導我在 python 中逐幀為 object 設置動畫?

謝謝

我在閱讀文檔時遺漏了一些東西,但我終於在此鏈接上找到了適合我需要的答案:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM