Added a new function (member of the Ipo object) EvaluateCurveOn(int pos, float time) which returns the value of the ipo curve number pos at the given time.

Updated doc accordingly.
This commit is contained in:
2003-08-01 19:47:01 +00:00
parent 4ebd7f6301
commit 08c1fe6818
3 changed files with 47 additions and 11 deletions

View File

@@ -141,12 +141,11 @@ static PyObject *M_Ipo_Get(PyObject *self, PyObject *args)
static PyObject * M_Ipo_Recalc(PyObject *self, PyObject *args) static PyObject * M_Ipo_Recalc(PyObject *self, PyObject *args)
{ {
void testhandles_ipocurve(IpoCurve *icu); void testhandles_ipocurve(IpoCurve *icu);
PyObject *a;
IpoCurve *icu; IpoCurve *icu;
//C_IpoCurve *p = (C_IpoCurve*)args; if (!PyArg_ParseTuple(args, "O", &a))
icu = IpoCurve_FromPyObject(args); return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected ipo argument)"));
printf("%d\n",IpoCurve_CheckPyObject(args)); icu = IpoCurve_FromPyObject(a);
printf("%p\n",icu);
testhandles_ipocurve(icu); testhandles_ipocurve(icu);
Py_INCREF(Py_None); Py_INCREF(Py_None);
@@ -412,8 +411,9 @@ static PyObject *Ipo_setCurveBeztriple(C_Ipo *self, PyObject *args)
PyObject *listargs=0; PyObject *listargs=0;
if (!PyArg_ParseTuple(args, "iiO",&num,&pos,&listargs)) if (!PyArg_ParseTuple(args, "iiO",&num,&pos,&listargs))
return (EXPP_ReturnPyObjError (PyExc_TypeError, return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected int int object argument"));
"expected int argument")); if(!PyTuple_Check(listargs))
return (EXPP_ReturnPyObjError (PyExc_TypeError,"3rd arg should be a tuple"));
icu =self->ipo->curve.first; icu =self->ipo->curve.first;
if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve")); if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve"));
for(i = 0;i<num;i++) for(i = 0;i<num;i++)
@@ -430,7 +430,8 @@ static PyObject *Ipo_setCurveBeztriple(C_Ipo *self, PyObject *args)
for(i=0;i<9;i++) for(i=0;i<9;i++)
{ {
PyObject * xx = PyList_GetItem(listargs,i); PyObject * xx = PyTuple_GetItem(listargs,i);
printf("%f\n", PyFloat_AsDouble(xx));
ptrbt->vec[i/3][i%3] = PyFloat_AsDouble(xx); ptrbt->vec[i/3][i%3] = PyFloat_AsDouble(xx);
} }
@@ -441,14 +442,35 @@ static PyObject *Ipo_setCurveBeztriple(C_Ipo *self, PyObject *args)
static PyObject *Ipo_EvaluateCurveOn(C_Ipo *self, PyObject *args)
{
float eval_icu(IpoCurve *icu, float ipotime) ;
int num = 0,i;
IpoCurve *icu;
float time = 0;
if (!PyArg_ParseTuple(args, "if",&num,&time))
return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected int argument"));
icu =self->ipo->curve.first;
if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve"));
for(i = 0;i<num;i++)
{
if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"Bad ipo number"));
icu=icu->next;
}
return PyFloat_FromDouble(eval_icu(icu,time));
}
static PyObject *Ipo_getCurvecurval(C_Ipo *self, PyObject *args) static PyObject *Ipo_getCurvecurval(C_Ipo *self, PyObject *args)
{ {
int num = 0,i; int num = 0,i;
IpoCurve *icu; IpoCurve *icu;
if (!PyArg_ParseTuple(args, "i",&num)) if (!PyArg_ParseTuple(args, "i",&num))
return (EXPP_ReturnPyObjError (PyExc_TypeError, return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected int argument"));
"expected int argument"));
icu =self->ipo->curve.first; icu =self->ipo->curve.first;
if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve")); if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve"));
for(i = 0;i<num;i++) for(i = 0;i<num;i++)

View File

@@ -99,6 +99,7 @@ static PyObject *Ipo_getNBezPoints(C_Ipo *self, PyObject *args);
static PyObject *Ipo_DeleteBezPoints(C_Ipo *self, PyObject *args); static PyObject *Ipo_DeleteBezPoints(C_Ipo *self, PyObject *args);
static PyObject *Ipo_getCurveBP(C_Ipo *self, PyObject *args); static PyObject *Ipo_getCurveBP(C_Ipo *self, PyObject *args);
static PyObject *Ipo_getCurvecurval(C_Ipo *self, PyObject *args); static PyObject *Ipo_getCurvecurval(C_Ipo *self, PyObject *args);
static PyObject *Ipo_EvaluateCurveOn(C_Ipo *self, PyObject *args);
static PyObject *Ipo_setCurveBeztriple(C_Ipo *self, PyObject *args); static PyObject *Ipo_setCurveBeztriple(C_Ipo *self, PyObject *args);
@@ -131,6 +132,8 @@ static PyMethodDef C_Ipo_methods[] = {
"() - Return curve number of Bez points"}, "() - Return curve number of Bez points"},
{"getCurveBP", (PyCFunction)Ipo_getCurveBP, METH_VARARGS, {"getCurveBP", (PyCFunction)Ipo_getCurveBP, METH_VARARGS,
"() - Return Ipo ncurves"}, "() - Return Ipo ncurves"},
{"EvaluateCurveOn", (PyCFunction)Ipo_EvaluateCurveOn, METH_VARARGS,
"() - Return curve value at given time"},
{"getCurveCurval", (PyCFunction)Ipo_getCurvecurval, METH_VARARGS, {"getCurveCurval", (PyCFunction)Ipo_getCurvecurval, METH_VARARGS,
"() - Return curval"}, "() - Return curval"},
{"getCurveBeztriple", (PyCFunction)Ipo_getCurveBeztriple, METH_VARARGS, {"getCurveBeztriple", (PyCFunction)Ipo_getCurveBeztriple, METH_VARARGS,

View File

@@ -137,3 +137,14 @@ class Ipo:
@rtype: float @rtype: float
@return: the current value of the selected curve of the Ipo. @return: the current value of the selected curve of the Ipo.
""" """
def EvaluateCurveOn(curvepos,time):
"""
Gets the current value of a curve of the Ipo.
@type curvepos: int
@param curvepos: the position of the curve in the ipo
@type time: float
@param time: the position of the curve in the ipo
@rtype: float
@return: the current value of the selected curve of the Ipo at the given time.
"""