* Added two modules:

Guignot contributed the Ipo and Metaball modules.  Metaball wasn't
   available in the 2.25 API, it's a new addition.
* Minor changes in other files.
This commit is contained in:
2003-06-05 18:03:46 +00:00
parent d29a8c0a3c
commit a9ced6d86a
8 changed files with 2023 additions and 21 deletions

View File

@@ -222,6 +222,8 @@ void M_Blender_Init (void)
PyDict_SetItemString (dict, "Lamp", M_Lamp_Init()); PyDict_SetItemString (dict, "Lamp", M_Lamp_Init());
PyDict_SetItemString (dict, "Curve", M_Curve_Init()); PyDict_SetItemString (dict, "Curve", M_Curve_Init());
PyDict_SetItemString (dict, "Armature", M_Armature_Init()); PyDict_SetItemString (dict, "Armature", M_Armature_Init());
PyDict_SetItemString (dict, "Ipo", M_Ipo_Init());
PyDict_SetItemString (dict, "Metaball", M_Metaball_Init());
PyDict_SetItemString (dict, "Image", M_Image_Init()); PyDict_SetItemString (dict, "Image", M_Image_Init());
PyDict_SetItemString (dict, "Window", M_Window_Init()); PyDict_SetItemString (dict, "Window", M_Window_Init());
PyDict_SetItemString (dict, "Draw", M_Draw_Init()); PyDict_SetItemString (dict, "Draw", M_Draw_Init());

View File

@@ -0,0 +1,460 @@
/*
*
* ***** 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 "Ipo.h"
/*****************************************************************************/
/* Function: M_Ipo_New */
/* Python equivalent: Blender.Ipo.New */
/*****************************************************************************/
static PyObject *M_Ipo_New(PyObject *self, PyObject *args)
{
Ipo *add_ipo(char *name, int idcode);
char*name = NULL;
int code = 0;
C_Ipo *pyipo;
Ipo *blipo;
if (!PyArg_ParseTuple(args, "si", &name,&code))
return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected string int arguments"));
blipo = add_ipo(name,code);
if (blipo)
pyipo = (C_Ipo *)PyObject_NEW(C_Ipo, &Ipo_Type);
else
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
"couldn't create Ipo Data in Blender"));
if (pyipo == NULL)
return (EXPP_ReturnPyObjError (PyExc_MemoryError,
"couldn't create Ipo Data object"));
pyipo->ipo = blipo;
return (PyObject *)pyipo;
}
/*****************************************************************************/
/* Function: M_Ipo_Get */
/* Python equivalent: Blender.Ipo.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_Ipo_Get(PyObject *self, PyObject *args)
{
char *name = NULL;
Ipo *ipo_iter;
PyObject *ipolist, *pystr;
C_Ipo *wanted_ipo = NULL;
char error_msg[64];
if (!PyArg_ParseTuple(args, "|s", &name))
return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected string argument (or nothing)"));
ipo_iter = G.main->ipo.first;
if (name) { /* (name) - Search ipo by name */
while ((ipo_iter) && (wanted_ipo == NULL)) {
if (strcmp (name, ipo_iter->id.name+2) == 0) {
wanted_ipo = (C_Ipo *)PyObject_NEW(C_Ipo, &Ipo_Type);
if (wanted_ipo) wanted_ipo->ipo = ipo_iter;
}
ipo_iter = ipo_iter->id.next;
}
if (wanted_ipo == NULL) { /* Requested ipo doesn't exist */
PyOS_snprintf(error_msg, sizeof(error_msg),
"Ipo \"%s\" not found", name);
return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg));
}
return (PyObject *)wanted_ipo;
}
else { /* () - return a list of all ipos in the scene */
int index = 0;
ipolist = PyList_New (BLI_countlist (&(G.main->ipo)));
if (ipolist == NULL)
return (PythonReturnErrorObject (PyExc_MemoryError,
"couldn't create PyList"));
while (ipo_iter) {
pystr = PyString_FromString (ipo_iter->id.name+2);
if (!pystr)
return (PythonReturnErrorObject (PyExc_MemoryError,
"couldn't create PyString"));
PyList_SET_ITEM (ipolist, index, pystr);
ipo_iter = ipo_iter->id.next;
index++;
}
return (ipolist);
}
}
/*****************************************************************************/
/* Function: M_Ipo_Init */
/*****************************************************************************/
PyObject *M_Ipo_Init (void)
{
PyObject *submodule;
printf ("In M_Ipo_Init()\n");
submodule = Py_InitModule3("Blender.Ipo",
M_Ipo_methods, M_Ipo_doc);
return (submodule);
}
/*****************************************************************************/
/* Python C_Ipo methods: */
/*****************************************************************************/
static PyObject *Ipo_getName(C_Ipo *self)
{
PyObject *attr = PyString_FromString(self->ipo->id.name+2);
if (attr) return attr;
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
"couldn't get Ipo.name attribute"));
}
static PyObject *Ipo_setName(C_Ipo *self, PyObject *args)
{
char *name;
char buf[21];
if (!PyArg_ParseTuple(args, "s", &name))
return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected string argument"));
PyOS_snprintf(buf, sizeof(buf), "%s", name);
rename_id(&self->ipo->id, buf);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *Ipo_getBlocktype(C_Ipo *self)
{
PyObject *attr = PyInt_FromLong(self->ipo->blocktype);
if (attr) return attr;
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
"couldn't get Ipo.blocktype attribute"));
}
static PyObject *Ipo_setBlocktype(C_Ipo *self, PyObject *args)
{
int blocktype = 0;
if (!PyArg_ParseTuple(args, "i", &blocktype))
return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected string argument"));
self->ipo->blocktype = (short)blocktype;
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *Ipo_getShowkey(C_Ipo *self)
{
PyObject *attr = PyInt_FromLong(self->ipo->showkey);
if (attr) return attr;
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
"couldn't get Ipo.showkey attribute"));
}
static PyObject *Ipo_setShowkey(C_Ipo *self, PyObject *args)
{
int showkey = 0;
if (!PyArg_ParseTuple(args, "i", &showkey))
return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected string argument"));
self->ipo->showkey = (short)showkey;
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *Ipo_getPad(C_Ipo *self)
{
PyObject *attr = PyInt_FromLong(self->ipo->pad);
if (attr) return attr;
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
"couldn't get Ipo.pad attribute"));
}
static PyObject *Ipo_setPad(C_Ipo *self, PyObject *args)
{
int pad = 0;
if (!PyArg_ParseTuple(args, "i", &pad))
return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected string argument"));
self->ipo->pad = pad;
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *Ipo_getRctf(C_Ipo *self)
{
PyObject* l = PyList_New(0);
PyList_Append( l, PyFloat_FromDouble(self->ipo->cur.xmin));
PyList_Append( l, PyFloat_FromDouble(self->ipo->cur.xmax));
PyList_Append( l, PyFloat_FromDouble(self->ipo->cur.ymin));
PyList_Append( l, PyFloat_FromDouble(self->ipo->cur.ymax));
return l;
}
static PyObject *Ipo_setRctf(C_Ipo *self, PyObject *args)
{
float v[4];
if (!PyArg_ParseTuple(args, "ffff",v,v+1,v+2,v+3))
return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected 4 float argument"));
self->ipo->cur.xmin = v[0];
self->ipo->cur.xmax = v[1];
self->ipo->cur.ymin = v[2];
self->ipo->cur.ymax = v[3];
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *Ipo_getNcurves(C_Ipo *self)
{
int i = 0;
IpoCurve *icu;
for (icu=self->ipo->curve.first; icu; icu=icu->next){
i++;
}
return (PyInt_FromLong(i) );
}
static PyObject *Ipo_getCurveBP(C_Ipo *self, PyObject *args)
{
struct BPoint *ptrbpoint;
int num = 0,i;
IpoCurve *icu;
PyObject* l;
if (!PyArg_ParseTuple(args, "i",&num))
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;
}
ptrbpoint = icu->bp;
if(!ptrbpoint)return EXPP_ReturnPyObjError(PyExc_TypeError,"No base point");
l = PyList_New(0);
for(i=0;i<4;i++)
PyList_Append( l, PyFloat_FromDouble(ptrbpoint->vec[i]));
return l;
}
static PyObject *Ipo_getCurveBeztriple(C_Ipo *self, PyObject *args)
{
struct BezTriple *ptrbt;
int num = 0,pos,i,j;
IpoCurve *icu;
PyObject* l = PyList_New(0);
if (!PyArg_ParseTuple(args, "ii",&num,&pos))
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;
}
if (pos >= icu->totvert)
return EXPP_ReturnPyObjError(PyExc_TypeError,"Bad bezt number");
ptrbt = icu->bezt + pos;
if(!ptrbt)
return EXPP_ReturnPyObjError(PyExc_TypeError,"No bez triple");
for(i=0;i<3;i++)
for(j=0;j<3;j++)
PyList_Append( l, PyFloat_FromDouble(ptrbt->vec[i][j]));
return l;
}
static PyObject *Ipo_setCurveBeztriple(C_Ipo *self, PyObject *args)
{
struct BezTriple *ptrbt;
int num = 0,pos,i;
IpoCurve *icu;
PyObject *listargs=0;
if (!PyArg_ParseTuple(args, "iiO",&num,&pos,&listargs))
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;
}
if (pos >= icu->totvert)
return EXPP_ReturnPyObjError(PyExc_TypeError,"Bad bezt number");
ptrbt = icu->bezt + pos;
if(!ptrbt)
return EXPP_ReturnPyObjError(PyExc_TypeError,"No bez triple");
for(i=0;i<9;i++)
{
PyObject * xx = PyList_GetItem(listargs,i);
ptrbt->vec[i/3][i%3] = PyFloat_AsDouble(xx);
}
Py_INCREF(Py_None);
return Py_None;
}
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"));
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(icu->curval);
}
/*****************************************************************************/
/* Function: IpoDeAlloc */
/* Description: This is a callback function for the C_Ipo type. It is */
/* the destructor function. */
/*****************************************************************************/
static void IpoDeAlloc (C_Ipo *self)
{
PyObject_DEL (self);
}
/*****************************************************************************/
/* Function: IpoGetAttr */
/* Description: This is a callback function for the C_Ipo type. It is */
/* the function that accesses C_Ipo "member variables" and */
/* methods. */
/*****************************************************************************/
static PyObject *IpoGetAttr (C_Ipo *self, char *name)
{
return Py_FindMethod(C_Ipo_methods, (PyObject *)self, name);
}
/*****************************************************************************/
/* Function: IpoSetAttr */
/* Description: This is a callback function for the C_Ipo type. It is the */
/* function that sets Ipo Data attributes (member variables).*/
/*****************************************************************************/
static int IpoSetAttr (C_Ipo *self, char *name, PyObject *value)
{
return 0; /* normal exit */
}
/*****************************************************************************/
/* Function: IpoPrint */
/* Description: This is a callback function for the C_Ipo type. It */
/* builds a meaninful string to 'print' ipo objects. */
/*****************************************************************************/
static int IpoPrint(C_Ipo *self, FILE *fp, int flags)
{
fprintf(fp, "[Ipo \"%s\"]", self->ipo->id.name+2);
return 0;
}
/*****************************************************************************/
/* Function: IpoRepr */
/* Description: This is a callback function for the C_Ipo type. It */
/* builds a meaninful string to represent ipo objects. */
/*****************************************************************************/
static PyObject *IpoRepr (C_Ipo *self)
{
return PyString_FromString(self->ipo->id.name+2);
}

View File

@@ -0,0 +1,180 @@
/*
*
* ***** 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_IPO_H
#define EXPP_IPO_H
#include <Python.h>
#include <BKE_main.h>
#include <BKE_global.h>
#include <BKE_object.h>
#include <BKE_library.h>
#include <BLI_blenlib.h>
#include <DNA_ipo_types.h>
#include "constant.h"
#include "gen_utils.h"
#include "modules.h"
/*****************************************************************************/
/* Python API function prototypes for the Ipo module. */
/*****************************************************************************/
static PyObject *M_Ipo_New (PyObject *self, PyObject *args);
static PyObject *M_Ipo_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.Ipo.__doc__ */
/*****************************************************************************/
char M_Ipo_doc[] = "";
char M_Ipo_New_doc[] ="";
char M_Ipo_Get_doc[] ="";
/*****************************************************************************/
/* Python method structure definition for Blender.Ipo module: */
/*****************************************************************************/
struct PyMethodDef M_Ipo_methods[] = {
{"New",(PyCFunction)M_Ipo_New, METH_VARARGS|METH_KEYWORDS,M_Ipo_New_doc},
{"Get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc},
{"get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python C_Ipo structure definition: */
/*****************************************************************************/
typedef struct {
PyObject_HEAD
Ipo *ipo;
} C_Ipo;
/*****************************************************************************/
/* Python C_Ipo methods declarations: */
/*****************************************************************************/
static PyObject *Ipo_getName(C_Ipo *self);
static PyObject *Ipo_setName(C_Ipo *self, PyObject *args);
static PyObject *Ipo_getBlocktype(C_Ipo *self);
static PyObject *Ipo_setBlocktype(C_Ipo *self, PyObject *args);
static PyObject *Ipo_getShowkey(C_Ipo *self);
static PyObject *Ipo_setShowkey(C_Ipo *self, PyObject *args);
static PyObject *Ipo_getPad(C_Ipo *self);
static PyObject *Ipo_setPad(C_Ipo *self, PyObject *args);
static PyObject *Ipo_getRctf(C_Ipo *self);
static PyObject *Ipo_setRctf(C_Ipo *self, PyObject *args);
static PyObject *Ipo_getNcurves(C_Ipo *self);
static PyObject *Ipo_getCurveBP(C_Ipo *self, PyObject *args);
static PyObject *Ipo_getCurvecurval(C_Ipo *self, PyObject *args);
static PyObject *Ipo_setCurveBeztriple(C_Ipo *self, PyObject *args);
static PyObject *Ipo_getCurveBeztriple(C_Ipo *self, PyObject *args);
/*****************************************************************************/
/* Python C_Ipo methods table: */
/*****************************************************************************/
static PyMethodDef C_Ipo_methods[] = {
/* name, method, flags, doc */
{"getName", (PyCFunction)Ipo_getName, METH_NOARGS,
"() - Return Ipo Data name"},
{"setName", (PyCFunction)Ipo_setName, METH_VARARGS,
"(str) - Change Ipo Data name"},
{"getBlocktype", (PyCFunction)Ipo_getBlocktype, METH_NOARGS,
"() - Return Ipo blocktype -"},
{"setBlocktype", (PyCFunction)Ipo_setBlocktype, METH_VARARGS,
"(str) - Change Ipo blocktype"},
{"getShowkey", (PyCFunction)Ipo_getShowkey, METH_NOARGS,
"() - Return Ipo showkey - "},
{"setShowkey", (PyCFunction)Ipo_setShowkey, METH_VARARGS,
"(str) - Change Ipo showkey"},
{"getPad", (PyCFunction)Ipo_getPad, METH_NOARGS,
"() - Return Ipo pad - "},
{"setPad", (PyCFunction)Ipo_setPad, METH_VARARGS,
"(str) - Change Ipo pad"},
{"getRctf", (PyCFunction)Ipo_getRctf, METH_NOARGS,
"() - Return Ipo rctf - "},
{"setRctf", (PyCFunction)Ipo_setRctf, METH_VARARGS,
"(str) - Change Ipo rctf"},
{"getNcurves", (PyCFunction)Ipo_getNcurves, METH_NOARGS,
"() - Return Ipo ncurves"},
{"getCurveBP", (PyCFunction)Ipo_getCurveBP, METH_VARARGS,
"() - Return Ipo ncurves"},
{"getCurveCurval", (PyCFunction)Ipo_getCurvecurval, METH_VARARGS,
"() - Return curval"},
{"getCurveBeztriple", (PyCFunction)Ipo_getCurveBeztriple, METH_VARARGS,
"() - Return Ipo ncurves"},
{"setCurveBeztriple", (PyCFunction)Ipo_setCurveBeztriple, METH_VARARGS,
"() - Return curval"},
{0}
};
/*****************************************************************************/
/* Python Ipo_Type callback function prototypes: */
/*****************************************************************************/
static void IpoDeAlloc (C_Ipo *self);
static int IpoPrint (C_Ipo *self, FILE *fp, int flags);
static int IpoSetAttr (C_Ipo *self, char *name, PyObject *v);
static PyObject *IpoGetAttr (C_Ipo *self, char *name);
static PyObject *IpoRepr (C_Ipo *self);
/*****************************************************************************/
/* Python Ipo_Type structure definition: */
/*****************************************************************************/
static PyTypeObject Ipo_Type =
{
PyObject_HEAD_INIT(&PyType_Type)
0, /* ob_size */
"Ipo", /* tp_name */
sizeof (C_Ipo), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)IpoDeAlloc, /* tp_dealloc */
(printfunc)IpoPrint, /* tp_print */
(getattrfunc)IpoGetAttr, /* tp_getattr */
(setattrfunc)IpoSetAttr, /* tp_setattr */
0, /* tp_compare */
(reprfunc)IpoRepr, /* 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_Ipo_methods, /* tp_methods */
0, /* tp_members */
};
#endif /* EXPP_IPO_H */

View File

@@ -53,7 +53,7 @@ static PyObject *M_Lamp_New(PyObject *self, PyObject *args, PyObject *keywords)
bl_lamp = add_lamp(); /* first create in Blender */ bl_lamp = add_lamp(); /* first create in Blender */
if (bl_lamp) /* now create the wrapper obj in Python */ if (bl_lamp) /* now create the wrapper obj in Python */
py_lamp = (C_Lamp *)Lamp_createPyObject(bl_lamp); py_lamp = (C_Lamp *)Lamp_CreatePyObject(bl_lamp);
else else
return (EXPP_ReturnPyObjError (PyExc_RuntimeError, return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
"couldn't create Lamp Data in Blender")); "couldn't create Lamp Data in Blender"));
@@ -112,7 +112,7 @@ static PyObject *M_Lamp_Get(PyObject *self, PyObject *args)
while ((lamp_iter) && (wanted_lamp == NULL)) { while ((lamp_iter) && (wanted_lamp == NULL)) {
if (strcmp (name, lamp_iter->id.name+2) == 0) if (strcmp (name, lamp_iter->id.name+2) == 0)
wanted_lamp = (C_Lamp *)Lamp_createPyObject(lamp_iter); wanted_lamp = (C_Lamp *)Lamp_CreatePyObject(lamp_iter);
lamp_iter = lamp_iter->id.next; lamp_iter = lamp_iter->id.next;
} }
@@ -216,11 +216,11 @@ PyObject *M_Lamp_Init (void)
/* Three Python Lamp_Type helper functions needed by the Object module: */ /* Three Python Lamp_Type helper functions needed by the Object module: */
/*****************************************************************************/ /*****************************************************************************/
/* Function: Lamp_createPyObject */ /* Function: Lamp_CreatePyObject */
/* Description: This function will create a new C_Lamp from an existing */ /* Description: This function will create a new C_Lamp from an existing */
/* Blender lamp structure. */ /* Blender lamp structure. */
/*****************************************************************************/ /*****************************************************************************/
PyObject *Lamp_createPyObject (Lamp *lamp) PyObject *Lamp_CreatePyObject (Lamp *lamp)
{ {
C_Lamp *pylamp; C_Lamp *pylamp;
float *rgb[3]; float *rgb[3];
@@ -243,21 +243,21 @@ PyObject *Lamp_createPyObject (Lamp *lamp)
} }
/*****************************************************************************/ /*****************************************************************************/
/* Function: Lamp_checkPyObject */ /* Function: Lamp_CheckPyObject */
/* Description: This function returns true when the given PyObject is of the */ /* Description: This function returns true when the given PyObject is of the */
/* type Lamp. Otherwise it will return false. */ /* type Lamp. Otherwise it will return false. */
/*****************************************************************************/ /*****************************************************************************/
int Lamp_checkPyObject (PyObject *pyobj) int Lamp_CheckPyObject (PyObject *pyobj)
{ {
return (pyobj->ob_type == &Lamp_Type); return (pyobj->ob_type == &Lamp_Type);
} }
/*****************************************************************************/ /*****************************************************************************/
/* Function: Lamp_fromPyObject */ /* Function: Lamp_FromPyObject */
/* Description: This function returns the Blender lamp from the given */ /* Description: This function returns the Blender lamp from the given */
/* PyObject. */ /* PyObject. */
/*****************************************************************************/ /*****************************************************************************/
Lamp *Lamp_fromPyObject (PyObject *pyobj) Lamp *Lamp_FromPyObject (PyObject *pyobj)
{ {
return ((C_Lamp *)pyobj)->lamp; return ((C_Lamp *)pyobj)->lamp;
} }

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,306 @@
/*
*
* ***** 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_METABALL_H
#define EXPP_METABALL_H
#include <Python.h>
#include <BKE_main.h>
#include <BKE_global.h>
#include <BKE_mball.h>
#include <BKE_object.h>
#include <BKE_library.h>
#include <BLI_blenlib.h>
#include <DNA_meta_types.h>
#include "constant.h"
#include "gen_utils.h"
#include "modules.h"
/*****************************************************************************/
/* Python C_Metaball defaults: */
/*****************************************************************************/
/*****************************************************************************/
/* Python API function prototypes for the Metaball module. */
/*****************************************************************************/
static PyObject *M_Metaball_New (PyObject *self, PyObject *args);
static PyObject *M_Metaball_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.Metaball.__doc__ */
/*****************************************************************************/
char M_Metaball_doc[] =
"The Blender Metaball module\n\n\nMetaballs are spheres\
that can join each other to create smooth,\
organic volumes\n. The spheres themseves are called\
'Metaelements' and can be accessed from the Metaball module.";
char M_Metaball_New_doc[] ="Creates a new metaball";
char M_Metaball_Get_doc[] ="Retreives an existing metaball";
/*****************************************************************************/
/* Python method structure definition for Blender.Metaball module: */
/*****************************************************************************/
struct PyMethodDef M_Metaball_methods[] = {
{"New",M_Metaball_New, METH_VARARGS,M_Metaball_New_doc},
{"Get", M_Metaball_Get, METH_VARARGS, M_Metaball_Get_doc},
{"get", M_Metaball_Get, METH_VARARGS, M_Metaball_Get_doc},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
/* Python C_Metaball structure definition: */
/*****************************************************************************/
typedef struct {
PyObject_HEAD
MetaBall *metaball;
} C_Metaball;
/*****************************************************************************/
/* Python C_Metaball methods declarations: */
/*****************************************************************************/
static PyObject *Metaball_getBbox(C_Metaball *self);
static PyObject *Metaball_getName(C_Metaball *self);
static PyObject *Metaball_setName(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getWiresize(C_Metaball *self);
static PyObject *Metaball_setWiresize(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getRendersize(C_Metaball *self);
static PyObject *Metaball_setRendersize(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getThresh(C_Metaball *self);
static PyObject *Metaball_setThresh(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getNMetaElems(C_Metaball *self);
static PyObject *Metaball_getNMetaElems1(C_Metaball *self);
static PyObject *Metaball_getMetatype(C_Metaball *self,PyObject*args);
static PyObject *Metaball_setMetatype(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getMetadata(C_Metaball *self,PyObject*args);
static PyObject *Metaball_setMetadata(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getMetalay(C_Metaball *self,PyObject*args);
static PyObject *Metaball_setMetalay(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getMetaflag(C_Metaball *self,PyObject*args);
static PyObject *Metaball_setMetaflag(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getMetaselcol(C_Metaball *self,PyObject*args);
static PyObject *Metaball_setMetaselcol(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getMetapad(C_Metaball *self,PyObject*args);
static PyObject *Metaball_setMetapad(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getMetax(C_Metaball *self,PyObject*args);
static PyObject *Metaball_setMetax(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getMetay(C_Metaball *self,PyObject*args);
static PyObject *Metaball_setMetay(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getMetaz(C_Metaball *self,PyObject*args);
static PyObject *Metaball_setMetaz(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getMetaexpx(C_Metaball *self,PyObject*args);
static PyObject *Metaball_setMetaexpx(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getMetaexpy(C_Metaball *self,PyObject*args);
static PyObject *Metaball_setMetaexpy(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getMetaexpz(C_Metaball *self,PyObject*args);
static PyObject *Metaball_setMetaexpz(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getMetarad(C_Metaball *self,PyObject*args);
static PyObject *Metaball_setMetarad(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getMetarad2(C_Metaball *self,PyObject*args);
static PyObject *Metaball_setMetarad2(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getMetas(C_Metaball *self,PyObject*args);
static PyObject *Metaball_setMetas(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getMetalen(C_Metaball *self,PyObject*args);
static PyObject *Metaball_setMetalen(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getMetamaxrad2(C_Metaball *self,PyObject*args);
static PyObject *Metaball_setMetamaxrad2(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getloc(C_Metaball *self);
static PyObject *Metaball_setloc(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getrot(C_Metaball *self);
static PyObject *Metaball_setrot(C_Metaball *self,PyObject*args);
static PyObject *Metaball_getsize(C_Metaball *self);
static PyObject *Metaball_setsize(C_Metaball *self,PyObject*args);
/*****************************************************************************/
/* Python C_Metaball methods table: */
/*****************************************************************************/
static PyMethodDef C_Metaball_methods[] = {
/* name, method, flags, doc */
{"getName", (PyCFunction)Metaball_getName,\
METH_NOARGS, "() - Return Metaball Data name"},
{"setName", (PyCFunction)Metaball_setName,\
METH_VARARGS, "() - Sets Metaball Data name"},
{"getWiresize", (PyCFunction)Metaball_getWiresize,\
METH_NOARGS, "() - Return Metaball Data wiresize"},
{"setWiresize", (PyCFunction)Metaball_setWiresize,\
METH_VARARGS, "() - Sets Metaball Data wiresize"},
{"getRendersize", (PyCFunction)Metaball_getRendersize,\
METH_NOARGS, "() - Return Metaball Data rendersize"},
{"setRendersize", (PyCFunction)Metaball_setRendersize,\
METH_VARARGS, "() - Sets Metaball Data rendersize"},
{"getThresh", (PyCFunction)Metaball_getThresh,\
METH_NOARGS, "() - Return Metaball Data thresh"},
{"setThresh", (PyCFunction)Metaball_setThresh,\
METH_VARARGS, "() - Sets Metaball Data thresh"},
{"getBbox", (PyCFunction)Metaball_getBbox,\
METH_NOARGS, "() - Return Metaball bounding box"},
{"getNMetaElems",(PyCFunction)Metaball_getNMetaElems,\
METH_NOARGS, "() - "},
{"getNMetaElems1",(PyCFunction)Metaball_getNMetaElems1,\
METH_NOARGS, "() - "},
{"getMetatype", (PyCFunction)Metaball_getMetatype , \
METH_VARARGS, "() - "},
{"setMetatype", (PyCFunction)Metaball_setMetatype , \
METH_VARARGS, "() - "},
{"getMetadata", (PyCFunction)Metaball_getMetadata , \
METH_VARARGS, "() - Gets Metaball MetaData "},
{"setMetadata", (PyCFunction)Metaball_setMetadata , \
METH_VARARGS, "() - "},
{"getMetalay", (PyCFunction)Metaball_getMetalay , \
METH_VARARGS, "() - "},
{"setMetalay", (PyCFunction)Metaball_setMetalay , \
METH_VARARGS, "() - "},
{"getMetaflag", (PyCFunction)Metaball_getMetaflag , \
METH_VARARGS, "() - "},
{"setMetaflag", (PyCFunction)Metaball_setMetaflag , \
METH_VARARGS, "() - "},
{"getMetaselcol", (PyCFunction)Metaball_getMetaselcol , \
METH_VARARGS, "() - "},
{"setMetaselcol", (PyCFunction)Metaball_setMetaselcol , \
METH_VARARGS, "() - "},
{"getMetapad", (PyCFunction)Metaball_getMetapad , \
METH_VARARGS, "() - "},
{"setMetapad", (PyCFunction)Metaball_setMetapad , \
METH_VARARGS, "() - "},
{"getMetax", (PyCFunction)Metaball_getMetax , \
METH_VARARGS, "() - "},
{"setMetax", (PyCFunction)Metaball_setMetax , \
METH_VARARGS, "() - "},
{"getMetay", (PyCFunction)Metaball_getMetay , \
METH_VARARGS, "() - "},
{"setMetay", (PyCFunction)Metaball_setMetay , \
METH_VARARGS, "() - "},
{"getMetaz", (PyCFunction)Metaball_getMetaz , \
METH_VARARGS, "() - "},
{"setMetaz", (PyCFunction)Metaball_setMetaz , \
METH_VARARGS, "() - "},
{"getMetaexpx", (PyCFunction)Metaball_getMetaexpx , \
METH_VARARGS, "() - "},
{"setMetaexpx", (PyCFunction)Metaball_setMetaexpx , \
METH_VARARGS, "() - "},
{"getMetaexpy", (PyCFunction)Metaball_getMetaexpy , \
METH_VARARGS, "() - "},
{"setMetaexpy", (PyCFunction)Metaball_setMetaexpy , \
METH_VARARGS, "() - "},
{"getMetaexpz", (PyCFunction)Metaball_getMetaexpz , \
METH_VARARGS, "() - "},
{"setMetaexpz", (PyCFunction)Metaball_setMetaexpz , \
METH_VARARGS, "() - "},
{"getMetarad", (PyCFunction)Metaball_getMetarad , \
METH_VARARGS, "() - "},
{"setMetarad", (PyCFunction)Metaball_setMetarad , \
METH_VARARGS, "() - "},
{"getMetarad2", (PyCFunction)Metaball_getMetarad2 , \
METH_VARARGS, "() - "},
{"setMetarad2", (PyCFunction)Metaball_setMetarad2 , \
METH_VARARGS, "() - "},
{"getMetas", (PyCFunction)Metaball_getMetas , \
METH_VARARGS, "() - "},
{"setMetas", (PyCFunction)Metaball_setMetas , \
METH_VARARGS, "() - "},
{"getMetalen", (PyCFunction)Metaball_getMetalen , \
METH_VARARGS, "() - "},
{"setMetalen", (PyCFunction)Metaball_setMetalen , \
METH_VARARGS, "() - "},
{"getMetamaxrad2", (PyCFunction)Metaball_getMetamaxrad2 , \
METH_VARARGS, "() - "},
{"setMetamaxrad2", (PyCFunction)Metaball_setMetamaxrad2 , \
METH_VARARGS, "() - "},
{"getloc", (PyCFunction)Metaball_getloc , \
METH_NOARGS, "() - Gets Metaball loc values"},
{"setloc", (PyCFunction)Metaball_setloc , \
METH_VARARGS, "(f f f) - Sets Metaball loc values"},
{"getrot", (PyCFunction)Metaball_getrot , \
METH_NOARGS, "() - Gets Metaball rot values"},
{"setrot", (PyCFunction)Metaball_setrot , \
METH_VARARGS, "(f f f) - Sets Metaball rot values"},
{"getsize", (PyCFunction)Metaball_getsize , \
METH_NOARGS, "() - Gets Metaball size values"},
{"setsize", (PyCFunction)Metaball_setsize , \
METH_VARARGS, "(f f f) - Sets Metaball size values"},
/*end of MetaElem data*/
{0}
};
/*****************************************************************************/
/* Python Metaball_Type callback function prototypes: */
/*****************************************************************************/
static void MetaballDeAlloc (C_Metaball *self);
static int MetaballPrint (C_Metaball *self, FILE *fp, int flags);
static int MetaballSetAttr (C_Metaball *self, char *name, PyObject *v);
static PyObject *MetaballGetAttr (C_Metaball *self, char *name);
static PyObject *MetaballRepr (C_Metaball *self);
/*****************************************************************************/
/* Python Metaball_Type structure definition: */
/*****************************************************************************/
static PyTypeObject Metaball_Type =
{
PyObject_HEAD_INIT(&PyType_Type)
0, /* ob_size */
"Metaball", /* tp_name */
sizeof (C_Metaball), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)MetaballDeAlloc, /* tp_dealloc */
(printfunc)MetaballPrint, /* tp_print */
(getattrfunc)MetaballGetAttr, /* tp_getattr */
(setattrfunc)MetaballSetAttr, /* tp_setattr */
0, /* tp_compare */
(reprfunc)MetaballRepr, /* 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_Metaball_methods, /* tp_methods */
0, /* tp_members */
};
#endif /* EXPP_METABALL_H */

View File

@@ -397,7 +397,7 @@ static PyObject *Object_getData (C_Object *self)
case ID_IP: case ID_IP:
break; break;
case ID_LA: case ID_LA:
data_object = Lamp_createPyObject (self->object->data); data_object = Lamp_CreatePyObject (self->object->data);
break; break;
case ID_MA: case ID_MA:
break; break;
@@ -592,9 +592,9 @@ static PyObject *Object_link (C_Object *self, PyObject *args)
"expected an object as argument")); "expected an object as argument"));
} }
if (Camera_CheckPyObject (py_data)) if (Camera_CheckPyObject (py_data))
data = (void*) Camera_FromPyObject (py_data); data = (void *)Camera_FromPyObject (py_data);
if (Lamp_checkPyObject (py_data)) if (Lamp_CheckPyObject (py_data))
data = (void*) Lamp_fromPyObject (py_data); data = (void *)Lamp_FromPyObject (py_data);
/* TODO: add the (N)Mesh check and from functions here when finished. */ /* TODO: add the (N)Mesh check and from functions here when finished. */
oldid = (ID*) self->object->data; oldid = (ID*) self->object->data;

View File

@@ -38,8 +38,10 @@
#include <DNA_camera_types.h> #include <DNA_camera_types.h>
#include <DNA_lamp_types.h> #include <DNA_lamp_types.h>
#include <DNA_curve_types.h> #include <DNA_curve_types.h>
#include <DNA_effect_types.h>
#include <DNA_armature_types.h> #include <DNA_armature_types.h>
#include <DNA_ipo_types.h>
#include <DNA_effect_types.h>
#include <DNA_meta_types.h>
#include <DNA_image_types.h> #include <DNA_image_types.h>
/*****************************************************************************/ /*****************************************************************************/
@@ -77,9 +79,9 @@ int Camera_CheckPyObject (PyObject *pyobj);
/* Lamp Data */ /* Lamp Data */
PyObject * M_Lamp_Init (void); PyObject * M_Lamp_Init (void);
PyObject * Lamp_createPyObject (struct Lamp *lamp); PyObject * Lamp_CreatePyObject (struct Lamp *lamp);
Lamp * Lamp_fromPyObject (PyObject *pyobj); Lamp * Lamp_FromPyObject (PyObject *pyobj);
int Lamp_checkPyObject (PyObject *pyobj); int Lamp_CheckPyObject (PyObject *pyobj);
/* Curve Data */ /* Curve Data */
PyObject * M_Curve_Init (void); PyObject * M_Curve_Init (void);
@@ -93,12 +95,23 @@ PyObject * M_ArmatureCreatePyObject (bArmature *armature);
bArmature* M_ArmatureFromPyObject (PyObject *py_obj); bArmature* M_ArmatureFromPyObject (PyObject *py_obj);
int M_ArmatureCheckPyObject (PyObject *py_obj); int M_ArmatureCheckPyObject (PyObject *py_obj);
/* Ipo Data */
PyObject * M_Ipo_Init (void);
PyObject * Ipo_CreatePyObject (struct Ipo *ipo);
struct Ipo * Ipo_FromPyObject (PyObject *py_obj);
int Ipo_CheckPyObject (PyObject *py_obj);
/* Metaball Data */
PyObject * M_Metaball_Init (void);
PyObject * Metaball_CreatePyObject (MetaBall *metaball);
struct MetaBall * Metaball_FromPyObject (PyObject *py_obj);
int Metaball_CheckPyObject (PyObject *py_obj);
/* Particle Effects Data */ /* Particle Effects Data */
/*PyObject * M_Effect_Init (void); PyObject * M_Effect_Init (void);
PyObject * EffectCreatePyObject (struct Effect *effect); PyObject * Effect_CreatePyObject (struct Effect *effect);
struct Effect * EffectFromPyObject (PyObject *py_obj); struct Effect * Effect_FromPyObject (PyObject *py_obj);
int EffectCheckPyObject (PyObject *py_obj); int Effect_CheckPyObject (PyObject *py_obj);
*/
/* Image */ /* Image */
PyObject * M_Image_Init (void); PyObject * M_Image_Init (void);