diff --git a/source/blender/python/api2_2x/BezTriple.c b/source/blender/python/api2_2x/BezTriple.c new file mode 100644 index 00000000000..ec8564f72c9 --- /dev/null +++ b/source/blender/python/api2_2x/BezTriple.c @@ -0,0 +1,178 @@ +/* + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * This is a new part of Blender. + * + * Contributor(s): Jacques Guignot + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#include "BezTriple.h" + +/*****************************************************************************/ +/* Function: M_BezTriple_New */ +/* Python equivalent: Blender.BezTriple.New */ +/*****************************************************************************/ +static PyObject *M_BezTriple_New(PyObject *self, PyObject *args) +{ + return 0; +} + +/*****************************************************************************/ +/* Function: M_BezTriple_Get */ +/* Python equivalent: Blender.BezTriple.Get */ +/* Description: Receives a string and returns the ipo data obj */ +/* whose name matches the string. If no argument is */ +/* passed in, a list of all ipo data names in the */ +/* current scene is returned. */ +/*****************************************************************************/ +static PyObject *M_BezTriple_Get(PyObject *self, PyObject *args) +{ + return 0; +} + + +/*****************************************************************************/ +/* Python C_BezTriple methods: */ +/*****************************************************************************/ +static PyObject *BezTriple_getName(C_BezTriple *self) +{ + return 0; +} + +static PyObject *BezTriple_setName(C_BezTriple *self, PyObject *args) +{ + return 0; +} + + +/*****************************************************************************/ +/* Function: BezTripleDeAlloc */ +/* Description: This is a callback function for the C_BezTriple type. It is */ +/* the destructor function. */ +/*****************************************************************************/ +static void BezTripleDeAlloc (C_BezTriple *self) +{ + PyObject_DEL (self); +} + +static PyObject* BezTriple_getPoints (C_BezTriple *self) +{ +struct BezTriple *bezt = self->beztriple; + PyObject* l = PyList_New(0); + int i; + for(i = 0;i<2;i++) + { + PyList_Append( l, PyFloat_FromDouble(bezt->vec[1][i])); + } + return l; +} + +int BezTriple_setPoints (C_BezTriple *self,PyObject *value) +{ + + int i; + struct BezTriple *bezt = self->beztriple; + if ( PyList_Check(value) == 0) + {puts("error in BezTriple_setPoints"); + return -1;} + for(i = 0;i<2;i++)bezt->vec[1][i] = PyFloat_AsDouble(PyList_GetItem(value, i)); + return 0; +} + +/*****************************************************************************/ +/* Function: BezTripleGetAttr */ +/* Description: This is a callback function for the C_BezTriple type. It is */ +/* the function that accesses C_BezTriple "member variables" and */ +/* methods. */ +/*****************************************************************************/ +static PyObject *BezTripleGetAttr (C_BezTriple *self, char *name) +{ +if (strcmp (name, "pt") == 0)return BezTriple_getPoints(self); + return Py_FindMethod(C_BezTriple_methods, (PyObject *)self, name); +} + +/*****************************************************************************/ +/* Function: BezTripleSetAttr */ +/* Description: This is a callback function for the C_BezTriple type. It is the */ +/* function that sets BezTriple Data attributes (member variables).*/ +/*****************************************************************************/ +static int BezTripleSetAttr (C_BezTriple *self, char *name, PyObject *value) +{ +if (strcmp (name, "pt") == 0)return BezTriple_setPoints(self,value); + return 0; /* normal exit */ +} + +/*****************************************************************************/ +/* Function: BezTripleRepr */ +/* Description: This is a callback function for the C_BezTriple type. It */ +/* builds a meaninful string to represent BezTriple objects. */ +/*****************************************************************************/ +static PyObject *BezTripleRepr (C_BezTriple *self) +{ + return PyString_FromString("[BezTriple]"); +} + +/* Three Python BezTriple_Type helper functions needed by the Object module: */ + +/*****************************************************************************/ +/* Function: BezTriple_CreatePyObject */ +/* Description: This function will create a new C_BezTriple from an existing */ +/* Blender ipo structure. */ +/*****************************************************************************/ +PyObject *BezTriple_CreatePyObject (BezTriple *bzt) +{ + C_BezTriple *pybeztriple; + + pybeztriple = (C_BezTriple *)PyObject_NEW (C_BezTriple, &BezTriple_Type); + + if (!pybeztriple) + return EXPP_ReturnPyObjError (PyExc_MemoryError, + "couldn't create C_BezTriple object"); + + pybeztriple->beztriple = bzt; + + return (PyObject *)pybeztriple; +} + +/*****************************************************************************/ +/* Function: BezTriple_CheckPyObject */ +/* Description: This function returns true when the given PyObject is of the */ +/* type BezTriple. Otherwise it will return false. */ +/*****************************************************************************/ +int BezTriple_CheckPyObject (PyObject *pyobj) +{ + return (pyobj->ob_type == &BezTriple_Type); +} + +/*****************************************************************************/ +/* Function: BezTriple_FromPyObject */ +/* Description: This function returns the Blender beztriple from the given */ +/* PyObject. */ +/*****************************************************************************/ +BezTriple *BezTriple_FromPyObject (PyObject *pyobj) +{ + return ((C_BezTriple *)pyobj)->beztriple; +} diff --git a/source/blender/python/api2_2x/BezTriple.h b/source/blender/python/api2_2x/BezTriple.h new file mode 100644 index 00000000000..c7c4b6e1dc4 --- /dev/null +++ b/source/blender/python/api2_2x/BezTriple.h @@ -0,0 +1,131 @@ +/* + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * This is a new part of Blender. + * + * Contributor(s): Jacques Guignot + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** +*/ + +#ifndef EXPP_BEZTRIPLE_H +#define EXPP_BEZTRIPLE_H + +#include + +#include +#include +#include +#include +#include +#include + +#include "constant.h" +#include "gen_utils.h" +#include "modules.h" + + +/*****************************************************************************/ +/* Python API function prototypes for the BezTriple module. */ +/*****************************************************************************/ +static PyObject *M_BezTriple_New (PyObject *self, PyObject *args); +static PyObject *M_BezTriple_Get (PyObject *self, PyObject *args); + + + +/*****************************************************************************/ +/* Python method structure definition for Blender.BezTriple module: */ +/*****************************************************************************/ + +struct PyMethodDef M_BezTriple_methods[] = { + {"New",(PyCFunction)M_BezTriple_New, METH_VARARGS|METH_KEYWORDS,0}, + {"Get", M_BezTriple_Get, METH_VARARGS, 0}, + {"get", M_BezTriple_Get, METH_VARARGS, 0}, + {NULL, NULL, 0, NULL} +}; + +/*****************************************************************************/ +/* Python C_BezTriple structure definition: */ +/*****************************************************************************/ +typedef struct { + PyObject_HEAD + BezTriple *beztriple; +} C_BezTriple; + +/*****************************************************************************/ +/* Python C_BezTriple methods declarations: */ +/*****************************************************************************/ +static PyObject *BezTriple_getName(C_BezTriple *self); +static PyObject *BezTriple_setName(C_BezTriple *self, PyObject *args); + +/*****************************************************************************/ +/* Python C_BezTriple methods table: */ +/*****************************************************************************/ +static PyMethodDef C_BezTriple_methods[] = { + /* name, method, flags, doc */ + {"getName", (PyCFunction)BezTriple_getName, METH_NOARGS, + "() - Return BezTriple Data name"}, +{"setName", (PyCFunction)BezTriple_setName, METH_VARARGS, + "(str) - Change BezTriple Data name"}, + {0} +}; + +/*****************************************************************************/ +/* Python BezTriple_Type callback function prototypes: */ +/*****************************************************************************/ +static void BezTripleDeAlloc (C_BezTriple *self); +//static int BezTriplePrint (C_BezTriple *self, FILE *fp, int flags); +static int BezTripleSetAttr (C_BezTriple *self, char *name, PyObject *v); +static PyObject *BezTripleGetAttr (C_BezTriple *self, char *name); +static PyObject *BezTripleRepr (C_BezTriple *self); + +/*****************************************************************************/ +/* Python BezTriple_Type structure definition: */ +/*****************************************************************************/ +PyTypeObject BezTriple_Type = +{ + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ + "BezTriple", /* tp_name */ + sizeof (C_BezTriple), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)BezTripleDeAlloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc)BezTripleGetAttr, /* tp_getattr */ + (setattrfunc)BezTripleSetAttr, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc)BezTripleRepr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_as_hash */ + 0,0,0,0,0,0, + 0, /* tp_doc */ + 0,0,0,0,0,0, + C_BezTriple_methods, /* tp_methods */ + 0, /* tp_members */ +}; + +#endif /* EXPP_BEZTRIPLE_H */ diff --git a/source/blender/python/api2_2x/Ipocurve.c b/source/blender/python/api2_2x/Ipocurve.c new file mode 100644 index 00000000000..ca1be596a33 --- /dev/null +++ b/source/blender/python/api2_2x/Ipocurve.c @@ -0,0 +1,214 @@ +/* + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * This is a new part of Blender. + * + * Contributor(s): Jacques Guignot + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** + */ + +#include "Ipocurve.h" +#include "BezTriple.c" +/*****************************************************************************/ +/* Function: M_IpoCurve_New */ +/* Python equivalent: Blender.IpoCurve.New */ +/*****************************************************************************/ +static PyObject *M_IpoCurve_New(PyObject *self, PyObject *args) +{ + return 0; +} + + +/*****************************************************************************/ +/* Function: Ipo_Init */ +/*****************************************************************************/ +PyObject *IpoCurve_Init (void) +{ + PyObject *submodule; + + IpoCurve_Type.ob_type = &PyType_Type; + + submodule = Py_InitModule3("Blender.IpoCurve", M_IpoCurve_methods, M_IpoCurve_doc); + + return (submodule); +} + +/*****************************************************************************/ +/* Function: M_IpoCurve_Get */ +/* Python equivalent: Blender.IpoCurve.Get */ +/* Description: Receives a string and returns the ipo data obj */ +/* whose name matches the string. If no argument is */ +/* passed in, a list of all ipo data names in the */ +/* current scene is returned. */ +/*****************************************************************************/ +static PyObject *M_IpoCurve_Get(PyObject *self, PyObject *args) +{ + return 0; +} + + +/*****************************************************************************/ +/* Python C_IpoCurve methods: */ +/*****************************************************************************/ + +static PyObject *IpoCurve_setName(C_IpoCurve *self, PyObject *args) +{ + return 0; +} + +static PyObject *IpoCurve_Recalc(C_IpoCurve *self) +{ + void testhandles_ipocurve(IpoCurve *icu); + IpoCurve *icu = self->ipocurve; + testhandles_ipocurve(icu); +} + +static PyObject* IpoCurve_getName (C_IpoCurve *self) +{ + char * nametab[24] = {"LocX","LocY","LocZ","dLocX","dLocY","dLocZ","RotX","RotY","RotZ","dRotX","dRotY","dRotZ","SizeX","SizeY","SizeZ","dSizeX","dSizeY","dSizeZ","Layer","Time","ColR","ColG","ColB","ColA"}; + + // printf("IpoCurve_getName %d\n",self->ipocurve->vartype); + if (self->ipocurve->adrcode <=0 ) +return PyString_FromString("Index too small"); + if (self->ipocurve->adrcode >= 25 ) +return PyString_FromString("Index too big"); + +return PyString_FromString(nametab[self->ipocurve->adrcode-1]); + +} + + + +static void IpoCurveDeAlloc (C_IpoCurve *self) +{ + PyObject_DEL (self); +} + +static PyObject* IpoCurve_getPoints (C_IpoCurve *self) +{ +struct BezTriple *bezt; + PyObject* l = PyList_New(0); + int i; + for(i = 0;iipocurve->totvert;i++) + { + bezt = self->ipocurve->bezt + i; + PyList_Append( l, BezTriple_CreatePyObject(bezt)); + } + return l; +} + + + +int IpoCurve_setPoints (C_IpoCurve *self, PyObject *value ) +{ +struct BezTriple *bezt; + PyObject* l = PyList_New(0); + int i; + for(i = 0;iipocurve->totvert;i++) + { + bezt = self->ipocurve->bezt + i; + PyList_Append( l, BezTriple_CreatePyObject(bezt)); + } + return l; +} + + +/*****************************************************************************/ +/* Function: IpoCurveGetAttr */ +/* Description: This is a callback function for the C_IpoCurve type. It is */ +/* the function that accesses C_IpoCurve "member variables" and */ +/* methods. */ +/*****************************************************************************/ +static PyObject *IpoCurveGetAttr (C_IpoCurve *self, char *name) +{ +if (strcmp (name, "bezierPoints") == 0)return IpoCurve_getPoints(self); +if (strcmp (name, "name") == 0)return IpoCurve_getName(self); + return Py_FindMethod(C_IpoCurve_methods, (PyObject *)self, name); +} + +/*****************************************************************************/ +/* Function: IpoCurveSetAttr */ +/* Description: This is a callback function for the C_IpoCurve type. It is the */ +/* function that sets IpoCurve Data attributes (member variables).*/ +/*****************************************************************************/ +static int IpoCurveSetAttr (C_IpoCurve *self, char *name, PyObject *value) +{ +if (strcmp (name, "bezierPoints") == 0)return IpoCurve_setPoints(self,value); + return 0; /* normal exit */ +} + +/*****************************************************************************/ +/* Function: IpoCurveRepr */ +/* Description: This is a callback function for the C_IpoCurve type. It */ +/* builds a meaninful string to represent ipo objects. */ +/*****************************************************************************/ +static PyObject *IpoCurveRepr (C_IpoCurve *self) +{ + char s[1024]; + sprintf(s,"IpoCurve %d %d %d %d %d %d %d %d \n",self->ipocurve->blocktype,self->ipocurve->adrcode,self->ipocurve->vartype,self->ipocurve->totvert,self->ipocurve->ipo,self->ipocurve->extrap,self->ipocurve->flag,self->ipocurve->rt); + return PyString_FromString(s); +} + +/* Three Python IpoCurve_Type helper functions needed by the Object module: */ + +/*****************************************************************************/ +/* Function: IpoCurve_CreatePyObject */ +/* Description: This function will create a new C_IpoCurve from an existing */ +/* Blender ipo structure. */ +/*****************************************************************************/ +PyObject *IpoCurve_CreatePyObject (IpoCurve *ipo) +{ + C_IpoCurve *pyipo; + + pyipo = (C_IpoCurve *)PyObject_NEW (C_IpoCurve, &IpoCurve_Type); + + if (!pyipo) + return EXPP_ReturnPyObjError (PyExc_MemoryError, + "couldn't create C_IpoCurve object"); + + pyipo->ipocurve = ipo; + + return (PyObject *)pyipo; +} + +/*****************************************************************************/ +/* Function: IpoCurve_CheckPyObject */ +/* Description: This function returns true when the given PyObject is of the */ +/* type IpoCurve. Otherwise it will return false. */ +/*****************************************************************************/ +int IpoCurve_CheckPyObject (PyObject *pyobj) +{ + return (pyobj->ob_type == &IpoCurve_Type); +} + +/*****************************************************************************/ +/* Function: IpoCurve_FromPyObject */ +/* Description: This function returns the Blender ipo from the given */ +/* PyObject. */ +/*****************************************************************************/ +IpoCurve *IpoCurve_FromPyObject (PyObject *pyobj) +{ + return ((C_IpoCurve *)pyobj)->ipocurve; +} diff --git a/source/blender/python/api2_2x/Ipocurve.h b/source/blender/python/api2_2x/Ipocurve.h new file mode 100644 index 00000000000..86c58b0f5c3 --- /dev/null +++ b/source/blender/python/api2_2x/Ipocurve.h @@ -0,0 +1,142 @@ +/* + * + * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * This is a new part of Blender. + * + * Contributor(s): Jacques Guignot + * + * ***** END GPL/BL DUAL LICENSE BLOCK ***** +*/ + +#ifndef EXPP_IPOCURVE_H +#define EXPP_IPOCURVE_H + +#include + +#include +#include +#include +#include +#include +#include + +#include "constant.h" +#include "gen_utils.h" +#include "modules.h" + + +/*****************************************************************************/ +/* Python API function prototypes for the IpoCurve module. */ +/*****************************************************************************/ +static PyObject *M_IpoCurve_New (PyObject *self, PyObject *args); +static PyObject *M_IpoCurve_Get (PyObject *self, PyObject *args); + +/*****************************************************************************/ +/* The following string definitions are used for documentation strings. */ +/* In Python these will be written to the console when doing a */ +/* Blender.IpoCurve.__doc__ */ +/*****************************************************************************/ +char M_IpoCurve_doc[] = ""; +char M_IpoCurve_New_doc[] =""; +char M_IpoCurve_Get_doc[] =""; + + +/*****************************************************************************/ +/* Python method structure definition for Blender.IpoCurve module: */ +/*****************************************************************************/ + +struct PyMethodDef M_IpoCurve_methods[] = { + {"New",(PyCFunction)M_IpoCurve_New, METH_VARARGS|METH_KEYWORDS,M_IpoCurve_New_doc}, + {"Get", M_IpoCurve_Get, METH_VARARGS, M_IpoCurve_Get_doc}, + {"get", M_IpoCurve_Get, METH_VARARGS, M_IpoCurve_Get_doc}, + {NULL, NULL, 0, NULL} +}; + +/*****************************************************************************/ +/* Python C_IpoCurve structure definition: */ +/*****************************************************************************/ +typedef struct { + PyObject_HEAD + IpoCurve *ipocurve; +} C_IpoCurve; + +/*****************************************************************************/ +/* Python C_IpoCurve methods declarations: */ +/*****************************************************************************/ +static PyObject *IpoCurve_getName(C_IpoCurve *self); +static PyObject *IpoCurve_Recalc(C_IpoCurve *self); +static PyObject *IpoCurve_setName(C_IpoCurve *self, PyObject *args); + +/*****************************************************************************/ +/* Python C_IpoCurve methods table: */ +/*****************************************************************************/ +static PyMethodDef C_IpoCurve_methods[] = { + /* name, method, flags, doc */ + {"getName", (PyCFunction)IpoCurve_getName, METH_NOARGS, + "() - Return IpoCurve Data name"}, + {"Recalc", (PyCFunction)IpoCurve_Recalc, METH_NOARGS, + "() - Return IpoCurve Data name"}, +{"setName", (PyCFunction)IpoCurve_setName, METH_VARARGS, + "(str) - Change IpoCurve Data name"}, + {0} +}; + +/*****************************************************************************/ +/* Python IpoCurve_Type callback function prototypes: */ +/*****************************************************************************/ +static void IpoCurveDeAlloc (C_IpoCurve *self); +//static int IpoCurvePrint (C_IpoCurve *self, FILE *fp, int flags); +static int IpoCurveSetAttr (C_IpoCurve *self, char *name, PyObject *v); +static PyObject *IpoCurveGetAttr (C_IpoCurve *self, char *name); +static PyObject *IpoCurveRepr (C_IpoCurve *self); + +/*****************************************************************************/ +/* Python IpoCurve_Type structure definition: */ +/*****************************************************************************/ +PyTypeObject IpoCurve_Type = +{ + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ + "IpoCurve", /* tp_name */ + sizeof (C_IpoCurve), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)IpoCurveDeAlloc, /* tp_dealloc */ + 0, /* tp_print */ + (getattrfunc)IpoCurveGetAttr, /* tp_getattr */ + (setattrfunc)IpoCurveSetAttr, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc)IpoCurveRepr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_as_hash */ + 0,0,0,0,0,0, + 0, /* tp_doc */ + 0,0,0,0,0,0, + C_IpoCurve_methods, /* tp_methods */ + 0, /* tp_members */ +}; + +#endif /* EXPP_IPOCURVE_H */