简体   繁体   English

Python FBX SDK – 如何缩放具有关键帧的模型?

[英]Python FBX SDK – How to scale models that have keyframes?

I am trying to script with Python FBX SDK to scale models.我正在尝试使用 Python FBX SDK 编写脚本来缩放模型。 And I am using LclScaling.Set() to set scale value.我正在使用LclScaling.Set()来设置比例值。 But I found if this model has keyframes, then the scaling is not applied.但是我发现如果这个 model 有关键帧,那么就不会应用缩放。

So my question is how to properly scale models that have keyframes.所以我的问题是如何正确缩放具有关键帧的模型。 Here is my code:这是我的代码:

scale = node.LclScaling.Get()
value = 0.5
node.LclScaling.Set(fbx.FbxDouble3(scale[0] * value, scale[1] * value, scale[2] * value))

In case you can't scale your model that already has animation keyframes, it seems that it has keyframes on a Scale parameter, even if scale is not changing during playback session.如果您无法缩放已经具有 animation 关键帧的 model,它似乎在Scale参数上有关键帧,即使在播放 Z21D6F40CFB511982E4424E0E250A9 期间比例没有变化。 That could be possible in situation when user animates just a position of a model pressing S shortcut.当用户按S快捷键为 model 的 position 设置动画时,这可能是可能的。 This shortcut generates 10 keyframes at a time, but only translation / rotation keyframes are important for you here.此快捷方式一次生成 10 个关键帧,但这里只有translation / rotation关键帧对您很重要。

在此处输入图像描述

Solution :解决方案

Delete redundant keyframes in Graph Editor manually or programmatically.手动或以编程方式删除图形编辑器中的冗余关键帧。

import maya.cmds as cmds

cmds.cutKey('pSphere1', time=(1,100), attribute='scaleX', option="keys")
cmds.cutKey('pSphere1', time=(1,100), attribute='scaleY', option="keys")
cmds.cutKey('pSphere1', time=(1,100), attribute='scaleZ', option="keys")

After this you can easily scale your model.在此之后,您可以轻松扩展 model。

PS附言

The other appropriate way is to update old scale keyframes for FBX model (first in the beginning and second in the end of animation).另一种适当的方法是更新 FBX model 的旧比例关键帧(首先在动画开始,然后在动画结束)。

I figured it out.我想到了。 In Maya, if I set translate or rotate keyframes, the scale property would also has Animation Node in FBX SDK.在 Maya 中,如果我设置平移或旋转关键帧,缩放属性也会在 FBX SDK 中具有 Animation 节点。 So, if I want to modify scale property, I should use SetChannelValue or FbxAnimCurveFilterScale instead of LclScaling.Set()所以,如果我想修改 scale 属性,我应该使用SetChannelValueFbxAnimCurveFilterScale而不是LclScaling.Set()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM