[英]Fix object position on frames to animate it
I would like to fix an object (for example an Ocube) at different positions depending of the frame number.我想根据帧号在不同位置修复 object(例如 Ocube)。
Here is my code, inspired by tutorials I've found ( https://github.com/PluginCafe/cinema4d_py_sdk_extended )这是我的代码,灵感来自我找到的教程( 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()
Problem :问题:
This code doesn't fix object in frames.此代码无法修复帧中的 object。 The cube change position at each loop iteration but it's not fixed frame by frame.
立方体在每次循环迭代时更改 position 但它不是逐帧固定的。 I guess I need to associated the track to a frame but I haven't found documentation to do this.
我想我需要将轨道与框架相关联,但我还没有找到执行此操作的文档。
What I want我想要的是
At each loop iteration, I want to reccord a object position as the "Reccord Active Objects" do.在每次循环迭代中,我想记录一个 object position 作为“记录活动对象”。
And automatically create a track as it appears on the timeline:并自动创建出现在时间线上的轨道:
Questions :问题:
Thanks谢谢
I was missing something when I read the documentation but I finally found an answer that fit my need at this link:我在阅读文档时遗漏了一些东西,但我终于在此链接上找到了适合我需要的答案:
https://github.com/PluginCafe/cinema4d_py_sdk_extended/blob/master/scripts/04_3d_concepts/scene_elements/animation/ctrack_create_keys_r13.py 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.