From 81dae537b1318b0c371eb0117ec5e04634fad269 Mon Sep 17 00:00:00 2001 From: Jacques Guignot Date: Sat, 21 Jun 2003 11:44:10 +0000 Subject: [PATCH] *** empty log message *** --- source/blender/python/api2_2x/Build.c | 338 ++++++++++++++++++ source/blender/python/api2_2x/Build.h | 93 +++++ source/blender/python/api2_2x/Effect.c | 327 +++++++++++++++++ source/blender/python/api2_2x/Effect.h | 117 ++++++ .../blender/python/api2_2x/doc/Curvedoc.txt | 105 ++++++ .../blender/python/api2_2x/doc/Effectdoc.txt | 257 +++++++++++++ source/blender/python/api2_2x/doc/Ipodoc.txt | 66 ++++ .../python/api2_2x/doc/Metaballdoc.txt | 58 +++ .../blender/python/api2_2x/doc/Worlddoc.txt | 58 +++ 9 files changed, 1419 insertions(+) create mode 100644 source/blender/python/api2_2x/Build.c create mode 100644 source/blender/python/api2_2x/Build.h create mode 100644 source/blender/python/api2_2x/Effect.c create mode 100644 source/blender/python/api2_2x/Effect.h create mode 100644 source/blender/python/api2_2x/doc/Curvedoc.txt create mode 100644 source/blender/python/api2_2x/doc/Effectdoc.txt create mode 100644 source/blender/python/api2_2x/doc/Ipodoc.txt create mode 100644 source/blender/python/api2_2x/doc/Metaballdoc.txt create mode 100644 source/blender/python/api2_2x/doc/Worlddoc.txt diff --git a/source/blender/python/api2_2x/Build.c b/source/blender/python/api2_2x/Build.c new file mode 100644 index 00000000000..b2f285986bf --- /dev/null +++ b/source/blender/python/api2_2x/Build.c @@ -0,0 +1,338 @@ +/* + * + * ***** 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 "Build.h" +#include "Effect.h" + +/*****************************************************************************/ +/* Python C_Build methods table: */ +/*****************************************************************************/ +static PyMethodDef C_Build_methods[] = { + {"getType", (PyCFunction)Effect_getType, + METH_NOARGS,"() - Return Effect type"}, + {"setType", (PyCFunction)Effect_setType, + METH_VARARGS,"() - Set Effect type"}, + {"getFlag", (PyCFunction)Effect_getFlag, + METH_NOARGS,"() - Return Effect flag"}, + {"setFlag", (PyCFunction)Effect_setFlag, + METH_VARARGS,"() - Set Effect flag"}, + {"getLen",(PyCFunction)Build_getLen, + METH_NOARGS,"()-Return Build len"}, + {"setLen",(PyCFunction)Build_setLen, METH_VARARGS, + "()- Sets Build len"}, + {"getSfra",(PyCFunction)Build_getSfra, + METH_NOARGS,"()-Return Build sfra"}, + {"setSfra",(PyCFunction)Build_setSfra, METH_VARARGS, + "()- Sets Build sfra"}, + {0} +}; +/*****************************************************************************/ +/* Python Build_Type structure definition: */ +/*****************************************************************************/ +PyTypeObject Build_Type = +{ + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ + "Build", /* tp_name */ + sizeof (C_Build), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)BuildDeAlloc, /* tp_dealloc */ + (printfunc)BuildPrint, /* tp_print */ + (getattrfunc)BuildGetAttr, /* tp_getattr */ + (setattrfunc)BuildSetAttr, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc)BuildRepr, /* 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_Build_methods, /* tp_methods */ + 0, /* tp_members */ +}; + +/*****************************************************************************/ +/* Python method structure definition for Blender.Build module: */ +/*****************************************************************************/ +struct PyMethodDef M_Build_methods[] = { + {"New",(PyCFunction)M_Build_New, METH_VARARGS,0}, + {"Get", M_Build_Get, METH_VARARGS, 0}, + {"get", M_Build_Get, METH_VARARGS, 0}, + {NULL, NULL, 0, NULL} +}; + + +/*****************************************************************************/ +/* Function: M_Build_New */ +/* Python equivalent: Blender.Effect.Build.New */ +/*****************************************************************************/ +PyObject *M_Build_New(PyObject *self, PyObject *args) +{ +int type = EFF_BUILD; + C_Effect *pyeffect; + Effect *bleffect = 0; + + printf ("In Effect_New()\n"); + + bleffect = add_effect(type); + if (bleffect == NULL) + return (EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't create Effect Data in Blender")); + + pyeffect = (C_Effect *)PyObject_NEW(C_Effect, &Effect_Type); + + + if (pyeffect == NULL) return (EXPP_ReturnPyObjError (PyExc_MemoryError, + "couldn't create Effect Data object")); + + pyeffect->effect = bleffect; + + return (PyObject *)pyeffect; + return 0; +} + +/*****************************************************************************/ +/* Function: M_Build_Get */ +/* Python equivalent: Blender.Effect.Build.Get */ +/*****************************************************************************/ +PyObject *M_Build_Get(PyObject *self, PyObject *args) +{ + /*arguments : string object name + int : position of effect in the obj's effect list */ + char *name = 0; + Object *object_iter; + Effect *eff; + C_Build *wanted_eff; + int num,i; + printf ("In Effect_Get()\n"); + if (!PyArg_ParseTuple(args, "si", &name, &num )) + return(EXPP_ReturnPyObjError(PyExc_AttributeError,\ + "expected string int argument")); + + object_iter = G.main->object.first; + if (!object_iter)return(EXPP_ReturnPyObjError(PyExc_AttributeError,\ + "Scene contains no object")); + + while (object_iter) + { + if (strcmp(name,object_iter->id.name+2)) + { + object_iter = object_iter->id.next; + continue; + } + + + if (object_iter->effect.first != NULL) + { + eff = object_iter->effect.first; + for(i = 0;itype != EFF_BUILD)continue; + eff = eff->next; + if (!eff) + return(EXPP_ReturnPyObjError(PyExc_AttributeError,"bject")); + } + wanted_eff = (C_Build *)PyObject_NEW(C_Build, &Build_Type); + wanted_eff->build = eff; + return (PyObject*)wanted_eff; + } + object_iter = object_iter->id.next; + } + Py_INCREF(Py_None); + return Py_None; +} + +/*****************************************************************************/ +/* Function: M_Build_Init */ +/*****************************************************************************/ +PyObject *M_Build_Init (void) +{ + PyObject *submodule; + printf ("In M_Build_Init()\n"); + Build_Type.ob_type = &PyType_Type; + submodule = Py_InitModule3("Blender.Build",M_Build_methods, 0); + return (submodule); +} + +/*****************************************************************************/ +/* Python C_Build methods: */ +/*****************************************************************************/ + +PyObject *Build_getLen(C_Build *self) +{ + BuildEff*ptr = (BuildEff*)self->build; + return PyFloat_FromDouble(ptr->len); +} + + +PyObject *Build_setLen(C_Build *self,PyObject *args) +{ + BuildEff*ptr = (BuildEff*)self->build; + float val = 0; +if (!PyArg_ParseTuple(args, "f", &val )) + return(EXPP_ReturnPyObjError(PyExc_AttributeError,\ + "expected float argument")); + ptr->len = val; + Py_INCREF(Py_None); + return Py_None; +} + + +PyObject *Build_getSfra(C_Build *self) +{ + BuildEff*ptr = (BuildEff*)self->build; + return PyFloat_FromDouble(ptr->sfra); +} + +PyObject *Build_setSfra(C_Build *self,PyObject *args) +{ + BuildEff*ptr = (BuildEff*)self->build; + float val = 0; + if (!PyArg_ParseTuple(args, "f", &val )) + return(EXPP_ReturnPyObjError(PyExc_AttributeError,"expected float argument")); + + ptr->sfra = val; + Py_INCREF(Py_None); + return Py_None; +} + +/*****************************************************************************/ +/* Function: BuildDeAlloc */ +/* Description: This is a callback function for the C_Build type. It is */ +/* the destructor function. */ +/*****************************************************************************/ +void BuildDeAlloc (C_Build *self) +{ + BuildEff*ptr = (BuildEff*)self; + PyObject_DEL (ptr); +} + +/*****************************************************************************/ +/* Function: BuildGetAttr */ +/* Description: This is a callback function for the C_Build type. It is */ +/* the function that accesses C_Build "member variables" and */ +/* methods. */ +/*****************************************************************************/ + +PyObject *BuildGetAttr (C_Build *self, char *name) +{ + if (!strcmp(name,"sfra"))return Build_getSfra( self); + if (!strcmp(name,"len"))return Build_getLen( self); + return Py_FindMethod(C_Build_methods, (PyObject *)self, name); +} + +/*****************************************************************************/ +/* Function: BuildSetAttr */ +/* Description: This is a callback function for the C_Build type. It is the */ +/* function that sets Build Data attributes (member variables). */ +/*****************************************************************************/ +int BuildSetAttr (C_Build *self, char *name, PyObject *value) +{ + PyObject *valtuple; + PyObject *error = NULL; + valtuple = Py_BuildValue("(N)", value); + + if (!valtuple) + return EXPP_ReturnIntError(PyExc_MemoryError, + "CameraSetAttr: couldn't create PyTuple"); + + if (!strcmp (name, "sfra")) error = Build_setSfra (self, valtuple); + else if (!strcmp (name, "len")) error = Build_setLen (self, valtuple); + + else { + Py_DECREF(valtuple); + return (EXPP_ReturnIntError (PyExc_KeyError, + "attribute not found")); + } + + /* Py_DECREF(valtuple);*/ + + if (error != Py_None) return -1; + + Py_DECREF(Py_None); + return 0; +} + +/*****************************************************************************/ +/* Function: BuildPrint */ +/* Description: This is a callback function for the C_Build type. It */ +/* builds a meaninful string to 'print' build objects. */ +/*****************************************************************************/ +int BuildPrint(C_Build *self, FILE *fp, int flags) +{ + return 0; +} + +/*****************************************************************************/ +/* Function: BuildRepr */ +/* Description: This is a callback function for the C_Build type. It */ +/* builds a meaninful string to represent build objects. */ +/*****************************************************************************/ +PyObject *BuildRepr (C_Build *self) +{ + return 0; +} + +PyObject* BuildCreatePyObject (struct Effect *build) +{ + C_Build * blen_object; + + printf ("In BuildCreatePyObject\n"); + + blen_object = (C_Build*)PyObject_NEW (C_Build, &Build_Type); + + if (blen_object == NULL) + { + return (NULL); + } + blen_object->build = build; + return ((PyObject*)blen_object); + +} + +int BuildCheckPyObject (PyObject *py_obj) +{ +return (py_obj->ob_type == &Build_Type); +} + + +struct Build* BuildFromPyObject (PyObject *py_obj) +{ + C_Build * blen_obj; + + blen_obj = (C_Build*)py_obj; + return ((struct Build*)blen_obj->build); + +} + diff --git a/source/blender/python/api2_2x/Build.h b/source/blender/python/api2_2x/Build.h new file mode 100644 index 00000000000..cf07926d6a4 --- /dev/null +++ b/source/blender/python/api2_2x/Build.h @@ -0,0 +1,93 @@ +/* + * + * ***** 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_BUILD_H +#define EXPP_BUILD_H + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "gen_utils.h" + +/*****************************************************************************/ +/* Python API function prototypes for the Build module. */ +/*****************************************************************************/ +PyObject *M_Build_New (PyObject *self, PyObject *args); +PyObject *M_Build_Get (PyObject *self, PyObject *args); + +/*****************************************************************************/ +/* Python C_Build structure definition: */ +/*****************************************************************************/ +typedef struct { + PyObject_HEAD + Effect *build; +} C_Build; +#include"Effect.h" +/*****************************************************************************/ +/* Python C_Build methods declarations: */ +/*****************************************************************************/ +PyObject *Effect_getType(C_Effect *self); +PyObject *Effect_setType(C_Effect *self, PyObject *args); +PyObject *Effect_getFlag(C_Effect *self); +PyObject *Effect_setFlag(C_Effect *self, PyObject *args); +PyObject *Build_getLen(C_Build *self); +PyObject *Build_setLen(C_Build *self,PyObject*a); +PyObject *Build_getSfra(C_Build *self); +PyObject *Build_setSfra(C_Build *self,PyObject*a); +PyObject *Build_getLen(C_Build *self); +PyObject *Build_setLen(C_Build *self,PyObject*a); +PyObject *Build_getSfra(C_Build *self); +PyObject *Build_setSfra(C_Build *self,PyObject*a); + + +/*****************************************************************************/ +/* Python Build_Type callback function prototypes: */ +/*****************************************************************************/ +void BuildDeAlloc (C_Build *msh); +int BuildPrint (C_Build *msh, FILE *fp, int flags); +int BuildSetAttr (C_Build *msh, char *name, PyObject *v); +PyObject *BuildGetAttr (C_Build *msh, char *name); +PyObject *BuildRepr (C_Build *msh); +PyObject* BuildCreatePyObject (struct Effect *build); +int BuildCheckPyObject (PyObject *py_obj); +struct Build* BuildFromPyObject (PyObject *py_obj); + + + +#endif /* EXPP_BUILD_H */ diff --git a/source/blender/python/api2_2x/Effect.c b/source/blender/python/api2_2x/Effect.c new file mode 100644 index 00000000000..2dc4c9991ac --- /dev/null +++ b/source/blender/python/api2_2x/Effect.c @@ -0,0 +1,327 @@ +/* + * + * ***** 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 "Effect.h" +#include "Build.h" +#include "Particle.h" +#include "Wave.h" + + +/*****************************************************************************/ +/* Python method structure definition for Blender.Effect module: */ +/*****************************************************************************/ + + + + +struct PyMethodDef M_Effect_methods[] = { + {"New",(PyCFunction)M_Effect_New, METH_VARARGS,NULL}, + {"Get", M_Effect_Get, METH_VARARGS,NULL}, + {"get", M_Effect_Get, METH_VARARGS, NULL}, + {NULL, NULL, 0, NULL} +}; + +/*****************************************************************************/ +/* Function: M_Effect_New */ +/* Python equivalent: Blender.Effect.New */ +/*****************************************************************************/ +PyObject *M_Effect_New(PyObject *self, PyObject *args) +{ + C_Effect *pyeffect; + Effect *bleffect = 0; + int type = -1; + char * btype = NULL; + Py_INCREF(Py_None); + return Py_None; + if (!PyArg_ParseTuple(args, "s",&btype)) + return (EXPP_ReturnPyObjError (PyExc_TypeError, + "expected type argument(wave,build or particle)")); + if (!strcmp( btype,"wave"))type = EFF_WAVE; + if (!strcmp( btype,"build"))type = EFF_BUILD; + if (!strcmp( btype,"particle"))type = EFF_PARTICLE; + if (type == -1) + return (EXPP_ReturnPyObjError (PyExc_TypeError, + "unknown type ")); + + + bleffect = add_effect(type); + if (bleffect == NULL) + return (EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't create Effect Data in Blender")); + + pyeffect = (C_Effect *)PyObject_NEW(C_Effect, &Effect_Type); + + + if (pyeffect == NULL) return (EXPP_ReturnPyObjError (PyExc_MemoryError, + "couldn't create Effect Data object")); + + pyeffect->effect = bleffect; + + return (PyObject *)pyeffect; +} + +/*****************************************************************************/ +/* Function: M_Effect_Get */ +/* Python equivalent: Blender.Effect.Get */ +/*****************************************************************************/ +PyObject *M_Effect_Get(PyObject *self, PyObject *args) +{ + /*arguments : string object name + int : position of effect in the obj's effect list */ + char *name = 0; + Object *object_iter; + Effect *eff; + C_Effect *wanted_eff; + int num,i; + if (!PyArg_ParseTuple(args, "|si", &name, &num )) + return(EXPP_ReturnPyObjError(PyExc_AttributeError,\ + "expected string int argument")); + object_iter = G.main->object.first; + if (!object_iter)return(EXPP_ReturnPyObjError(PyExc_AttributeError,\ + "Scene contains no object")); + if(name){ + while (object_iter) + { + if (strcmp(name,object_iter->id.name+2)) + { + object_iter = object_iter->id.next; + continue; + } + + + if (object_iter->effect.first != NULL){ + eff = object_iter->effect.first; + for(i = 0;inext; + wanted_eff = (C_Effect *)PyObject_NEW(C_Effect, &Effect_Type); + wanted_eff->effect = eff; + return (PyObject*)wanted_eff; + } + object_iter = object_iter->id.next; + } + } + else{ +PyObject * effectlist = PyList_New (0); + while (object_iter) + { + if (object_iter->effect.first != NULL){ + eff = object_iter->effect.first; + while (eff){ + C_Effect *found_eff = (C_Effect *)PyObject_NEW(C_Effect, &Effect_Type); + found_eff->effect = eff; + PyList_Append (effectlist , (PyObject *)found_eff); + eff = eff->next; + } + } + object_iter = object_iter->id.next; + } + return effectlist; + } + Py_INCREF(Py_None); + return Py_None; +} + +/*****************************************************************************/ +/* Function: M_Effect_Init */ +/*****************************************************************************/ + + +PyObject *M_Build_Init (void); +PyObject *M_Wave_Init (void); +PyObject *M_Particle_Init (void); + +PyObject *M_Effect_Init (void) +{ + PyObject *submodule, *dict; + printf ("In M_Effect_Init()\n"); + Effect_Type.ob_type = &PyType_Type; + submodule = Py_InitModule3("Blender.Effect",M_Effect_methods, 0 ); + dict = PyModule_GetDict (submodule); + PyDict_SetItemString (dict, "Wave", M_Wave_Init()); + PyDict_SetItemString (dict, "Build", M_Build_Init()); + PyDict_SetItemString (dict, "Particle", M_Particle_Init()); + return (submodule); +} + +/*****************************************************************************/ +/* Python C_Effect methods: */ +/*****************************************************************************/ + +PyObject *Effect_getType(C_Effect *self) +{ + PyObject *attr = PyInt_FromLong((long)self->effect->type); + if (attr) return attr; + return (EXPP_ReturnPyObjError (PyExc_RuntimeError,\ + "couldn't get mode attribute")); +} + + +PyObject *Effect_setType(C_Effect *self, PyObject *args) +{ + int value; + if (!PyArg_ParseTuple(args, "i", &value)) + return (EXPP_ReturnPyObjError (PyExc_TypeError,\ + "expected an int as argument")); + self->effect->type = value; + Py_INCREF(Py_None); + return Py_None; +} + +PyObject *Effect_getFlag(C_Effect *self) +{ + PyObject *attr = PyInt_FromLong((long)self->effect->flag); + if (attr) return attr; + return (EXPP_ReturnPyObjError (PyExc_RuntimeError,\ + "couldn't get mode attribute")); +} + + +PyObject *Effect_setFlag(C_Effect *self, PyObject *args) +{ + int value; + if (!PyArg_ParseTuple(args, "i", &value)) + return (EXPP_ReturnPyObjError (PyExc_TypeError,\ + "expected an int as argument")); + self->effect->flag = value; + Py_INCREF(Py_None); + return Py_None; +} + + + + + +/*****************************************************************************/ +/* Function: EffectDeAlloc */ +/* Description: This is a callback function for the C_Effect type. It is */ +/* the destructor function. */ +/*****************************************************************************/ +void EffectDeAlloc (C_Effect *self) +{ + PyObject_DEL (self); +} + +/*****************************************************************************/ +/* Function: EffectGetAttr */ +/* Description: This is a callback function for the C_Effect type. It is */ +/* the function that accesses C_Effect "member variables" and */ +/* methods. */ +/*****************************************************************************/ + + +PyObject *EffectGetAttr (C_Effect *self, char *name) +{ + switch(self->effect->type) + { + case EFF_BUILD : return BuildGetAttr( (C_Build*)self, name); + case EFF_WAVE : return WaveGetAttr ((C_Wave*)self, name); + case EFF_PARTICLE : return ParticleGetAttr ((C_Particle*)self, name); + } + + return Py_FindMethod(C_Effect_methods, (PyObject *)self, name); +} + +/*****************************************************************************/ +/* Function: EffectSetAttr */ +/* Description: This is a callback function for the C_Effect type. It is the */ +/* function that sets Effect Data attributes (member variables).*/ +/*****************************************************************************/ + + +int EffectSetAttr (C_Effect *self, char *name, PyObject *value) +{ + switch(self->effect->type) + { + case EFF_BUILD : return BuildSetAttr( (C_Build*)self, name,value); + case EFF_WAVE : return WaveSetAttr ((C_Wave*)self, name,value); + case EFF_PARTICLE : return ParticleSetAttr ((C_Particle*)self, name,value); + } + return 0; /* normal exit */ +} + +/*****************************************************************************/ +/* Function: EffectPrint */ +/* Description: This is a callback function for the C_Effect type. It */ +/* builds a meaninful string to 'print' effcte objects. */ +/*****************************************************************************/ +int EffectPrint(C_Effect *self, FILE *fp, int flags) +{ +if (self->effect->type == EFF_BUILD)puts("Effect Build"); +if (self->effect->type == EFF_PARTICLE)puts("Effect Particle"); +if (self->effect->type == EFF_WAVE)puts("Effect Wave"); + + return 0; +} + +/*****************************************************************************/ +/* Function: EffectRepr */ +/* Description: This is a callback function for the C_Effect type. It */ +/* builds a meaninful string to represent effcte objects. */ +/*****************************************************************************/ +PyObject *EffectRepr (C_Effect *self) +{ +char*str=""; +if (self->effect->type == EFF_BUILD)str = "Effect Build"; +if (self->effect->type == EFF_PARTICLE)str = "Effect Particle"; +if (self->effect->type == EFF_WAVE)str = "Effect Wave"; +return PyString_FromString(str); +} + +PyObject* EffectCreatePyObject (struct Effect *effect) +{ + C_Effect * blen_object; + + printf ("In EffectCreatePyObject\n"); + + blen_object = (C_Effect*)PyObject_NEW (C_Effect, &Effect_Type); + + if (blen_object == NULL) + { + return (NULL); + } + blen_object->effect = effect; + return ((PyObject*)blen_object); + +} + +int EffectCheckPyObject (PyObject *py_obj) +{ +return (py_obj->ob_type == &Effect_Type); +} + + +struct Effect* EffectFromPyObject (PyObject *py_obj) +{ + C_Effect * blen_obj; + + blen_obj = (C_Effect*)py_obj; + return ((Effect*)blen_obj->effect); + +} diff --git a/source/blender/python/api2_2x/Effect.h b/source/blender/python/api2_2x/Effect.h new file mode 100644 index 00000000000..4ccec72cfdf --- /dev/null +++ b/source/blender/python/api2_2x/Effect.h @@ -0,0 +1,117 @@ +/* + * + * ***** 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_EFFECT_H +#define EXPP_EFFECT_H + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include"gen_utils.h" + + +/*****************************************************************************/ +/* Python C_Effect methods table: */ +/*****************************************************************************/ +static PyMethodDef C_Effect_methods[] = { + {0} +}; + +/*****************************************************************************/ +/* Python API function prototypes for the Effect module. */ +/*****************************************************************************/ +PyObject *M_Effect_New (PyObject *self, PyObject *args); +PyObject *M_Effect_Get (PyObject *self, PyObject *args); + + +/*****************************************************************************/ +/* Python C_Effect structure definition: */ +/*****************************************************************************/ +typedef struct { + PyObject_HEAD + Effect *effect; +} C_Effect; + +/*****************************************************************************/ +/* Python C_Effect methods declarations: */ +/*****************************************************************************/ +/*PyObject *Effect_getType(C_Effect *self);*/ + + +/*****************************************************************************/ +/* Python Effect_Type callback function prototypes: */ +/*****************************************************************************/ +void EffectDeAlloc (C_Effect *msh); +int EffectPrint (C_Effect *msh, FILE *fp, int flags); +int EffectSetAttr (C_Effect *msh, char *name, PyObject *v); +PyObject *EffectGetAttr (C_Effect *msh, char *name); +PyObject *EffectRepr (C_Effect *msh); +PyObject* EffectCreatePyObject (struct Effect *effect); +int EffectCheckPyObject (PyObject *py_obj); +struct Effect* EffectFromPyObject (PyObject *py_obj); +/*****************************************************************************/ +/* Python Effect_Type structure definition: */ +/*****************************************************************************/ +static PyTypeObject Effect_Type = +{ + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ + "Effect", /* tp_name */ + sizeof (C_Effect), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)EffectDeAlloc, /* tp_dealloc */ + (printfunc)EffectPrint, /* tp_print */ + (getattrfunc)EffectGetAttr, /* tp_getattr */ + (setattrfunc)EffectSetAttr, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc)EffectRepr, /* 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_Effect_methods, /* tp_methods */ + 0, /* tp_members */ +}; + +#endif /* EXPP_EFFECT_H */ diff --git a/source/blender/python/api2_2x/doc/Curvedoc.txt b/source/blender/python/api2_2x/doc/Curvedoc.txt new file mode 100644 index 00000000000..cb435ff4048 --- /dev/null +++ b/source/blender/python/api2_2x/doc/Curvedoc.txt @@ -0,0 +1,105 @@ +CURVE Module documentation + + + + +INTRODUCTION + +The Curve module gives access to the curves objects. Curves are used for many things in blender : creation of graphical objects, duplication of meshes, displacement of meshes, in IPOs for instance. +Blender has three main types of curves : + nurbs curves, each control point has three coordinates. + bezier curves, each control point has nine coordinates. + text curves, which represent graphical text objects. + + + + + + +functions of the module : + +Get(Name:string) : returns the Curve whose name is Name. + +get : same as Get + +New(Name:string (optional)) : Creates a new Curve Object. +If the parameter Name is given, it will be the name of the Curve Object, +else the name will be choosen by blender. + + +Curve Object member functions : + +getName() : Retreives the Curve Object name. + +setName(Name : string) : Sets the Curve Object name. + +getPathLen() : Retrieves the Curve Object path length. + +setPathLen(len:int) : Sets the Curve Object path length. + +getTotcol() : Retreives the parameter totcol of the Curve. + +setTotcol(val:int) : Sets the parameter totcol +/*I do not know what means this parameter...*/ + +getFlag()Retrieves the mode of the Curve Object + +setFlag(val:int) :Sets the mode of the Curve. + +The mode of the curve is a combination of parameters. +Bits 0,1,2 : "Back", "Front" and "3D". +Bit 3 : "CurvePath" is set. +Bit 4 : "CurveFollow" is set. + +getBevresol() : Retreives the bevel resolution of the curve. + +setBevresol(val:float) : Sets the bevel resolution of the curve. + +getResolu() : Retreives the U-resolution of the curve. + +setResolu(val:int) : sets the U-resolution of the curve. + +getResolv() : Retreives the V-resolution of the curve. + +setResolv(val:int) : sets the V-resolution of the curve. + +getWidth() : Retreives the bevel width of the curve. + +setWidth(val:float) : Sets the bevel width. + +getExt1() : Retreives the bevel height1 of the curve. + +setExt1(val:float) : Sets the bevel height1 of the curve. + +getExt2() : Retreives the bevel height2 of the curve. + +setExt2(val:float) : Sets the bevel height2 of the curve. + +getControlPoint(i:int) : Retreives the i-th control point. +Depending upon the curve type, returne a list of 4(nurbs) or 9(bez) floats. + +setControlPoint(i:int, x1:float,...x4:float) +setControlPoint(i:int, x1:float,...x9:float) : Sets the i-th control point value. + +getLoc() : Retreives the Curve location(from the center) + +setLoc(x:float,y:float,z:float) : Sets the Curve location + +getRot() : Retreives the Curve rotation(from the center) + +setRot(x:float,y:float,z:float) : Sets the Curve rotation. + +getSize() : Retreives the Curve size. + +setSize(x:float,y:float,z:float) : Sets the Curve size. + +Direct acces to the parameters values : You cann read and write the parameter XXX with the following syntax : +val = obj.XXX +or obj.XXX = val. +The possible parameters names are :"name","pathlen","resolu","resolv","width","ext1", and "ext2" + + + + + +Submodules : No submodule. diff --git a/source/blender/python/api2_2x/doc/Effectdoc.txt b/source/blender/python/api2_2x/doc/Effectdoc.txt new file mode 100644 index 00000000000..2aa8a20eecf --- /dev/null +++ b/source/blender/python/api2_2x/doc/Effectdoc.txt @@ -0,0 +1,257 @@ +EFFECT Module documentation + + +INTRODUCTION +The module effect allows you to access all the data of an effect. +An effect can modify an object (typically a mesh) in three different ways. + a) the build effect : makes the mesh appear progressivly. + b) the wave effect : waves appear on the mesh (which should be fine-grained) + c) the particle effect : every vertex of the mesh emits particles, +which can themselves emit new particles. This effect is the most parametrizable. + +In the blender internals, the effect object is just a placeholder for the "real" + effect, which can be a wave, particle or build effect. The python API follows +this structure : the Effect module grants access to (the few) data which + are shared between all effects. It has three submodules : Wave, Build, Particle +, which grant r/w access to the real parameters of these effects. + + + + +functions of the module : + +Get(Name:string,pos:int) : returns the pos-th Effect associated + to the object whose name is Name. + +get : same as Get + +New(Type:string ) : Creates and returns a new Effect Object. +The parameter Type can take the values "particle", "wave" or "build" + + + +Effect object member functions : + +getType() : Retrieves the type of the Effect Object. + +setType(val:int) : Sets the type of the Effect Object. +The possible values of the type are : + 0 : effect build. + 1 : effect particle. + 2 : effect wave. + + +getMode()Retrieves the mode of the Effect Object + +setMode(val:int) :Sets the mode + +The mode of the effect is a combination of parameters, whose semantics depend upon the effect type. +All types : +Bit 0 : set to 1 if the effect is selected in the effects window. +Wave effect : +Bits 1,2,3 : set to 1 if the button "X", "Y" or "Cycl" is clicked. +Particle effect : +Bits 1,2,3 : set to 1 if the button "Bspline", "Static" or "Face" is clicked. + + + + + + +Submodules : Wave, Build, Particle. + + + + +Wave module + + + +functions of the module : + +Get(Name:string,pos:int) : returns the pos-th wave Effect associated to the object whose name is Name. + +get : same as Get + +New( ) : Creates and returns a new Wave Object. + + +Wave object member functions : + +getStartx() : returns the startx parameter of the wave object. + +setStartx(val:int) : sets the startx parameter of the wave object. + +getStarty() : returns the starty parameter of the wave object. + +setStarty(val:int) : sets the starty parameter of the wave object. + +getHeight() : returns the height parameter of the wave object. + +setHeight(val:int) : sets the height parameter of the wave object. + +getWidth() : returns the width parameter of the wave object. + +setWidth(val:int) : sets the width parameter of the wave object. + +getNarrow() : returns the narrow parameter of the wave object. + +setNarrow(val:int) : sets the narrow parameter of the wave object. + +getSpeed() : returns the speed parameter of the wave object. + +setSpeed(val:int) : sets the speed parameter of the wave object. + +getMinfac() : returns the minfac parameter of the wave object. + +setMinfac(val:int) : sets the minfac parameter of the wave object. + +getDamp() : returns the damp parameter of the wave object. + +setDamp(val:int) : sets the damp parameter of the wave object. + +getTimeoffs() : returns the timeoffs parameter of the wave object. + +setTimeoffs(val:int) : sets the time offset parameter of the wave object. + +getLifetime() : returns the lifetime parameter of the wave object. + +setLifetime(val:int) : sets the lifetime parameter of the wave object. + + + +The Object.attr syntax + +Wave attributes can be read/written with the object.attr syntax. +Example : + +w = Blender.Wave.Get("Obname",3) #retreives the 4th effect associated to the object named Obname +a = w.speed # a is now the value corresponding to the speed of the effect +w.speed = 42 # the speed of the effect is now equal to 42 + +The parameter can take these values : "lifetime","timeoffs","damp","minfac","speed","narrow","width","height","startx","starty" + + + + +Build module + + + +functions of the module : + +Get(Name:string,pos:int) : returns the pos-th build Effect associated to the object whose name is Name. + +get(Name:string,pos:int) : same as Get + +New( ) : Creates and returns a new Build Object. + + +Build object member functions : + +getLen() : returns the length of the effect (in frames). + +setLen(val:float) : sets the length of the effect (in frames). + +getSfra() : returns the starting frame of the effect. + +setSfra(val:float) : sets the starting frame of the effect. + + +The Object.attribute syntax + +The attribute can take these values : "sfra","len". + + +Particle module + + + +functions of the module : + +Get(Name:string,pos:int) : returns the pos-th particle Effect associated to the object whose name is Name. + +get(Name:string,pos:int) : same as Get + +New( ) : Creates and returns a new Effect Object. + + +Particle object member functions : + +getStartTime() : returns the start time of the particle effect (in frames). + +setStartTime(val:float) : sets the start time of the particle effect (in frames). + +getEndTime() : returns the end time of the particle effect (in frames). + +setEndTime(val:float) : sets the end time of the particle effect (in frames). + +getLifeTime() : returns the life time of the particles. + +setLifeTime(val:float) : sets the life time of the particles. + +getNormfac() : returns the normal strength of the particles (relatively to mesh). + +setNormfac(val:float) : sets the normal strength of the particles(relatively to mesh). + +getObfac() : returns the initial of the particles relatively to objects. + +setObfac(val:float) : sets the initial of the particles relatively to objects. + +getRandfac() : returns the initial random speed of the particles. + +setRandfac(val:float) : sets the initial random speed of the particles. + +getTexfac() : returns the initial speed of the particles caused by the texture. + +setTexfac(val:float) : sets the initial speed of the particles caused by the texture. + +getRandlife() : returns the variability of the life of the particles. + +setRandlife(val:float) : sets the variability of the life of the particles. + +getNabla() : returns the dimension of the area for gradient computation. + +setNabla(val:float) : sets the dimension of the area for gradient computation. + +getTotpart() : returns the total number of particles. + +setTotpart(val:int) : sets the total number of particles. + +getTotkey() : returns the number of key positions. + +setTotkey(val:int) : sets the number of key positions. + +getSeed() : returns the seed of the RNG. + +setSeed(val:int) : sets the seed of the RNG. + +getSeed() : returns the x,y,z components of the constant force applied to the particles. + +setSeed(valx:float,valy:float,valz:float) : sets the x,y,z components of the constant force applied to the particles. + +getMult() : returns the 4 probabilities of a particle having a child. + +setMult(val1:float,val2:float,val3:float,val4:float) : sets the 4 probabilities of a particle having a child. + +getLife() : returns the lifespan of the 4 generation particles. + +setLife(val1:float,val2:float,val3:float,val4:float) : sets the lifespan of the 4 generation particles. + +getMat() : returns the material used by the 4 generation particles. + +setMat(val1:float,val2:float,val3:float,val4:float) : sets the material used by the 4 generation particles. + +getChild() : returns the number of children a particle may have. + +setChild(val1:float,val2:float,val3:float,val4:float) : sets the number of children a particle may have. + +getDefvec() : returns the x, y and z axis of the force defined by the texture. + +setDefvec(val1:float,val2:float,val3:float) : sets the x, y and z axis of the force defined by the texture. + + + +The Object.attribute syntax + +The attribute can take these values : "seed","nabla","sta","end","lifetime","normfac","obfac","randfac","texfac","randlife","vectsize","totpart","force","mult","life","child","mat","defvec". \ No newline at end of file diff --git a/source/blender/python/api2_2x/doc/Ipodoc.txt b/source/blender/python/api2_2x/doc/Ipodoc.txt new file mode 100644 index 00000000000..81d51595fa9 --- /dev/null +++ b/source/blender/python/api2_2x/doc/Ipodoc.txt @@ -0,0 +1,66 @@ +IPO Module documentation + + +INTRODUCTION +The module ipo allows you to access all the data of an ipo. +The most important part(s) of an ipo is its ipocurve(s). The ipocurve has a set of bezier points (defined by 9 coordinates). The ipo module grants the user read/write access to these points. + + + + +functions of the module : + +Get(Name:string) : returns the Ipo associated whose name is Name. + +get : same as Get + +New(Name:string , idcode:int ) : Creates and returns a new Ipo Object. +The parameters are mandatory. If the name is already used, blender will change it to name.XXX (XXX is an integer) + + + +Ipo object member functions : + +getName() : Retrieves the name of the Ipo Object. + +setName(newname:string) : Sets the name of the Ipo Object. + +getBlocktype() : Retrieves the blocktype of the Ipo Object. + +setBlocktype(newblocktype:string) : Sets the blocktype of the Ipo Object. + +getShowkey() : Retrieves the showkey of the Ipo Object. + +setShowkey(val:int) : Sets the showkey of the Ipo Object. + +getPad() : Retrieves the pad of the Ipo Object. + +setPad(val:int) : Sets the pad of the Ipo Object. + +getRctf() : Retrieves the rctf of the Ipo Object. + +setRctf(val:int) : Sets the rctf of the Ipo Object. + +I do not fully understand the meaning of these parameters. + + + +getNcurves() : returns the number of ipocurves the ipo object contains. + +getBP() : returns the basepoint of the ipo object (generally NULL) + +getCurveCurval(numcurve:int) : returns the current value of the ipo curve number numcurve. + +getCurveBeztriple(numcurve:int,numpoint:int) : returns a list of 9 floats, which are the coordinates of the control point number numpoint of the ipocurve number numcurve. + + + +setCurveBeztriple(numcurve:int,numpoint:int,newvalues : list of 9 floats) : sets the coordinates of the control point number numpoint of the ipocurve number numcurve to newvalues. (the z coordinate should be 0, but blender does not complain if non null values are passed) + + + +Example : +import Blender + +d = Blender.Ipo.Get('ObIpo') # hope there is an ipo named "ObIpo"...Else create it before. + diff --git a/source/blender/python/api2_2x/doc/Metaballdoc.txt b/source/blender/python/api2_2x/doc/Metaballdoc.txt new file mode 100644 index 00000000000..2c64a43571e --- /dev/null +++ b/source/blender/python/api2_2x/doc/Metaballdoc.txt @@ -0,0 +1,58 @@ +METABALL Module documentation + + +INTRODUCTION +The metaball module effect allows you to access all the data of an metaball. +A metaball consists of several (maybe only one) metaelems, which are spheres, interacting with each other, thus creating soft organic volumes. + + + +functions of the module : +New(name) : creates ans returns a metaball object. +Get(opt : name) : if the parameter name is given, returns the metaball object whose name has been passed, or Py_None, if no such metaball exists in the current scene. If no parameter is given, returns a list of all the metaballs in the current scene. +get : alias for Get + +Metaball object member functions : + +getName()Return Metaball name +setName(string newname) - Sets Metaball name +getWiresize() - Return Metaball wire size +setWiresize(float val) - Sets Metaball wire size +getRendersize() - Return Metaball render size +setRendersize(float newval- Sets Metaball render size +getThresh()- Return Metaball threshold +setThresh(float newval)- Sets Metaball threshold +getBbox,- Return Metaball bounding box(a list of eight lists of three elements) +getNMetaElems() Returns the number of Metaelems (basic spheres) +getMetatype(int num_metaelem): returns the type of the metaelem number num_metaelem. +0 : ball +1 : tubex +2 : tubey +3 : tubez +setMetatype(int num_metaelem,int newtype) : sets the type of the metaelem number num_metaelem. +getMetadata(field_name,int num_metaelem) gets Metaball MetaData. Explained later. +setMetadata(field_name,int num_metaelem,newval) sets Metaball MetaData. Explained later. +getMetalay(int num_metaelem) +getMetax(int num_metaelem) : gets the x coordinate of the metaelement +setMetax(int num_metaelem,float newval) : sets the x coordinate of the metaelement +getMetay(int num_metaelem) : gets the y coordinate of the metaelement +setMetay(int num_metaelem,float newval) : sets the y coordinate of the metaelement +getMetaz(int num_metaelem) : gets the z coordinate of the metaelement +setMetaz(int num_metaelem,float newval) : sets the z coordinate of the metaelement +getMetas(int num_metaelem) : gets the s coordinate of the metaelement +setMetas(int num_metaelem,float newval) : sets the s coordinate of the metaelement +getMetalen(int num_metaelem) : gets the length of the metaelement. Important for tubes. +setMetalen(int num_metaelem,float newval) : sets the length of the metaelement. Important for tubes. +getloc, - Gets Metaball loc values +setloc, (f f f) - Sets Metaball loc values +getrot, () - Gets Metaball rot values +setrot,, (f f f) - Sets Metaball rot values +getsize,() - Gets Metaball size values +setsize,(f f f) - Sets Metaball size values + + + + +The Object.attribute syntax + +The attribute can take these values : seed,nabla,sta,end,lifetime,normfac,obfac,randfac,texfac,randlife,vectsize,totpart,force,mult,life,child,mat,defvec. \ No newline at end of file diff --git a/source/blender/python/api2_2x/doc/Worlddoc.txt b/source/blender/python/api2_2x/doc/Worlddoc.txt new file mode 100644 index 00000000000..2c64a43571e --- /dev/null +++ b/source/blender/python/api2_2x/doc/Worlddoc.txt @@ -0,0 +1,58 @@ +METABALL Module documentation + + +INTRODUCTION +The metaball module effect allows you to access all the data of an metaball. +A metaball consists of several (maybe only one) metaelems, which are spheres, interacting with each other, thus creating soft organic volumes. + + + +functions of the module : +New(name) : creates ans returns a metaball object. +Get(opt : name) : if the parameter name is given, returns the metaball object whose name has been passed, or Py_None, if no such metaball exists in the current scene. If no parameter is given, returns a list of all the metaballs in the current scene. +get : alias for Get + +Metaball object member functions : + +getName()Return Metaball name +setName(string newname) - Sets Metaball name +getWiresize() - Return Metaball wire size +setWiresize(float val) - Sets Metaball wire size +getRendersize() - Return Metaball render size +setRendersize(float newval- Sets Metaball render size +getThresh()- Return Metaball threshold +setThresh(float newval)- Sets Metaball threshold +getBbox,- Return Metaball bounding box(a list of eight lists of three elements) +getNMetaElems() Returns the number of Metaelems (basic spheres) +getMetatype(int num_metaelem): returns the type of the metaelem number num_metaelem. +0 : ball +1 : tubex +2 : tubey +3 : tubez +setMetatype(int num_metaelem,int newtype) : sets the type of the metaelem number num_metaelem. +getMetadata(field_name,int num_metaelem) gets Metaball MetaData. Explained later. +setMetadata(field_name,int num_metaelem,newval) sets Metaball MetaData. Explained later. +getMetalay(int num_metaelem) +getMetax(int num_metaelem) : gets the x coordinate of the metaelement +setMetax(int num_metaelem,float newval) : sets the x coordinate of the metaelement +getMetay(int num_metaelem) : gets the y coordinate of the metaelement +setMetay(int num_metaelem,float newval) : sets the y coordinate of the metaelement +getMetaz(int num_metaelem) : gets the z coordinate of the metaelement +setMetaz(int num_metaelem,float newval) : sets the z coordinate of the metaelement +getMetas(int num_metaelem) : gets the s coordinate of the metaelement +setMetas(int num_metaelem,float newval) : sets the s coordinate of the metaelement +getMetalen(int num_metaelem) : gets the length of the metaelement. Important for tubes. +setMetalen(int num_metaelem,float newval) : sets the length of the metaelement. Important for tubes. +getloc, - Gets Metaball loc values +setloc, (f f f) - Sets Metaball loc values +getrot, () - Gets Metaball rot values +setrot,, (f f f) - Sets Metaball rot values +getsize,() - Gets Metaball size values +setsize,(f f f) - Sets Metaball size values + + + + +The Object.attribute syntax + +The attribute can take these values : seed,nabla,sta,end,lifetime,normfac,obfac,randfac,texfac,randlife,vectsize,totpart,force,mult,life,child,mat,defvec. \ No newline at end of file