@@ -138,6 +138,108 @@ static PyObject *py_ue_fbx_object_key_get_seconds(ue_PyFbxObject *self, PyObject
138138 return PyFloat_FromDouble (fbx_anim_curve->KeyGetTime (index).GetSecondDouble ());
139139}
140140
141+ static PyObject *py_ue_fbx_object_key_get_left_tangent (ue_PyFbxObject *self, PyObject *args) {
142+ int index;
143+ if (!PyArg_ParseTuple (args, " i" , &index)) {
144+ return nullptr ;
145+ }
146+ FbxAnimCurve *fbx_anim_curve = FbxCast<FbxAnimCurve>(self->fbx_object );
147+ if (!fbx_anim_curve)
148+ return PyErr_Format (PyExc_Exception, " object is not a FbxAnimCurve" );
149+ return PyFloat_FromDouble (fbx_anim_curve->KeyGetLeftDerivative (index));
150+ }
151+
152+ static PyObject *py_ue_fbx_object_key_get_right_tangent (ue_PyFbxObject *self, PyObject *args) {
153+ int index;
154+ if (!PyArg_ParseTuple (args, " i" , &index)) {
155+ return nullptr ;
156+ }
157+ FbxAnimCurve *fbx_anim_curve = FbxCast<FbxAnimCurve>(self->fbx_object );
158+ if (!fbx_anim_curve)
159+ return PyErr_Format (PyExc_Exception, " object is not a FbxAnimCurve" );
160+ return PyFloat_FromDouble (fbx_anim_curve->KeyGetRightDerivative (index));
161+ }
162+
163+ static PyObject *py_ue_fbx_object_key_get_interp_mode (ue_PyFbxObject *self, PyObject *args) {
164+ int index;
165+ if (!PyArg_ParseTuple (args, " i" , &index)) {
166+ return nullptr ;
167+ }
168+ FbxAnimCurve *fbx_anim_curve = FbxCast<FbxAnimCurve>(self->fbx_object );
169+ if (!fbx_anim_curve)
170+ return PyErr_Format (PyExc_Exception, " object is not a FbxAnimCurve" );
171+
172+ ERichCurveInterpMode Mode = RCIM_Linear;
173+ // Convert the interpolation type from FBX to Unreal.
174+ switch (fbx_anim_curve->KeyGetInterpolation (index))
175+ {
176+ case FbxAnimCurveDef::eInterpolationCubic:
177+ Mode = RCIM_Cubic;
178+ break ;
179+
180+ case FbxAnimCurveDef::eInterpolationConstant:
181+ if (fbx_anim_curve->KeyGetTangentMode (index) != (FbxAnimCurveDef::ETangentMode)FbxAnimCurveDef::eConstantStandard)
182+ {
183+ // warning not support
184+ ;
185+ }
186+ Mode = RCIM_Constant;
187+ break ;
188+
189+ case FbxAnimCurveDef::eInterpolationLinear:
190+ Mode = RCIM_Linear;
191+ break ;
192+ }
193+
194+ return PyLong_FromUnsignedLong (uint64 (Mode));
195+ }
196+
197+ static PyObject *py_ue_fbx_object_key_get_tangent_mode (ue_PyFbxObject *self, PyObject *args) {
198+ int index;
199+ if (!PyArg_ParseTuple (args, " i" , &index)) {
200+ return nullptr ;
201+ }
202+ FbxAnimCurve *fbx_anim_curve = FbxCast<FbxAnimCurve>(self->fbx_object );
203+ if (!fbx_anim_curve)
204+ return PyErr_Format (PyExc_Exception, " object is not a FbxAnimCurve" );
205+
206+ ERichCurveTangentMode Mode = RCTM_Auto;
207+ // Convert the interpolation type from FBX to Unreal.
208+ if ( fbx_anim_curve->KeyGetInterpolation (index) ==
209+ FbxAnimCurveDef::eInterpolationCubic )
210+ {
211+ switch (fbx_anim_curve->KeyGetTangentMode (index))
212+ {
213+ // Auto tangents will now be imported as user tangents to allow the
214+ // user to modify them without inadvertently resetting other tangents
215+ // case KFbxAnimCurveDef::eTANGENT_AUTO:
216+ // if ((KFbxAnimCurveDef::eTANGENT_GENERIC_CLAMP & FbxKey.GetTangentMode(true)))
217+ // {
218+ // Mode = CIM_CurveAutoClamped;
219+ // }
220+ // else
221+ // {
222+ // Mode = CIM_CurveAuto;
223+ // }
224+ // break;
225+ case FbxAnimCurveDef::eTangentBreak:
226+ Mode = RCTM_Break;
227+ break ;
228+ case FbxAnimCurveDef::eTangentAuto:
229+ Mode = RCTM_Auto;
230+ break ;
231+ case FbxAnimCurveDef::eTangentUser:
232+ case FbxAnimCurveDef::eTangentTCB:
233+ Mode = RCTM_User;
234+ break ;
235+ default :
236+ break ;
237+ }
238+ }
239+
240+ return PyLong_FromUnsignedLong (uint64 (Mode));
241+ }
242+
141243static PyMethodDef ue_PyFbxObject_methods[] = {
142244 { " get_member_count" , (PyCFunction)py_ue_fbx_object_get_member_count, METH_VARARGS, " " },
143245 { " get_member" , (PyCFunction)py_ue_fbx_object_get_member, METH_VARARGS, " " },
@@ -153,6 +255,10 @@ static PyMethodDef ue_PyFbxObject_methods[] = {
153255 { " key_get_count" , (PyCFunction)py_ue_fbx_object_key_get_count, METH_VARARGS, " " },
154256 { " key_get_value" , (PyCFunction)py_ue_fbx_object_key_get_value, METH_VARARGS, " " },
155257 { " key_get_seconds" , (PyCFunction)py_ue_fbx_object_key_get_seconds, METH_VARARGS, " " },
258+ { " key_get_left_tangent" , (PyCFunction)py_ue_fbx_object_key_get_left_tangent, METH_VARARGS, " " },
259+ { " key_get_right_tangent" , (PyCFunction)py_ue_fbx_object_key_get_right_tangent, METH_VARARGS, " " },
260+ { " key_get_interp_mode" , (PyCFunction)py_ue_fbx_object_key_get_interp_mode, METH_VARARGS, " " },
261+ { " key_get_tangent_mode" , (PyCFunction)py_ue_fbx_object_key_get_tangent_mode, METH_VARARGS, " " },
156262 { NULL } /* Sentinel */
157263};
158264
0 commit comments