From c467b19c75d7a9ce4afb2d46566447414c92801e Mon Sep 17 00:00:00 2001 From: Willian Padovani Germano Date: Sat, 12 Jul 2003 18:02:54 +0000 Subject: Exppython: - More documentation files for epydoc. - Few minor changes in other files. --- source/blender/python/api2_2x/Draw.h | 8 +- source/blender/python/api2_2x/Image.c | 42 ++- source/blender/python/api2_2x/Lamp.c | 10 +- source/blender/python/api2_2x/Material.c | 195 ++++++++--- source/blender/python/api2_2x/NMesh.c | 153 +++++++-- source/blender/python/api2_2x/NMesh.h | 15 +- source/blender/python/api2_2x/Scene.c | 88 +++-- source/blender/python/api2_2x/Types.c | 2 + source/blender/python/api2_2x/Types.h | 1 + source/blender/python/api2_2x/doc/Armature.py | 76 +++++ source/blender/python/api2_2x/doc/Blender.py | 10 +- source/blender/python/api2_2x/doc/Camera.py | 4 +- source/blender/python/api2_2x/doc/Draw.py | 353 +++++++++++++++++++ source/blender/python/api2_2x/doc/Image.py | 115 +++++++ source/blender/python/api2_2x/doc/Lamp.py | 4 +- source/blender/python/api2_2x/doc/Material.py | 468 ++++++++++++++++++++++++++ source/blender/python/api2_2x/doc/NMesh.py | 297 ++++++++++++++++ source/blender/python/api2_2x/doc/Scene.py | 193 +++++++++++ source/blender/python/api2_2x/doc/Types.py | 53 +++ source/blender/python/api2_2x/doc/Window.py | 5 +- 20 files changed, 1956 insertions(+), 136 deletions(-) create mode 100644 source/blender/python/api2_2x/doc/Armature.py create mode 100644 source/blender/python/api2_2x/doc/Draw.py create mode 100644 source/blender/python/api2_2x/doc/Image.py create mode 100644 source/blender/python/api2_2x/doc/Material.py create mode 100644 source/blender/python/api2_2x/doc/NMesh.py create mode 100644 source/blender/python/api2_2x/doc/Scene.py create mode 100644 source/blender/python/api2_2x/doc/Types.py (limited to 'source/blender/python') diff --git a/source/blender/python/api2_2x/Draw.h b/source/blender/python/api2_2x/Draw.h index 51858e1a09d..c84cc91ff58 100644 --- a/source/blender/python/api2_2x/Draw.h +++ b/source/blender/python/api2_2x/Draw.h @@ -75,7 +75,7 @@ PyObject *M_Window_Redraw(PyObject *self, PyObject *args); int g_window_redrawn; static char Draw_doc[] = -"Module Blender.Draw ... XXX improve this"; +"The Blender.Draw submodule"; static void exit_pydraw (SpaceText *st); static uiBlock *Get_uiBlock (void); @@ -189,7 +189,7 @@ button\n\n\ (default) The number of the option to be selected by default\n\ [tooltip=""] The button's tooltip\n\n\ The menu options are specified through the name of the\n\ -button. Options are followed by a format code and seperated\n\ +button. Options are followed by a format code and separated\n\ by the '|' (pipe) character.\n\ Valid format codes are\n\ %t - The option should be used as the title\n\ @@ -267,12 +267,12 @@ static PyObject *Method_String (PyObject *self, PyObject *args); static char Method_GetStringWidth_doc[] = "(text, font = 'normal') - Return the width in pixels of the given string\n\ -(font) The font type: 'normal' (default), 'small' or 'tiny'."; +(font) The font size: 'normal' (default), 'small' or 'tiny'."; static char Method_Text_doc[] = "(text, font = 'normal') - Draw text onscreen\n\n\ (text) The text to draw\n\ -(font) The font type: 'normal' (default), 'small' or 'tiny'.\n\n\ +(font) The font size: 'normal' (default), 'small' or 'tiny'.\n\n\ NEW! - This function now returns the width of the drawn string."; static PyObject *Method_GetStringWidth (PyObject *self, PyObject *args); diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c index 72c6df7cf15..a93de2ede5a 100644 --- a/source/blender/python/api2_2x/Image.c +++ b/source/blender/python/api2_2x/Image.c @@ -226,6 +226,8 @@ PyObject *Image_Init (void) /*****************************************************************************/ static PyObject *Image_getName(BPy_Image *self); static PyObject *Image_getFilename(BPy_Image *self); +static PyObject *Image_getXRep(BPy_Image *self); +static PyObject *Image_getYRep(BPy_Image *self); static PyObject *Image_setName(BPy_Image *self, PyObject *args); static PyObject *Image_setXRep(BPy_Image *self, PyObject *args); static PyObject *Image_setYRep(BPy_Image *self, PyObject *args); @@ -236,15 +238,19 @@ static PyObject *Image_setYRep(BPy_Image *self, PyObject *args); static PyMethodDef BPy_Image_methods[] = { /* name, method, flags, doc */ {"getName", (PyCFunction)Image_getName, METH_NOARGS, - "() - Return Image Data name"}, - {"getFilename", (PyCFunction)Image_getFilename, METH_VARARGS, - "() - Return Image Data filename"}, + "() - Return Image object name"}, + {"getFilename", (PyCFunction)Image_getFilename, METH_NOARGS, + "() - Return Image object filename"}, + {"getXRep", (PyCFunction)Image_getXRep, METH_NOARGS, + "() - Return Image object x repetition value"}, + {"getYRep", (PyCFunction)Image_getYRep, METH_NOARGS, + "() - Return Image object y repetition value"}, {"setName", (PyCFunction)Image_setName, METH_VARARGS, - "(str) - Change Image Data name"}, + "(str) - Change Image object name"}, {"setXRep", (PyCFunction)Image_setXRep, METH_VARARGS, - "(int) - Change Image Data x repetition value"}, + "(int) - Change Image object x repetition value"}, {"setYRep", (PyCFunction)Image_setYRep, METH_VARARGS, - "(int) - Change Image Data y repetition value"}, + "(int) - Change Image object y repetition value"}, {0} }; @@ -348,6 +354,26 @@ static PyObject *Image_getFilename(BPy_Image *self) "couldn't get Image.filename attribute")); } +static PyObject *Image_getXRep(BPy_Image *self) +{ + PyObject *attr = PyInt_FromLong(self->image->xrep); + + if (attr) return attr; + + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Image.xrep attribute"); +} + +static PyObject *Image_getYRep(BPy_Image *self) +{ + PyObject *attr = PyInt_FromLong(self->image->yrep); + + if (attr) return attr; + + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Image.yrep attribute"); +} + static PyObject *Image_setName(BPy_Image *self, PyObject *args) { char *name; @@ -437,7 +463,7 @@ static PyObject *Image_getAttr (BPy_Image *self, char *name) /*****************************************************************************/ /* Function: Image_setAttr */ /* Description: This is a callback function for the BPy_Image type. It is the*/ -/* function that changes Image Data members values. If this */ +/* function that changes Image object members values. If this */ /* data is linked to a Blender Image, it also gets updated. */ /*****************************************************************************/ static int Image_setAttr (BPy_Image *self, char *name, PyObject *value) @@ -462,7 +488,7 @@ static int Image_setAttr (BPy_Image *self, char *name, PyObject *value) error = Image_setXRep (self, valtuple); else if (strcmp (name, "yrep") == 0) error = Image_setYRep (self, valtuple); - else { /* Error: no such member in the Image Data structure */ + else { /* Error: no such member in the Image object structure */ Py_DECREF(value); Py_DECREF(valtuple); return (EXPP_ReturnIntError (PyExc_KeyError, diff --git a/source/blender/python/api2_2x/Lamp.c b/source/blender/python/api2_2x/Lamp.c index 5b9086fd680..95c6b0697f0 100644 --- a/source/blender/python/api2_2x/Lamp.c +++ b/source/blender/python/api2_2x/Lamp.c @@ -181,7 +181,7 @@ static PyObject *M_Lamp_Get(PyObject *self, PyObject *args) } } -static PyObject *M_Lamp_TypesDict (void) +static PyObject *Lamp_TypesDict (void) { /* create the Blender.Lamp.Types constant dict */ PyObject *Types = M_constant_New(); @@ -198,7 +198,7 @@ static PyObject *M_Lamp_TypesDict (void) return Types; } -static PyObject *M_Lamp_ModesDict (void) +static PyObject *Lamp_ModesDict (void) { /* create the Blender.Lamp.Modes constant dict */ PyObject *Modes = M_constant_New(); @@ -229,15 +229,15 @@ PyObject *Lamp_Init (void) Lamp_Type.ob_type = &PyType_Type; - Types = M_Lamp_TypesDict (); - Modes = M_Lamp_ModesDict (); + Types = Lamp_TypesDict (); + Modes = Lamp_ModesDict (); submodule = Py_InitModule3("Blender.Lamp", M_Lamp_methods, M_Lamp_doc); if (Types) PyModule_AddObject(submodule, "Types", Types); if (Modes) PyModule_AddObject(submodule, "Modes", Modes); - return (submodule); + return submodule; } /* Three Python Lamp_Type helper functions needed by the Object module: */ diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c index 30b3d61ea81..d6a42e17cda 100644 --- a/source/blender/python/api2_2x/Material.c +++ b/source/blender/python/api2_2x/Material.c @@ -48,18 +48,18 @@ #define EXPP_MAT_MODE_SHADOW MA_SHADOW #define EXPP_MAT_MODE_SHADELESS MA_SHLESS #define EXPP_MAT_MODE_WIRE MA_WIRE -#define EXPP_MAT_MODE_VCOLLIGHT MA_VERTEXCOL +#define EXPP_MAT_MODE_VCOL_LIGHT MA_VERTEXCOL #define EXPP_MAT_MODE_HALO MA_HALO #define EXPP_MAT_MODE_ZTRANSP MA_ZTRA -#define EXPP_MAT_MODE_VCOLPAINT MA_VERTEXCOLP +#define EXPP_MAT_MODE_VCOL_PAINT MA_VERTEXCOLP #define EXPP_MAT_MODE_ZINVERT MA_ZINV #define EXPP_MAT_MODE_HALORINGS MA_HALO_RINGS #define EXPP_MAT_MODE_ENV MA_ENV #define EXPP_MAT_MODE_HALOLINES MA_HALO_LINES #define EXPP_MAT_MODE_ONLYSHADOW MA_ONLYSHADOW -#define EXPP_MAT_MODE_XALPHA MA_HALO_XALPHA -#define EXPP_MAT_MODE_STAR MA_STAR -#define EXPP_MAT_MODE_FACETEX MA_FACETEXTURE +#define EXPP_MAT_MODE_HALOXALPHA MA_HALO_XALPHA +#define EXPP_MAT_MODE_HALOSTAR MA_STAR +#define EXPP_MAT_MODE_TEXFACE MA_FACETEXTURE #define EXPP_MAT_MODE_HALOTEX MA_HALOTEX #define EXPP_MAT_MODE_HALOPUNO MA_HALOPUNO #define EXPP_MAT_MODE_NOMIST MA_NOMIST @@ -79,8 +79,8 @@ #define EXPP_MAT_EMIT_MAX 1.0 #define EXPP_MAT_REF_MIN 0.0 #define EXPP_MAT_REF_MAX 1.0 -#define EXPP_MAT_SPEBPy_MIN 0.0 -#define EXPP_MAT_SPEBPy_MAX 2.0 +#define EXPP_MAT_SPEC_MIN 0.0 +#define EXPP_MAT_SPEC_MAX 2.0 #define EXPP_MAT_SPECTRA_MIN 0.0 #define EXPP_MAT_SPECTRA_MAX 1.0 #define EXPP_MAT_ZOFFS_MIN 0.0 @@ -96,8 +96,12 @@ #define EXPP_MAT_HARD_MIN 1 #define EXPP_MAT_HARD_MAX 255 /* 127 with MODE HALO ON */ +#define EXPP_MAT_HALOSEED_MIN 1 +#define EXPP_MAT_HALOSEED_MAX 255 #define EXPP_MAT_NFLARES_MIN 1 #define EXPP_MAT_NFLARES_MAX 32 +#define EXPP_MAT_FLARESEED_MIN 1 +#define EXPP_MAT_FLARESEED_MAX 255 #define EXPP_MAT_NSTARS_MIN 3 #define EXPP_MAT_NSTARS_MAX 50 #define EXPP_MAT_NLINES_MIN 0 @@ -244,18 +248,63 @@ static PyObject *M_Material_Get(PyObject *self, PyObject *args) } } +static PyObject *Lamp_ModesDict (void) +{ + PyObject *Modes = M_constant_New(); + +#undef EXPP_ADDCONST +#define EXPP_ADDCONST(name) \ + constant_insert(c, #name, PyInt_FromLong(EXPP_MAT_MODE_##name)) + +/* So that: + * EXPP_ADDCONST(TRACEABLE) becomes: + * constant_insert(c, "TRACEABLE", PyInt_FromLong(EXPP_MAT_MODE_TRACEABLE)) + */ + + if (Modes) { + BPy_constant *c = (BPy_constant *)Modes; + + EXPP_ADDCONST(TRACEABLE); + EXPP_ADDCONST(SHADOW); + EXPP_ADDCONST(SHADELESS); + EXPP_ADDCONST(WIRE); + EXPP_ADDCONST(VCOL_LIGHT); + EXPP_ADDCONST(HALO); + EXPP_ADDCONST(ZTRANSP); + EXPP_ADDCONST(VCOL_PAINT); + EXPP_ADDCONST(ZINVERT); + EXPP_ADDCONST(HALORINGS); + EXPP_ADDCONST(ENV); + EXPP_ADDCONST(HALOLINES); + EXPP_ADDCONST(ONLYSHADOW); + EXPP_ADDCONST(HALOXALPHA); + EXPP_ADDCONST(HALOSTAR); + EXPP_ADDCONST(TEXFACE); + EXPP_ADDCONST(HALOTEX); + EXPP_ADDCONST(HALOPUNO); + EXPP_ADDCONST(NOMIST); + EXPP_ADDCONST(HALOSHADE); + EXPP_ADDCONST(HALOFLARE); + } + + return Modes; +} + /*****************************************************************************/ /* Function: Material_Init */ /*****************************************************************************/ PyObject *Material_Init (void) { - PyObject *submodule; + PyObject *submodule, *Modes; Material_Type.ob_type = &PyType_Type; + Modes = Lamp_ModesDict (); + submodule = Py_InitModule3("Blender.Material", M_Material_methods, M_Material_doc); + if (Modes) PyModule_AddObject(submodule, "Modes", Modes); return (submodule); } @@ -281,7 +330,9 @@ static PyObject *Material_getSpecTransp(BPy_Material *self); static PyObject *Material_getAdd(BPy_Material *self); static PyObject *Material_getZOffset(BPy_Material *self); static PyObject *Material_getHaloSize(BPy_Material *self); +static PyObject *Material_getHaloSeed(BPy_Material *self); static PyObject *Material_getFlareSize(BPy_Material *self); +static PyObject *Material_getFlareSeed(BPy_Material *self); static PyObject *Material_getFlareBoost(BPy_Material *self); static PyObject *Material_getSubSize(BPy_Material *self); static PyObject *Material_getHardness(BPy_Material *self); @@ -305,7 +356,9 @@ static PyObject *Material_setSpecTransp(BPy_Material *self, PyObject *args); static PyObject *Material_setAdd(BPy_Material *self, PyObject *args); static PyObject *Material_setZOffset(BPy_Material *self, PyObject *args); static PyObject *Material_setHaloSize(BPy_Material *self, PyObject *args); +static PyObject *Material_setHaloSeed(BPy_Material *self, PyObject *args); static PyObject *Material_setFlareSize(BPy_Material *self, PyObject *args); +static PyObject *Material_setFlareSeed(BPy_Material *self, PyObject *args); static PyObject *Material_setFlareBoost(BPy_Material *self, PyObject *args); static PyObject *Material_setSubSize(BPy_Material *self, PyObject *args); static PyObject *Material_setHardness(BPy_Material *self, PyObject *args); @@ -349,21 +402,26 @@ static PyMethodDef BPy_Material_methods[] = { {"getAdd", (PyCFunction)Material_getAdd, METH_NOARGS, "() - Return Material's glow factor"}, {"getZOffset", (PyCFunction)Material_getZOffset, METH_NOARGS, - "() - Return Material's artificial offset "}, + "() - Return Material's artificial offset for faces"}, {"getHaloSize", (PyCFunction)Material_getHaloSize, METH_NOARGS, "() - Return Material's halo size"}, + {"getHaloSeed", (PyCFunction)Material_getHaloSeed, METH_NOARGS, + "() - Return Material's seed for random ring dimension and line " + "location in halos"}, {"getFlareSize", (PyCFunction)Material_getFlareSize, METH_NOARGS, "() - Return Material's (flare size)/(halo size) factor"}, + {"getFlareSeed", (PyCFunction)Material_getFlareSeed, METH_NOARGS, + "() - Return Material's flare offset in the seed table"}, {"getFlareBoost", (PyCFunction)Material_getFlareBoost, METH_NOARGS, "() - Return Material's flare boost"}, {"getSubSize", (PyCFunction)Material_getSubSize, METH_NOARGS, "() - Return Material's dimension of subflare, dots and circles"}, {"getHardness", (PyCFunction)Material_getHardness, METH_NOARGS, - "() - Return Material's hardness"}, + "() - Return Material's specular hardness"}, {"getNFlares", (PyCFunction)Material_getNFlares, METH_NOARGS, "() - Return Material's number of flares in halo"}, {"getNStars", (PyCFunction)Material_getNStars, METH_NOARGS, - "() - Return Material's number of stars in halo"}, + "() - Return Material's number of points in the halo stars"}, {"getNLines", (PyCFunction)Material_getNLines, METH_NOARGS, "() - Return Material's number of lines in halo"}, {"getNRings", (PyCFunction)Material_getNRings, METH_NOARGS, @@ -373,13 +431,13 @@ static PyMethodDef BPy_Material_methods[] = { {"setMode", (PyCFunction)Material_setMode, METH_VARARGS, "([s[,s]]) - Set Material mode flag(s)"}, {"setRGBCol", (PyCFunction)Material_setRGBCol, METH_VARARGS, - "([s[,s]]) - Set Material's rgb color triplet"}, + "(f,f,f or [f,f,f]) - Set Material's rgb color triplet"}, {"setAmbCol", (PyCFunction)Material_setAmbCol, METH_VARARGS, - "([s[,s]]) - Set Material's ambient color"}, + "(f,f,f or [f,f,f]) - Set Material's ambient color"}, {"setSpecCol", (PyCFunction)Material_setSpecCol, METH_VARARGS, - "([s[,s]]) - Set Material's specular color"}, + "(f,f,f or [f,f,f]) - Set Material's specular color"}, {"setMirCol", (PyCFunction)Material_setMirCol, METH_VARARGS, - "([s[,s]]) - Set Material's mirror color"}, + "(f,f,f or [f,f,f]) - Set Material's mirror color"}, {"setAmb", (PyCFunction)Material_setAmb, METH_VARARGS, "(f) - Set how much the Material's color is affected" " by \nthe global ambient colors - [0.0, 1.0]"}, @@ -399,23 +457,27 @@ static PyMethodDef BPy_Material_methods[] = { "(f) - Set Material's artificial offset - [0.0, 10.0]"}, {"setHaloSize", (PyCFunction)Material_setHaloSize, METH_VARARGS, "(f) - Set Material's halo size - [0.0, 100.0]"}, + {"setHaloSeed", (PyCFunction)Material_setHaloSeed, METH_VARARGS, + "(i) - Set Material's halo seed - [0, 255]"}, {"setFlareSize", (PyCFunction)Material_setFlareSize, METH_VARARGS, "(f) - Set Material's factor: (flare size)/(halo size) - [0.1, 25.0]"}, + {"setFlareSeed", (PyCFunction)Material_setFlareSeed, METH_VARARGS, + "(i) - Set Material's flare seed - [0, 255]"}, {"setFlareBoost", (PyCFunction)Material_setFlareBoost, METH_VARARGS, "(f) - Set Material's flare boost - [0.1, 10.0]"}, {"setSubSize", (PyCFunction)Material_setSubSize, METH_VARARGS, "(f) - Set Material's dimension of subflare," " dots and circles - [0.1, 25.0]"}, {"setHardness", (PyCFunction)Material_setHardness, METH_VARARGS, - "(f) - Set Material's hardness - [1, 255 (127 if halo mode is ON)]"}, + "(i) - Set Material's hardness - [1, 255 (127 if halo mode is ON)]"}, {"setNFlares", (PyCFunction)Material_setNFlares, METH_VARARGS, - "(f) - Set Material's number of flares in halo - [1, 32]"}, + "(i) - Set Material's number of flares in halo - [1, 32]"}, {"setNStars", (PyCFunction)Material_setNStars, METH_VARARGS, - "(f) - Set Material's number of stars in halo - [3, 50]"}, + "(i) - Set Material's number of stars in halo - [3, 50]"}, {"setNLines", (PyCFunction)Material_setNLines, METH_VARARGS, - "(f) - Set Material's number of lines in halo - [0, 250]"}, + "(i) - Set Material's number of lines in halo - [0, 250]"}, {"setNRings", (PyCFunction)Material_setNRings, METH_VARARGS, - "(f) - Set Material's number of rings in halo - [0, 24]"}, + "(i) - Set Material's number of rings in halo - [0, 24]"}, {0} }; @@ -684,6 +746,26 @@ static PyObject *Material_getSubSize(BPy_Material *self) "couldn't get Material.subSize attribute"); } +static PyObject *Material_getHaloSeed(BPy_Material *self) +{ + PyObject *attr = PyInt_FromLong((long)self->material->seed1); + + if (attr) return attr; + + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Material.haloSeed attribute"); +} + +static PyObject *Material_getFlareSeed(BPy_Material *self) +{ + PyObject *attr = PyInt_FromLong((long)self->material->seed2); + + if (attr) return attr; + + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "couldn't get Material.flareSeed attribute"); +} + static PyObject *Material_getHardness(BPy_Material *self) { PyObject *attr = PyInt_FromLong((long)self->material->har); @@ -754,7 +836,7 @@ static PyObject *Material_setName(BPy_Material *self, PyObject *args) /* Possible modes are traceable, shadow, shadeless, wire, vcolLight, * vcolPaint, halo, ztransp, zinvert, haloRings, env, haloLines, * onlyShadow, xalpha, star, faceTexture, haloTex, haloPuno, noMist, - * haloShade, haloFlare */ + * haloShaded, haloFlare */ static PyObject *Material_setMode(BPy_Material *self, PyObject *args) { int i, flag = 0; @@ -782,9 +864,9 @@ static PyObject *Material_setMode(BPy_Material *self, PyObject *args) else if (strcmp(m[i], "Wire") == 0) flag |= (short)EXPP_MAT_MODE_WIRE; else if (strcmp(m[i], "VColLight") == 0) - flag |= (short)EXPP_MAT_MODE_VCOLLIGHT; + flag |= (short)EXPP_MAT_MODE_VCOL_LIGHT; else if (strcmp(m[i], "VColPaint") == 0) - flag |= (short)EXPP_MAT_MODE_VCOLPAINT; + flag |= (short)EXPP_MAT_MODE_VCOL_PAINT; else if (strcmp(m[i], "Halo") == 0) flag |= (short)EXPP_MAT_MODE_HALO; else if (strcmp(m[i], "ZTransp") == 0) @@ -799,19 +881,19 @@ static PyObject *Material_setMode(BPy_Material *self, PyObject *args) flag |= (short)EXPP_MAT_MODE_HALOLINES; else if (strcmp(m[i], "OnlyShadow") == 0) flag |= (short)EXPP_MAT_MODE_ONLYSHADOW; - else if (strcmp(m[i], "XAlpha") == 0) - flag |= (short)EXPP_MAT_MODE_XALPHA; - else if (strcmp(m[i], "Star") == 0) - flag |= (short)EXPP_MAT_MODE_STAR; - else if (strcmp(m[i], "FaceTex") == 0) - flag |= (short)EXPP_MAT_MODE_FACETEX; + else if (strcmp(m[i], "HaloXAlpha") == 0) + flag |= (short)EXPP_MAT_MODE_HALOXALPHA; + else if (strcmp(m[i], "HaloStar") == 0) + flag |= (short)EXPP_MAT_MODE_HALOSTAR; + else if (strcmp(m[i], "TexFace") == 0) + flag |= (short)EXPP_MAT_MODE_TEXFACE; else if (strcmp(m[i], "HaloTex") == 0) flag |= (short)EXPP_MAT_MODE_HALOTEX; else if (strcmp(m[i], "HaloPuno") == 0) flag |= (short)EXPP_MAT_MODE_HALOPUNO; else if (strcmp(m[i], "NoMist") == 0) flag |= (short)EXPP_MAT_MODE_NOMIST; - else if (strcmp(m[i], "HaloShade") == 0) + else if (strcmp(m[i], "HaloShaded") == 0) flag |= (short)EXPP_MAT_MODE_HALOSHADE; else if (strcmp(m[i], "HaloFlare") == 0) flag |= (short)EXPP_MAT_MODE_HALOFLARE; @@ -962,8 +1044,8 @@ static PyObject *Material_setSpec(BPy_Material *self, PyObject *args) return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected float argument in [0.0, 1.0]")); - self->material->spec = EXPP_ClampFloat (value, EXPP_MAT_SPEBPy_MIN, - EXPP_MAT_SPEBPy_MAX); + self->material->spec = EXPP_ClampFloat (value, EXPP_MAT_SPEC_MIN, + EXPP_MAT_SPEC_MAX); return EXPP_incr_ret (Py_None); } @@ -1052,6 +1134,35 @@ static PyObject *Material_setSubSize(BPy_Material *self, PyObject *args) return EXPP_incr_ret (Py_None); } +static PyObject *Material_setHaloSeed(BPy_Material *self, PyObject *args) +{ + short value; + + if (!PyArg_ParseTuple(args, "h", &value)) + return (EXPP_ReturnPyObjError (PyExc_TypeError, + "expected int argument in [1, 255]")); + + self->material->seed1 = EXPP_ClampInt (value, EXPP_MAT_HALOSEED_MIN, + EXPP_MAT_HALOSEED_MAX); + + return EXPP_incr_ret (Py_None); +} + +static PyObject *Material_setFlareSeed(BPy_Material *self, PyObject *args) +{ + short value; + + if (!PyArg_ParseTuple(args, "h", &value)) + return (EXPP_ReturnPyObjError (PyExc_TypeError, + "expected int argument in [1, 255]")); + + self->material->seed2 = EXPP_ClampInt (value, EXPP_MAT_FLARESEED_MIN, + EXPP_MAT_FLARESEED_MAX); + + return EXPP_incr_ret (Py_None); +} + + static PyObject *Material_setHardness(BPy_Material *self, PyObject *args) { short value; @@ -1168,10 +1279,14 @@ static PyObject *Material_getAttr (BPy_Material *self, char *name) attr = PyFloat_FromDouble((double)self->material->zoffs); else if (strcmp(name, "haloSize") == 0) attr = PyFloat_FromDouble((double)self->material->hasize); + else if (strcmp(name, "haloSeed") == 0) + attr = PyInt_FromLong((double)self->material->seed1); else if (strcmp(name, "flareSize") == 0) attr = PyFloat_FromDouble((double)self->material->flaresize); else if (strcmp(name, "flareBoost") == 0) attr = PyFloat_FromDouble((double)self->material->flareboost); + else if (strcmp(name, "flareSeed") == 0) + attr = PyInt_FromLong((double)self->material->seed2); else if (strcmp(name, "subSize") == 0) attr = PyFloat_FromDouble((double)self->material->subsize); else if (strcmp(name, "hard") == 0) @@ -1186,13 +1301,13 @@ static PyObject *Material_getAttr (BPy_Material *self, char *name) attr = PyInt_FromLong((long)self->material->ringc); else if (strcmp(name, "__members__") == 0) { - attr = /* 26 items */ - Py_BuildValue("[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s]", + attr = /* 28 items */ + Py_BuildValue("[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s]", "name", "mode", "rgbCol", "ambCol", "specCol", "mirCol", - "R", "G", "B", "alpha", "amb", "emit", "ref", - "spec", "specTransp", "add", "zOffset", "haloSize", - "flareSize", "flareBoost", "subSize", "hard", "nFlares", - "nStars", "nLines", "nRings"); + "R", "G", "B", "alpha", "amb", "emit", "ref", "spec", + "specTransp", "add", "zOffset", "haloSize", "haloSeed", + "flareSize", "flareBoost", "flareSeed", "subSize", "hard", + "nFlares", "nStars", "nLines", "nRings"); } if (!attr) @@ -1266,10 +1381,14 @@ static int Material_setAttr (BPy_Material *self, char *name, PyObject *value) error = Material_setZOffset (self, valtuple); else if (strcmp (name, "haloSize") == 0) error = Material_setHaloSize (self, valtuple); + else if (strcmp (name, "haloSeed") == 0) + error = Material_setHaloSeed (self, valtuple); else if (strcmp (name, "flareSize") == 0) error = Material_setFlareSize (self, valtuple); else if (strcmp (name, "flareBoost") == 0) error = Material_setFlareBoost (self, valtuple); + else if (strcmp (name, "flareSeed") == 0) + error = Material_setFlareSeed (self, valtuple); else if (strcmp (name, "subSize") == 0) error = Material_setSubSize (self, valtuple); else if (strcmp (name, "hard") == 0) diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c index fdfd6d6714f..6eb092593c3 100644 --- a/source/blender/python/api2_2x/NMesh.c +++ b/source/blender/python/api2_2x/NMesh.c @@ -79,6 +79,8 @@ static PyObject *NMCol_getattr(PyObject *self, char *name) else if (strcmp(name, "g") == 0) return Py_BuildValue("i", mc->g); else if (strcmp(name, "b") == 0) return Py_BuildValue("i", mc->b); else if (strcmp(name, "a") == 0) return Py_BuildValue("i", mc->a); + else if (strcmp(name, "__members__") == 0) + return Py_BuildValue("[s,s,s,s]", "r", "g", "b", "a"); return EXPP_ReturnPyObjError(PyExc_AttributeError, name); } @@ -112,8 +114,8 @@ PyTypeObject NMCol_Type = { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ - "NMCol", /* tp_name */ - sizeof(BPy_NMCol), /* tp_basicsize */ + "Blender NMCol", /* tp_name */ + sizeof(BPy_NMCol), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ (destructor) NMCol_dealloc, /* tp_dealloc */ @@ -231,6 +233,10 @@ static PyObject *NMFace_getattr(PyObject *self, char *name) else if (strcmp(name, "uv") == 0) return Py_BuildValue("O", mf->uv); + else if (strcmp(name, "__members__") == 0) + return Py_BuildValue("[s,s,s,s,s,s,s,s,s,s]", + "v", "col", "mat", "materialIndex", "smooth", + "image", "mode", "flag", "transp", "uv"); return Py_FindMethod(NMFace_methods, (PyObject*)self, name); } @@ -351,8 +357,8 @@ PyTypeObject NMFace_Type = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ - "NMFace", /*tp_name*/ - sizeof(BPy_NMFace), /*tp_basicsize*/ + "Blender NMFace", /*tp_name*/ + sizeof(BPy_NMFace), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor) NMFace_dealloc, /*tp_dealloc*/ @@ -404,7 +410,9 @@ static PyObject *NMVert_getattr(PyObject *self, char *name) else if (strcmp(name, "no") == 0) return newVectorObject(mv->no, 3); else if (strcmp(name, "uvco") == 0) return newVectorObject(mv->uvco, 3); - else if (strcmp(name, "index") == 0) return PyInt_FromLong(mv->index); + else if (strcmp(name, "index") == 0) return PyInt_FromLong(mv->index); + else if (strcmp(name, "__members__") == 0) + return Py_BuildValue("[s,s,s,s]", "co", "no", "uvco", "index"); return EXPP_ReturnPyObjError (PyExc_AttributeError, name); } @@ -522,8 +530,8 @@ PyTypeObject NMVert_Type = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ - "NMVert", /*tp_name*/ - sizeof(BPy_NMVert), /*tp_basicsize*/ + "Blender NMVert", /*tp_name*/ + sizeof(BPy_NMVert), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor) NMVert_dealloc, /*tp_dealloc*/ @@ -547,6 +555,49 @@ static void NMesh_dealloc(PyObject *self) PyObject_DEL(self); } +static PyObject *NMesh_removeAllKeys (PyObject *self, PyObject *args) +{ + BPy_NMesh *nm = (BPy_NMesh *)self; + Mesh *me = nm->mesh; + + if (!PyArg_ParseTuple (args, "")) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "this function expects no arguments"); + + if (!me || !me->key) return EXPP_incr_ret (Py_False); + + me->key->id.us--; + me->key = 0; + + return EXPP_incr_ret (Py_True); +} + +static PyObject *NMesh_insertKey(PyObject *self, PyObject *args) +{ + int fra = -1, oldfra = -1; + BPy_NMesh *nm = (BPy_NMesh *)self; + Mesh *mesh = nm->mesh; + + if (!PyArg_ParseTuple(args, "|i", &fra)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected int argument (or nothing)"); + + if (fra > 0) { + oldfra = G.scene->r.cfra; + G.scene->r.cfra = fra; + } + + if (!mesh) + return EXPP_ReturnPyObjError (PyExc_RuntimeError, + "update this NMesh first with its .update() method"); + + insert_meshkey(mesh); + + if (fra > 0) G.scene->r.cfra = oldfra; + + return EXPP_incr_ret (Py_None); +} + static PyObject *NMesh_getSelectedFaces(PyObject *self, PyObject *args) { BPy_NMesh *nm = (BPy_NMesh *)self; @@ -780,6 +831,8 @@ static struct PyMethodDef NMesh_methods[] = MethodDef(getActiveFace), MethodDef(getSelectedFaces), MethodDef(getVertexInfluences), + MethodDef(insertKey), + MethodDef(removeAllKeys), MethodDef(update), {NULL, NULL} }; @@ -812,6 +865,10 @@ static PyObject *NMesh_getattr(PyObject *self, char *name) else if (strcmp(name, "faces") == 0) return EXPP_incr_ret(me->faces); + else if (strcmp(name, "__members__") == 0) + return Py_BuildValue("[s,s,s,s,s]", + "name", "materials", "verts", "users", "faces"); + return Py_FindMethod(NMesh_methods, (PyObject*)self, name); } @@ -819,21 +876,21 @@ static int NMesh_setattr(PyObject *self, char *name, PyObject *v) { BPy_NMesh *me = (BPy_NMesh *)self; - if (!strcmp(name, "name")) { - char buf[21]; + if (!strcmp(name, "name")) { + char buf[21]; - if (!PyString_Check(v)) - return EXPP_ReturnIntError (PyExc_TypeError, - "expected string argument"); + if (!PyString_Check(v)) + return EXPP_ReturnIntError (PyExc_TypeError, + "expected string argument"); - PyOS_snprintf(buf, sizeof(buf), "%s", PyString_AsString(v)); - rename_id(&me->mesh->id, buf); + PyOS_snprintf(buf, sizeof(buf), "%s", PyString_AsString(v)); + rename_id(&me->mesh->id, buf); - Py_DECREF (me->name); - me->name = PyString_FromString(me->mesh->id.name+2); - } + Py_DECREF (me->name); + me->name = PyString_FromString(me->mesh->id.name+2); + } - else if (!strcmp(name, "verts") || !strcmp(name, "faces") || + else if (!strcmp(name, "verts") || !strcmp(name, "faces") || !strcmp(name, "materials")) { if(PySequence_Check(v)) { @@ -866,8 +923,8 @@ PyTypeObject NMesh_Type = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ - "NMesh", /*tp_name*/ - sizeof(BPy_NMesh), /*tp_basicsize*/ + "Blender NMesh", /*tp_name*/ + sizeof(BPy_NMesh), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor) NMesh_dealloc, /*tp_dealloc*/ @@ -1139,9 +1196,13 @@ static PyObject *M_NMesh_GetRawFromObject(PyObject *self, PyObject *args) else nmesh = new_NMesh(me); } - ((BPy_NMesh *) nmesh)->mesh = 0; // hack: to mark that (deformed) mesh is readonly, - // so the update function will not try to write it. - return nmesh; + +/* hack: to mark that (deformed) mesh is readonly, so the update function + * will not try to write it. */ + + ((BPy_NMesh *) nmesh)->mesh = 0; + + return nmesh; } static void mvert_from_data(MVert *mv, MSticky *st, BPy_NMVert *from) @@ -1316,10 +1377,28 @@ static int check_validFaceUV(BPy_NMesh *nmesh) return 1; } +/* this is a copy of unlink_mesh in mesh.c, because ... */ +void EXPP_unlink_mesh(Mesh *me) +{ + int a; + + if(me==0) return; + + for(a=0; atotcol; a++) { + if(me->mat[a]) me->mat[a]->id.us--; + me->mat[a]= 0; + } +/* ... here we want to preserve mesh keys + if(me->key) me->key->id.us--; + me->key= 0; +*/ + if(me->texcomesh) me->texcomesh= 0; +} + static int unlink_existingMeshData(Mesh *mesh) { freedisplist(&mesh->disp); - unlink_mesh(mesh); + EXPP_unlink_mesh(mesh); if(mesh->mvert) MEM_freeN(mesh->mvert); if(mesh->mface) MEM_freeN(mesh->mface); if(mesh->mcol) MEM_freeN(mesh->mcol); @@ -1346,7 +1425,7 @@ Material **nmesh_updateMaterials(BPy_NMesh *nmesh) if (mesh->mat) MEM_freeN(mesh->mat); - mesh->mat = matlist; + mesh->mat = matlist; } else { matlist = 0; @@ -1361,22 +1440,22 @@ PyObject *NMesh_assignMaterials_toObject(BPy_NMesh *nmesh, Object *ob) Material *ma; int i; short old_matmask; - Mesh *mesh = nmesh->mesh; - int nmats; /* number of mats == len(nmesh->materials)*/ + Mesh *mesh = nmesh->mesh; + int nmats; /* number of mats == len(nmesh->materials)*/ old_matmask = ob->colbits; /*@ HACK: save previous colbits */ ob->colbits = 0; /* make assign_material work on mesh linked material */ - nmats = PyList_Size(nmesh->materials); + nmats = PyList_Size(nmesh->materials); - if (nmats > 0 && !mesh->mat) { - ob->totcol = nmats; - mesh->totcol = nmats; - mesh->mat = MEM_callocN(sizeof(void *)*nmats, "bpy_memats"); + if (nmats > 0 && !mesh->mat) { + ob->totcol = nmats; + mesh->totcol = nmats; + mesh->mat = MEM_callocN(sizeof(void *)*nmats, "bpy_memats"); - if (ob->mat) MEM_freeN(ob->mat); - ob->mat = MEM_callocN(sizeof(void *)*nmats, "bpy_obmats"); - } + if (ob->mat) MEM_freeN(ob->mat); + ob->mat = MEM_callocN(sizeof(void *)*nmats, "bpy_obmats"); + } for (i = 0; i < nmats; i++) { pymat = (BPy_Material *)PySequence_GetItem(nmesh->materials, i); @@ -1501,7 +1580,7 @@ static int convert_NMeshToMesh (Mesh *mesh, BPy_NMesh *nmesh) newtf++; newmf++; - if (newmc) newmc++; + if (newmc) newmc += 4; } nmesh->flags |= NMESH_HASFACEUV; @@ -1604,7 +1683,7 @@ static PyObject *M_NMesh_PutRaw(PyObject *self, PyObject *args) if (ob) { // we created a new object NMesh_assignMaterials_toObject(nmesh, ob); - EXPP_synchronizeMaterialLists (ob, ob->data); + EXPP_synchronizeMaterialLists (ob, ob->data); return Object_CreatePyObject(ob); } else { diff --git a/source/blender/python/api2_2x/NMesh.h b/source/blender/python/api2_2x/NMesh.h index c7271c42db4..6f1fbf59596 100644 --- a/source/blender/python/api2_2x/NMesh.h +++ b/source/blender/python/api2_2x/NMesh.h @@ -54,6 +54,7 @@ #include "BLI_blenlib.h" #include "BIF_space.h" #include "DNA_mesh_types.h" +#include "DNA_key_types.h" #include "DNA_object_types.h" #include "DNA_material_types.h" #include "DNA_armature_types.h" @@ -66,6 +67,9 @@ #include "gen_utils.h" #include "modules.h" + +void insert_meshkey(Mesh *me); /* defined in editkey.c */ + /* EXPP PyType Objects */ PyTypeObject NMesh_Type; @@ -87,7 +91,7 @@ static PyObject *g_nmeshmodule = NULL; #define BPy_NMCol_Check(v) ((v)->ob_type == &NMCol_Type) static char M_NMesh_doc[] = -"The Blender.NMesh module"; +"The Blender.NMesh submodule"; static char M_NMesh_Col_doc[]= "([r, g, b, a]) - Get a new mesh color\n\n\ @@ -103,6 +107,15 @@ static char M_NMesh_Vert_doc[] = "([x, y, z]) - Get a new vertice\n\n\ [x, y, z] Specify new coordinates"; +static char NMesh_insertKey_doc[] = +"(frame = None) - inserts a Mesh key at the given frame\n\ +if called without arguments, it inserts the key at the current Scene frame"; + +static char NMesh_removeAllKeys_doc[] = +"() - removes all keys from this mesh\n\ +returns True if successful or False if this NMesh wasn't linked to a real\n\ +Blender Mesh yet or the Mesh had no keys"; + static char NMesh_getSelectedFaces_doc[] = "(flag = None) - returns list of selected Faces\n\ If flag = 1, return indices instead"; diff --git a/source/blender/python/api2_2x/Scene.c b/source/blender/python/api2_2x/Scene.c index 7ef62a92c76..cf5254601e2 100644 --- a/source/blender/python/api2_2x/Scene.c +++ b/source/blender/python/api2_2x/Scene.c @@ -52,6 +52,8 @@ PyObject *M_Object_Get (PyObject *self, PyObject *args); /* from Object.c */ /* Python BPy_Scene defaults: */ /*****************************************************************************/ #define EXPP_SCENE_FRAME_MAX 18000 +#define EXPP_SCENE_RENDER_WINRESOLUTION_MIN 4 +#define EXPP_SCENE_RENDER_WINRESOLUTION_MAX 10000 /*****************************************************************************/ /* Python API function prototypes for the Scene module. */ @@ -59,23 +61,30 @@ PyObject *M_Object_Get (PyObject *self, PyObject *args); /* from Object.c */ static PyObject *M_Scene_New (PyObject *self, PyObject *args, PyObject *keywords); static PyObject *M_Scene_Get (PyObject *self, PyObject *args); -static PyObject *M_Scene_getCurrent (PyObject *self); -static PyObject *M_Scene_unlink (PyObject *self, PyObject *arg); +static PyObject *M_Scene_GetCurrent (PyObject *self); +static PyObject *M_Scene_Unlink (PyObject *self, PyObject *arg); /*****************************************************************************/ /* The following string definitions are used for documentation strings. */ /* In Python these will be written to the console when doing a */ /* Blender.Scene.__doc__ */ /*****************************************************************************/ -static char M_Scene_doc[] = ""; +static char M_Scene_doc[] = +"The Blender.Scene submodule"; -static char M_Scene_New_doc[] = ""; +static char M_Scene_New_doc[] = +"(name = 'Scene') - Create a new Scene called 'name' in Blender."; -static char M_Scene_Get_doc[] = ""; +static char M_Scene_Get_doc[] = +"(name = None) - Return the scene called 'name'.\n\ + If 'name' is None, return a list with all Scenes."; -static char M_Scene_getCurrent_doc[] = ""; +static char M_Scene_GetCurrent_doc[] = +"() - Return the currently active Scene in Blender."; -static char M_Scene_unlink_doc[] = ""; +static char M_Scene_Unlink_doc[] = +"(scene) - Unlink (delete) scene 'Scene' from Blender.\n\ +(scene) is of type Blender scene."; /*****************************************************************************/ /* Python method structure definition for Blender.Scene module: */ @@ -85,9 +94,12 @@ struct PyMethodDef M_Scene_methods[] = { M_Scene_New_doc}, {"Get", M_Scene_Get, METH_VARARGS, M_Scene_Get_doc}, {"get", M_Scene_Get, METH_VARARGS, M_Scene_Get_doc}, - {"getCurrent",(PyCFunction)M_Scene_getCurrent, - METH_NOARGS, M_Scene_getCurrent_doc}, - {"unlink", M_Scene_unlink, METH_VARARGS, M_Scene_unlink_doc}, + {"GetCurrent",(PyCFunction)M_Scene_GetCurrent, + METH_NOARGS, M_Scene_GetCurrent_doc}, + {"getCurrent",(PyCFunction)M_Scene_GetCurrent, + METH_NOARGS, M_Scene_GetCurrent_doc}, + {"Unlink", M_Scene_Unlink, METH_VARARGS, M_Scene_Unlink_doc}, + {"unlink", M_Scene_Unlink, METH_VARARGS, M_Scene_Unlink_doc}, {NULL, NULL, 0, NULL} }; @@ -123,9 +135,9 @@ static PyMethodDef BPy_Scene_methods[] = { {"setName", (PyCFunction)Scene_setName, METH_VARARGS, "(str) - Change Scene name"}, {"getWinSize", (PyCFunction)Scene_getWinSize, METH_NOARGS, - "() - Return Scene size"}, + "() - Return Render window [x,y] dimensions"}, {"setWinSize", (PyCFunction)Scene_setWinSize, METH_VARARGS, - "(str) - Change Scene size"}, + "(str) - Change Render window [x,y] dimensions"}, {"copy", (PyCFunction)Scene_copy, METH_VARARGS, "(duplicate_objects = 1) - Return a copy of this scene\n" "The optional argument duplicate_objects defines how the scene\n" @@ -288,12 +300,12 @@ static PyObject *M_Scene_Get(PyObject *self, PyObject *args) } } -static PyObject *M_Scene_getCurrent (PyObject *self) +static PyObject *M_Scene_GetCurrent (PyObject *self) { return Scene_CreatePyObject ((Scene *)G.scene); } -static PyObject *M_Scene_unlink (PyObject *self, PyObject *args) +static PyObject *M_Scene_Unlink (PyObject *self, PyObject *args) { PyObject *pyobj; Scene *scene; @@ -381,34 +393,38 @@ static PyObject *Scene_setName(BPy_Scene *self, PyObject *args) return Py_None; } - - static PyObject *Scene_getWinSize(BPy_Scene *self) { -PyObject* list = PyList_New (0); -Scene *scene = self->scene; -PyList_Append (list, PyInt_FromLong(scene->r.xsch)); -PyList_Append (list, PyInt_FromLong(scene->r.ysch)); - return list; + PyObject* list = PyList_New (0); + Scene *scene = self->scene; + + PyList_Append (list, PyInt_FromLong(scene->r.xsch)); + PyList_Append (list, PyInt_FromLong(scene->r.ysch)); + + return list; } static PyObject *Scene_setWinSize(BPy_Scene *self, PyObject *args) { - PyObject *listargs=0, * tmp; - int i; - if (!PyArg_ParseTuple(args, "O", &listargs)) - return (EXPP_ReturnPyObjError(PyExc_TypeError,"expected a list")); - if (!PyList_Check(listargs)) - return (EXPP_ReturnPyObjError(PyExc_TypeError,"expected a list")); - puts("popo"); - tmp = PyList_GetItem(listargs,0); - printf("%d\n",self->scene->r.xsch); - self->scene->r.xsch = (short)PyInt_AsLong(tmp); - printf("%d\n",self->scene->r.xsch); - tmp = PyList_GetItem(listargs,1); - self->scene->r.ysch = (short)PyInt_AsLong(tmp); + int xres = -1, yres = -1; + + if (!PyArg_ParseTuple(args, "(ii)", &xres, &yres)) + return EXPP_ReturnPyObjError (PyExc_TypeError, + "expected a [x, y] list as argument"); + + if (xres > 0) + self->scene->r.xsch = EXPP_ClampInt(xres, + EXPP_SCENE_RENDER_WINRESOLUTION_MIN, + EXPP_SCENE_RENDER_WINRESOLUTION_MAX); + + if (yres > 0) + self->scene->r.ysch = EXPP_ClampInt(yres, + EXPP_SCENE_RENDER_WINRESOLUTION_MIN, + EXPP_SCENE_RENDER_WINRESOLUTION_MAX); + Py_INCREF(Py_None); - return Py_None; + + return Py_None; } static PyObject *Scene_copy (BPy_Scene *self, PyObject *args) @@ -495,7 +511,7 @@ static PyObject *Scene_update (BPy_Scene *self) static PyObject *Scene_link (BPy_Scene *self, PyObject *args) { Scene *scene = self->scene; - BPy_Object *bpy_obj; /* XXX Change to BPy or whatever is chosen */ + BPy_Object *bpy_obj; if (!scene) return EXPP_ReturnPyObjError (PyExc_RuntimeError, diff --git a/source/blender/python/api2_2x/Types.c b/source/blender/python/api2_2x/Types.c index ed78af7f4d6..7a26c88b6e7 100644 --- a/source/blender/python/api2_2x/Types.c +++ b/source/blender/python/api2_2x/Types.c @@ -60,6 +60,8 @@ PyObject *Types_Init (void) /* Blender Object Data Types */ + PyDict_SetItemString(dict, "SceneType", (PyObject *)&Scene_Type); + PyDict_SetItemString(dict, "NMeshType", (PyObject *)&NMesh_Type); PyDict_SetItemString(dict, "NMFaceType", (PyObject *)&NMFace_Type); PyDict_SetItemString(dict, "NMVertType", (PyObject *)&NMVert_Type); diff --git a/source/blender/python/api2_2x/Types.h b/source/blender/python/api2_2x/Types.h index 7cc126dc4db..ced99ceecd3 100644 --- a/source/blender/python/api2_2x/Types.h +++ b/source/blender/python/api2_2x/Types.h @@ -37,6 +37,7 @@ extern PyTypeObject Button_Type, Material_Type; extern PyTypeObject Object_Type; +extern PyTypeObject Scene_Type; extern PyTypeObject NMesh_Type, NMFace_Type, NMVert_Type, NMCol_Type; extern PyTypeObject Camera_Type, Lamp_Type, Image_Type, Text_Type; extern PyTypeObject Armature_Type, Bone_Type; diff --git a/source/blender/python/api2_2x/doc/Armature.py b/source/blender/python/api2_2x/doc/Armature.py new file mode 100644 index 00000000000..b57dc43a562 --- /dev/null +++ b/source/blender/python/api2_2x/doc/Armature.py @@ -0,0 +1,76 @@ +# Blender.Armature module and the Armature PyType object + +""" +The Blender.Armature submodule. + +Armature +======== + +This module provides access to B{Armature} objects in Blender. These are +"skeletons", used to deform and animate other objects -- meshes, for +example. + +Example:: + import Blender + from Blender import Armature + # + armatures = Armature.Get() + for a in armatures: + print "Armature ", a + print "- The root bones of %s: %s" % (a.name, a.getBones()) +""" + +def New (name = 'ArmatureData'): + """ + Create a new Armature object. + @type name: string + @param name: The Armature name. + @rtype: Blender Armature + @return: The created Armature object. + """ + +def Get (name = None): + """ + Get the Armature object(s) from Blender. + @type name: string + @param name: The name of the Armature. + @rtype: Blender Armature or a list of Blender Armatures + @return: It depends on the I{name} parameter: + - (name): The Armature object with the given I{name}; + - (): A list with all Armature objects in the current scene. + """ + +class Armature: + """ + The Armature object + =================== + This object gives access to Armature-specific data in Blender. + @cvar name: The Armature name. + @cvar bones: The Armature root bones (cannot be set yet). + """ + + def getName(): + """ + Get the name of this Armature object. + @rtype: string + """ + + def setName(name): + """ + Set the name of this Armature object. + @type name: string + @param name: The new name. + """ + + def getBones(): + """ + Get the Armature root bones. + @rtype: list + @return: a list of Armature bones. + """ + + def setBones(bones): + """ + Set the Armature root bones (still unimplemented). + @warn: This method wasn't implemented yet. + """ diff --git a/source/blender/python/api2_2x/doc/Blender.py b/source/blender/python/api2_2x/doc/Blender.py index 6f701c2defb..5847b6802d1 100644 --- a/source/blender/python/api2_2x/doc/Blender.py +++ b/source/blender/python/api2_2x/doc/Blender.py @@ -12,14 +12,22 @@ This is the main Blender module. Blender Python ============== + - The L{Blender} module + Submodules: ----------- + - L{Types} + - L{Scene} + - L{NMesh} - L{Material} + - L{Armature} - L{Camera} - L{Lamp} - L{BGL} - L{Window} + - L{Draw} + - L{Image} - L{Text} Introduction: @@ -31,7 +39,7 @@ Blender Python - Links to Blender, Blender Python, later: script lists @author: The Blender Python Team -@requires: Blender 2.28 or newer. +@requires: Blender 2.27-NewPy (2.28 pre-release) or newer. @version: 0.1 @see: U{www.blender.org} @see: U{projects.blender.org} diff --git a/source/blender/python/api2_2x/doc/Camera.py b/source/blender/python/api2_2x/doc/Camera.py index 59e8857dd93..02b54dbcf43 100644 --- a/source/blender/python/api2_2x/doc/Camera.py +++ b/source/blender/python/api2_2x/doc/Camera.py @@ -37,8 +37,8 @@ def Get (name = None): @type name: string @param name: The name of the Camera Data. @rtype: Blender Camera or a list of Blender Cameras - @return: It depends on the 'name' parameter: - - (name): The Camera Data object with the given name; + @return: It depends on the I{name} parameter: + - (name): The Camera Data object with the given I{name}; - (): A list with all Camera Data objects in the current scene. """ diff --git a/source/blender/python/api2_2x/doc/Draw.py b/source/blender/python/api2_2x/doc/Draw.py new file mode 100644 index 00000000000..a0135b1bcfd --- /dev/null +++ b/source/blender/python/api2_2x/doc/Draw.py @@ -0,0 +1,353 @@ +# Blender.Draw module and the Button PyType object + +""" +The Blender.Draw submodule. + +Draw +==== + +This module provides access to a B{windowing interface} in Blender. Its widgets +include many kinds of buttons: push, toggle, menu, number, string, slider, +scrollbar, plus support for text drawing. It also includes keyboard keys and +mouse button code values in its dictionary (print dir(Blender.Draw)). + +Example:: + import Blender + from Blender import Draw, BGL + # + mystring = "" + mymsg = "" + toggle = 0 + # + def event(evt, val): # the function to handle input events + global mystring, mymsg + + if not val: # val = 0: it's a key/mbutton release + if evt in [Draw.LEFTMOUSE, Draw.MIDDLEMOUSE, Draw.RIGHTMOUSE]: + mymsg = "You released a mouse button." + Draw.Redraw(1) + return + + if evt == Draw.ESCKEY: + Draw.Exit() # exit when user presses ESC + return + + elif Draw.AKEY <= evt <= Draw.ZKEY: mystring += chr(evt) + elif evt == Draw.SPACEKEY: mystring += ' ' + elif evt == Draw.BACKSPACEKEY and len(mystring): + mystring = mystring[:-1] + else: return # this is important: only re-register if an event was caught + + Draw.Register(gui, event, button_event) # re-register to stay in the loop + # + def button_event(evt): # the function to handle Draw Button events + global mymsg, toggle + if evt == 1: + mymsg = "You pressed the toggle button." + toggle = 1 - toggle + Draw.Redraw(1) + else: + Draw.Register(gui, event, button_event) + # + def gui(): # the function to draw the screen + global mystring, mymsg, toggle + if len(mystring) > 90: mystring = "" + BGL.glClearColor(0,0,1,1) + BGL.glClear(BGL.GL_COLOR_BUFFER_BIT) + BGL.glColor3f(1,1,1) + Draw.Toggle("Toggle", 1, 10, 10, 55, 20, toggle,"A toggle button") + BGL.glRasterPos2i(72, 16) + if toggle: toggle_state = "down" + else: toggle_state = "up" + Draw.Text("The toggle button is %s." % toggle_state, "small") + BGL.glRasterPos2i(10, 230) + Draw.Text("Type letters from a to z, ESC to leave.") + BGL.glRasterPos2i(20, 200) + Draw.Text(mystring) + BGL.glColor3f(1,0.4,0.3) + BGL.glRasterPos2i(340, 70) + Draw.Text(mymsg, "tiny") + # + Draw.Register(gui, event, button_event) # registering the 3 callbacks +@warn: Inside the windowing loop (after Draw.Register() has been executed and +before Draw.Exit() is called), don't use the redraw functions from other +modules (Blender and Window). The Draw submodule has its own Draw.Redraw() and +Draw.Draw() functions that can be used inside the windowing loop. +""" + +def Exit(): + """ + Exit the windowing interface. + """ + +def Register(draw = None, event = None, button = None): + """ + Register callbacks for windowing. + @type draw: function + @type event: function + @type button: function + @param draw: A function to draw the screen, taking no arguments: f(). + @param event: A function to handle keyboard and mouse input events, taking + two arguments: f(evt, val), where: + - 'evt' (int) is the event number; + - 'val' (int) is the value modifier. If val = 0, the event refers to a + key or mouse button being released. Otherwise it's a key/button press. + @param button: A function to handle Draw Button events, taking one argument: + f(evt), where: + - 'evt' is the button number (see the I{event} parameter in L{Button}). + """ + +def Redraw(after = 0): + """ + Queue a redraw event. Redraw events are buffered so that, regardless of how + many events are queued, the window only receives one redraw event. + @type after: int + @param after: If non-zero, the redraw is processed before other input events. + """ + +def Draw(): + """ + Force an immediate redraw. Forced redraws are not buffered. In other words, + the window is redrawn once every time this function is called. + """ + +def Create(value): + """ + Create a default Button object. + @type value: int, float or string + @param value: The value to store in the button. + @rtype: Blender Button + @return: The Button created. + """ + +def Button(name, event, x, y, width, height, tooltip = None): + """ + Create a new (push) Button object. + @type name: string + @param name: The string to display on the button. + @type event: int + @param event: The event number to pass to the button event function when + activated. + @type x: int + @type y: int + @param x: The lower left x (horizontal) coordinate of the button. + @param y: The lower left y (vertical) coordinate of the button. + @type width: int + @type height: int + @param width: The button width. + @param height: The button height. + @type tooltip: string + @param tooltip: The button's tooltip (the string that appears when the mouse + is kept over the button). + """ + +def Menu(name, event, x, y, width, height, default, tooltip = None): + """ + Create a new Menu Button object. + + The menu options are specified through the 'name' of the button. Options are + I{followed} by a format code and separated by the '|' (pipe) character. Valid + format codes are: + - %t - The option should be used as the title; + - %xB{N} - The option should set the integer B{N} in the button value. + + Example:: + name = "The Title %t|First Entry %x1|Second Entry %x2|Third Entry %x3" + menu = Draw.Menu(name, 2, 60, 120, 200, 40, 3, "Just a test menu.") + # note that, since default = 3, the "Third Entry" + # will appear as the default choice in the Menu. + + @type name: string + @param name: The string to display on the button. + @type event: int + @param event: The event number to pass to the button event function when + activated. + @type x: int + @type y: int + @param x: The lower left x (horizontal) coordinate of the button. + @param y: The lower left y (vertical) coordinate of the button. + @type width: int + @type height: int + @param width: The button width. + @param height: The button height. + @type default: int + @param default: The number of the option to be selected by default. + @type tooltip: string + @param tooltip: The button's tooltip (the string that appears when the mouse + is kept over the button). + @rtype: Blender Button + @return: The Button created. + """ + +def Toggle(name, event, x, y, width, height, default, tooltip = None): + """ + Create a new Toggle Button object. + @type name: string + @param name: The string to display on the button. + @type event: int + @param event: The event number to pass to the button event function when + activated. + @type x: int + @type y: int + @param x: The lower left x (horizontal) coordinate of the button. + @param y: The lower left y (vertical) coordinate of the button. + @type width: int + @type height: int + @param width: The button width. + @param height: The button height. + @type default: int + @param default: The value specifying the default state: + (0 for "up", 1 for "down"). + @type tooltip: string + @param tooltip: The button's tooltip (the string that appears when the mouse + is kept over the button). + @rtype: Blender Button + @return: The Button created. + """ + +def Slider(name, event, x, y, width, height, initial, min, max, realtime = 1, + tooltip = None): + """ + Create a new Toggle Button object. + @type name: string + @param name: The string to display on the button. + @type event: int + @param event: The event number to pass to the button event function when + activated. + @type x: int + @type y: int + @param x: The lower left x (horizontal) coordinate of the button. + @param y: The lower left y (vertical) coordinate of the button. + @type width: int + @type height: int + @param width: The button width. + @param height: The button height. + @type initial: int or float + @type min: int or float + @type max: int or float + @param initial: The initial value. + @param min: The minimum value. + @param max: The maximum value. + @type realtime: int + @param realtime: If non-zero (the default), the slider will emit events as + it is edited. + @type tooltip: string + @param tooltip: The button's tooltip (the string that appears when the mouse + is kept over the button). + @rtype: Blender Button + @return: The Button created. + """ + +def Scrollbar(event, x, y, width, height, initial, min, max, realtime = 1, + tooltip = None): + """ + Create a new Scrollbar Button object. + @type event: int + @param event: The event number to pass to the button event function when + activated. + @type x: int + @type y: int + @param x: The lower left x (horizontal) coordinate of the button. + @param y: The lower left y (vertical) coordinate of the button. + @type width: int + @type height: int + @param width: The button width. + @param height: The button height. + @type initial: int or float + @type min: int or float + @type max: int or float + @param initial: The initial value. + @param min: The minimum value. + @param max: The maximum value. + @type realtime: int + @param realtime: If non-zero (the default), the slider will emit events as + it is edited. + @type tooltip: string + @param tooltip: The button's tooltip (the string that appears when the mouse + is kept over the button). + @rtype: Blender Button + @return: The Button created. + """ + +def Number(name, event, x, y, width, height, initial, min, max, realtime = 1, + tooltip = None): + """ + Create a new Number Button object. + @type name: string + @param name: The string to display on the button. + @type event: int + @param event: The event number to pass to the button event function when + activated. + @type x: int + @type y: int + @param x: The lower left x (horizontal) coordinate of the button. + @param y: The lower left y (vertical) coordinate of the button. + @type width: int + @type height: int + @param width: The button width. + @param height: The button height. + @type initial: int or float + @type min: int or float + @type max: int or float + @param initial: The initial value. + @param min: The minimum value. + @param max: The maximum value. + @type realtime: int + @param realtime: If non-zero (the default), the slider will emit events as + it is edited. + @type tooltip: string + @param tooltip: The button's tooltip (the string that appears when the mouse + is kept over the button). + @rtype: Blender Button + @return: The Button created. + """ + + +def String(name, event, x, y, width, height, initial, length, tooltip = None): + """ + Create a new String Button object. + @type name: string + @param name: The string to display on the button. + @type event: int + @param event: The event number to pass to the button event function when + activated. + @type x: int + @type y: int + @param x: The lower left x (horizontal) coordinate of the button. + @param y: The lower left y (vertical) coordinate of the button. + @type width: int + @type height: int + @param width: The button width. + @param height: The button height. + @type initial: string + @param initial: The string to display initially. + @type length: int + @param length: The maximum input length. + @type tooltip: string + @param tooltip: The button's tooltip (the string that appears when the mouse + is kept over the button). + @rtype: Blender Button + @return: The Button created. + """ + +def GetStringWidth(string, fontsize = 'normal'): + """ + Get the width in pixels of a string. + @type string: string + @param string: A string. + @type fontsize: string + @param fontsize: The size of the font: 'normal', 'small' or 'tiny'. + @rtype: int + @return: The width of I{string} with the chosen I{fontsize}. + """ + +def Text(string, fontsize = 'normal'): + """ + Draw a string on the screen. + @type string: string + @param string: The text string to draw. + @type fontsize: string + @param fontsize: The size of the font: 'normal', 'small' or 'tiny'. + @rtype: int + @return: The width of I{string} drawn with the chosen I{fontsize}. + """ diff --git a/source/blender/python/api2_2x/doc/Image.py b/source/blender/python/api2_2x/doc/Image.py new file mode 100644 index 00000000000..96f75496540 --- /dev/null +++ b/source/blender/python/api2_2x/doc/Image.py @@ -0,0 +1,115 @@ +# Blender.Image module and the Image PyType object + +""" +The Blender.Image submodule. + +Image +===== + +This module provides access to B{Image} objects in Blender. + +Example:: + import Blender + from Blender import Image + # + image = Image.Load("/path/to/my/image.png") # load an image file + print "Image from", image.getFilename(), + print "loaded to obj", image.getName()) + image.setXRep(4) # set x tiling factor + image.setYRep(2) # set y tiling factor + print "All Images available now:", Image.Get() +""" + +def Load (filename): + """ + Load the image called 'filename' into an Image object. + @type filename: string + @param filename: The full path to the image file. + @rtype: Blender Image + @return: A Blender Image object with the data from I{filename}. + """ + +def New (name): + """ + Create a new Image object (not implemented yet!). + @type name: string + @param name: The name of the new Image object. + @rtype: Blender Image + @return: A new Blender Image object. + @warn: This function wasn't implemented yet. It simply returns None. + """ + +def Get (name = None): + """ + Get the Image object(s) from Blender. + @type name: string + @param name: The name of the Image object. + @rtype: Blender Image or a list of Blender Images + @return: It depends on the I{name} parameter: + - (name): The Image object called I{name}, None if not found; + - (): A list with all Image objects in the current scene. + """ + + +class Image: + """ + The Image object + ================ + This object gives access to Images in Blender. In the future it will allow + direct read/write access to their pixel buffers, too. + @cvar name: The name of this Image object. + @cvar filename: The filename (path) to the image file loaded into this Image + object. + @cvar xrep: Texture tiling: the number of repetitions in the x (horizontal) + axis. + @cvar yrep: Texture tiling: the number of repetitions in the y (vertical) + axis. + """ + + def getName(): + """ + Get the name of this Image object. + @rtype: string + """ + + def getFilename(): + """ + Get the filename of the image file loaded into this Image object. + @rtype: string + """ + + def getXRep(): + """ + Get the number of repetitions in the x (horizontal) axis for this Image. + This is for texture tiling. + @rtype: int + """ + + def getYRep(): + """ + Get the number of repetitions in the y (vertical) axis for this Image. + This is for texture tiling. + @rtype: int + """ + + def setName(name): + """ + Set the name of this Image object. + @type name: string + @param name: The new name. + """ + + def setXRep(xrep): + """ + Texture tiling: set the number of x repetitions for this Image. + @type xrep: int + @param xrep: The new value in [1, 16]. + """ + + def setYRep(yrep): + """ + Texture tiling: set the number of y repetitions for this Image. + @type yrep: int + @param yrep: The new value in [1, 16]. + """ + diff --git a/source/blender/python/api2_2x/doc/Lamp.py b/source/blender/python/api2_2x/doc/Lamp.py index 35290d54a75..95f1d61a1eb 100644 --- a/source/blender/python/api2_2x/doc/Lamp.py +++ b/source/blender/python/api2_2x/doc/Lamp.py @@ -34,8 +34,8 @@ def Get (name = None): @type name: string @param name: The name of the Lamp Data. @rtype: Blender Lamp or a list of Blender Lamps - @return: It depends on the 'name' parameter: - - (name): The Lamp Data object with the given name; + @return: It depends on the I{name} parameter: + - (name): The Lamp Data object with the given I{name}; - (): A list with all Lamp Data objects in the current scene. """ diff --git a/source/blender/python/api2_2x/doc/Material.py b/source/blender/python/api2_2x/doc/Material.py new file mode 100644 index 00000000000..9b42affb83f --- /dev/null +++ b/source/blender/python/api2_2x/doc/Material.py @@ -0,0 +1,468 @@ +# Blender.Material module and the Material PyObject + +""" +The Blender.Material submodule. + +Material +======== + +This module provides access to B{Material} objects in Blender. + +Example:: + import Blender + from Blender import Material + mat = Material.New('newMat') # create a new Material called 'newMat' + print mat.rgbCol # print its rgb color triplet + mat.rgbCol = [0.8, 0.2, 0.2] # change its color + mat.setAlpha(0.2) # mat.alpha = 0.2 -- almost transparent + mat.emit = 0.7 # equivalent to mat.setEmit(0.8) + mat.mode |= Material.Modes.ZTRANSP # turn on Z-Buffer transparency + mat.setName('RedBansheeSkin') # change its name + mat.setAdd(0.8) # make it glow + mat.setMode('Halo') # turn 'Halo' "on" and all others "off" + +@type Modes: readonly dictionary +@var Modes: The available Material Modes. + - TRACEABLE - Make Material visible for shadow lamps. + - SHADOW - Enable Material for shadows. + - SHADELESS - Make Material insensitive to light or shadow. + - WIRE - Render only the edges of faces. + - VCOL_LIGHT - Add vertex colors as extra light. + - VCOL_PAINT - Replace basic colors with vertex colors. + - HALO - Render as a halo. + - ZTRANSP - Z-buffer transparent faces. + - ZINVERT - Render with inverted Z-buffer. + - - HALORINGS - Render rings over the basic halo. + - ENV - Do not render Material. + - - HALOLINES - Render star shaped lines over the basic halo. + - ONLYSHADOW - Let alpha be determined on the degree of shadow. + - - HALOXALPHA - Use extreme alpha. + - TEXFACE - UV-Editor assigned texture gives color and texture info + for faces. + - - HALOSTAR - Render halo as a star. + - NOMIST - Set the Material insensitive to mist. + - - HALOSHADED - Let halo receive light. + - HALOTEX - Give halo a texture. + - HALOPUNO - Use the vertex normal to specify the dimension of the halo. + - HALOFLARE - Render halo as a lens flare. + +@warn: Some Modes are only available when the 'Halo' mode is I{off} and + others only when it is I{on}. But these two subsets of modes share the same + numerical values in their Blender C #defines. So, for example, if 'Halo' is + on, then 'NoMist' is actually interpreted as 'HaloShaded'. We marked all + such possibilities in the Modes dict below: each halo-related mode that + uses an already taken value is preceded by "-" and appear below the normal + mode which also uses that value. +""" + +def New (name = 'Mat'): + """ + Create a new Material object. + @type name: string + @param name: The Material name. + @rtype: Blender Material + @return: The created Material object. + """ + +def Get (name = None): + """ + Get the Material object(s) from Blender. + @type name: string + @param name: The name of the Material. + @rtype: Blender Material or a list of Blender Materials + @return: It depends on the 'name' parameter: + - (name): The Material object with the given name; + - (): A list with all Material objects in the current scene. + """ + +class Material: + """ + The Material object + =================== + This object gives access to Materials in Blender. + @cvar name: Material's name. + @type mode: int + @cvar mode: Mode flags as an or'ed int value. See the Modes dictionary keys + and descriptions in L{Modes}. + @cvar rgbCol: Material's RGB color triplet. + @cvar ambCol: Ambient color rgb triplet. + @cvar specCol: Specular color rgb triplet. + @cvar mirCol: Mirror color rgb triplet. + @cvar R: Red component of L{rgbCol} - [0.0, 1.0]. + @cvar G: Green component of L{rgbCol} - [0.0, 1.0]. + @cvar B: Blue component of L{rgbCol} - [0.0, 1.0]. + @cvar alpha: Alpha (translucency) component of the Material - [0.0, 1.0]. + @cvar amb: Ambient factor - [0.0, 1.0]. + @cvar emit: Emitting light intensity - [0.0, 1.0]. + @cvar ref: Reflectivity - [0.0, 1.0]. + @cvar spec: Specularity - [0.0, 2.0]. + @cvar specTransp: Specular transparency - [0.0, 1.0]. + @cvar add: Glow factor - [0.0, 1.0]. + @cvar zOffset: Artificial Z offset for faces - [0.0, 10.0]. + @cvar haloSize: Dimension of the halo - [0.0, 100.0]. + @cvar flareSize: Factor the flare is larger than the halo - [0.1, 25.0]. + @cvar flareBoost: Flare's extra strength - [0.1, 10.0]. + @cvar haloSeed: To use random values for ring dimension and line location - + [0, 255]. + @cvar flareSeed: Offset in the seed table - [0, 255]. + @cvar subSize: Dimension of subflares, dots and circles - [0.1, 25.0]. + @cvar hard: Hardness of the specularity - [1, 255]. + @cvar nFlares: Number of halo subflares - [1, 32]. + @cvar nStars: Number of points on the halo stars - [3, 50]. + @cvar nLines: Number of star shaped lines on each halo - [0, 250]. + @cvar nRings: Number of halo rings - [0, 24]. + @warning: Most member variables assume values in some [Min, Max] interval. + When trying to set them, the given parameter will be clamped to lie in + that range: if val < Min, then val = Min, if val > Max, then val = Max. + """ + + def getName(): + """ + Get the name of this Material object. + @rtype: string + """ + + def setName(name): + """ + Set the name of this Material object. + @type name: string + @param name: The new name. + """ + + def getMode(): + """ + Get this Material's mode flags. + @rtype: int + @return: B{OR'ed value}. Use the Modes dictionary to check which flags + are 'on'. + + Example:: + import Blender + from Blender import Material + flags = mymat.getMode() + if flags & Material.Modes['HALO']: + print "This material is rendered as a halo" + else: + print "Not a halo" + """ + + def setMode(m = None, m2 = None, m3 = None, and_so_on = None, + up_to_21 = None): + """ + Set this Material's mode flags. Mode strings given are turned 'on'. + Those not provided are turned 'off', so mat.setMode() -- without + arguments -- turns off all mode flags for Material mat. + @type m: string + @param m: A mode flag. From 1 to 21 can be set at the same time. + """ + + def getRGBCol(): + """ + Get the rgb color triplet. + @rtype: list of 3 floats + @return: [r, g, b] + """ + + def setRGBCol(rgb = None): + """ + Set the rgb color triplet. If B{rgb} is None, set the color to black. + @type rgb: three floats or a list of three floats + @param rgb: The rgb color values in [0.0, 1.0] as: + - a list of three floats: setRGBCol ([r, g, b]) B{or} + - three floats as separate parameters: setRGBCol (r,g,b). + """ + + def getAmbCol(): + """ + Get the ambient color triplet. + @rtype: list of 3 floats + @return: [ambR, ambG, ambB] + """ + + def setAmbCol(rgb = None): + """ + Set the ambient color triplet. If B{rgb} is None, set the color to black. + @type rgb: three floats or a list of three floats + @param rgb: The rgb color values in [0.0, 1.0] as: + - a list of three floats: setAmbCol ([r, g, b]) B{or} + - three floats as separate parameters: setAmbCol (r,g,b). + """ + + def getSpecCol(): + """ + Get the specular color triplet. + @rtype: list of 3 floats + @return: [specR, specG, specB] + """ + + def setSpecCol(rgb = None): + """ + Set the specular color triplet. If B{rgb} is None, set the color to black. + @type rgb: three floats or a list of three floats + @param rgb: The rgb color values in [0.0, 1.0] as: + - a list of three floats: setSpecCol ([r, g, b]) B{or} + - three floats as separate parameters: setSpecCol (r,g,b). + """ + + def getMirCol(): + """ + Get the mirror color triplet. + @rtype: list of 3 floats + @return: [mirR, mirG, mirb] + """ + + def setMirCol(rgb = None): + """ + Set the mirror color triplet. If B{rgb} is None, set the color to black. + @type rgb: three floats or a list of three floats + @param rgb: The rgb color values in [0.0, 1.0] as: + - a list of three floats: setMirCol ([r, g, b]) B{or} + - three floats as separate parameters: setMirCol (r,g,b). + """ + + def getAlpha(): + """ + Get the alpha (transparency) value. + @rtype: float + """ + + def setAlpha(alpha): + """ + Set the alpha (transparency) value. + @type alpha: float + @param alpha: The new value in [0.0, 1.0]. + """ + + def getAmb(): + """ + Get the ambient color blend factor. + @rtype: float + """ + + def setAmb(amb): + """ + Set the ambient color blend factor. + @type amb: float + @param amb: The new value in [0.0, 1.0]. + """ + + def getEmit(): + """ + Get the emitting light intensity. + @rtype: float + """ + + def setEmit(emit): + """ + Set the emitting light intensity. + @type emit: float + @param emit: The new value in [0.0, 1.0]. + """ + + def getRef(): + """ + Get the reflectivity value. + @rtype: float + """ + + def setRef(ref): + """ + Set the reflectivity value. + @type ref: float + @param ref: The new value in [0.0, 1.0]. + """ + + def getSpec(): + """ + Get the specularity value. + @rtype: float + """ + + def setSpec(spec): + """ + Set the specularity value. + @type spec: float + @param spec: The new value in [0.0, 2.0]. + """ + + def getSpecTransp(): + """ + Get the specular transparency. + @rtype: float + """ + + def setSpecTransp(spectransp): + """ + Set the specular transparency. + @type spectransp: float + @param spectransp: The new value in [0.0, 1.0]. + """ + + def getAdd(): + """ + Get the glow factor. + @rtype: float + """ + + def setAdd(add): + """ + Set the glow factor. + @type add: float + @param add: The new value in [0.0, 1.0]. + """ + + def getZOffset(): + """ + Get the artificial offset for faces with this Material. + @rtype: float + """ + + def setZOffset(zoffset): + """ + Set the artificial offset for faces with this Material. + @type zoffset: float + @param zoffset: The new value in [0.0, 10.0]. + """ + + def getHaloSize(): + """ + Get the halo size. + @rtype: float + """ + + def setHaloSize(halosize): + """ + Set the halo size. + @type halosize: float + @param halosize: The new value in [0.0, 100.0]. + """ + + def getHaloSeed(): + """ + Get the seed for random ring dimension and line location in halos. + @rtype: int + """ + + def setHaloSeed(haloseed): + """ + Set the seed for random ring dimension and line location in halos. + @type haloseed: int + @param haloseed: The new value in [0, 255]. + """ + + def getFlareSize(): + """ + Get the ratio: flareSize / haloSize. + @rtype: float + """ + + def setFlareSize(flaresize): + """ + Set the ratio: flareSize / haloSize. + @type flaresize: float + @param flaresize: The new value in [0.1, 25.0]. + """ + + def getFlareSeed(): + """ + Get flare's offset in the seed table. + @rtype: int + """ + + def setFlareSeed(flareseed): + """ + Set flare's offset in the seed table. + @type flareseed: int + @param flareseed: The new value in [0, 255]. + """ + + def getFlareBoost(): + """ + Get the flare's extra strength. + @rtype: float + """ + + def setFlareBoost(flareboost): + """ + Set the flare's extra strength. + @type flareboost: float + @param flareboost: The new value in [0.1, 10.0]. + """ + + def getSubSize(): + """ + Get the dimension of subflare, dots and circles. + @rtype: float + """ + + def setSubSize(subsize): + """ + Set the dimension of subflare, dots and circles. + @type subsize: float + @param subsize: The new value in [0.1, 25.0]. + """ + + def getHardness(): + """ + Get the hardness of the specularity. + @rtype: int + """ + + def setHardness(hardness): + """ + Set the hardness of the specularity. + @type hardness: int + @param hardness: The new value in [1, 255]. + """ + + def getNFlares(): + """ + Get the number of halo subflares. + @rtype: int + """ + + def setNFlares(nflares): + """ + Set the number of halo subflares. + @type nflares: int + @param nflares: The new value in [1, 32]. + """ + + def getNStars(): + """ + Get the number of points in the halo stars. + @rtype: int + """ + + def setNStars(nstars): + """ + Set the number of points in the halo stars. + @type nstars: int + @param nstars: The new value in [3, 50]. + """ + + def getNLines(): + """ + Get the number of star shaped lines on each halo. + @rtype: int + """ + + def setNLines(nlines): + """ + Set the number of star shaped lines on each halo. + @type nlines: int + @param nlines: The new value in [0, 250]. + """ + + def getNRings(): + """ + Get the number of rings on each halo. + @rtype: int + """ + + def setNRings(nrings): + """ + Set the number of rings on each halo. + @type nrings: int + @param nrings: The new value in [0, 24]. + """ diff --git a/source/blender/python/api2_2x/doc/NMesh.py b/source/blender/python/api2_2x/doc/NMesh.py new file mode 100644 index 00000000000..d1ffc0059c4 --- /dev/null +++ b/source/blender/python/api2_2x/doc/NMesh.py @@ -0,0 +1,297 @@ +# Blender.NMesh module and the NMesh PyType object + +""" +The Blender.NMesh submodule. + +Mesh Data +========= + +This module provides access to B{Mesh Data} objects in Blender. + +Example:: + + import Blender + from Blender import NMesh, Object, Scene + # + me = NMesh.GetRaw("Plane") # get the mesh data called "Plane" + if me.materials: + print me.materials # print the list of materials + mat = me.materials[0] # grab the first material in the list + mat.R = 1.0 # redefine its red component + for v in me.verts: # loop the list of vertices + v.co[0] *= 2.5 # multiply the coordinates + v.co[1] *= 5.0 + v.co[2] *= 2.5 + me.update() # update the real mesh in Blender + +@type FaceFlags: readonly dictionary +@type FaceModes: readonly dictionary +@type FaceTranspModes: readonly dictionary +@var FaceFlags: The available face selection flags: + - SELECT - selected. + - HIDE - hidden. + - ACTIVE - the active face. +@var FaceModes: The available face modes: + - ALL - set all modes at once. + - BILLBOARD - always orient after camera. + - HALO - halo face, always point to camera. + - DINAMYC - respond to collisions. + - INVISIBLE - invisible face. + - LIGHT - dinamyc lighting. + - OBCOL - use object colour instead of vertex colours. + - SHADOW - shadow type. + - SHAREDVERT - apparently unused in Blender. + - SHAREDCOL - shared vertex colours (per vertex). + - TEX - has texture image. + - TILES - uses tiled image. + - TWOSIDE - two-sided face. +@var FaceTranspModes: Note: these are ENUMS, they can't be combined (and'ed, + or'ed, etc) like a bit vector. The available face transparency modes: + - SOLID - draw solid. + - ADD - add to background (halo). + - ALPHA - draw with transparency. + - SUB - subtract from background. +""" + +def Col(col = [255, 255, 255, 255]): + """ + Get a new mesh rgba color. + @type col: list + @param col: A list [red, green, blue, alpha] of int values in [0, 255]. + @rtype: NMCol + @return: A new NMCol (mesh rgba color) object. + """ + +def Vert(x = 0, y = 0, z = 0): + """ + Get a new vertex object. + @type x: float + @type y: float + @type z: float + @param x: The x coordinate of the vertex. + @param y: The y coordinate of the vertex. + @param z: The z coordinate of the vertex. + @rtype: NMVert + @return: A new NMVert object. + """ + +def Face(vertexList = None): + """ + Get a new face object. + @type vertexList: list + @param vertexList: A list of B{up to 4} NMVerts (mesh vertex + objects). + @rtype: NMFace + @return: A new NMFace object. + """ + +def New(): + """ + Create a new mesh object. + rtype: NMesh + @return: A new (B{empty}) NMesh object. + """ + +def GetRaw(name = None): + """ + Get the mesh data object called I{name} from Blender. + @type name: string + @param name: The name of the mesh data object. + @rtype: NMesh + @return: It depends on the 'name' parameter: + - (name) - The NMesh wrapper of the mesh called I{name}, + None if not found. + - () - A new (empty) NMesh object. + """ + +def GetRawFromObject(name): + """ + Get the mesh data object from the Object in Blender called I{name}. + @type name: string + @param name: The name of an Object of type "Mesh". + @rtype: NMesh + @return: The NMesh wrapper of the mesh data from the Object called I{name}. + """ + +def PutRaw(nmesh, name = None, recalculate_normals = 1): + """ + Put an NMesh object back in Blender. + @type nmesh: NMesh + @type name: string + @type recalculate_normals: int + @param name: The name of the mesh data object in Blender which will receive + this nmesh data. It can be an existing mesh data object or a new one. + @param recalculate_normals: If non-zero, the vertex normals for the mesh will + be recalculated. + @rtype: None or Object + @return: It depends on the 'name' parameter: + - I{name} refers to an existing mesh data obj already linked to an + object: return None. + - I{name} refers to a new mesh data obj or an unlinked (no users) one: + return the created Blender Object wrapper. + """ + +class NMCol: + """ + The NMCol object + ================ + This object is a list of ints: [r, g, b, a] representing an + rgba colour. + @cvar r: The Red component in [0, 255]. + @cvar g: The Green component in [0, 255]. + @cvar b: The Blue component in [0, 255]. + @cvar a: The Alpha (transparency) component in [0, 255]. + """ + +class NMVert: + """ + The NMVert object + ================= + This object holds mesh vertex data. + @cvar co: The vertex coordinates (x, y, z). + @cvar no: The vertex normal vector (nx, ny, nz). + @cvar uvco: The vertex texture "sticky" coordinates. + @cvar index: The vertex index, if owned by a mesh. + """ + +class NMFace: + """ + The NMFace object + ================= + This object holds mesh face data. + @type v: list + @cvar v: The list of face vertices (B{up to 4}). + @cvar col: The list of vertex colours. + @cvar mat: Same as I{materialIndex} below. + @cvar materialIndex: The index of this face's material in its NMesh materials + list. + @cvar smooth: If non-zero, the vertex normals are averaged to make this + face look smooth. + @cvar image: The Image used as a texture for this face. + @cvar mode: The display mode (see L{Mesh.FaceModes}) + @cvar flag: Bit vector specifying selection flags + (see L{NMesh.FaceFlags}). + @cvar transp: Transparency mode bit vector + (see L{NMesh.FaceTranspModes}). + @cvar uv: List of per-face UV coordinates: [(u0, v0), (u1, v1), ...]. + """ + + def append(vertex): + """ + Append a vertex to this face's vertex list. + @type vertex: NMVert + @param vertex: An NMVert object. + """ + +class NMesh : + """ + The NMesh Data object + ===================== + This object gives access to mesh data in Blender. We refer to mesh as the + object in Blender and NMesh as its Python counterpart. + @cvar name: The NMesh name. It's common to use this field to store extra + data about the mesh (to be exported to another program, for example). + @cvar materials: The list of materials used by this NMesh. + @cvar verts: The list of NMesh vertices (NMVerts). + @cvar users: The number of Objects using (linked to) this mesh. + @cvar faces: The list of NMesh faces (NMFaces). + """ + + def hasVertexColours(flag = None): + """ + Get (and optionally set) if this NMesh has vertex colours. + @type flag: int + @param flag: If given and non-zero, the "vertex colour" flag for this NMesh + is turned I{on}. + @rtype: bool + @return: The current value of the "vertex colour" flag. + @warn: If a mesh has both vertex colours and textured faces, this function + will return False. This is due to the way Blender deals internally with + the vertex colours array (if there are textured faces, it is copied to + the textured face structure and the original array is freed/deleted). + If you want to know if a mesh has both textured faces and vertex + colours, set *in Blender* the "VCol Paint" flag for each material that + covers an area that was also vertex painted and then check in your + Python script if that material flag is set. Of course also tell others + who use your script to do the same. The "VCol Paint" material mode flag + is the way to tell Blender itself to render with vertex colours, too, so + it's a natural solution. + """ + + def hasFaceUV(flag = None): + """ + Get (and optionally set) if this NMesh has UV-mapped textured faces. + @type flag: int + @param flag: If given and non-zero, the "textured faces" flag for this + NMesh is turned I{on}. + @rtype: bool + @return: The current value of the "textured faces" flag. + """ + + def hasVertexUV(flag = None): + """ + Get (and optionally set) the "sticky" flag that controls if a mesh has + per vertex UV coordinates. + @type flag: int + @param flag: If given and non-zero, the "sticky" flag for this NMesh is + turned I{on}. + @rtype: bool + @return: The current value of the "sticky" flag. + """ + + def getActiveFace(): + """ + Get the index of the active face. + @rtype: int + @return: The index of the active face. + """ + + def getSelectedFaces(flag = None): + """ + Get list of selected faces. + @type flag: int + @param flag: If given and non-zero, the list will have indices instead of + the NMFace objects themselves. + @rtype: list + @return: It depends on the I{flag} parameter: + - if None or zero: List of NMFace objects. + - if non-zero: List of indices to NMFace objects. + """ + + def getVertexInfluences(index): + """ + Get influences of bones in a specific vertex. + @type index: int + @param index: The index of a vertex. + @rtype: list + @return: List of pairs (name, weight), where name is the bone name (string) + and its weight is a float value. + """ + + def insertKey(frame = None): + """ + Insert a mesh key at the given frame. + @type frame: int + @param frame: The Scene frame where the mesh key should be inserted. If + None, the current frame is used. + """ + + def removeAllKeys(): + """ + Remove all mesh keys stored in this mesh. + @rtype: bool + @return: True if succesful or False if this NMesh wasn't linked to a real + Blender Mesh yet (or was, but the Mesh had no keys). + @warn: Currently the mesh keys from meshs that are grabbed with + NMesh.GetRaw() or .GetRawFromObject() are preserved, so if you want to + clear them or don't want them at all, remember to call this method. Of + course NMeshes created with NMesh.New() don't have mesh keys until you + add them. + """ + + def update(): + """ + Update the mesh in Blender. The changes made are put back to the mesh in + Blender, if available, or put in a newly created mesh object if this NMesh + wasn't linked to one, yet. + """ diff --git a/source/blender/python/api2_2x/doc/Scene.py b/source/blender/python/api2_2x/doc/Scene.py new file mode 100644 index 00000000000..3983735e227 --- /dev/null +++ b/source/blender/python/api2_2x/doc/Scene.py @@ -0,0 +1,193 @@ +# Blender.Scene module and the Scene PyType object + +""" +The Blender.Scene submodule. + +Scene +===== + +This module provides access to B{Scenes} in Blender. + +Example:: + +""" + +def New (name = 'Scene'): + """ + Create a new Scene in Blender. + @type name: string + @param name: The Scene name. + @rtype: Blender Scene + @return: The created Scene. + """ + +def Get (name = None): + """ + Get the Scene(s) from Blender. + @type name: string + @param name: The name of a Scene. + @rtype: Blender Scene or a list of Blender Scenes + @return: It depends on the I{name} parameter: + - (name): The Scene with the given I{name}; + - (): A list with all Scenes currently in Blender. + """ + +def GetCurrent(): + """ + Get the currently active Scene in Blender. + @rtype: Blender Scene + @return: The currently active Scene. + """ + +def Unlink(scene): + """ + Unlink (delete) a Scene from Blender. + @type scene: Blender Scene + @param scene: The Scene to be unlinked. + """ + +class Scene: + """ + The Scene object + ================ + This object gives access to Scene data in Blender. + @cvar name: The Scene name. + """ + + def getName(): + """ + Get the name of this Scene. + @rtype: string + """ + + def setName(name): + """ + Set the name of this Scene. + @type name: string + @param name: The new name. + """ + + def getWinSize(): + """ + Get the current x,y resolution of the render window. These are the + dimensions of the image created by the Blender Renderer. + @rtype: list + @return: [width, height]. + """ + + def setWinSize(dimensions): + """ + Set the width and height of the render window. These are the dimensions + of the image created by the Blender Renderer. + @type dimensions: list + @param dimensions: The new [width, height] values. + """ + + def copy(duplicate_objects = 1): + """ + Make a copy of this Scene. + @type duplicate_objects: int + @param duplicate_objects: Defines how the Scene children are duplicated: + - 0: Link Objects; + - 1: Link Object Data; + - 2: Full copy. + @rtype: Scene + @return: The copied Blender Scene. + """ + + def startFrame(frame = None): + """ + Get (and optionally set) the start frame value. + @type frame: int + @param frame: The start frame. If None, this method simply returns the + current start frame. + @rtype: int + @return: The start frame value. + """ + + def endFrame(frame = None): + """ + Get (and optionally set) the end frame value. + @type frame: int + @param frame: The end frame. If None, this method simply returns the + current end frame. + @rtype: int + @return: The end frame value. + """ + + def currentFrame(frame = None): + """ + Get (and optionally set) the current frame value. + @type frame: int + @param frame: The current frame. If None, this method simply returns the + current frame value. + @rtype: int + @return: The current frame value. + """ + + def frameSettings(start = None, end = None, current = None): + """ + Get (and optionally set) the start, end and current frame values. + @type start: int + @type end: int + @type current: int + @param start: The start frame value. + @param end: The end frame value. + @param current: The current frame value. + @rtype: tuple + @return: The frame values in a tuple: [start, end, current]. + """ + + def makeCurrent(): + """ + Make this Scene the currently active one in Blender. + """ + + def link(object): + """ + Link an Object to this Scene. + @type object: Blender Object + @param object: A Blender Object. + """ + + def unlink(object): + """ + Unlink an Object from this Scene. + @type object: Blender Object + @param object: A Blender Object. + """ + + def getRenderdir(): + """ + Get the current directory where rendered images are saved. + @rtype: string + @return: The path to the current render dir + """ + + def getBackbufdir(): + """ + Get the location of the backbuffer image. + @rtype: string + @return: The path to the chosen backbuffer image. + """ + + def getChildren(): + """ + Get all objects linked to this Scene. + @rtype: list + @return: A list with all Blender Objects linked to this Scene. + """ + + def getCurrentCamera(): + """ + Get the currently active Camera for this Scene. + @rtype: Blender Camera + @return: The currently active Camera. + """ + + def setCurrentCamera(camera): + """ + Set the currently active Camera in this Scene. + @type camera: Blender Camera + @param camera: The new active Camera. + """ diff --git a/source/blender/python/api2_2x/doc/Types.py b/source/blender/python/api2_2x/doc/Types.py new file mode 100644 index 00000000000..34733849c7a --- /dev/null +++ b/source/blender/python/api2_2x/doc/Types.py @@ -0,0 +1,53 @@ +# The Blender.Types submodule + +""" +The Blender.Types submodule +=========================== + +This module is a dictionary of Blender Python types, for type checking. + +Example:: + + import Blender + from Blender import Types, Object, NMesh, Camera, Lamp + # + objs = Object.Get() # a list of all objects in the current scene + for o in objs: + print + print o, type(o) + data = o.getData() + print type(data) + if type(data) == Types.NMeshType: + if len(data.verts): + print "its vertices are obviously of type:", type(data.verts[0]) + print "and its faces:", Types.NMFaceType + elif type(data) == Types.CameraType: + print "It's a Camera." + elif type(data) == Types.LampType: + print "Let there be light!" + +@var ObjectType: Blender Object. The base object, linked to its specific data + at its .data member variable. +@var NMeshType: Blender NMesh. The mesh structure. +@var NMFaceType: Blender NMFace. A mesh face, with one (a point), two (an edge), + three (a triangular face) or four (a quad face) vertices. +@var NMVertType: Blender NMVert. A mesh vertex. +@var NMColType: Blender NMCol. A mesh rgba colour. +@var ArmatureType: Blender Armature. The "skeleton", for animating and deforming +objects. +@var BoneType: Blender Bone. Bones are, obviously, the "pieces" of an Armature. +@var CurveType: Blender Curve. +@var IpoType: Blender Ipo. +@var MetaballType: Blender Metaball. +@var CameraType: Blender Camera. +@var ImageType: Blender Image. +@var LampType: Blender Lamp. +@var TextType: Blender Text. +@var MaterialType: Blender Material. +@var SceneType: A Blender Scene. Container of all other objects. +@var ButtonType: Blender Button. One of the Draw widgets. +@var vectorType: Blender vector. Used in NMesh. +@var bufferType: Blender buffer. A contiguous piece of storage, used in BGL. +@var constantType: Blender constant. A constant dictionary. +@var rgbTupleType: Blender rgbTuple. A (red, green, blue) triplet. +""" diff --git a/source/blender/python/api2_2x/doc/Window.py b/source/blender/python/api2_2x/doc/Window.py index b659221aa65..c4a3bf9d67d 100644 --- a/source/blender/python/api2_2x/doc/Window.py +++ b/source/blender/python/api2_2x/doc/Window.py @@ -108,9 +108,10 @@ def ImageSelector (callback, title = 'SELECT IMAGE'): def DrawProgressBar (done, text): """ Draw a progress bar in the upper right corner of the screen. To cancel it - prematurely, users can press the "Esc" key. + prematurely, users can press the "Esc" key. Start it with done = 0 and end + it with done = 1. @type done: float - @param done: A float in [0, 1] that tells the advance in the progress + @param done: A float in [0.0, 1.0] that tells the advance in the progress bar. @type text: string @param text: Info about what is currently being done "behind the scenes". -- cgit v1.2.3