Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Guignot <guignot@wanadoo.fr>2003-08-01 23:47:01 +0400
committerJacques Guignot <guignot@wanadoo.fr>2003-08-01 23:47:01 +0400
commit08c1fe681830c660df9a21e7824b83d21c4164da (patch)
treef1a4f5bf9f45f359ea50cb387f2be3810fb74d1a /source/blender/python
parent4ebd7f6301d5fdaab3c7d14415cacb743249eb47 (diff)
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.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/api2_2x/Ipo.c44
-rw-r--r--source/blender/python/api2_2x/Ipo.h3
-rw-r--r--source/blender/python/api2_2x/doc/Ipo.py11
3 files changed, 47 insertions, 11 deletions
diff --git a/source/blender/python/api2_2x/Ipo.c b/source/blender/python/api2_2x/Ipo.c
index 9673a1ae44e..1c506199324 100644
--- a/source/blender/python/api2_2x/Ipo.c
+++ b/source/blender/python/api2_2x/Ipo.c
@@ -141,12 +141,11 @@ static PyObject *M_Ipo_Get(PyObject *self, PyObject *args)
static PyObject * M_Ipo_Recalc(PyObject *self, PyObject *args)
{
void testhandles_ipocurve(IpoCurve *icu);
-
-IpoCurve *icu;
- //C_IpoCurve *p = (C_IpoCurve*)args;
- icu = IpoCurve_FromPyObject(args);
- printf("%d\n",IpoCurve_CheckPyObject(args));
- printf("%p\n",icu);
+ PyObject *a;
+IpoCurve *icu;
+if (!PyArg_ParseTuple(args, "O", &a))
+ return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected ipo argument)"));
+icu = IpoCurve_FromPyObject(a);
testhandles_ipocurve(icu);
Py_INCREF(Py_None);
@@ -412,8 +411,9 @@ static PyObject *Ipo_setCurveBeztriple(C_Ipo *self, PyObject *args)
PyObject *listargs=0;
if (!PyArg_ParseTuple(args, "iiO",&num,&pos,&listargs))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument"));
+ return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected int int object argument"));
+ if(!PyTuple_Check(listargs))
+return (EXPP_ReturnPyObjError (PyExc_TypeError,"3rd arg should be a tuple"));
icu =self->ipo->curve.first;
if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve"));
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++)
{
- 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);
}
@@ -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)
{
int num = 0,i;
IpoCurve *icu;
if (!PyArg_ParseTuple(args, "i",&num))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument"));
+ 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++)
diff --git a/source/blender/python/api2_2x/Ipo.h b/source/blender/python/api2_2x/Ipo.h
index eaa71dbe4d1..1b36c725449 100644
--- a/source/blender/python/api2_2x/Ipo.h
+++ b/source/blender/python/api2_2x/Ipo.h
@@ -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_getCurveBP(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);
@@ -131,6 +132,8 @@ static PyMethodDef C_Ipo_methods[] = {
"() - Return curve number of Bez points"},
{"getCurveBP", (PyCFunction)Ipo_getCurveBP, METH_VARARGS,
"() - Return Ipo ncurves"},
+ {"EvaluateCurveOn", (PyCFunction)Ipo_EvaluateCurveOn, METH_VARARGS,
+ "() - Return curve value at given time"},
{"getCurveCurval", (PyCFunction)Ipo_getCurvecurval, METH_VARARGS,
"() - Return curval"},
{"getCurveBeztriple", (PyCFunction)Ipo_getCurveBeztriple, METH_VARARGS,
diff --git a/source/blender/python/api2_2x/doc/Ipo.py b/source/blender/python/api2_2x/doc/Ipo.py
index fc2cb144eff..0368e0209e1 100644
--- a/source/blender/python/api2_2x/doc/Ipo.py
+++ b/source/blender/python/api2_2x/doc/Ipo.py
@@ -137,3 +137,14 @@ class Ipo:
@rtype: float
@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.
+ """