71
71
/*****************************************************************************/
73
73
struct PyMethodDef M_Ipo_methods[] = {
74
{"New", (PyCFunction) M_Ipo_New, METH_VARARGS | METH_KEYWORDS,
76
{"Get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc},
77
{"get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc},
78
{"Recalc", M_Ipo_Recalc, METH_VARARGS, M_Ipo_Get_doc},
74
{"New", ( PyCFunction ) M_Ipo_New, METH_VARARGS | METH_KEYWORDS,
76
{"Get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc},
77
{"get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc},
78
{"Recalc", M_Ipo_Recalc, METH_VARARGS, M_Ipo_Get_doc},
82
82
/*****************************************************************************/
83
83
/* Python BPy_Ipo methods declarations: */
84
84
/*****************************************************************************/
85
static PyObject *Ipo_getName (BPy_Ipo * self);
86
static PyObject *Ipo_setName (BPy_Ipo * self, PyObject * args);
87
static PyObject *Ipo_getBlocktype (BPy_Ipo * self);
88
static PyObject *Ipo_setBlocktype (BPy_Ipo * self, PyObject * args);
89
static PyObject *Ipo_getRctf (BPy_Ipo * self);
90
static PyObject *Ipo_setRctf (BPy_Ipo * self, PyObject * args);
92
static PyObject *Ipo_getCurve (BPy_Ipo * self, PyObject * args);
93
static PyObject *Ipo_getCurves (BPy_Ipo * self);
94
static PyObject *Ipo_addCurve (BPy_Ipo * self, PyObject * args);
95
static PyObject *Ipo_getNcurves (BPy_Ipo * self);
96
static PyObject *Ipo_getNBezPoints (BPy_Ipo * self, PyObject * args);
97
static PyObject *Ipo_DeleteBezPoints (BPy_Ipo * self, PyObject * args);
98
static PyObject *Ipo_getCurveBP (BPy_Ipo * self, PyObject * args);
99
static PyObject *Ipo_getCurvecurval (BPy_Ipo * self, PyObject * args);
100
static PyObject *Ipo_EvaluateCurveOn (BPy_Ipo * self, PyObject * args);
103
static PyObject *Ipo_setCurveBeztriple (BPy_Ipo * self, PyObject * args);
104
static PyObject *Ipo_getCurveBeztriple (BPy_Ipo * self, PyObject * args);
85
static PyObject *Ipo_getName( BPy_Ipo * self );
86
static PyObject *Ipo_setName( BPy_Ipo * self, PyObject * args );
87
static PyObject *Ipo_getBlocktype( BPy_Ipo * self );
88
static PyObject *Ipo_setBlocktype( BPy_Ipo * self, PyObject * args );
89
static PyObject *Ipo_getRctf( BPy_Ipo * self );
90
static PyObject *Ipo_setRctf( BPy_Ipo * self, PyObject * args );
92
static PyObject *Ipo_getCurve( BPy_Ipo * self, PyObject * args );
93
static PyObject *Ipo_getCurves( BPy_Ipo * self );
94
static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * args );
95
static PyObject *Ipo_delCurve( BPy_Ipo * self, PyObject * args );
96
static PyObject *Ipo_getNcurves( BPy_Ipo * self );
97
static PyObject *Ipo_getNBezPoints( BPy_Ipo * self, PyObject * args );
98
static PyObject *Ipo_DeleteBezPoints( BPy_Ipo * self, PyObject * args );
99
static PyObject *Ipo_getCurveBP( BPy_Ipo * self, PyObject * args );
100
static PyObject *Ipo_getCurvecurval( BPy_Ipo * self, PyObject * args );
101
static PyObject *Ipo_EvaluateCurveOn( BPy_Ipo * self, PyObject * args );
104
static PyObject *Ipo_setCurveBeztriple( BPy_Ipo * self, PyObject * args );
105
static PyObject *Ipo_getCurveBeztriple( BPy_Ipo * self, PyObject * args );
106
107
/*****************************************************************************/
107
108
/* Python BPy_Ipo methods table: */
108
109
/*****************************************************************************/
109
110
static PyMethodDef BPy_Ipo_methods[] = {
110
/* name, method, flags, doc */
111
{"getName", (PyCFunction) Ipo_getName, METH_NOARGS,
112
"() - Return Ipo Data name"},
113
{"setName", (PyCFunction) Ipo_setName, METH_VARARGS,
114
"(str) - Change Ipo Data name"},
115
{"getBlocktype", (PyCFunction) Ipo_getBlocktype, METH_NOARGS,
116
"() - Return Ipo blocktype -"},
117
{"setBlocktype", (PyCFunction) Ipo_setBlocktype, METH_VARARGS,
118
"(str) - Change Ipo blocktype"},
119
{"getRctf", (PyCFunction) Ipo_getRctf, METH_NOARGS,
120
"() - Return Ipo rctf - "},
121
{"setRctf", (PyCFunction) Ipo_setRctf, METH_VARARGS,
122
"(str) - Change Ipo rctf"},
123
{"addCurve", (PyCFunction) Ipo_addCurve, METH_VARARGS,
124
"() - Return Ipo ncurves"},
125
{"getNcurves", (PyCFunction) Ipo_getNcurves, METH_NOARGS,
126
"() - Return Ipo ncurves"},
127
{"getNBezPoints", (PyCFunction) Ipo_getNBezPoints, METH_VARARGS,
128
"() - Return curve number of Bez points"},
129
{"delBezPoint", (PyCFunction) Ipo_DeleteBezPoints, METH_VARARGS,
130
"() - Return curve number of Bez points"},
131
{"getCurveBP", (PyCFunction) Ipo_getCurveBP, METH_VARARGS,
132
"() - Return Ipo ncurves"},
133
{"EvaluateCurveOn", (PyCFunction) Ipo_EvaluateCurveOn, METH_VARARGS,
134
"() - Return curve value at given time"},
135
{"getCurveCurval", (PyCFunction) Ipo_getCurvecurval, METH_VARARGS,
136
"() - Return curval"},
137
{"getCurveBeztriple", (PyCFunction) Ipo_getCurveBeztriple, METH_VARARGS,
138
"() - Return Ipo ncurves"},
139
{"setCurveBeztriple", (PyCFunction) Ipo_setCurveBeztriple, METH_VARARGS,
140
"() - Return curval"},
141
{"getCurves", (PyCFunction) Ipo_getCurves, METH_NOARGS,
142
"() - Return curval"},
143
{"getCurve", (PyCFunction) Ipo_getCurve, METH_VARARGS,
144
"() - Return curval"},
145
{NULL, NULL, 0, NULL}
111
/* name, method, flags, doc */
112
{"getName", ( PyCFunction ) Ipo_getName, METH_NOARGS,
113
"() - Return Ipo Data name"},
114
{"setName", ( PyCFunction ) Ipo_setName, METH_VARARGS,
115
"(str) - Change Ipo Data name"},
116
{"getBlocktype", ( PyCFunction ) Ipo_getBlocktype, METH_NOARGS,
117
"() - Return Ipo blocktype -"},
118
{"setBlocktype", ( PyCFunction ) Ipo_setBlocktype, METH_VARARGS,
119
"(str) - Change Ipo blocktype"},
120
{"getRctf", ( PyCFunction ) Ipo_getRctf, METH_NOARGS,
121
"() - Return Ipo rctf - "},
122
{"setRctf", ( PyCFunction ) Ipo_setRctf, METH_VARARGS,
123
"(str) - Change Ipo rctf"},
124
{"addCurve", ( PyCFunction ) Ipo_addCurve, METH_VARARGS,
125
"() - Return Ipo ncurves"},
126
{"delCurve", ( PyCFunction ) Ipo_delCurve, METH_VARARGS,
127
"() - Delete Ipo curves"},
128
{"getNcurves", ( PyCFunction ) Ipo_getNcurves, METH_NOARGS,
129
"() - Return Ipo ncurves"},
130
{"getNBezPoints", ( PyCFunction ) Ipo_getNBezPoints, METH_VARARGS,
131
"() - Return curve number of Bez points"},
132
{"delBezPoint", ( PyCFunction ) Ipo_DeleteBezPoints, METH_VARARGS,
133
"() - Return curve number of Bez points"},
134
{"getCurveBP", ( PyCFunction ) Ipo_getCurveBP, METH_VARARGS,
135
"() - Return Ipo ncurves"},
136
{"EvaluateCurveOn", ( PyCFunction ) Ipo_EvaluateCurveOn, METH_VARARGS,
137
"() - Return curve value at given time"},
138
{"getCurveCurval", ( PyCFunction ) Ipo_getCurvecurval, METH_VARARGS,
139
"() - Return curval"},
140
{"getCurveBeztriple", ( PyCFunction ) Ipo_getCurveBeztriple,
142
"() - Return Ipo ncurves"},
143
{"setCurveBeztriple", ( PyCFunction ) Ipo_setCurveBeztriple,
145
"() - Return curval"},
146
{"getCurves", ( PyCFunction ) Ipo_getCurves, METH_NOARGS,
147
"() - Return curval"},
148
{"getCurve", ( PyCFunction ) Ipo_getCurve, METH_VARARGS,
149
"() - Return curval"},
150
{NULL, NULL, 0, NULL}
148
153
/*****************************************************************************/
149
154
/* Python Ipo_Type callback function prototypes: */
150
155
/*****************************************************************************/
151
static void IpoDeAlloc (BPy_Ipo * self);
156
static void IpoDeAlloc( BPy_Ipo * self );
152
157
//static int IpoPrint (BPy_Ipo *self, FILE *fp, int flags);
153
static int IpoSetAttr (BPy_Ipo * self, char *name, PyObject * v);
154
static PyObject *IpoGetAttr (BPy_Ipo * self, char *name);
155
static PyObject *IpoRepr (BPy_Ipo * self);
158
static int IpoSetAttr( BPy_Ipo * self, char *name, PyObject * v );
159
static PyObject *IpoGetAttr( BPy_Ipo * self, char *name );
160
static PyObject *IpoRepr( BPy_Ipo * self );
157
162
/*****************************************************************************/
158
163
/* Python Ipo_Type structure definition: */
159
164
/*****************************************************************************/
160
165
PyTypeObject Ipo_Type = {
161
PyObject_HEAD_INIT (NULL) 0, /* ob_size */
163
sizeof (BPy_Ipo), /* tp_basicsize */
166
(destructor) IpoDeAlloc, /* tp_dealloc */
168
(getattrfunc) IpoGetAttr, /* tp_getattr */
169
(setattrfunc) IpoSetAttr, /* tp_setattr */
171
(reprfunc) IpoRepr, /* tp_repr */
172
0, /* tp_as_number */
173
0, /* tp_as_sequence */
174
0, /* tp_as_mapping */
179
BPy_Ipo_methods, /* tp_methods */
166
PyObject_HEAD_INIT( NULL ) /* required macro */ 0, /* ob_size */
168
sizeof( BPy_Ipo ), /* tp_basicsize */
171
( destructor ) IpoDeAlloc, /* tp_dealloc */
173
( getattrfunc ) IpoGetAttr, /* tp_getattr */
174
( setattrfunc ) IpoSetAttr, /* tp_setattr */
176
( reprfunc ) IpoRepr, /* tp_repr */
177
0, /* tp_as_number */
178
0, /* tp_as_sequence */
179
0, /* tp_as_mapping */
184
BPy_Ipo_methods, /* tp_methods */
183
188
/*****************************************************************************/
241
259
/* passed in, a list of all ipo data names in the */
242
260
/* current scene is returned. */
243
261
/*****************************************************************************/
245
M_Ipo_Get (PyObject * self, PyObject * args)
262
static PyObject *M_Ipo_Get( PyObject * self, PyObject * args )
249
PyObject *ipolist, *pyobj;
250
BPy_Ipo *wanted_ipo = NULL;
253
if (!PyArg_ParseTuple (args, "|s", &name))
254
return (EXPP_ReturnPyObjError (PyExc_TypeError,
255
"expected string argument (or nothing)"));
257
ipo_iter = G.main->ipo.first;
260
{ /* (name) - Search ipo by name */
261
while ((ipo_iter) && (wanted_ipo == NULL))
263
if (strcmp (name, ipo_iter->id.name + 2) == 0)
265
wanted_ipo = (BPy_Ipo *) PyObject_NEW (BPy_Ipo, &Ipo_Type);
267
wanted_ipo->ipo = ipo_iter;
269
ipo_iter = ipo_iter->id.next;
272
if (wanted_ipo == NULL)
273
{ /* Requested ipo doesn't exist */
274
PyOS_snprintf (error_msg, sizeof (error_msg),
275
"Ipo \"%s\" not found", name);
276
return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg));
279
return (PyObject *) wanted_ipo;
283
{ /* () - return a list with all ipos in the scene */
286
ipolist = PyList_New (BLI_countlist (&(G.main->ipo)));
289
return (PythonReturnErrorObject (PyExc_MemoryError,
290
"couldn't create PyList"));
294
pyobj = Ipo_CreatePyObject (ipo_iter);
297
return (PythonReturnErrorObject (PyExc_MemoryError,
298
"couldn't create PyString"));
300
PyList_SET_ITEM (ipolist, index, pyobj);
302
ipo_iter = ipo_iter->id.next;
266
PyObject *ipolist, *pyobj;
267
BPy_Ipo *wanted_ipo = NULL;
270
if( !PyArg_ParseTuple( args, "|s", &name ) )
271
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
272
"expected string argument (or nothing)" ) );
274
ipo_iter = G.main->ipo.first;
276
if( name ) { /* (name) - Search ipo by name */
277
while( ( ipo_iter ) && ( wanted_ipo == NULL ) ) {
278
if( strcmp( name, ipo_iter->id.name + 2 ) == 0 ) {
280
( BPy_Ipo * ) PyObject_NEW( BPy_Ipo,
283
wanted_ipo->ipo = ipo_iter;
285
ipo_iter = ipo_iter->id.next;
288
if( wanted_ipo == NULL ) { /* Requested ipo doesn't exist */
289
PyOS_snprintf( error_msg, sizeof( error_msg ),
290
"Ipo \"%s\" not found", name );
291
return ( EXPP_ReturnPyObjError
292
( PyExc_NameError, error_msg ) );
295
return ( PyObject * ) wanted_ipo;
298
else { /* () - return a list with all ipos in the scene */
301
ipolist = PyList_New( BLI_countlist( &( G.main->ipo ) ) );
303
if( ipolist == NULL )
304
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
305
"couldn't create PyList" ) );
308
pyobj = Ipo_CreatePyObject( ipo_iter );
311
return ( EXPP_ReturnPyObjError
313
"couldn't create PyString" ) );
315
PyList_SET_ITEM( ipolist, index, pyobj );
317
ipo_iter = ipo_iter->id.next;
312
M_Ipo_Recalc (PyObject * self, PyObject * args)
326
static PyObject *M_Ipo_Recalc( PyObject * self, PyObject * args )
314
void testhandles_ipocurve (IpoCurve * icu);
317
if (!PyArg_ParseTuple (args, "O", &a))
318
return (EXPP_ReturnPyObjError
319
(PyExc_TypeError, "expected ipo argument)"));
320
icu = IpoCurve_FromPyObject (a);
321
testhandles_ipocurve (icu);
328
void testhandles_ipocurve( IpoCurve * icu );
331
if( !PyArg_ParseTuple( args, "O", &a ) )
332
return ( EXPP_ReturnPyObjError
333
( PyExc_TypeError, "expected ipo argument)" ) );
334
icu = IpoCurve_FromPyObject( a );
335
testhandles_ipocurve( icu );
337
Py_INCREF( Py_None );
328
342
/*****************************************************************************/
329
343
/* Function: Ipo_Init */
330
344
/*****************************************************************************/
345
PyObject *Ipo_Init( void )
336
Ipo_Type.ob_type = &PyType_Type;
338
submodule = Py_InitModule3 ("Blender.Ipo", M_Ipo_methods, M_Ipo_doc);
349
Ipo_Type.ob_type = &PyType_Type;
351
submodule = Py_InitModule3( "Blender.Ipo", M_Ipo_methods, M_Ipo_doc );
353
return ( submodule );
343
356
/*****************************************************************************/
344
357
/* Python BPy_Ipo methods: */
345
358
/*****************************************************************************/
347
Ipo_getName (BPy_Ipo * self)
349
PyObject *attr = PyString_FromString (self->ipo->id.name + 2);
359
Ipo_setName (BPy_Ipo * self, PyObject * args)
364
if (!PyArg_ParseTuple (args, "s", &name))
365
return (EXPP_ReturnPyObjError
366
(PyExc_TypeError, "expected string argument"));
368
PyOS_snprintf (buf, sizeof (buf), "%s", name);
370
rename_id (&self->ipo->id, buf);
377
Ipo_getBlocktype (BPy_Ipo * self)
379
PyObject *attr = PyInt_FromLong (self->ipo->blocktype);
382
return (EXPP_ReturnPyObjError
383
(PyExc_RuntimeError, "couldn't get Ipo.blocktype attribute"));
388
Ipo_setBlocktype (BPy_Ipo * self, PyObject * args)
392
if (!PyArg_ParseTuple (args, "i", &blocktype))
393
return (EXPP_ReturnPyObjError
394
(PyExc_TypeError, "expected string argument"));
396
self->ipo->blocktype = (short) blocktype;
404
Ipo_getRctf (BPy_Ipo * self)
406
PyObject *l = PyList_New (0);
407
PyList_Append (l, PyFloat_FromDouble (self->ipo->cur.xmin));
408
PyList_Append (l, PyFloat_FromDouble (self->ipo->cur.xmax));
409
PyList_Append (l, PyFloat_FromDouble (self->ipo->cur.ymin));
410
PyList_Append (l, PyFloat_FromDouble (self->ipo->cur.ymax));
417
Ipo_setRctf (BPy_Ipo * self, PyObject * args)
420
if (!PyArg_ParseTuple (args, "ffff", v, v + 1, v + 2, v + 3))
421
return (EXPP_ReturnPyObjError
422
(PyExc_TypeError, "expected 4 float argument"));
424
self->ipo->cur.xmin = v[0];
425
self->ipo->cur.xmax = v[1];
426
self->ipo->cur.ymin = v[2];
427
self->ipo->cur.ymax = v[3];
434
Ipo_getNcurves (BPy_Ipo * self)
439
for (icu = self->ipo->curve.first; icu; icu = icu->next)
444
return (PyInt_FromLong (i));
449
Ipo_addCurve (BPy_Ipo * self, PyObject * args)
451
IpoCurve *get_ipocurve (ID * from, short type, int adrcode, Ipo * useipo);
452
void allspace (unsigned short event, short val);
453
void allqueue (unsigned short event, short val);
454
int param = 0, ok = 0;
458
struct Object *object = NULL;
460
if (!PyArg_ParseTuple (args, "s", &s))
461
return (EXPP_ReturnPyObjError
462
(PyExc_TypeError, "expected string argument"));
464
/* insertkey demande un pointeur sur l'objet pour lequel on veut ajouter
466
link = G.main->object.first;
469
object = (Object *) link;
470
if (object->ipo == self->ipo)
474
/* todo : what kind of object....
475
#define GS(a) (*((short *)(a)))
476
printf("object %p\n",object);
477
printf("type %d\n",GS(object->id.name));
480
if (!strcmp (s, "LocX"))
485
if (!strcmp (s, "LocY"))
490
if (!strcmp (s, "LocZ"))
495
if (!strcmp (s, "RotX"))
500
if (!strcmp (s, "RotY"))
505
if (!strcmp (s, "RotZ"))
510
if (!strcmp (s, "SizeX"))
515
if (!strcmp (s, "SizeY"))
520
if (!strcmp (s, "SizeZ"))
526
if (!strcmp (s, "DLocX"))
531
if (!strcmp (s, "DLocY"))
536
if (!strcmp (s, "DLocZ"))
541
if (!strcmp (s, "DRotX"))
546
if (!strcmp (s, "DRotY"))
551
if (!strcmp (s, "DRotZ"))
556
if (!strcmp (s, "DSizeX"))
561
if (!strcmp (s, "DSizeY"))
566
if (!strcmp (s, "DSizeZ"))
572
if (!strcmp (s, "Layer"))
577
if (!strcmp (s, "Time"))
583
if (!strcmp (s, "ColR"))
588
if (!strcmp (s, "ColG"))
593
if (!strcmp (s, "ColB"))
598
if (!strcmp (s, "ColA"))
604
return (EXPP_ReturnPyObjError (PyExc_ValueError, "Not a valid param."));
606
/* add a new curve to the ipo. we pass in self->ipo so a new one does
608
icu = get_ipocurve (&(object->id), ID_OB, param, self->ipo );
612
#define REDRAWIPO 0x4023
613
allspace (REMAKEIPO, 0);
614
allqueue (REDRAWIPO, 0);
616
return IpoCurve_CreatePyObject (icu);
622
Ipo_getCurve (BPy_Ipo * self, PyObject * args)
624
//int num = 0 , i = 0;
627
if (!PyArg_ParseTuple (args, "s", &str))
628
return (EXPP_ReturnPyObjError
629
(PyExc_TypeError, "expected string argument"));
630
for (icu = self->ipo->curve.first; icu; icu = icu->next)
633
GetIpoCurveName (icu, str1);
634
if (!strcmp (str1, str))
635
return IpoCurve_CreatePyObject (icu);
644
GetIpoCurveName (IpoCurve * icu, char *s)
646
switch (icu->blocktype)
650
getname_mat_ei (icu->adrcode, s);
655
getname_world_ei (icu->adrcode, s);
660
getname_cam_ei (icu->adrcode, s);
665
getname_ob_ei (icu->adrcode, s);
673
Ipo_getCurves (BPy_Ipo * self)
675
PyObject *attr = PyList_New (0);
677
for (icu = self->ipo->curve.first; icu; icu = icu->next)
679
PyList_Append (attr, IpoCurve_CreatePyObject (icu));
686
Ipo_getNBezPoints (BPy_Ipo * self, PyObject * args)
690
if (!PyArg_ParseTuple (args, "i", &num))
691
return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument"));
692
icu = self->ipo->curve.first;
694
return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve"));
695
for (i = 0; i < num; i++)
698
return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad curve number"));
702
return (PyInt_FromLong (icu->totvert));
706
Ipo_DeleteBezPoints (BPy_Ipo * self, PyObject * args)
710
if (!PyArg_ParseTuple (args, "i", &num))
711
return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument"));
712
icu = self->ipo->curve.first;
714
return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve"));
715
for (i = 0; i < num; i++)
718
return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad curve number"));
723
return (PyInt_FromLong (icu->totvert));
728
Ipo_getCurveBP (BPy_Ipo * self, PyObject * args)
730
struct BPoint *ptrbpoint;
735
if (!PyArg_ParseTuple (args, "i", &num))
736
return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument"));
737
icu = self->ipo->curve.first;
739
return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve"));
740
for (i = 0; i < num; i++)
743
return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad curve number"));
749
return EXPP_ReturnPyObjError (PyExc_TypeError, "No base point");
752
for (i = 0; i < 4; i++)
753
PyList_Append (l, PyFloat_FromDouble (ptrbpoint->vec[i]));
758
Ipo_getCurveBeztriple (BPy_Ipo * self, PyObject * args)
760
struct BezTriple *ptrbt;
761
int num = 0, pos, i, j;
763
PyObject *l = PyList_New (0);
765
if (!PyArg_ParseTuple (args, "ii", &num, &pos))
766
return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument"));
767
icu = self->ipo->curve.first;
769
return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve"));
770
for (i = 0; i < num; i++)
773
return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad ipo number"));
776
if (pos >= icu->totvert)
777
return EXPP_ReturnPyObjError (PyExc_TypeError, "Bad bezt number");
779
ptrbt = icu->bezt + pos;
781
return EXPP_ReturnPyObjError (PyExc_TypeError, "No bez triple");
783
for (i = 0; i < 3; i++)
784
for (j = 0; j < 3; j++)
785
PyList_Append (l, PyFloat_FromDouble (ptrbt->vec[i][j]));
791
Ipo_setCurveBeztriple (BPy_Ipo * self, PyObject * args)
793
struct BezTriple *ptrbt;
796
PyObject *listargs = 0;
798
if (!PyArg_ParseTuple (args, "iiO", &num, &pos, &listargs))
799
return (EXPP_ReturnPyObjError
800
(PyExc_TypeError, "expected int int object argument"));
801
if (!PyTuple_Check (listargs))
802
return (EXPP_ReturnPyObjError
803
(PyExc_TypeError, "3rd arg should be a tuple"));
804
icu = self->ipo->curve.first;
806
return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve"));
807
for (i = 0; i < num; i++)
810
return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad ipo number"));
813
if (pos >= icu->totvert)
814
return EXPP_ReturnPyObjError (PyExc_TypeError, "Bad bezt number");
816
ptrbt = icu->bezt + pos;
818
return EXPP_ReturnPyObjError (PyExc_TypeError, "No bez triple");
820
for (i = 0; i < 9; i++)
822
PyObject *xx = PyTuple_GetItem (listargs, i);
823
ptrbt->vec[i / 3][i % 3] = PyFloat_AsDouble (xx);
832
Ipo_EvaluateCurveOn (BPy_Ipo * self, PyObject * args)
834
float eval_icu (IpoCurve * icu, float ipotime);
840
if (!PyArg_ParseTuple (args, "if", &num, &time))
841
return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument"));
843
icu = self->ipo->curve.first;
845
return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve"));
847
for (i = 0; i < num; i++)
850
return (EXPP_ReturnPyObjError (PyExc_TypeError, "Bad ipo number"));
854
return PyFloat_FromDouble (eval_icu (icu, time));
859
Ipo_getCurvecurval (BPy_Ipo * self, PyObject * args)
863
char *stringname = 0;
865
icu = self->ipo->curve.first;
867
return (EXPP_ReturnPyObjError (PyExc_TypeError, "No IPO curve"));
869
if (PyNumber_Check (PySequence_GetItem (args, 0))) // args is an integer
871
if (!PyArg_ParseTuple (args, "i", &numcurve))
872
return (EXPP_ReturnPyObjError
873
(PyExc_TypeError, "expected int or string argument"));
874
for (i = 0; i < numcurve; i++)
877
return (EXPP_ReturnPyObjError
878
(PyExc_TypeError, "Bad ipo number"));
883
else // args is a string
885
if (!PyArg_ParseTuple (args, "s", &stringname))
886
return (EXPP_ReturnPyObjError
887
(PyExc_TypeError, "expected int or string argument"));
891
GetIpoCurveName (icu, str1);
892
if (!strcmp (str1, stringname))
899
return PyFloat_FromDouble (icu->curval);
359
static PyObject *Ipo_getName( BPy_Ipo * self )
361
PyObject *attr = PyString_FromString( self->ipo->id.name + 2 );
365
Py_INCREF( Py_None );
370
static PyObject *Ipo_setName( BPy_Ipo * self, PyObject * args )
375
if( !PyArg_ParseTuple( args, "s", &name ) )
376
return ( EXPP_ReturnPyObjError
377
( PyExc_TypeError, "expected string argument" ) );
379
PyOS_snprintf( buf, sizeof( buf ), "%s", name );
381
rename_id( &self->ipo->id, buf );
383
Py_INCREF( Py_None );
387
static PyObject *Ipo_getBlocktype( BPy_Ipo * self )
389
PyObject *attr = PyInt_FromLong( self->ipo->blocktype );
392
return ( EXPP_ReturnPyObjError
393
( PyExc_RuntimeError,
394
"couldn't get Ipo.blocktype attribute" ) );
398
static PyObject *Ipo_setBlocktype( BPy_Ipo * self, PyObject * args )
402
if( !PyArg_ParseTuple( args, "i", &blocktype ) )
403
return ( EXPP_ReturnPyObjError
404
( PyExc_TypeError, "expected string argument" ) );
406
self->ipo->blocktype = ( short ) blocktype;
408
Py_INCREF( Py_None );
413
static PyObject *Ipo_getRctf( BPy_Ipo * self )
415
PyObject *l = PyList_New( 0 );
416
PyList_Append( l, PyFloat_FromDouble( self->ipo->cur.xmin ) );
417
PyList_Append( l, PyFloat_FromDouble( self->ipo->cur.xmax ) );
418
PyList_Append( l, PyFloat_FromDouble( self->ipo->cur.ymin ) );
419
PyList_Append( l, PyFloat_FromDouble( self->ipo->cur.ymax ) );
425
static PyObject *Ipo_setRctf( BPy_Ipo * self, PyObject * args )
428
if( !PyArg_ParseTuple( args, "ffff", v, v + 1, v + 2, v + 3 ) )
429
return ( EXPP_ReturnPyObjError
430
( PyExc_TypeError, "expected 4 float argument" ) );
432
self->ipo->cur.xmin = v[0];
433
self->ipo->cur.xmax = v[1];
434
self->ipo->cur.ymin = v[2];
435
self->ipo->cur.ymax = v[3];
437
Py_INCREF( Py_None );
441
static PyObject *Ipo_getNcurves( BPy_Ipo * self )
446
for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
450
return ( PyInt_FromLong( i ) );
455
Lamp ipo Name to Channel
458
static int Ipo_laIcuName( char *s, int *param )
464
char *lamp_names[LA_TOTIPO] =
465
{ "Energ", "R", "G", "B", "Dist", "SpoSi",
466
"SpoBl", "Quad1", "Quad2", "HaInt",
467
/* lamp texture names */
468
"OfsX", "OfsY", "OfsZ", "SizeX", "SizeY",
469
"SizeZ", "texR", "texG", "texB", "DefVar",
473
for( i = 0; i < LA_TOTIPO; i++ ) {
474
if( !strcmp( s, lamp_names[i] ) ) { /* found it! */
485
World Ipo Name to Channel
488
static int Ipo_woIcuName( char *s, int *param )
490
extern int wo_ar[]; /* channel values from ipo.c */
493
char *world_names[WO_TOTIPO] = { "HorR", "HorG", "HorB",
494
"ZenR", "ZenG", "ZenB",
496
"Misi", "MisDi", "MisSta", "MisHi",
497
"StarR", "StarB", "StarG",
499
/* world textures names */
500
"OfsX", "OfsY", "OfsZ",
501
"SizeX", "SizeY", "SizeZ",
502
"texR", "texG", "texB",
503
"DefVar", "Col", "Nor", "Var",
506
for( i = 0; i < WO_TOTIPO; i++ ) {
507
if( !strcmp( s, world_names[i] ) ) { /* found it! */
516
static int Ipo_maIcuName( char *s, int *param )
523
char *material_names[MA_TOTIPO] = { "R", "G", "B",
524
"SpecR", "SpecG", "SpecB",
525
"MirR", "MirG", "MirB", "Ref", "Alpha",
526
"Emit", "Amb", "Spec",
527
"Hard", "SpTra", "Ior", "Mode",
529
"RayMir", "FresMir", "FresMirI",
530
"FresTra", "FresTraI",
532
"OfsX", "OfsY", "OfsZ",
533
"SizeX", "SizeY", "SizeZ",
534
"texR", "texG", "texB",
535
"DefVar", "Col", "Nor", "Var",
540
for( i = 0; i < MA_TOTIPO; i++ ) {
541
if( !strcmp( s, material_names[i] ) ) { /* found it! */
550
static int Ipo_keIcuName( char *s, int *param )
555
if( !strcmp( s, "Speed" ) ) {
559
for( nr = 1; nr < 64; nr++ ) {
560
sprintf( key, "Key %d", nr );
561
if( !strcmp( s, key ) ) {
571
static int Ipo_seqIcuName( char *s, int *param )
574
if( !strcmp( s, "Fac" ) ) {
582
static int Ipo_cuIcuName( char *s, int *param )
585
if( !strcmp( s, "Speed" ) ) {
593
static int Ipo_coIcuName( char *s, int *param )
596
if( !strcmp( s, "Inf" ) ) {
604
static int Ipo_acIcuName( char *s, int *param )
607
if( !strcmp( s, "LocX" ) ) {
611
if( !strcmp( s, "LocY" ) ) {
615
if( !strcmp( s, "LocZ" ) ) {
619
if( !strcmp( s, "SizeX" ) ) {
623
if( !strcmp( s, "SizeY" ) ) {
627
if( !strcmp( s, "SizeZ" ) ) {
631
if( !strcmp( s, "QuatX" ) ) {
635
if( !strcmp( s, "QuatY" ) ) {
639
if( !strcmp( s, "QuatZ" ) ) {
643
if( !strcmp( s, "QuatW" ) ) {
652
Camera ipo name to channel
655
static int Ipo_caIcuName( char *s, int *param )
657
/* for Camera ipos CAM_TOTNAM == CAM_TOTIPO
658
and cam_ic_names[] holds the complete set of names, so we use that.
661
extern char *cam_ic_names[];
666
for( i = 0; i < CAM_TOTIPO; i++ ) {
667
if( !strcmp( s, cam_ic_names[i] ) ) { /* found it! */
678
texture ipo name to channel
681
static int Ipo_texIcuName( char *s, int *param )
683
/* this is another case where TE_TOTIPO == TE_TOTNAM.
684
te_ic_names[] has all our names so use that.
687
extern char *tex_ic_names[];
691
for( i = 0; i < TE_TOTIPO; i++){
692
if( !strcmp( s, tex_ic_names[i] ) ){
701
static int Ipo_obIcuName( char *s, int *param )
704
if( !strcmp( s, "LocX" ) ) {
708
if( !strcmp( s, "LocY" ) ) {
712
if( !strcmp( s, "LocZ" ) ) {
716
if( !strcmp( s, "RotX" ) ) {
720
if( !strcmp( s, "RotY" ) ) {
724
if( !strcmp( s, "RotZ" ) ) {
728
if( !strcmp( s, "SizeX" ) ) {
732
if( !strcmp( s, "SizeY" ) ) {
736
if( !strcmp( s, "SizeZ" ) ) {
741
if( !strcmp( s, "dLocX" ) ) {
745
if( !strcmp( s, "dLocY" ) ) {
749
if( !strcmp( s, "dLocZ" ) ) {
753
if( !strcmp( s, "dRotX" ) ) {
757
if( !strcmp( s, "dRotY" ) ) {
761
if( !strcmp( s, "dRotZ" ) ) {
765
if( !strcmp( s, "dSizeX" ) ) {
769
if( !strcmp( s, "dSizeY" ) ) {
773
if( !strcmp( s, "dSizeZ" ) ) {
778
if( !strcmp( s, "Layer" ) ) {
782
if( !strcmp( s, "Time" ) ) {
787
if( !strcmp( s, "ColR" ) ) {
791
if( !strcmp( s, "ColG" ) ) {
795
if( !strcmp( s, "ColB" ) ) {
799
if( !strcmp( s, "ColA" ) ) {
803
if( !strcmp( s, "FStreng" ) ) {
807
if( !strcmp( s, "FFall" ) ) {
808
*param = OB_PD_FFALL;
811
if( !strcmp( s, "Damping" ) ) {
812
*param = OB_PD_SDAMP;
815
if( !strcmp( s, "RDamp" ) ) {
816
*param = OB_PD_RDAMP;
819
if( !strcmp( s, "Perm" ) ) {
829
Function: Ipo_addCurve
830
Bpy: Blender.Ipo.addCurve( 'curname')
832
add a new curve to an existing IPO.
834
ipo = Blender.Ipo.New('Object','ObIpo')
835
cu = ipo.addCurve('LocX')
838
static PyObject *Ipo_addCurve( BPy_Ipo * self, PyObject * args )
840
int param = 0; /* numeric curve name constant */
843
char *cur_name = 0; /* input arg: curve name */
848
if( !PyArg_ParseTuple( args, "s", &cur_name ) )
849
return ( EXPP_ReturnPyObjError
850
( PyExc_TypeError, "expected string argument" ) );
853
/* chase down the ipo list looking for ours */
854
link = G.main->ipo.first;
857
ipo = ( Ipo * ) link;
858
if( ipo == self->ipo ) {
865
if( ipo && ipofound ) {
867
} else { /* runtime error here: our ipo not found */
868
return ( EXPP_ReturnPyObjError
869
( PyExc_RuntimeError, "Ipo not found" ) );
874
depending on the block type,
875
check if the input arg curve name is valid
876
and set param to numeric value.
878
switch ( ipo->blocktype ) {
880
ok = Ipo_obIcuName( cur_name, ¶m );
883
ok = Ipo_caIcuName( cur_name, ¶m );
886
ok = Ipo_laIcuName( cur_name, ¶m );
889
ok = Ipo_texIcuName( cur_name, ¶m );
892
ok = Ipo_woIcuName( cur_name, ¶m );
895
ok = Ipo_maIcuName( cur_name, ¶m );
898
ok = Ipo_acIcuName( cur_name, ¶m );
901
ok = Ipo_coIcuName( cur_name, ¶m );
904
ok = Ipo_cuIcuName( cur_name, ¶m );
907
ok = Ipo_keIcuName( cur_name, ¶m );
910
ok = Ipo_seqIcuName( cur_name, ¶m );
916
if( !ok ) /* curve type was invalid */
917
return EXPP_ReturnPyObjError
918
( PyExc_NameError, "curve name was invalid" );
920
/* ask blender to create the new ipo curve */
921
icu = get_ipocurve( NULL, ipo->blocktype, param, self->ipo );
923
if( icu == 0 ) /* could not create curve */
924
return EXPP_ReturnPyObjError
925
( PyExc_RuntimeError,
926
"blender could not create ipo curve" );
928
allspace( REMAKEIPO, 0 );
929
EXPP_allqueue( REDRAWIPO, 0 );
931
/* create a bpy wrapper for the new ipo curve */
932
return IpoCurve_CreatePyObject( icu );
936
Function: Ipo_delCurve
937
Bpy: Blender.Ipo.delCurve(curtype)
939
delete an existing curve from IPO.
941
ipo = Blender.Ipo.New('Object','ObIpo')
942
cu = ipo.delCurve('LocX')
945
static PyObject *Ipo_delCurve( BPy_Ipo * self, PyObject * args )
950
if( !PyArg_ParseTuple( args, "s", &strname ) )
951
return ( EXPP_ReturnPyObjError
952
( PyExc_TypeError, "string argument" ) );
954
for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
955
char *str1 = getIpoCurveName( icu );
956
if( !strcmp( str1, strname ) ) {
957
BLI_remlink( &( self->ipo->curve ), icu );
959
MEM_freeN( icu->bezt );
962
Py_INCREF( Py_None );
967
return ( EXPP_ReturnPyObjError
968
( PyExc_RuntimeError, "IpoCurve not found" ) );
973
static PyObject *Ipo_getCurve( BPy_Ipo * self, PyObject * args )
978
if( !PyArg_ParseTuple( args, "s", &str ) )
979
return ( EXPP_ReturnPyObjError
980
( PyExc_TypeError, "expected string argument" ) );
982
for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
983
str1 = getIpoCurveName( icu );
984
if( !strcmp( str1, str ) )
985
return IpoCurve_CreatePyObject( icu );
988
Py_INCREF( Py_None );
992
static PyObject *Ipo_getCurves( BPy_Ipo * self )
994
PyObject *attr = PyList_New( 0 );
996
for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
997
PyList_Append( attr, IpoCurve_CreatePyObject( icu ) );
1003
static PyObject *Ipo_getNBezPoints( BPy_Ipo * self, PyObject * args )
1007
if( !PyArg_ParseTuple( args, "i", &num ) )
1008
return ( EXPP_ReturnPyObjError
1009
( PyExc_TypeError, "expected int argument" ) );
1010
icu = self->ipo->curve.first;
1012
return ( EXPP_ReturnPyObjError
1013
( PyExc_TypeError, "No IPO curve" ) );
1014
for( i = 0; i < num; i++ ) {
1016
return ( EXPP_ReturnPyObjError
1017
( PyExc_TypeError, "Bad curve number" ) );
1021
return ( PyInt_FromLong( icu->totvert ) );
1024
static PyObject *Ipo_DeleteBezPoints( BPy_Ipo * self, PyObject * args )
1028
if( !PyArg_ParseTuple( args, "i", &num ) )
1029
return ( EXPP_ReturnPyObjError
1030
( PyExc_TypeError, "expected int argument" ) );
1031
icu = self->ipo->curve.first;
1033
return ( EXPP_ReturnPyObjError
1034
( PyExc_TypeError, "No IPO curve" ) );
1035
for( i = 0; i < num; i++ ) {
1037
return ( EXPP_ReturnPyObjError
1038
( PyExc_TypeError, "Bad curve number" ) );
1043
return ( PyInt_FromLong( icu->totvert ) );
1049
* this method is UNSUPPORTED.
1050
* Calling this method throws a TypeError Exception.
1052
* it looks like the original intent was to return the first point
1053
* of a BPoint Ipo curve. However, BPoint ipos are not currently
1057
static PyObject *Ipo_getCurveBP( BPy_Ipo * self, PyObject * args )
1060
/* unsupported method */
1061
return EXPP_ReturnPyObjError( PyExc_NotImplementedError,
1062
"bpoint ipos are not supported" );
1066
struct BPoint *ptrbpoint;
1071
if( !PyArg_ParseTuple( args, "i", &num ) )
1072
return ( EXPP_ReturnPyObjError
1073
( PyExc_TypeError, "expected int argument" ) );
1074
icu = self->ipo->curve.first;
1076
return ( EXPP_ReturnPyObjError
1077
( PyExc_TypeError, "No IPO curve" ) );
1078
for( i = 0; i < num; i++ ) {
1080
return ( EXPP_ReturnPyObjError
1081
( PyExc_TypeError, "Bad curve number" ) );
1085
ptrbpoint = icu->bp;
1087
return EXPP_ReturnPyObjError( PyExc_TypeError,
1090
l = PyList_New( 0 );
1091
for( i = 0; i < 4; i++ )
1092
PyList_Append( l, PyFloat_FromDouble( ptrbpoint->vec[i] ) );
1097
static PyObject *Ipo_getCurveBeztriple( BPy_Ipo * self, PyObject * args )
1099
struct BezTriple *ptrbt;
1100
int num = 0, pos, i, j;
1102
PyObject *l = PyList_New( 0 );
1104
if( !PyArg_ParseTuple( args, "ii", &num, &pos ) )
1105
return ( EXPP_ReturnPyObjError
1106
( PyExc_TypeError, "expected int argument" ) );
1107
icu = self->ipo->curve.first;
1109
return ( EXPP_ReturnPyObjError
1110
( PyExc_TypeError, "No IPO curve" ) );
1111
for( i = 0; i < num; i++ ) {
1113
return ( EXPP_ReturnPyObjError
1114
( PyExc_TypeError, "Bad ipo number" ) );
1117
if( pos >= icu->totvert )
1118
return EXPP_ReturnPyObjError( PyExc_TypeError,
1119
"Bad bezt number" );
1121
ptrbt = icu->bezt + pos;
1123
return EXPP_ReturnPyObjError( PyExc_TypeError,
1126
for( i = 0; i < 3; i++ )
1127
for( j = 0; j < 3; j++ )
1129
PyFloat_FromDouble( ptrbt->
1135
static PyObject *Ipo_setCurveBeztriple( BPy_Ipo * self, PyObject * args )
1137
struct BezTriple *ptrbt;
1138
int num = 0, pos, i;
1140
PyObject *listargs = 0;
1142
if( !PyArg_ParseTuple( args, "iiO", &num, &pos, &listargs ) )
1143
return ( EXPP_ReturnPyObjError
1145
"expected int int object argument" ) );
1146
if( !PyTuple_Check( listargs ) )
1147
return ( EXPP_ReturnPyObjError
1148
( PyExc_TypeError, "3rd arg should be a tuple" ) );
1149
icu = self->ipo->curve.first;
1151
return ( EXPP_ReturnPyObjError
1152
( PyExc_TypeError, "No IPO curve" ) );
1153
for( i = 0; i < num; i++ ) {
1155
return ( EXPP_ReturnPyObjError
1156
( PyExc_TypeError, "Bad ipo number" ) );
1159
if( pos >= icu->totvert )
1160
return EXPP_ReturnPyObjError( PyExc_TypeError,
1161
"Bad bezt number" );
1163
ptrbt = icu->bezt + pos;
1165
return EXPP_ReturnPyObjError( PyExc_TypeError,
1168
for( i = 0; i < 9; i++ ) {
1169
PyObject *xx = PyTuple_GetItem( listargs, i );
1170
ptrbt->vec[i / 3][i % 3] = PyFloat_AsDouble( xx );
1173
Py_INCREF( Py_None );
1178
static PyObject *Ipo_EvaluateCurveOn( BPy_Ipo * self, PyObject * args )
1180
float eval_icu( IpoCurve * icu, float ipotime );
1186
if( !PyArg_ParseTuple( args, "if", &num, &time ) )
1187
return ( EXPP_ReturnPyObjError
1188
( PyExc_TypeError, "expected int argument" ) );
1190
icu = self->ipo->curve.first;
1192
return ( EXPP_ReturnPyObjError
1193
( PyExc_TypeError, "No IPO curve" ) );
1195
for( i = 0; i < num; i++ ) {
1197
return ( EXPP_ReturnPyObjError
1198
( PyExc_TypeError, "Bad ipo number" ) );
1202
return PyFloat_FromDouble( eval_icu( icu, time ) );
1206
static PyObject *Ipo_getCurvecurval( BPy_Ipo * self, PyObject * args )
1208
int numcurve = 0, i;
1210
char *stringname = 0, *str1 = 0;
1212
icu = self->ipo->curve.first;
1214
return ( EXPP_ReturnPyObjError
1215
( PyExc_TypeError, "No IPO curve" ) );
1217
if( PyNumber_Check( PySequence_GetItem( args, 0 ) ) ) // args is an integer
1219
if( !PyArg_ParseTuple( args, "i", &numcurve ) )
1220
return ( EXPP_ReturnPyObjError
1222
"expected int or string argument" ) );
1223
for( i = 0; i < numcurve; i++ ) {
1225
return ( EXPP_ReturnPyObjError
1227
"Bad ipo number" ) );
1232
else // args is a string
1234
if( !PyArg_ParseTuple( args, "s", &stringname ) )
1235
return ( EXPP_ReturnPyObjError
1237
"expected int or string argument" ) );
1239
str1 = getIpoCurveName( icu );
1240
if( !strcmp( str1, stringname ) )
1247
return PyFloat_FromDouble( icu->curval );
1248
Py_INCREF( Py_None );