- More renaming all around to follow our conventions
- Implemented partially Blender.Sys - Worked on issues related to sys, path - Took away most "debug" printfs
This commit is contained in:
parent
569a32a2ea
commit
eaf1cdd383
@ -30,6 +30,8 @@
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
extern char bprogname[]; /* holds a copy of argv[0], from creator.c */
|
||||
|
||||
/* Global to control whether the global dictionary should be preserved or not
|
||||
* each time a script is executed by the Python Interpreter: */
|
||||
extern short EXPP_releaseGlobalDict; /* defaults to TRUE */
|
||||
@ -61,9 +63,5 @@ void BPY_copy_scriptlink(struct ScriptLink *scriptlink);
|
||||
/* format importer hook */
|
||||
int BPY_call_importloader(char *name);
|
||||
|
||||
/* XXX The 3 functions below are implemented in Draw.c */
|
||||
/*
|
||||
int BPY_spacetext_is_pywin(struct SpaceText *st);
|
||||
void BPY_spacetext_do_pywin_draw(struct SpaceText *st);
|
||||
void BPY_spacetext_do_pywin_event(struct SpaceText *st, unsigned short event, short val);
|
||||
*/
|
||||
void init_syspath(void);
|
||||
|
||||
|
@ -40,6 +40,8 @@
|
||||
|
||||
#include <MEM_guardedalloc.h>
|
||||
|
||||
#include <BLI_blenlib.h> /* for BLI_last_slash() */
|
||||
|
||||
#include <BKE_global.h>
|
||||
#include <BKE_main.h>
|
||||
#include <BKE_text.h>
|
||||
@ -54,6 +56,8 @@
|
||||
#include <DNA_text_types.h>
|
||||
#include <DNA_world_types.h>
|
||||
|
||||
#include <DNA_userdef_types.h> /* for U.pythondir */
|
||||
|
||||
#include "BPY_extern.h"
|
||||
#include "api2_2x/EXPP_interface.h"
|
||||
|
||||
@ -89,7 +93,7 @@ void DoAllScriptsFromList (ListBase * list, short event);
|
||||
/*****************************************************************************/
|
||||
void BPY_start_python(void)
|
||||
{
|
||||
printf ("In BPY_start_python\n");
|
||||
//printf ("In BPY_start_python\n");
|
||||
/* TODO: Shouldn't "blender" be replaced by PACKAGE ?? (config.h) */
|
||||
Py_SetProgramName("blender");
|
||||
|
||||
@ -97,6 +101,8 @@ void BPY_start_python(void)
|
||||
|
||||
initBlenderApi2_2x ();
|
||||
|
||||
init_syspath();
|
||||
|
||||
return; /* We could take away all these return; ... */
|
||||
}
|
||||
|
||||
@ -105,18 +111,94 @@ void BPY_start_python(void)
|
||||
/*****************************************************************************/
|
||||
void BPY_end_python(void)
|
||||
{
|
||||
printf ("In BPY_end_python\n");
|
||||
//printf ("In BPY_end_python\n");
|
||||
Py_Finalize();
|
||||
return;
|
||||
}
|
||||
|
||||
void syspath_append(PyObject *dir)
|
||||
{
|
||||
PyObject *mod_sys, *dict, *path;
|
||||
|
||||
PyErr_Clear();
|
||||
|
||||
mod_sys = PyImport_ImportModule("sys"); /* new ref */
|
||||
dict = PyModule_GetDict(mod_sys); /* borrowed ref */
|
||||
path = PyDict_GetItemString(dict, "path"); /* borrowed ref */
|
||||
|
||||
if (!PyList_Check(path)) return;
|
||||
|
||||
PyList_Append(path, dir);
|
||||
|
||||
if (PyErr_Occurred()) Py_FatalError("could not build sys.path");
|
||||
|
||||
Py_DECREF(mod_sys);
|
||||
}
|
||||
|
||||
void init_syspath(void)
|
||||
{
|
||||
PyObject *path;
|
||||
PyObject *mod, *d;
|
||||
PyObject *p;
|
||||
char *c, *progname;
|
||||
char execdir[FILE_MAXDIR + FILE_MAXFILE];/*defines from DNA_space_types.h*/
|
||||
|
||||
int n;
|
||||
|
||||
path = Py_BuildValue("s", bprogname);
|
||||
|
||||
mod = PyImport_ImportModule("Blender.sys");
|
||||
|
||||
if (mod) {
|
||||
d = PyModule_GetDict(mod);
|
||||
PyDict_SetItemString(d, "progname", path);
|
||||
Py_DECREF(mod);
|
||||
}
|
||||
else
|
||||
printf("Warning: could not set Blender.sys.progname\n");
|
||||
|
||||
progname = BLI_last_slash(bprogname); /* looks for the last dir separator */
|
||||
|
||||
c = Py_GetPath(); /* get python system path */
|
||||
PySys_SetPath(c); /* initialize */
|
||||
|
||||
n = progname - bprogname;
|
||||
if (n > 0) {
|
||||
strncpy(execdir, bprogname, n);
|
||||
if (execdir[n-1] == '.') n--; /*fix for when run as ./blender */
|
||||
execdir[n] = '\0';
|
||||
|
||||
p = Py_BuildValue("s", execdir);
|
||||
syspath_append(p); /* append to module search path */
|
||||
|
||||
/* set Blender.sys.progname */
|
||||
}
|
||||
else
|
||||
printf ("Warning: could not determine argv[0] path\n");
|
||||
|
||||
if (U.pythondir) { /* XXX not working, U.pythondir is NULL here ?!?*/
|
||||
/* maybe it wasn't defined yet at this point in start-up ...*/
|
||||
p = Py_BuildValue("s", U.pythondir);
|
||||
syspath_append(p); /* append to module search path */
|
||||
}
|
||||
|
||||
/* set sys.executable to the Blender exe */
|
||||
mod = PyImport_ImportModule("sys"); /* new ref */
|
||||
|
||||
if (mod) {
|
||||
d = PyModule_GetDict(mod); /* borrowed ref */
|
||||
PyDict_SetItemString(d, "executable", Py_BuildValue("s", bprogname));
|
||||
Py_DECREF(mod);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Description: This function will return the linenumber on which an error */
|
||||
/* has occurred in the Python script. */
|
||||
/*****************************************************************************/
|
||||
int BPY_Err_getLinenumber(void)
|
||||
{
|
||||
printf ("In BPY_Err_getLinenumber\n");
|
||||
//printf ("In BPY_Err_getLinenumber\n");
|
||||
return g_script_error.lineno;
|
||||
}
|
||||
|
||||
@ -125,7 +207,7 @@ int BPY_Err_getLinenumber(void)
|
||||
/*****************************************************************************/
|
||||
const char *BPY_Err_getFilename(void)
|
||||
{
|
||||
printf ("In BPY_Err_getFilename\n");
|
||||
//printf ("In BPY_Err_getFilename\n");
|
||||
return g_script_error.filename;
|
||||
}
|
||||
|
||||
@ -222,7 +304,7 @@ struct _object *BPY_txt_do_python(struct SpaceText* st)
|
||||
{
|
||||
PyObject *dict, *ret;
|
||||
|
||||
printf ("\nIn BPY_txt_do_python\n");
|
||||
//printf ("\nIn BPY_txt_do_python\n");
|
||||
|
||||
if (!st->text) return NULL;
|
||||
|
||||
@ -290,7 +372,7 @@ struct _object *BPY_txt_do_python(struct SpaceText* st)
|
||||
/*****************************************************************************/
|
||||
void BPY_free_compiled_text(struct Text* text)
|
||||
{
|
||||
printf ("In BPY_free_compiled_text\n");
|
||||
//printf ("In BPY_free_compiled_text\n");
|
||||
if (!text->compiled) return;
|
||||
Py_DECREF((PyObject*) text->compiled);
|
||||
text->compiled = NULL;
|
||||
@ -308,7 +390,7 @@ void BPY_free_compiled_text(struct Text* text)
|
||||
/*****************************************************************************/
|
||||
void BPY_clear_bad_scriptlinks(struct Text *byebye)
|
||||
{
|
||||
printf ("In BPY_clear_bad_scriptlinks\n");
|
||||
//printf ("In BPY_clear_bad_scriptlinks\n");
|
||||
/*
|
||||
BPY_clear_bad_scriptlist(getObjectList(), byebye);
|
||||
BPY_clear_bad_scriptlist(getLampList(), byebye);
|
||||
@ -330,7 +412,7 @@ void BPY_clear_bad_scriptlinks(struct Text *byebye)
|
||||
/*****************************************************************************/
|
||||
void BPY_do_all_scripts(short event)
|
||||
{
|
||||
printf ("In BPY_do_all_scripts(event=%d)\n",event);
|
||||
/*printf ("In BPY_do_all_scripts(event=%d)\n",event);*/
|
||||
|
||||
DoAllScriptsFromList (&(G.main->object), event);
|
||||
DoAllScriptsFromList (&(G.main->lamp), event);
|
||||
@ -357,7 +439,7 @@ void BPY_do_pyscript(struct ID *id, short event)
|
||||
PyObject * dict;
|
||||
PyObject * ret;
|
||||
|
||||
printf ("In BPY_do_pyscript(id=%s, event=%d)\n",id->name, event);
|
||||
/*printf ("In BPY_do_pyscript(id=%s, event=%d)\n",id->name, event);*/
|
||||
|
||||
scriptlink = setScriptLinks (id, event);
|
||||
|
||||
@ -396,7 +478,7 @@ void BPY_do_pyscript(struct ID *id, short event)
|
||||
/*****************************************************************************/
|
||||
void BPY_free_scriptlink(struct ScriptLink *slink)
|
||||
{
|
||||
printf ("In BPY_free_scriptlink\n");
|
||||
//printf ("In BPY_free_scriptlink\n");
|
||||
|
||||
if (slink->totscript) {
|
||||
if(slink->flag) MEM_freeN(slink->flag);
|
||||
@ -414,7 +496,7 @@ void BPY_copy_scriptlink(struct ScriptLink *scriptlink)
|
||||
{
|
||||
void *tmp;
|
||||
|
||||
printf ("In BPY_copy_scriptlink\n");
|
||||
//printf ("In BPY_copy_scriptlink\n");
|
||||
|
||||
if (scriptlink->totscript) {
|
||||
|
||||
|
@ -42,12 +42,10 @@ static PyObject *M_Armature_New(PyObject *self, PyObject *args,
|
||||
char *type_str = "Armature";
|
||||
char *name_str = "ArmatureData";
|
||||
static char *kwlist[] = {"type_str", "name_str", NULL};
|
||||
C_Armature *py_armature; /* for Armature Data object wrapper in Python */
|
||||
BPy_Armature *py_armature; /* for Armature Data object wrapper in Python */
|
||||
bArmature *bl_armature; /* for actual Armature Data we create in Blender */
|
||||
char buf[21];
|
||||
|
||||
printf ("In Armature_New()\n");
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, keywords, "|ss", kwlist,
|
||||
&type_str, &name_str))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
@ -55,7 +53,7 @@ static PyObject *M_Armature_New(PyObject *self, PyObject *args,
|
||||
|
||||
bl_armature = add_armature(); /* first create in Blender */
|
||||
if (bl_armature) /* now create the wrapper obj in Python */
|
||||
py_armature = (C_Armature *)PyObject_NEW(C_Armature, &Armature_Type);
|
||||
py_armature = (BPy_Armature *)PyObject_NEW(BPy_Armature, &Armature_Type);
|
||||
else
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't create Armature Data in Blender"));
|
||||
@ -85,9 +83,8 @@ static PyObject *M_Armature_Get(PyObject *self, PyObject *args)
|
||||
{
|
||||
char *name = NULL;
|
||||
bArmature *armature_iter;
|
||||
C_Armature *wanted_armature;
|
||||
BPy_Armature *wanted_armature;
|
||||
|
||||
printf ("In Armature_Get()\n");
|
||||
if (!PyArg_ParseTuple(args, "|s", &name))
|
||||
return (EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
"expected string argument (or nothing)"));
|
||||
@ -102,7 +99,7 @@ static PyObject *M_Armature_Get(PyObject *self, PyObject *args)
|
||||
while ((armature_iter) && (wanted_armature == NULL)) {
|
||||
|
||||
if (strcmp (name, armature_iter->id.name+2) == 0) {
|
||||
wanted_armature = (C_Armature *)PyObject_NEW(C_Armature, &Armature_Type);
|
||||
wanted_armature = (BPy_Armature *)PyObject_NEW(BPy_Armature, &Armature_Type);
|
||||
if (wanted_armature) wanted_armature->armature = armature_iter;
|
||||
}
|
||||
|
||||
@ -132,7 +129,7 @@ static PyObject *M_Armature_Get(PyObject *self, PyObject *args)
|
||||
"couldn't create PyList"));
|
||||
|
||||
while (armature_iter) {
|
||||
pyobj = M_ArmatureCreatePyObject (armature_iter);
|
||||
pyobj = Armature_CreatePyObject (armature_iter);
|
||||
|
||||
if (!pyobj)
|
||||
return (PythonReturnErrorObject (PyExc_MemoryError,
|
||||
@ -150,15 +147,13 @@ static PyObject *M_Armature_Get(PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_Armature_Init */
|
||||
/* Function: Armature_Init */
|
||||
/*****************************************************************************/
|
||||
PyObject *M_Armature_Init (void)
|
||||
PyObject *Armature_Init (void)
|
||||
{
|
||||
PyObject *submodule;
|
||||
PyObject *dict;
|
||||
|
||||
printf ("In M_Armature_Init()\n");
|
||||
|
||||
Armature_Type.ob_type = &PyType_Type;
|
||||
|
||||
submodule = Py_InitModule3("Blender.Armature",
|
||||
@ -166,15 +161,15 @@ PyObject *M_Armature_Init (void)
|
||||
|
||||
/* Add the Bone submodule to this module */
|
||||
dict = PyModule_GetDict (submodule);
|
||||
PyDict_SetItemString (dict, "Bone", M_Bone_Init());
|
||||
PyDict_SetItemString (dict, "Bone", Bone_Init());
|
||||
|
||||
return (submodule);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_Armature methods: */
|
||||
/* Python BPy_Armature methods: */
|
||||
/*****************************************************************************/
|
||||
static PyObject *Armature_getName(C_Armature *self)
|
||||
static PyObject *Armature_getName(BPy_Armature *self)
|
||||
{
|
||||
PyObject *attr = PyString_FromString(self->armature->id.name+2);
|
||||
|
||||
@ -186,7 +181,7 @@ static PyObject *Armature_getName(C_Armature *self)
|
||||
|
||||
|
||||
/** Create and return a list of the root bones for this armature. */
|
||||
static PyObject *Armature_getBones(C_Armature *self)
|
||||
static PyObject *Armature_getBones(BPy_Armature *self)
|
||||
{
|
||||
int totbones = 0;
|
||||
PyObject *listbones = NULL;
|
||||
@ -202,7 +197,7 @@ static PyObject *Armature_getBones(C_Armature *self)
|
||||
listbones = PyList_New(totbones);
|
||||
for (i=0; i<totbones; i++) {
|
||||
/* Wrap and set to corresponding element of the list. */
|
||||
PyList_SetItem(listbones, i, M_BoneCreatePyObject(current) );
|
||||
PyList_SetItem(listbones, i, Bone_CreatePyObject(current) );
|
||||
current = current->next;
|
||||
}
|
||||
|
||||
@ -210,7 +205,7 @@ static PyObject *Armature_getBones(C_Armature *self)
|
||||
}
|
||||
|
||||
|
||||
static PyObject *Armature_setName(C_Armature *self, PyObject *args)
|
||||
static PyObject *Armature_setName(BPy_Armature *self, PyObject *args)
|
||||
{
|
||||
char *name;
|
||||
char buf[21];
|
||||
@ -228,7 +223,7 @@ static PyObject *Armature_setName(C_Armature *self, PyObject *args)
|
||||
}
|
||||
|
||||
/*
|
||||
static PyObject *Armature_setBones(C_Armature *self, PyObject *args)
|
||||
static PyObject *Armature_setBones(BPy_Armature *self, PyObject *args)
|
||||
{
|
||||
// TODO: Implement me!
|
||||
printf("ERROR: Armature_setBones NOT implemented yet!\n");
|
||||
@ -239,22 +234,22 @@ static PyObject *Armature_setName(C_Armature *self, PyObject *args)
|
||||
*/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: ArmatureDeAlloc */
|
||||
/* Description: This is a callback function for the C_Armature type. It is */
|
||||
/* Function: Armature_dealloc */
|
||||
/* Description: This is a callback function for the BPy_Armature type. It is */
|
||||
/* the destructor function. */
|
||||
/*****************************************************************************/
|
||||
static void ArmatureDeAlloc (C_Armature *self)
|
||||
static void Armature_dealloc (BPy_Armature *self)
|
||||
{
|
||||
PyObject_DEL (self);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: ArmatureGetAttr */
|
||||
/* Description: This is a callback function for the C_Armature type. It is */
|
||||
/* the function that accesses C_Armature member variables and */
|
||||
/* Function: Armature_getAttr */
|
||||
/* Description: This is a callback function for the BPy_Armature type. It is */
|
||||
/* the function that accesses BPy_Armature member variables and */
|
||||
/* methods. */
|
||||
/*****************************************************************************/
|
||||
static PyObject* ArmatureGetAttr (C_Armature *self, char *name)
|
||||
static PyObject* Armature_getAttr (BPy_Armature *self, char *name)
|
||||
{
|
||||
PyObject *attr = Py_None;
|
||||
|
||||
@ -275,17 +270,17 @@ static PyObject* ArmatureGetAttr (C_Armature *self, char *name)
|
||||
if (attr != Py_None) return attr; /* member attribute found, return it */
|
||||
|
||||
/* not an attribute, search the methods table */
|
||||
return Py_FindMethod(C_Armature_methods, (PyObject *)self, name);
|
||||
return Py_FindMethod(BPy_Armature_methods, (PyObject *)self, name);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: ArmatureSetAttr */
|
||||
/* Description: This is a callback function for the C_Armature type. It is */
|
||||
/* Function: Armature_setAttr */
|
||||
/* Description: This is a callback function for the BPy_Armature type. It is */
|
||||
/* the function that changes Armature Data members values. If */
|
||||
/* this data is linked to a Blender Armature, it also gets */
|
||||
/* updated. */
|
||||
/*****************************************************************************/
|
||||
static int ArmatureSetAttr (C_Armature *self, char *name, PyObject *value)
|
||||
static int Armature_setAttr (BPy_Armature *self, char *name, PyObject *value)
|
||||
{
|
||||
PyObject *valtuple;
|
||||
PyObject *error = NULL;
|
||||
@ -317,50 +312,48 @@ static int ArmatureSetAttr (C_Armature *self, char *name, PyObject *value)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: ArmaturePrint */
|
||||
/* Description: This is a callback function for the C_Armature type. It */
|
||||
/* Function: Armature_print */
|
||||
/* Description: This is a callback function for the BPy_Armature type. It */
|
||||
/* builds a meaninful string to 'print' armature objects. */
|
||||
/*****************************************************************************/
|
||||
static int ArmaturePrint(C_Armature *self, FILE *fp, int flags)
|
||||
static int Armature_print(BPy_Armature *self, FILE *fp, int flags)
|
||||
{
|
||||
fprintf(fp, "[Armature \"%s\"]", self->armature->id.name+2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: ArmatureRepr */
|
||||
/* Description: This is a callback function for the C_Armature type. It */
|
||||
/* Function: Armature_repr */
|
||||
/* Description: This is a callback function for the BPy_Armature type. It */
|
||||
/* builds a meaninful string to represent armature objects. */
|
||||
/*****************************************************************************/
|
||||
static PyObject *ArmatureRepr (C_Armature *self)
|
||||
static PyObject *Armature_repr (BPy_Armature *self)
|
||||
{
|
||||
return PyString_FromString(self->armature->id.name+2);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: ArmatureCmp */
|
||||
/* Description: This is a callback function for the C_Armature type. It */
|
||||
/* Function: Armature_compare */
|
||||
/* Description: This is a callback function for the BPy_Armature type. It */
|
||||
/* compares the two armatures: translate comparison to the */
|
||||
/* C pointers. */
|
||||
/*****************************************************************************/
|
||||
static int ArmatureCmp (C_Armature *a, C_Armature *b)
|
||||
static int Armature_compare (BPy_Armature *a, BPy_Armature *b)
|
||||
{
|
||||
bArmature *pa = a->armature, *pb = b->armature;
|
||||
return (pa == pb) ? 0:-1;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_ArmatureCreatePyObject */
|
||||
/* Function: Armature_CreatePyObject */
|
||||
/* Description: This function will create a new BlenArmature from an */
|
||||
/* existing Armature structure. */
|
||||
/*****************************************************************************/
|
||||
PyObject* M_ArmatureCreatePyObject (struct bArmature *obj)
|
||||
PyObject* Armature_CreatePyObject (struct bArmature *obj)
|
||||
{
|
||||
C_Armature * blen_armature;
|
||||
BPy_Armature * blen_armature;
|
||||
|
||||
printf ("In M_ArmatureCreatePyObject\n");
|
||||
|
||||
blen_armature = (C_Armature*)PyObject_NEW (C_Armature, &Armature_Type);
|
||||
blen_armature = (BPy_Armature*)PyObject_NEW (BPy_Armature, &Armature_Type);
|
||||
|
||||
if (blen_armature == NULL)
|
||||
{
|
||||
@ -371,24 +364,24 @@ PyObject* M_ArmatureCreatePyObject (struct bArmature *obj)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_ArmatureCheckPyObject */
|
||||
/* Function: Armature_CheckPyObject */
|
||||
/* Description: This function returns true when the given PyObject is of the */
|
||||
/* type Armature. Otherwise it will return false. */
|
||||
/*****************************************************************************/
|
||||
int M_ArmatureCheckPyObject (PyObject *py_obj)
|
||||
int Armature_CheckPyObject (PyObject *py_obj)
|
||||
{
|
||||
return (py_obj->ob_type == &Armature_Type);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_ArmatureFromPyObject */
|
||||
/* Function: Armature_FromPyObject */
|
||||
/* Description: This function returns the Blender armature from the given */
|
||||
/* PyObject. */
|
||||
/*****************************************************************************/
|
||||
struct bArmature* M_ArmatureFromPyObject (PyObject *py_obj)
|
||||
struct bArmature* Armature_FromPyObject (PyObject *py_obj)
|
||||
{
|
||||
C_Armature * blen_obj;
|
||||
BPy_Armature * blen_obj;
|
||||
|
||||
blen_obj = (C_Armature*)py_obj;
|
||||
blen_obj = (BPy_Armature*)py_obj;
|
||||
return (blen_obj->armature);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@
|
||||
static PyObject *M_Armature_New (PyObject *self, PyObject *args,
|
||||
PyObject *keywords);
|
||||
static PyObject *M_Armature_Get (PyObject *self, PyObject *args);
|
||||
PyObject *M_Armature_Init (void);
|
||||
PyObject *Armature_Init (void);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* The following string definitions are used for documentation strings. */
|
||||
@ -92,25 +92,25 @@ struct PyMethodDef M_Armature_methods[] = {
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_Armature structure definition: */
|
||||
/* Python BPy_Armature structure definition: */
|
||||
/*****************************************************************************/
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
bArmature *armature;
|
||||
} C_Armature;
|
||||
} BPy_Armature;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_Armature methods declarations: */
|
||||
/* Python BPy_Armature methods declarations: */
|
||||
/*****************************************************************************/
|
||||
static PyObject *Armature_getName(C_Armature *self);
|
||||
static PyObject *Armature_getBones(C_Armature *self);
|
||||
static PyObject *Armature_setName(C_Armature *self, PyObject *args);
|
||||
//static PyObject *Armature_setBones(C_Armature *self, PyObject *args);
|
||||
static PyObject *Armature_getName(BPy_Armature *self);
|
||||
static PyObject *Armature_getBones(BPy_Armature *self);
|
||||
static PyObject *Armature_setName(BPy_Armature *self, PyObject *args);
|
||||
//static PyObject *Armature_setBones(BPy_Armature *self, PyObject *args);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_Armature methods table: */
|
||||
/* Python BPy_Armature methods table: */
|
||||
/*****************************************************************************/
|
||||
static PyMethodDef C_Armature_methods[] = {
|
||||
static PyMethodDef BPy_Armature_methods[] = {
|
||||
/* name, method, flags, doc */
|
||||
{"getName", (PyCFunction)Armature_getName, METH_NOARGS,
|
||||
"() - return Armature name"},
|
||||
@ -127,12 +127,12 @@ static PyMethodDef C_Armature_methods[] = {
|
||||
/*****************************************************************************/
|
||||
/* Python TypeArmature callback function prototypes: */
|
||||
/*****************************************************************************/
|
||||
static void ArmatureDeAlloc (C_Armature *armature);
|
||||
static PyObject *ArmatureGetAttr (C_Armature *armature, char *name);
|
||||
static int ArmatureSetAttr (C_Armature *armature, char *name, PyObject *v);
|
||||
static int ArmatureCmp (C_Armature *a1, C_Armature *a2);
|
||||
static PyObject *ArmatureRepr (C_Armature *armature);
|
||||
static int ArmaturePrint (C_Armature *armature, FILE *fp, int flags);
|
||||
static void Armature_dealloc (BPy_Armature *armature);
|
||||
static PyObject *Armature_getAttr (BPy_Armature *armature, char *name);
|
||||
static int Armature_setAttr (BPy_Armature *armature, char *name, PyObject *v);
|
||||
static int Armature_compare (BPy_Armature *a1, BPy_Armature *a2);
|
||||
static PyObject *Armature_repr (BPy_Armature *armature);
|
||||
static int Armature_print (BPy_Armature *armature, FILE *fp, int flags);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python TypeArmature structure definition: */
|
||||
@ -141,16 +141,16 @@ PyTypeObject Armature_Type =
|
||||
{
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
"Armature", /* tp_name */
|
||||
sizeof (C_Armature), /* tp_basicsize */
|
||||
"Blender Armature", /* tp_name */
|
||||
sizeof (BPy_Armature), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
/* methods */
|
||||
(destructor)ArmatureDeAlloc, /* tp_dealloc */
|
||||
(printfunc)ArmaturePrint, /* tp_print */
|
||||
(getattrfunc)ArmatureGetAttr, /* tp_getattr */
|
||||
(setattrfunc)ArmatureSetAttr, /* tp_setattr */
|
||||
(cmpfunc)ArmatureCmp, /* tp_compare */
|
||||
(reprfunc)ArmatureRepr, /* tp_repr */
|
||||
(destructor)Armature_dealloc, /* tp_dealloc */
|
||||
(printfunc)Armature_print, /* tp_print */
|
||||
(getattrfunc)Armature_getAttr, /* tp_getattr */
|
||||
(setattrfunc)Armature_setAttr, /* tp_setattr */
|
||||
(cmpfunc)Armature_compare, /* tp_compare */
|
||||
(reprfunc)Armature_repr, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
@ -158,7 +158,7 @@ PyTypeObject Armature_Type =
|
||||
0,0,0,0,0,0,
|
||||
0, /* tp_doc */
|
||||
0,0,0,0,0,0,
|
||||
C_Armature_methods, /* tp_methods */
|
||||
BPy_Armature_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
};
|
||||
|
||||
|
@ -42,34 +42,34 @@ PyObject *g_blenderdict;
|
||||
/*****************************************************************************/
|
||||
PyObject *Blender_Set (PyObject *self, PyObject *args)
|
||||
{
|
||||
char * name;
|
||||
PyObject * arg;
|
||||
int framenum;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "sO", &name, &arg))
|
||||
{
|
||||
/* TODO: Do we need to generate a nice error message here? */
|
||||
return (NULL);
|
||||
}
|
||||
char * name;
|
||||
PyObject * arg;
|
||||
int framenum;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "sO", &name, &arg))
|
||||
{
|
||||
/* TODO: Do we need to generate a nice error message here? */
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (StringEqual (name, "curframe"))
|
||||
{
|
||||
if (!PyArg_Parse(arg, "i", &framenum))
|
||||
{
|
||||
/* TODO: Do we need to generate a nice error message here? */
|
||||
return (NULL);
|
||||
}
|
||||
if (StringEqual (name, "curframe"))
|
||||
{
|
||||
if (!PyArg_Parse(arg, "i", &framenum))
|
||||
{
|
||||
/* TODO: Do we need to generate a nice error message here? */
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
G.scene->r.cfra = framenum;
|
||||
G.scene->r.cfra = framenum;
|
||||
|
||||
update_for_newframe();
|
||||
}
|
||||
else
|
||||
{
|
||||
return (PythonReturnErrorObject (PyExc_AttributeError,
|
||||
"bad request identifier"));
|
||||
}
|
||||
return ( PythonIncRef (Py_None) );
|
||||
update_for_newframe();
|
||||
}
|
||||
else
|
||||
{
|
||||
return (PythonReturnErrorObject (PyExc_AttributeError,
|
||||
"bad request identifier"));
|
||||
}
|
||||
return ( PythonIncRef (Py_None) );
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -78,78 +78,76 @@ PyObject *Blender_Set (PyObject *self, PyObject *args)
|
||||
/*****************************************************************************/
|
||||
PyObject *Blender_Get (PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject * object;
|
||||
PyObject * dict;
|
||||
char * str;
|
||||
PyObject * object;
|
||||
PyObject * dict;
|
||||
char * str;
|
||||
|
||||
printf ("In Blender_Get()\n");
|
||||
if (!PyArg_ParseTuple (args, "O", &object))
|
||||
{
|
||||
/* TODO: Do we need to generate a nice error message here? */
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
if (!PyArg_ParseTuple (args, "O", &object))
|
||||
{
|
||||
/* TODO: Do we need to generate a nice error message here? */
|
||||
return (NULL);
|
||||
}
|
||||
if (PyString_Check (object))
|
||||
{
|
||||
str = PyString_AsString (object);
|
||||
|
||||
if (PyString_Check (object))
|
||||
{
|
||||
str = PyString_AsString (object);
|
||||
if (StringEqual (str, "curframe"))
|
||||
{
|
||||
return ( PyInt_FromLong (G.scene->r.cfra) );
|
||||
}
|
||||
if (StringEqual (str, "curtime"))
|
||||
{
|
||||
return ( PyFloat_FromDouble (frame_to_float (G.scene->r.cfra) ) );
|
||||
}
|
||||
if (StringEqual (str, "staframe"))
|
||||
{
|
||||
return ( PyInt_FromLong (G.scene->r.sfra) );
|
||||
}
|
||||
if (StringEqual (str, "endframe"))
|
||||
{
|
||||
return ( PyInt_FromLong (G.scene->r.efra) );
|
||||
}
|
||||
if (StringEqual (str, "filename"))
|
||||
{
|
||||
return ( PyString_FromString (G.sce) );
|
||||
}
|
||||
/* According to the old file (opy_blender.c), the following if
|
||||
statement is a quick hack and needs some clean up. */
|
||||
if (StringEqual (str, "vrmloptions"))
|
||||
{
|
||||
dict = PyDict_New ();
|
||||
|
||||
if (StringEqual (str, "curframe"))
|
||||
{
|
||||
return ( PyInt_FromLong (G.scene->r.cfra) );
|
||||
}
|
||||
if (StringEqual (str, "curtime"))
|
||||
{
|
||||
return ( PyFloat_FromDouble (frame_to_float (G.scene->r.cfra) ) );
|
||||
}
|
||||
if (StringEqual (str, "staframe"))
|
||||
{
|
||||
return ( PyInt_FromLong (G.scene->r.sfra) );
|
||||
}
|
||||
if (StringEqual (str, "endframe"))
|
||||
{
|
||||
return ( PyInt_FromLong (G.scene->r.efra) );
|
||||
}
|
||||
if (StringEqual (str, "filename"))
|
||||
{
|
||||
return ( PyString_FromString (G.sce) );
|
||||
}
|
||||
/* According to the old file (opy_blender.c), the following if
|
||||
statement is a quick hack and needs some clean up. */
|
||||
if (StringEqual (str, "vrmloptions"))
|
||||
{
|
||||
dict = PyDict_New ();
|
||||
PyDict_SetItemString (dict, "twoside",
|
||||
PyInt_FromLong (U.vrmlflag & USERDEF_VRML_TWOSIDED));
|
||||
|
||||
PyDict_SetItemString (dict, "twoside",
|
||||
PyInt_FromLong (U.vrmlflag & USERDEF_VRML_TWOSIDED));
|
||||
PyDict_SetItemString (dict, "layers",
|
||||
PyInt_FromLong (U.vrmlflag & USERDEF_VRML_LAYERS));
|
||||
|
||||
PyDict_SetItemString (dict, "layers",
|
||||
PyInt_FromLong (U.vrmlflag & USERDEF_VRML_LAYERS));
|
||||
PyDict_SetItemString (dict, "autoscale",
|
||||
PyInt_FromLong (U.vrmlflag & USERDEF_VRML_AUTOSCALE));
|
||||
|
||||
PyDict_SetItemString (dict, "autoscale",
|
||||
PyInt_FromLong (U.vrmlflag & USERDEF_VRML_AUTOSCALE));
|
||||
return (dict);
|
||||
} /* End 'quick hack' part. */
|
||||
if (StringEqual (str, "version"))
|
||||
{
|
||||
return ( PyInt_FromLong (G.version) );
|
||||
}
|
||||
/* TODO: Do we want to display a usefull message here that the
|
||||
requested data is unknown?
|
||||
else
|
||||
{
|
||||
return (PythonReturnErrorObject (..., "message") );
|
||||
}
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
return (PythonReturnErrorObject (PyExc_AttributeError,
|
||||
"expected string argument"));
|
||||
}
|
||||
|
||||
return (dict);
|
||||
} /* End 'quick hack' part. */
|
||||
if (StringEqual (str, "version"))
|
||||
{
|
||||
return ( PyInt_FromLong (G.version) );
|
||||
}
|
||||
/* TODO: Do we want to display a usefull message here that the
|
||||
requested data is unknown?
|
||||
else
|
||||
{
|
||||
return (PythonReturnErrorObject (..., "message") );
|
||||
}
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
return (PythonReturnErrorObject (PyExc_AttributeError,
|
||||
"expected string argument"));
|
||||
}
|
||||
|
||||
return (PythonReturnErrorObject (PyExc_AttributeError,
|
||||
return (PythonReturnErrorObject (PyExc_AttributeError,
|
||||
"bad request identifier"));
|
||||
}
|
||||
|
||||
@ -160,17 +158,15 @@ PyObject *Blender_Get (PyObject *self, PyObject *args)
|
||||
PyObject *Blender_Redraw(PyObject *self, PyObject *args)
|
||||
{
|
||||
|
||||
int wintype = SPACE_VIEW3D;
|
||||
int wintype = SPACE_VIEW3D;
|
||||
|
||||
printf ("In Blender_Redraw()\n");
|
||||
|
||||
if (!PyArg_ParseTuple (args, "|i", &wintype))
|
||||
{
|
||||
return EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
if (!PyArg_ParseTuple (args, "|i", &wintype))
|
||||
{
|
||||
return EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
"expected int argument (or nothing)");
|
||||
}
|
||||
}
|
||||
|
||||
return M_Window_Redraw(self, Py_BuildValue("(i)", wintype));
|
||||
return M_Window_Redraw(self, Py_BuildValue("(i)", wintype));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -187,15 +183,13 @@ PyObject *Blender_Redraw(PyObject *self, PyObject *args)
|
||||
/*****************************************************************************/
|
||||
PyObject *Blender_ReleaseGlobalDict(PyObject *self, PyObject *args)
|
||||
{
|
||||
printf ("In Blender_ReleaseGlobalDict()\n");
|
||||
|
||||
if (!PyArg_ParseTuple (args, "|i", &EXPP_releaseGlobalDict))
|
||||
{
|
||||
return EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
if (!PyArg_ParseTuple (args, "|i", &EXPP_releaseGlobalDict))
|
||||
{
|
||||
return EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
"expected int argument (or nothing)");
|
||||
}
|
||||
}
|
||||
|
||||
return Py_BuildValue("i", (EXPP_releaseGlobalDict?1:0));
|
||||
return Py_BuildValue("i", (EXPP_releaseGlobalDict?1:0));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -203,33 +197,33 @@ PyObject *Blender_ReleaseGlobalDict(PyObject *self, PyObject *args)
|
||||
/*****************************************************************************/
|
||||
void M_Blender_Init (void)
|
||||
{
|
||||
PyObject * module;
|
||||
PyObject * dict;
|
||||
PyObject * module;
|
||||
PyObject * dict;
|
||||
|
||||
printf ("In M_Blender_Init()\n");
|
||||
g_blenderdict = NULL;
|
||||
g_blenderdict = NULL;
|
||||
|
||||
/* TODO: create a docstring for the Blender module */
|
||||
module = Py_InitModule3("Blender", Blender_methods, NULL);
|
||||
/* TODO: create a docstring for the Blender module */
|
||||
module = Py_InitModule3("Blender", Blender_methods, NULL);
|
||||
|
||||
dict = PyModule_GetDict (module);
|
||||
g_blenderdict = dict;
|
||||
PyDict_SetItemString (dict, "Scene", Scene_Init());
|
||||
PyDict_SetItemString (dict, "Object", M_Object_Init());
|
||||
PyDict_SetItemString (dict, "Types", Types_Init());
|
||||
PyDict_SetItemString (dict, "NMesh", NMesh_Init());
|
||||
PyDict_SetItemString (dict, "Material", Material_Init());
|
||||
PyDict_SetItemString (dict, "Camera", Camera_Init());
|
||||
PyDict_SetItemString (dict, "Lamp", Lamp_Init());
|
||||
PyDict_SetItemString (dict, "Curve", M_Curve_Init());
|
||||
PyDict_SetItemString (dict, "Armature", M_Armature_Init());
|
||||
PyDict_SetItemString (dict, "Ipo", M_Ipo_Init());
|
||||
PyDict_SetItemString (dict, "Metaball", M_Metaball_Init());
|
||||
PyDict_SetItemString (dict, "Image", Image_Init());
|
||||
PyDict_SetItemString (dict, "Window", Window_Init());
|
||||
PyDict_SetItemString (dict, "Draw", Draw_Init());
|
||||
PyDict_SetItemString (dict, "BGL", BGL_Init());
|
||||
PyDict_SetItemString (dict, "Effect", M_Effect_Init());
|
||||
PyDict_SetItemString (dict, "Text", Text_Init());
|
||||
PyDict_SetItemString (dict, "World", M_World_Init());
|
||||
dict = PyModule_GetDict (module);
|
||||
g_blenderdict = dict;
|
||||
PyDict_SetItemString (dict, "sys", sys_Init());
|
||||
PyDict_SetItemString (dict, "Scene", Scene_Init());
|
||||
PyDict_SetItemString (dict, "Object", Object_Init());
|
||||
PyDict_SetItemString (dict, "Types", Types_Init());
|
||||
PyDict_SetItemString (dict, "NMesh", NMesh_Init());
|
||||
PyDict_SetItemString (dict, "Material", Material_Init());
|
||||
PyDict_SetItemString (dict, "Camera", Camera_Init());
|
||||
PyDict_SetItemString (dict, "Lamp", Lamp_Init());
|
||||
PyDict_SetItemString (dict, "Curve", Curve_Init());
|
||||
PyDict_SetItemString (dict, "Armature", Armature_Init());
|
||||
PyDict_SetItemString (dict, "Ipo", Ipo_Init());
|
||||
PyDict_SetItemString (dict, "Metaball", Metaball_Init());
|
||||
PyDict_SetItemString (dict, "Image", Image_Init());
|
||||
PyDict_SetItemString (dict, "Window", Window_Init());
|
||||
PyDict_SetItemString (dict, "Draw", Draw_Init());
|
||||
PyDict_SetItemString (dict, "BGL", BGL_Init());
|
||||
PyDict_SetItemString (dict, "Effect", Effect_Init());
|
||||
PyDict_SetItemString (dict, "Text", Text_Init());
|
||||
PyDict_SetItemString (dict, "World", World_Init());
|
||||
}
|
||||
|
@ -73,32 +73,32 @@ struct PyMethodDef M_Bone_methods[] = {
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_Bone methods declarations: */
|
||||
/* Python BPy_Bone methods declarations: */
|
||||
/*****************************************************************************/
|
||||
static PyObject *Bone_getName(C_Bone *self);
|
||||
static PyObject *Bone_getRoll(C_Bone *self);
|
||||
static PyObject *Bone_getHead(C_Bone *self);
|
||||
static PyObject *Bone_getTail(C_Bone *self);
|
||||
static PyObject *Bone_getLoc(C_Bone *self);
|
||||
static PyObject *Bone_getSize(C_Bone *self);
|
||||
static PyObject *Bone_getQuat(C_Bone *self);
|
||||
static PyObject *Bone_getParent(C_Bone *self);
|
||||
static PyObject *Bone_hasParent(C_Bone *self);
|
||||
static PyObject *Bone_getChildren(C_Bone *self);
|
||||
static PyObject *Bone_setName(C_Bone *self, PyObject *args);
|
||||
static PyObject *Bone_setRoll(C_Bone *self, PyObject *args);
|
||||
static PyObject *Bone_setHead(C_Bone *self, PyObject *args);
|
||||
static PyObject *Bone_setTail(C_Bone *self, PyObject *args);
|
||||
static PyObject *Bone_setLoc(C_Bone *self, PyObject *args);
|
||||
static PyObject *Bone_setSize(C_Bone *self, PyObject *args);
|
||||
static PyObject *Bone_setQuat(C_Bone *self, PyObject *args);
|
||||
//static PyObject *Bone_setParent(C_Bone *self, PyObject *args);
|
||||
//static PyObject *Bone_setChildren(C_Bone *self, PyObject *args);
|
||||
static PyObject *Bone_getName(BPy_Bone *self);
|
||||
static PyObject *Bone_getRoll(BPy_Bone *self);
|
||||
static PyObject *Bone_getHead(BPy_Bone *self);
|
||||
static PyObject *Bone_getTail(BPy_Bone *self);
|
||||
static PyObject *Bone_getLoc(BPy_Bone *self);
|
||||
static PyObject *Bone_getSize(BPy_Bone *self);
|
||||
static PyObject *Bone_getQuat(BPy_Bone *self);
|
||||
static PyObject *Bone_getParent(BPy_Bone *self);
|
||||
static PyObject *Bone_hasParent(BPy_Bone *self);
|
||||
static PyObject *Bone_getChildren(BPy_Bone *self);
|
||||
static PyObject *Bone_setName(BPy_Bone *self, PyObject *args);
|
||||
static PyObject *Bone_setRoll(BPy_Bone *self, PyObject *args);
|
||||
static PyObject *Bone_setHead(BPy_Bone *self, PyObject *args);
|
||||
static PyObject *Bone_setTail(BPy_Bone *self, PyObject *args);
|
||||
static PyObject *Bone_setLoc(BPy_Bone *self, PyObject *args);
|
||||
static PyObject *Bone_setSize(BPy_Bone *self, PyObject *args);
|
||||
static PyObject *Bone_setQuat(BPy_Bone *self, PyObject *args);
|
||||
//static PyObject *Bone_setParent(BPy_Bone *self, PyObject *args);
|
||||
//static PyObject *Bone_setChildren(BPy_Bone *self, PyObject *args);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_Bone methods table: */
|
||||
/* Python BPy_Bone methods table: */
|
||||
/*****************************************************************************/
|
||||
static PyMethodDef C_Bone_methods[] = {
|
||||
static PyMethodDef BPy_Bone_methods[] = {
|
||||
/* name, method, flags, doc */
|
||||
{"getName", (PyCFunction)Bone_getName, METH_NOARGS, "() - return Bone name"},
|
||||
{"getRoll", (PyCFunction)Bone_getRoll, METH_NOARGS, "() - return Bone roll"},
|
||||
@ -136,12 +136,12 @@ static PyMethodDef C_Bone_methods[] = {
|
||||
/*****************************************************************************/
|
||||
/* Python TypeBone callback function prototypes: */
|
||||
/*****************************************************************************/
|
||||
static void BoneDeAlloc (C_Bone *bone);
|
||||
static PyObject *BoneGetAttr (C_Bone *bone, char *name);
|
||||
static int BoneSetAttr (C_Bone *bone, char *name, PyObject *v);
|
||||
static int BoneCmp (C_Bone *a1, C_Bone *a2);
|
||||
static PyObject *BoneRepr (C_Bone *bone);
|
||||
static int BonePrint (C_Bone *bone, FILE *fp, int flags);
|
||||
static void Bone_dealloc (BPy_Bone *bone);
|
||||
static PyObject *Bone_getAttr (BPy_Bone *bone, char *name);
|
||||
static int Bone_setAttr (BPy_Bone *bone, char *name, PyObject *v);
|
||||
static int Bone_compare (BPy_Bone *a1, BPy_Bone *a2);
|
||||
static PyObject *Bone_repr (BPy_Bone *bone);
|
||||
static int Bone_print (BPy_Bone *bone, FILE *fp, int flags);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python TypeBone structure definition: */
|
||||
@ -149,26 +149,26 @@ static int BonePrint (C_Bone *bone, FILE *fp, int flags);
|
||||
PyTypeObject Bone_Type =
|
||||
{
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
"Bone", /* tp_name */
|
||||
sizeof (C_Bone), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
0, /* ob_size */
|
||||
"Blender Bone", /* tp_name */
|
||||
sizeof (BPy_Bone), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
/* methods */
|
||||
(destructor)BoneDeAlloc, /* tp_dealloc */
|
||||
(printfunc)BonePrint, /* tp_print */
|
||||
(getattrfunc)BoneGetAttr, /* tp_getattr */
|
||||
(setattrfunc)BoneSetAttr, /* tp_setattr */
|
||||
(cmpfunc)BoneCmp, /* tp_compare */
|
||||
(reprfunc)BoneRepr, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
0, /* tp_as_hash */
|
||||
(destructor)Bone_dealloc, /* tp_dealloc */
|
||||
(printfunc)Bone_print, /* tp_print */
|
||||
(getattrfunc)Bone_getAttr, /* tp_getattr */
|
||||
(setattrfunc)Bone_setAttr, /* tp_setattr */
|
||||
(cmpfunc)Bone_compare, /* tp_compare */
|
||||
(reprfunc)Bone_repr, /* 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, /* tp_doc */
|
||||
0,0,0,0,0,0,
|
||||
C_Bone_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
BPy_Bone_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
};
|
||||
|
||||
|
||||
@ -181,11 +181,9 @@ PyTypeObject Bone_Type =
|
||||
static PyObject *M_Bone_New(PyObject *self, PyObject *args, PyObject *keywords)
|
||||
{
|
||||
char *name_str = "BoneName";
|
||||
C_Bone *py_bone = NULL; /* for Bone Data object wrapper in Python */
|
||||
BPy_Bone *py_bone = NULL; /* for Bone Data object wrapper in Python */
|
||||
Bone *bl_bone = NULL; /* for actual Bone Data we create in Blender */
|
||||
|
||||
printf ("In Bone_New()\n");
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|s", &name_str))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected string or empty argument"));
|
||||
@ -195,7 +193,7 @@ static PyObject *M_Bone_New(PyObject *self, PyObject *args, PyObject *keywords)
|
||||
strncpy(bl_bone->name,name_str,sizeof(bl_bone->name));
|
||||
|
||||
if (bl_bone) /* now create the wrapper obj in Python */
|
||||
py_bone = (C_Bone *)PyObject_NEW(C_Bone, &Bone_Type);
|
||||
py_bone = (BPy_Bone *)PyObject_NEW(BPy_Bone, &Bone_Type);
|
||||
else
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't create Bone Data in Blender"));
|
||||
@ -218,16 +216,14 @@ static PyObject *M_Bone_New(PyObject *self, PyObject *args, PyObject *keywords)
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_Bone_Init */
|
||||
/* Function: Bone_Init */
|
||||
/*****************************************************************************/
|
||||
PyObject *M_Bone_Init (void)
|
||||
PyObject *Bone_Init (void)
|
||||
{
|
||||
PyObject *submodule;
|
||||
|
||||
Bone_Type.ob_type = &PyType_Type;
|
||||
|
||||
printf ("In M_Bone_Init()\n");
|
||||
|
||||
submodule = Py_InitModule3("Blender.Armature.Bone",
|
||||
M_Bone_methods, M_Bone_doc);
|
||||
|
||||
@ -235,9 +231,9 @@ PyObject *M_Bone_Init (void)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_Bone methods: */
|
||||
/* Python BPy_Bone methods: */
|
||||
/*****************************************************************************/
|
||||
static PyObject *Bone_getName(C_Bone *self)
|
||||
static PyObject *Bone_getName(BPy_Bone *self)
|
||||
{
|
||||
PyObject *attr=NULL;
|
||||
|
||||
@ -253,7 +249,7 @@ static PyObject *Bone_getName(C_Bone *self)
|
||||
}
|
||||
|
||||
|
||||
static PyObject *Bone_getRoll(C_Bone *self)
|
||||
static PyObject *Bone_getRoll(BPy_Bone *self)
|
||||
{
|
||||
PyObject *attr=NULL;
|
||||
|
||||
@ -269,7 +265,7 @@ static PyObject *Bone_getRoll(C_Bone *self)
|
||||
}
|
||||
|
||||
|
||||
static PyObject *Bone_getHead(C_Bone *self)
|
||||
static PyObject *Bone_getHead(BPy_Bone *self)
|
||||
{
|
||||
PyObject *attr=NULL;
|
||||
|
||||
@ -286,7 +282,7 @@ static PyObject *Bone_getHead(C_Bone *self)
|
||||
}
|
||||
|
||||
|
||||
static PyObject *Bone_getTail(C_Bone *self)
|
||||
static PyObject *Bone_getTail(BPy_Bone *self)
|
||||
{
|
||||
PyObject *attr=NULL;
|
||||
|
||||
@ -303,7 +299,7 @@ static PyObject *Bone_getTail(C_Bone *self)
|
||||
}
|
||||
|
||||
|
||||
static PyObject *Bone_getLoc (C_Bone *self)
|
||||
static PyObject *Bone_getLoc (BPy_Bone *self)
|
||||
{
|
||||
PyObject *attr=NULL;
|
||||
|
||||
@ -320,7 +316,7 @@ static PyObject *Bone_getLoc (C_Bone *self)
|
||||
}
|
||||
|
||||
|
||||
static PyObject *Bone_getSize(C_Bone *self)
|
||||
static PyObject *Bone_getSize(BPy_Bone *self)
|
||||
{
|
||||
PyObject *attr=NULL;
|
||||
|
||||
@ -337,7 +333,7 @@ static PyObject *Bone_getSize(C_Bone *self)
|
||||
}
|
||||
|
||||
|
||||
static PyObject *Bone_getQuat(C_Bone *self)
|
||||
static PyObject *Bone_getQuat(BPy_Bone *self)
|
||||
{
|
||||
PyObject *attr=NULL;
|
||||
|
||||
@ -354,14 +350,14 @@ static PyObject *Bone_getQuat(C_Bone *self)
|
||||
}
|
||||
|
||||
|
||||
static PyObject *Bone_hasParent(C_Bone *self)
|
||||
static PyObject *Bone_hasParent(BPy_Bone *self)
|
||||
{
|
||||
|
||||
if (!self->bone) (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't get attribute from a NULL bone"));
|
||||
|
||||
/*
|
||||
return M_BoneCreatePyObject(self->bone->parent);
|
||||
return Bone_CreatePyObject(self->bone->parent);
|
||||
*/
|
||||
if (self->bone->parent)
|
||||
{
|
||||
@ -377,13 +373,13 @@ static PyObject *Bone_hasParent(C_Bone *self)
|
||||
}
|
||||
|
||||
|
||||
static PyObject *Bone_getParent(C_Bone *self)
|
||||
static PyObject *Bone_getParent(BPy_Bone *self)
|
||||
{
|
||||
|
||||
if (!self->bone) (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't get attribute from a NULL bone"));
|
||||
|
||||
if (self->bone->parent) return M_BoneCreatePyObject(self->bone->parent);
|
||||
if (self->bone->parent) return Bone_CreatePyObject(self->bone->parent);
|
||||
else /*(EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"couldn't get parent bone, because bone hasn't got a parent."));*/
|
||||
{
|
||||
@ -394,7 +390,7 @@ static PyObject *Bone_getParent(C_Bone *self)
|
||||
}
|
||||
|
||||
|
||||
static PyObject *Bone_getChildren(C_Bone *self)
|
||||
static PyObject *Bone_getChildren(BPy_Bone *self)
|
||||
{
|
||||
int totbones = 0;
|
||||
Bone* current = NULL;
|
||||
@ -413,7 +409,7 @@ static PyObject *Bone_getChildren(C_Bone *self)
|
||||
listbones = PyList_New(totbones);
|
||||
for (i=0; i<totbones; i++) {
|
||||
assert(current);
|
||||
PyList_SetItem(listbones, i, M_BoneCreatePyObject(current));
|
||||
PyList_SetItem(listbones, i, Bone_CreatePyObject(current));
|
||||
current = current->next;
|
||||
}
|
||||
|
||||
@ -421,7 +417,7 @@ static PyObject *Bone_getChildren(C_Bone *self)
|
||||
}
|
||||
|
||||
|
||||
static PyObject *Bone_setName(C_Bone *self, PyObject *args)
|
||||
static PyObject *Bone_setName(BPy_Bone *self, PyObject *args)
|
||||
{
|
||||
char *name;
|
||||
|
||||
@ -439,7 +435,7 @@ static PyObject *Bone_setName(C_Bone *self, PyObject *args)
|
||||
}
|
||||
|
||||
|
||||
PyObject *Bone_setRoll(C_Bone *self, PyObject *args)
|
||||
PyObject *Bone_setRoll(BPy_Bone *self, PyObject *args)
|
||||
{
|
||||
float roll;
|
||||
|
||||
@ -457,7 +453,7 @@ PyObject *Bone_setRoll(C_Bone *self, PyObject *args)
|
||||
}
|
||||
|
||||
|
||||
static PyObject *Bone_setHead(C_Bone *self, PyObject *args)
|
||||
static PyObject *Bone_setHead(BPy_Bone *self, PyObject *args)
|
||||
{
|
||||
float f1,f2,f3;
|
||||
|
||||
@ -477,7 +473,7 @@ static PyObject *Bone_setHead(C_Bone *self, PyObject *args)
|
||||
}
|
||||
|
||||
|
||||
static PyObject *Bone_setTail(C_Bone *self, PyObject *args)
|
||||
static PyObject *Bone_setTail(BPy_Bone *self, PyObject *args)
|
||||
{
|
||||
float f1,f2,f3;
|
||||
|
||||
@ -497,7 +493,7 @@ static PyObject *Bone_setTail(C_Bone *self, PyObject *args)
|
||||
}
|
||||
|
||||
|
||||
static PyObject *Bone_setLoc(C_Bone *self, PyObject *args)
|
||||
static PyObject *Bone_setLoc(BPy_Bone *self, PyObject *args)
|
||||
{
|
||||
float f1,f2,f3;
|
||||
|
||||
@ -517,7 +513,7 @@ static PyObject *Bone_setLoc(C_Bone *self, PyObject *args)
|
||||
}
|
||||
|
||||
|
||||
static PyObject *Bone_setSize(C_Bone *self, PyObject *args)
|
||||
static PyObject *Bone_setSize(BPy_Bone *self, PyObject *args)
|
||||
{
|
||||
float f1,f2,f3;
|
||||
|
||||
@ -537,7 +533,7 @@ static PyObject *Bone_setSize(C_Bone *self, PyObject *args)
|
||||
}
|
||||
|
||||
|
||||
static PyObject *Bone_setQuat(C_Bone *self, PyObject *args)
|
||||
static PyObject *Bone_setQuat(BPy_Bone *self, PyObject *args)
|
||||
{
|
||||
float f1,f2,f3,f4;
|
||||
|
||||
@ -559,22 +555,22 @@ static PyObject *Bone_setQuat(C_Bone *self, PyObject *args)
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: BoneDeAlloc */
|
||||
/* Description: This is a callback function for the C_Bone type. It is */
|
||||
/* Function: Bone_dealloc */
|
||||
/* Description: This is a callback function for the BPy_Bone type. It is */
|
||||
/* the destructor function. */
|
||||
/*****************************************************************************/
|
||||
static void BoneDeAlloc (C_Bone *self)
|
||||
static void Bone_dealloc (BPy_Bone *self)
|
||||
{
|
||||
PyObject_DEL (self);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: BoneGetAttr */
|
||||
/* Description: This is a callback function for the C_Bone type. It is */
|
||||
/* the function that accesses C_Bone member variables and */
|
||||
/* Function: Bone_getAttr */
|
||||
/* Description: This is a callback function for the BPy_Bone type. It is */
|
||||
/* the function that accesses BPy_Bone member variables and */
|
||||
/* methods. */
|
||||
/*****************************************************************************/
|
||||
static PyObject* BoneGetAttr (C_Bone *self, char *name)
|
||||
static PyObject* Bone_getAttr (BPy_Bone *self, char *name)
|
||||
{
|
||||
PyObject *attr = Py_None;
|
||||
|
||||
@ -611,16 +607,16 @@ static PyObject* BoneGetAttr (C_Bone *self, char *name)
|
||||
if (attr != Py_None) return attr; /* member attribute found, return it */
|
||||
|
||||
/* not an attribute, search the methods table */
|
||||
return Py_FindMethod(C_Bone_methods, (PyObject *)self, name);
|
||||
return Py_FindMethod(BPy_Bone_methods, (PyObject *)self, name);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: BoneSetAttr */
|
||||
/* Description: This is a callback function for the C_Bone type. It is the */
|
||||
/* Function: Bone_setAttr */
|
||||
/* Description: This is a callback function for the BPy_Bone type. It is the */
|
||||
/* function that changes Bone Data members values. If this */
|
||||
/* data is linked to a Blender Bone, it also gets updated. */
|
||||
/*****************************************************************************/
|
||||
static int BoneSetAttr (C_Bone *self, char *name, PyObject *value)
|
||||
static int Bone_setAttr (BPy_Bone *self, char *name, PyObject *value)
|
||||
{
|
||||
PyObject *valtuple;
|
||||
PyObject *error = NULL;
|
||||
@ -650,11 +646,11 @@ static int BoneSetAttr (C_Bone *self, char *name, PyObject *value)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: BonePrint */
|
||||
/* Description: This is a callback function for the C_Bone type. It */
|
||||
/* Function: Bone_print */
|
||||
/* Description: This is a callback function for the BPy_Bone type. It */
|
||||
/* builds a meaninful string to 'print' bone objects. */
|
||||
/*****************************************************************************/
|
||||
static int BonePrint(C_Bone *self, FILE *fp, int flags)
|
||||
static int Bone_print(BPy_Bone *self, FILE *fp, int flags)
|
||||
{
|
||||
if (self->bone) fprintf(fp, "[Bone \"%s\"]", self->bone->name);
|
||||
else fprintf(fp, "[Bone NULL]");
|
||||
@ -662,23 +658,23 @@ static int BonePrint(C_Bone *self, FILE *fp, int flags)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: BoneRepr */
|
||||
/* Description: This is a callback function for the C_Bone type. It */
|
||||
/* Function: Bone_repr */
|
||||
/* Description: This is a callback function for the BPy_Bone type. It */
|
||||
/* builds a meaninful string to represent bone objects. */
|
||||
/*****************************************************************************/
|
||||
static PyObject *BoneRepr (C_Bone *self)
|
||||
static PyObject *Bone_repr (BPy_Bone *self)
|
||||
{
|
||||
if (self->bone) return PyString_FromString(self->bone->name);
|
||||
else return PyString_FromString("NULL");
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/* Function: BoneCmp */
|
||||
/* Description: This is a callback function for the C_Bone type. It */
|
||||
/* Function: Bone_compare */
|
||||
/* Description: This is a callback function for the BPy_Bone type. It */
|
||||
/* compares the two bones: translate comparison to the */
|
||||
/* C pointers. */
|
||||
/**************************************************************************/
|
||||
static int BoneCmp (C_Bone *a, C_Bone *b)
|
||||
static int Bone_compare (BPy_Bone *a, BPy_Bone *b)
|
||||
{
|
||||
Bone *pa = a->bone, *pb = b->bone;
|
||||
return (pa == pb) ? 0:-1;
|
||||
@ -688,17 +684,15 @@ static int BoneCmp (C_Bone *a, C_Bone *b)
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_BoneCreatePyObject */
|
||||
/* Function: Bone_CreatePyObject */
|
||||
/* Description: This function will create a new BlenBone from an existing */
|
||||
/* Bone structure. */
|
||||
/*****************************************************************************/
|
||||
PyObject* M_BoneCreatePyObject (struct Bone *obj)
|
||||
PyObject* Bone_CreatePyObject (struct Bone *obj)
|
||||
{
|
||||
C_Bone * blen_bone;
|
||||
BPy_Bone * blen_bone;
|
||||
|
||||
printf (" In M_BoneCreatePyObject\n");
|
||||
|
||||
blen_bone = (C_Bone*)PyObject_NEW (C_Bone, &Bone_Type);
|
||||
blen_bone = (BPy_Bone*)PyObject_NEW (BPy_Bone, &Bone_Type);
|
||||
|
||||
if (blen_bone == NULL)
|
||||
{
|
||||
@ -709,24 +703,24 @@ PyObject* M_BoneCreatePyObject (struct Bone *obj)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_BoneCheckPyObject */
|
||||
/* Function: Bone_CheckPyObject */
|
||||
/* Description: This function returns true when the given PyObject is of the */
|
||||
/* type Bone. Otherwise it will return false. */
|
||||
/*****************************************************************************/
|
||||
int M_BoneCheckPyObject (PyObject *py_obj)
|
||||
int Bone_CheckPyObject (PyObject *py_obj)
|
||||
{
|
||||
return (py_obj->ob_type == &Bone_Type);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_BoneFromPyObject */
|
||||
/* Function: Bone_FromPyObject */
|
||||
/* Description: This function returns the Blender bone from the given */
|
||||
/* PyObject. */
|
||||
/*****************************************************************************/
|
||||
struct Bone* M_BoneFromPyObject (PyObject *py_obj)
|
||||
struct Bone* Bone_FromPyObject (PyObject *py_obj)
|
||||
{
|
||||
C_Bone * blen_obj;
|
||||
BPy_Bone * blen_obj;
|
||||
|
||||
blen_obj = (C_Bone*)py_obj;
|
||||
blen_obj = (BPy_Bone*)py_obj;
|
||||
return (blen_obj->bone);
|
||||
}
|
||||
|
@ -37,18 +37,18 @@
|
||||
#include <DNA_armature_types.h>
|
||||
|
||||
/** Bone module initialization function. */
|
||||
PyObject *M_Bone_Init (void);
|
||||
PyObject *Bone_Init (void);
|
||||
|
||||
|
||||
/** Python C_Bone structure definition. */
|
||||
/** Python BPy_Bone structure definition. */
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
Bone *bone;
|
||||
} C_Bone;
|
||||
} BPy_Bone;
|
||||
|
||||
|
||||
PyObject* M_BoneCreatePyObject (struct Bone *obj);
|
||||
int M_BoneCheckPyObject (PyObject *py_obj);
|
||||
Bone* M_BoneFromPyObject (PyObject *py_obj);
|
||||
PyObject* Bone_CreatePyObject (struct Bone *obj);
|
||||
int Bone_CheckPyObject (PyObject *py_obj);
|
||||
Bone* Bone_FromPyObject (PyObject *py_obj);
|
||||
|
||||
#endif
|
||||
|
@ -152,12 +152,12 @@ struct PyMethodDef M_Build_methods[] = {
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_Build_Init */
|
||||
/* Function: Build_Init */
|
||||
/*****************************************************************************/
|
||||
PyObject *M_Build_Init (void)
|
||||
PyObject *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,M_Build_doc );
|
||||
return (submodule);
|
||||
|
@ -49,12 +49,12 @@ PyTypeObject Camera_Type =
|
||||
sizeof (BPy_Camera), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
/* methods */
|
||||
(destructor)Camera_DeAlloc, /* tp_dealloc */
|
||||
(printfunc)Camera_Print, /* tp_print */
|
||||
(getattrfunc)Camera_GetAttr, /* tp_getattr */
|
||||
(setattrfunc)Camera_SetAttr, /* tp_setattr */
|
||||
(cmpfunc)Camera_Compare, /* tp_compare */
|
||||
(reprfunc)Camera_Repr, /* tp_repr */
|
||||
(destructor)Camera_dealloc, /* tp_dealloc */
|
||||
(printfunc)Camera_print, /* tp_print */
|
||||
(getattrfunc)Camera_getAttr, /* tp_getattr */
|
||||
(setattrfunc)Camera_setAttr, /* tp_setattr */
|
||||
(cmpfunc)Camera_compare, /* tp_compare */
|
||||
(reprfunc)Camera_repr, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
@ -183,8 +183,6 @@ PyObject *Camera_Init (void)
|
||||
{
|
||||
PyObject *submodule;
|
||||
|
||||
printf ("In M_Camera_Init()\n");
|
||||
|
||||
Camera_Type.ob_type = &PyType_Type;
|
||||
|
||||
submodule = Py_InitModule3("Blender.Camera",
|
||||
@ -470,12 +468,12 @@ static PyObject *Camera_setDrawSize(BPy_Camera *self, PyObject *args)
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static void Camera_DeAlloc (BPy_Camera *self)
|
||||
static void Camera_dealloc (BPy_Camera *self)
|
||||
{
|
||||
PyObject_DEL (self);
|
||||
}
|
||||
|
||||
static PyObject *Camera_GetAttr (BPy_Camera *self, char *name)
|
||||
static PyObject *Camera_getAttr (BPy_Camera *self, char *name)
|
||||
{
|
||||
PyObject *attr = Py_None;
|
||||
|
||||
@ -520,7 +518,7 @@ static PyObject *Camera_GetAttr (BPy_Camera *self, char *name)
|
||||
return Py_FindMethod(BPy_Camera_methods, (PyObject *)self, name);
|
||||
}
|
||||
|
||||
static int Camera_SetAttr (BPy_Camera *self, char *name, PyObject *value)
|
||||
static int Camera_setAttr (BPy_Camera *self, char *name, PyObject *value)
|
||||
{
|
||||
PyObject *valtuple;
|
||||
PyObject *error = NULL;
|
||||
@ -579,19 +577,19 @@ static int Camera_SetAttr (BPy_Camera *self, char *name, PyObject *value)
|
||||
return 0; /* normal exit */
|
||||
}
|
||||
|
||||
static int Camera_Compare (BPy_Camera *a, BPy_Camera *b)
|
||||
static int Camera_compare (BPy_Camera *a, BPy_Camera *b)
|
||||
{
|
||||
Camera *pa = a->camera, *pb = b->camera;
|
||||
return (pa == pb) ? 0:-1;
|
||||
}
|
||||
|
||||
static int Camera_Print(BPy_Camera *self, FILE *fp, int flags)
|
||||
static int Camera_print(BPy_Camera *self, FILE *fp, int flags)
|
||||
{
|
||||
fprintf(fp, "[Camera \"%s\"]", self->camera->id.name+2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyObject *Camera_Repr (BPy_Camera *self)
|
||||
static PyObject *Camera_repr (BPy_Camera *self)
|
||||
{
|
||||
return PyString_FromString(self->camera->id.name+2);
|
||||
}
|
||||
|
@ -173,12 +173,12 @@ static PyMethodDef BPy_Camera_methods[] = {
|
||||
/*****************************************************************************/
|
||||
/* Python Camera_Type callback function prototypes: */
|
||||
/*****************************************************************************/
|
||||
static void Camera_DeAlloc (BPy_Camera *self);
|
||||
static int Camera_Print (BPy_Camera *self, FILE *fp, int flags);
|
||||
static int Camera_SetAttr (BPy_Camera *self, char *name, PyObject *v);
|
||||
static int Camera_Compare (BPy_Camera *a, BPy_Camera *b);
|
||||
static PyObject *Camera_GetAttr (BPy_Camera *self, char *name);
|
||||
static PyObject *Camera_Repr (BPy_Camera *self);
|
||||
static void Camera_dealloc (BPy_Camera *self);
|
||||
static int Camera_print (BPy_Camera *self, FILE *fp, int flags);
|
||||
static int Camera_setAttr (BPy_Camera *self, char *name, PyObject *v);
|
||||
static int Camera_compare (BPy_Camera *a, BPy_Camera *b);
|
||||
static PyObject *Camera_getAttr (BPy_Camera *self, char *name);
|
||||
static PyObject *Camera_repr (BPy_Camera *self);
|
||||
|
||||
|
||||
#endif /* EXPP_CAMERA_H */
|
||||
|
@ -43,7 +43,6 @@ static PyObject *M_Curve_New(PyObject *self, PyObject *args)
|
||||
BPy_Curve *pycurve; /* for Curve Data object wrapper in Python */
|
||||
Curve *blcurve = 0; /* for actual Curve Data we create in Blender */
|
||||
|
||||
printf ("In Curve_New()\n");
|
||||
if (!PyArg_ParseTuple(args, "|s", &name))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected string argument or no argument"));
|
||||
@ -81,7 +80,6 @@ static PyObject *M_Curve_Get(PyObject *self, PyObject *args)
|
||||
Curve *curv_iter;
|
||||
BPy_Curve *wanted_curv;
|
||||
|
||||
printf ("In Curve_Get()\n");
|
||||
if (!PyArg_ParseTuple(args, "|s", &name))//expects nothing or a string
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected string argument"));
|
||||
@ -133,12 +131,11 @@ BPy_Curve *found_cur=(BPy_Curve*)PyObject_NEW(BPy_Curve,&Curve_Type);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_Curve_Init */
|
||||
/* Function: Curve_Init */
|
||||
/*****************************************************************************/
|
||||
PyObject *M_Curve_Init (void)
|
||||
PyObject *Curve_Init (void)
|
||||
{
|
||||
PyObject *submodule;
|
||||
printf ("In M_Curve_Init()\n");
|
||||
|
||||
Curve_Type.ob_type = &PyType_Type;
|
||||
|
||||
@ -677,8 +674,6 @@ PyObject* CurveCreatePyObject (struct Curve *curve)
|
||||
{
|
||||
BPy_Curve * blen_object;
|
||||
|
||||
printf ("In CurveCreatePyObject\n");
|
||||
|
||||
blen_object = (BPy_Curve*)PyObject_NEW (BPy_Curve, &Curve_Type);
|
||||
|
||||
if (blen_object == NULL)
|
||||
|
@ -283,7 +283,6 @@ static PyObject *Method_Draw (PyObject *self, PyObject *args)
|
||||
{
|
||||
/*@ If forced drawing is disable queue a redraw event instead */
|
||||
if (EXPP_disable_force_draw) {
|
||||
printf ("\nEXPP_disable_force_draw\n");
|
||||
scrarea_queue_winredraw(curarea);
|
||||
return EXPP_incr_ret (Py_None);
|
||||
}
|
||||
@ -656,8 +655,6 @@ PyObject *Draw_Init (void)
|
||||
{
|
||||
PyObject *submodule, *dict;
|
||||
|
||||
printf("In M_Draw_Init()\n");
|
||||
|
||||
Button_Type.ob_type = &PyType_Type;
|
||||
|
||||
submodule = Py_InitModule3("Blender.Draw", Draw_methods, Draw_doc);
|
||||
|
@ -49,7 +49,7 @@
|
||||
|
||||
void initBlenderApi2_2x (void)
|
||||
{
|
||||
printf ("initBlenderApi2_2x\n");
|
||||
//printf ("initBlenderApi2_2x\n");
|
||||
g_blenderdict = NULL;
|
||||
M_Blender_Init ();
|
||||
}
|
||||
@ -73,7 +73,7 @@ ScriptLink * setScriptLinks(ID *id, short event)
|
||||
int obj_id;
|
||||
|
||||
obj_id = MAKE_ID2 (id->name[0], id->name[1]);
|
||||
printf ("In setScriptLinks (id=%s, event=%d)\n",id->name, event);
|
||||
//printf ("In setScriptLinks (id=%s, event=%d)\n",id->name, event);
|
||||
|
||||
switch (obj_id)
|
||||
{
|
||||
@ -83,7 +83,7 @@ ScriptLink * setScriptLinks(ID *id, short event)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
link = M_ObjectCreatePyObject (object);
|
||||
link = Object_CreatePyObject (object);
|
||||
scriptlink = &(object->scriptlink);
|
||||
break;
|
||||
case ID_LA:
|
||||
|
@ -148,24 +148,25 @@ PyObject * effectlist = PyList_New (0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_Effect_Init */
|
||||
/* Function: Effect_Init */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
PyObject *M_Build_Init (void);
|
||||
PyObject *M_Wave_Init (void);
|
||||
PyObject *M_Particle_Init (void);
|
||||
PyObject *Build_Init (void);
|
||||
PyObject *Wave_Init (void);
|
||||
PyObject *Particle_Init (void);
|
||||
|
||||
PyObject *M_Effect_Init (void)
|
||||
PyObject *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 );
|
||||
|
||||
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());
|
||||
PyDict_SetItemString (dict, "Wave", Wave_Init());
|
||||
PyDict_SetItemString (dict, "Build", Build_Init());
|
||||
PyDict_SetItemString (dict, "Particle", Particle_Init());
|
||||
return (submodule);
|
||||
}
|
||||
|
||||
@ -297,8 +298,6 @@ PyObject* EffectCreatePyObject (struct Effect *effect)
|
||||
{
|
||||
BPy_Effect * blen_object;
|
||||
|
||||
printf ("In EffectCreatePyObject\n");
|
||||
|
||||
blen_object = (BPy_Effect*)PyObject_NEW (BPy_Effect, &Effect_Type);
|
||||
|
||||
if (blen_object == NULL)
|
||||
|
@ -40,7 +40,7 @@
|
||||
#include "Image.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_Image defaults: */
|
||||
/* Python BPy_Image defaults: */
|
||||
/*****************************************************************************/
|
||||
#define EXPP_IMAGE_REP 1
|
||||
#define EXPP_IMAGE_REP_MIN 1
|
||||
@ -124,11 +124,11 @@ static PyObject *M_Image_Get(PyObject *self, PyObject *args)
|
||||
|
||||
if (name) { /* (name) - Search image by name */
|
||||
|
||||
C_Image *wanted_image = NULL;
|
||||
BPy_Image *wanted_image = NULL;
|
||||
|
||||
while ((img_iter) && (wanted_image == NULL)) {
|
||||
if (strcmp (name, img_iter->id.name+2) == 0) {
|
||||
wanted_image = (C_Image *)PyObject_NEW(C_Image, &Image_Type);
|
||||
wanted_image = (BPy_Image *)PyObject_NEW(BPy_Image, &Image_Type);
|
||||
if (wanted_image) wanted_image->image = img_iter;
|
||||
}
|
||||
img_iter = img_iter->id.next;
|
||||
@ -181,13 +181,13 @@ static PyObject *M_Image_Load(PyObject *self, PyObject *args)
|
||||
{
|
||||
char *fname;
|
||||
Image *img_ptr;
|
||||
C_Image *img;
|
||||
BPy_Image *img;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s", &fname))
|
||||
return (EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
"expected string argument"));
|
||||
|
||||
img = (C_Image *)PyObject_NEW(C_Image, &Image_Type);
|
||||
img = (BPy_Image *)PyObject_NEW(BPy_Image, &Image_Type);
|
||||
|
||||
if (!img)
|
||||
return (EXPP_ReturnPyObjError (PyExc_MemoryError,
|
||||
@ -222,18 +222,18 @@ PyObject *Image_Init (void)
|
||||
/************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_Image methods declarations: */
|
||||
/* Python BPy_Image methods declarations: */
|
||||
/*****************************************************************************/
|
||||
static PyObject *Image_getName(C_Image *self);
|
||||
static PyObject *Image_getFilename(C_Image *self);
|
||||
static PyObject *Image_setName(C_Image *self, PyObject *args);
|
||||
static PyObject *Image_setXRep(C_Image *self, PyObject *args);
|
||||
static PyObject *Image_setYRep(C_Image *self, PyObject *args);
|
||||
static PyObject *Image_getName(BPy_Image *self);
|
||||
static PyObject *Image_getFilename(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);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_Image methods table: */
|
||||
/* Python BPy_Image methods table: */
|
||||
/*****************************************************************************/
|
||||
static PyMethodDef C_Image_methods[] = {
|
||||
static PyMethodDef BPy_Image_methods[] = {
|
||||
/* name, method, flags, doc */
|
||||
{"getName", (PyCFunction)Image_getName, METH_NOARGS,
|
||||
"() - Return Image Data name"},
|
||||
@ -249,14 +249,14 @@ static PyMethodDef C_Image_methods[] = {
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python Image_Type callback function prototypes: */
|
||||
/* Python Image_Type callback function prototypes: */
|
||||
/*****************************************************************************/
|
||||
static void Image_Dealloc (C_Image *self);
|
||||
static int Image_SetAttr (C_Image *self, char *name, PyObject *v);
|
||||
static int Image_Compare (C_Image *a, C_Image *b);
|
||||
static int Image_Print (C_Image *self, FILE *fp, int flags);
|
||||
static PyObject *Image_GetAttr (C_Image *self, char *name);
|
||||
static PyObject *Image_Repr (C_Image *self);
|
||||
static void Image_Dealloc (BPy_Image *self);
|
||||
static int Image_SetAttr (BPy_Image *self, char *name, PyObject *v);
|
||||
static int Image_Compare (BPy_Image *a, BPy_Image *b);
|
||||
static int Image_Print (BPy_Image *self, FILE *fp, int flags);
|
||||
static PyObject *Image_GetAttr (BPy_Image *self, char *name);
|
||||
static PyObject *Image_Repr (BPy_Image *self);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python Image_Type structure definition: */
|
||||
@ -265,8 +265,8 @@ PyTypeObject Image_Type =
|
||||
{
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
"Image", /* tp_name */
|
||||
sizeof (C_Image), /* tp_basicsize */
|
||||
"Blender Image", /* tp_name */
|
||||
sizeof (BPy_Image), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
/* methods */
|
||||
(destructor)Image_Dealloc, /* tp_dealloc */
|
||||
@ -282,34 +282,34 @@ PyTypeObject Image_Type =
|
||||
0,0,0,0,0,0,
|
||||
0, /* tp_doc */
|
||||
0,0,0,0,0,0,
|
||||
C_Image_methods, /* tp_methods */
|
||||
BPy_Image_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: ImageDealloc */
|
||||
/* Description: This is a callback function for the C_Image type. It is */
|
||||
/* Description: This is a callback function for the BPy_Image type. It is */
|
||||
/* the destructor function. */
|
||||
/*****************************************************************************/
|
||||
static void Image_Dealloc (C_Image *self)
|
||||
static void Image_Dealloc (BPy_Image *self)
|
||||
{
|
||||
PyObject_DEL (self);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Image_CreatePyObject */
|
||||
/* Description: This function will create a new C_Image from an existing */
|
||||
/* Description: This function will create a new BPy_Image from an existing */
|
||||
/* Blender image structure. */
|
||||
/*****************************************************************************/
|
||||
PyObject *Image_CreatePyObject (Image *image)
|
||||
{
|
||||
C_Image *py_img;
|
||||
BPy_Image *py_img;
|
||||
|
||||
py_img = (C_Image *)PyObject_NEW (C_Image, &Image_Type);
|
||||
py_img = (BPy_Image *)PyObject_NEW (BPy_Image, &Image_Type);
|
||||
|
||||
if (!py_img)
|
||||
return EXPP_ReturnPyObjError (PyExc_MemoryError,
|
||||
"couldn't create C_Image object");
|
||||
"couldn't create BPy_Image object");
|
||||
|
||||
py_img->image = image;
|
||||
|
||||
@ -327,9 +327,9 @@ int Image_CheckPyObject (PyObject *pyobj)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_Image methods: */
|
||||
/* Python BPy_Image methods: */
|
||||
/*****************************************************************************/
|
||||
static PyObject *Image_getName(C_Image *self)
|
||||
static PyObject *Image_getName(BPy_Image *self)
|
||||
{
|
||||
PyObject *attr = PyString_FromString(self->image->id.name+2);
|
||||
|
||||
@ -339,7 +339,7 @@ static PyObject *Image_getName(C_Image *self)
|
||||
"couldn't get Image.name attribute"));
|
||||
}
|
||||
|
||||
static PyObject *Image_getFilename(C_Image *self)
|
||||
static PyObject *Image_getFilename(BPy_Image *self)
|
||||
{
|
||||
PyObject *attr = PyString_FromString(self->image->name);
|
||||
|
||||
@ -349,7 +349,7 @@ static PyObject *Image_getFilename(C_Image *self)
|
||||
"couldn't get Image.filename attribute"));
|
||||
}
|
||||
|
||||
static PyObject *Image_setName(C_Image *self, PyObject *args)
|
||||
static PyObject *Image_setName(BPy_Image *self, PyObject *args)
|
||||
{
|
||||
char *name;
|
||||
char buf[21];
|
||||
@ -366,7 +366,7 @@ static PyObject *Image_setName(C_Image *self, PyObject *args)
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *Image_setXRep(C_Image *self, PyObject *args)
|
||||
static PyObject *Image_setXRep(BPy_Image *self, PyObject *args)
|
||||
{
|
||||
short value;
|
||||
|
||||
@ -384,7 +384,7 @@ static PyObject *Image_setXRep(C_Image *self, PyObject *args)
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static PyObject *Image_setYRep(C_Image *self, PyObject *args)
|
||||
static PyObject *Image_setYRep(BPy_Image *self, PyObject *args)
|
||||
{
|
||||
short value;
|
||||
|
||||
@ -404,11 +404,11 @@ static PyObject *Image_setYRep(C_Image *self, PyObject *args)
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Image_GetAttr */
|
||||
/* Description: This is a callback function for the C_Image type. It is */
|
||||
/* the function that accesses C_Image member variables and */
|
||||
/* Description: This is a callback function for the BPy_Image type. It is */
|
||||
/* the function that accesses BPy_Image member variables and */
|
||||
/* methods. */
|
||||
/*****************************************************************************/
|
||||
static PyObject *Image_GetAttr (C_Image *self, char *name)
|
||||
static PyObject *Image_GetAttr (BPy_Image *self, char *name)
|
||||
{
|
||||
PyObject *attr = Py_None;
|
||||
|
||||
@ -432,16 +432,16 @@ static PyObject *Image_GetAttr (C_Image *self, char *name)
|
||||
if (attr != Py_None) return attr; /* attribute found, return its value */
|
||||
|
||||
/* not an attribute, search the methods table */
|
||||
return Py_FindMethod(C_Image_methods, (PyObject *)self, name);
|
||||
return Py_FindMethod(BPy_Image_methods, (PyObject *)self, name);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Image_SetAttr */
|
||||
/* Description: This is a callback function for the C_Image type. It is the */
|
||||
/* Description: This is a callback function for the BPy_Image type. It is the*/
|
||||
/* function that changes Image Data members values. If this */
|
||||
/* data is linked to a Blender Image, it also gets updated. */
|
||||
/*****************************************************************************/
|
||||
static int Image_SetAttr (C_Image *self, char *name, PyObject *value)
|
||||
static int Image_SetAttr (BPy_Image *self, char *name, PyObject *value)
|
||||
{
|
||||
PyObject *valtuple;
|
||||
PyObject *error = NULL;
|
||||
@ -480,13 +480,13 @@ static int Image_SetAttr (C_Image *self, char *name, PyObject *value)
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Image_Compare */
|
||||
/* Description: This is a callback function for the C_Image type. It */
|
||||
/* Description: This is a callback function for the BPy_Image type. It */
|
||||
/* compares two Image_Type objects. Only the "==" and "!=" */
|
||||
/* comparisons are meaninful. Returns 0 for equality and -1 if */
|
||||
/* they don't point to the same Blender Image struct. */
|
||||
/* In Python it becomes 1 if they are equal, 0 otherwise. */
|
||||
/*****************************************************************************/
|
||||
static int Image_Compare (C_Image *a, C_Image *b)
|
||||
static int Image_Compare (BPy_Image *a, BPy_Image *b)
|
||||
{
|
||||
Image *pa = a->image, *pb = b->image;
|
||||
return (pa == pb) ? 0:-1;
|
||||
@ -494,10 +494,10 @@ static int Image_Compare (C_Image *a, C_Image *b)
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Image_Print */
|
||||
/* Description: This is a callback function for the C_Image type. It */
|
||||
/* Description: This is a callback function for the BPy_Image type. It */
|
||||
/* builds a meaninful string to 'print' image objects. */
|
||||
/*****************************************************************************/
|
||||
static int Image_Print(C_Image *self, FILE *fp, int flags)
|
||||
static int Image_Print(BPy_Image *self, FILE *fp, int flags)
|
||||
{
|
||||
fprintf(fp, "[Image \"%s\"]", self->image->id.name+2);
|
||||
return 0;
|
||||
@ -505,10 +505,10 @@ static int Image_Print(C_Image *self, FILE *fp, int flags)
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Image_Repr */
|
||||
/* Description: This is a callback function for the C_Image type. It */
|
||||
/* Description: This is a callback function for the BPy_Image type. It */
|
||||
/* builds a meaninful string to represent image objects. */
|
||||
/*****************************************************************************/
|
||||
static PyObject *Image_Repr (C_Image *self)
|
||||
static PyObject *Image_Repr (BPy_Image *self)
|
||||
{
|
||||
return PyString_FromString(self->image->id.name+2);
|
||||
}
|
||||
|
@ -37,17 +37,17 @@
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_Image structure definition */
|
||||
/* Python BPy_Image structure definition */
|
||||
/*****************************************************************************/
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
Image *image;
|
||||
|
||||
} C_Image;
|
||||
} BPy_Image;
|
||||
|
||||
extern PyTypeObject Image_Type; /* The Image PyType Object */
|
||||
|
||||
#define C_Image_Check(v) ((v)->ob_type == &Image_Type) /* for type checking */
|
||||
#define BPy_Image_Check(v) ((v)->ob_type == &Image_Type)/*for type checking*/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Module Blender.Image - public functions */
|
||||
|
@ -132,15 +132,14 @@ static PyObject *M_Ipo_Get(PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_Ipo_Init */
|
||||
/* Function: Ipo_Init */
|
||||
/*****************************************************************************/
|
||||
PyObject *M_Ipo_Init (void)
|
||||
PyObject *Ipo_Init (void)
|
||||
{
|
||||
PyObject *submodule;
|
||||
|
||||
Ipo_Type.ob_type = &PyType_Type;
|
||||
|
||||
printf ("In M_Ipo_Init()\n");
|
||||
submodule = Py_InitModule3("Blender.Ipo", M_Ipo_methods, M_Ipo_doc);
|
||||
|
||||
return (submodule);
|
||||
|
@ -188,7 +188,7 @@ static PyObject *M_Lamp_TypesDict (void)
|
||||
PyObject *Types = M_constant_New();
|
||||
|
||||
if (Types) {
|
||||
C_constant *c = (C_constant *)Types;
|
||||
BPy_constant *c = (BPy_constant *)Types;
|
||||
|
||||
constant_insert (c, "Lamp", PyInt_FromLong (EXPP_LAMP_TYPE_LAMP));
|
||||
constant_insert (c, "Sun", PyInt_FromLong (EXPP_LAMP_TYPE_SUN));
|
||||
@ -205,7 +205,7 @@ static PyObject *M_Lamp_ModesDict (void)
|
||||
PyObject *Modes = M_constant_New();
|
||||
|
||||
if (Modes) {
|
||||
C_constant *c = (C_constant *)Modes;
|
||||
BPy_constant *c = (BPy_constant *)Modes;
|
||||
|
||||
constant_insert (c, "Shadows", PyInt_FromLong (EXPP_LAMP_MODE_SHADOWS));
|
||||
constant_insert (c, "Halo", PyInt_FromLong (EXPP_LAMP_MODE_HALO));
|
||||
|
@ -73,7 +73,6 @@ static PyObject *M_Metaball_New(PyObject *self, PyObject *args)
|
||||
if (!PyArg_ParseTuple(args, "|s", &name))
|
||||
return (EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
"expected string argument (or nothing)"));
|
||||
printf ("In MetaBall_New()\n");
|
||||
|
||||
blmball = add_mball(); /* first create the MetaBall Data in Blender */
|
||||
|
||||
@ -159,15 +158,15 @@ static PyObject *M_Metaball_Get(PyObject *self, PyObject *args)
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Function: M_Metaball_Init */
|
||||
/*******************************************************************************/
|
||||
PyObject *M_Metaball_Init (void)
|
||||
/******************************************************************************/
|
||||
/* Function: Metaball_Init */
|
||||
/******************************************************************************/
|
||||
PyObject *Metaball_Init (void)
|
||||
{
|
||||
PyObject *submodule;
|
||||
|
||||
Metaball_Type.ob_type = &PyType_Type;
|
||||
printf ("In M_Metaball_Init()\n");
|
||||
|
||||
submodule = Py_InitModule3("Blender.Metaball",
|
||||
M_Metaball_methods, M_Metaball_doc);
|
||||
|
||||
|
@ -49,9 +49,9 @@ static void NMCol_dealloc(PyObject *self)
|
||||
PyObject_DEL(self); /* XXX PyObject_Del ?*/
|
||||
}
|
||||
|
||||
static C_NMCol *newcol (char r, char g, char b, char a)
|
||||
static BPy_NMCol *newcol (char r, char g, char b, char a)
|
||||
{
|
||||
C_NMCol *mc = (C_NMCol *) PyObject_NEW (C_NMCol, &NMCol_Type);
|
||||
BPy_NMCol *mc = (BPy_NMCol *) PyObject_NEW (BPy_NMCol, &NMCol_Type);
|
||||
|
||||
mc->r= r;
|
||||
mc->g= g;
|
||||
@ -73,7 +73,7 @@ static PyObject *M_NMesh_Col(PyObject *self, PyObject *args)
|
||||
|
||||
static PyObject *NMCol_getattr(PyObject *self, char *name)
|
||||
{
|
||||
C_NMCol *mc = (C_NMCol *)self;
|
||||
BPy_NMCol *mc = (BPy_NMCol *)self;
|
||||
|
||||
if (strcmp(name, "r") == 0) return Py_BuildValue("i", mc->r);
|
||||
else if (strcmp(name, "g") == 0) return Py_BuildValue("i", mc->g);
|
||||
@ -85,7 +85,7 @@ static PyObject *NMCol_getattr(PyObject *self, char *name)
|
||||
|
||||
static int NMCol_setattr(PyObject *self, char *name, PyObject *v)
|
||||
{
|
||||
C_NMCol *mc = (C_NMCol *)self;
|
||||
BPy_NMCol *mc = (BPy_NMCol *)self;
|
||||
short ival;
|
||||
|
||||
if(!PyArg_Parse(v, "h", &ival)) return -1;
|
||||
@ -101,7 +101,7 @@ static int NMCol_setattr(PyObject *self, char *name, PyObject *v)
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject *NMCol_repr(C_NMCol *self)
|
||||
PyObject *NMCol_repr(BPy_NMCol *self)
|
||||
{
|
||||
static char s[256];
|
||||
sprintf (s, "[NMCol - <%d, %d, %d, %d>]", self->r, self->g, self->b, self->a);
|
||||
@ -113,7 +113,7 @@ PyTypeObject NMCol_Type =
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
"NMCol", /* tp_name */
|
||||
sizeof(C_NMCol), /* tp_basicsize */
|
||||
sizeof(BPy_NMCol), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
/* methods */
|
||||
(destructor) NMCol_dealloc, /* tp_dealloc */
|
||||
@ -137,7 +137,7 @@ PyTypeObject NMCol_Type =
|
||||
/*****************************/
|
||||
static void NMFace_dealloc (PyObject *self)
|
||||
{
|
||||
C_NMFace *mf = (C_NMFace *)self;
|
||||
BPy_NMFace *mf = (BPy_NMFace *)self;
|
||||
|
||||
Py_DECREF(mf->v);
|
||||
Py_DECREF(mf->uv);
|
||||
@ -146,9 +146,9 @@ static void NMFace_dealloc (PyObject *self)
|
||||
PyObject_DEL(self);
|
||||
}
|
||||
|
||||
static C_NMFace *new_NMFace(PyObject *vertexlist)
|
||||
static BPy_NMFace *new_NMFace(PyObject *vertexlist)
|
||||
{
|
||||
C_NMFace *mf = PyObject_NEW (C_NMFace, &NMFace_Type);
|
||||
BPy_NMFace *mf = PyObject_NEW (BPy_NMFace, &NMFace_Type);
|
||||
|
||||
mf->v = vertexlist;
|
||||
mf->uv = PyList_New(0);
|
||||
@ -180,7 +180,7 @@ static PyObject *M_NMesh_Face(PyObject *self, PyObject *args)
|
||||
static PyObject *NMFace_append(PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *vert;
|
||||
C_NMFace *f = (C_NMFace *)self;
|
||||
BPy_NMFace *f = (BPy_NMFace *)self;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!", &NMVert_Type, &vert))
|
||||
return EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
@ -202,7 +202,7 @@ static struct PyMethodDef NMFace_methods[] =
|
||||
|
||||
static PyObject *NMFace_getattr(PyObject *self, char *name)
|
||||
{
|
||||
C_NMFace *mf = (C_NMFace *)self;
|
||||
BPy_NMFace *mf = (BPy_NMFace *)self;
|
||||
|
||||
if(strcmp(name, "v") == 0)
|
||||
return Py_BuildValue("O", mf->v);
|
||||
@ -236,7 +236,7 @@ static PyObject *NMFace_getattr(PyObject *self, char *name)
|
||||
|
||||
static int NMFace_setattr(PyObject *self, char *name, PyObject *v)
|
||||
{
|
||||
C_NMFace *mf = (C_NMFace *)self;
|
||||
BPy_NMFace *mf = (BPy_NMFace *)self;
|
||||
short ival;
|
||||
|
||||
if (strcmp(name, "v") == 0) {
|
||||
@ -308,7 +308,7 @@ static int NMFace_setattr(PyObject *self, char *name, PyObject *v)
|
||||
return 0;
|
||||
}
|
||||
|
||||
mf->image = ((C_Image *)pyimg)->image;
|
||||
mf->image = ((BPy_Image *)pyimg)->image;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -321,17 +321,17 @@ static PyObject *NMFace_repr (PyObject *self)
|
||||
return PyString_FromString("[NMFace]");
|
||||
}
|
||||
|
||||
static int NMFace_len(C_NMFace *self)
|
||||
static int NMFace_len(BPy_NMFace *self)
|
||||
{
|
||||
return PySequence_Length(self->v);
|
||||
}
|
||||
|
||||
static PyObject *NMFace_item(C_NMFace *self, int i)
|
||||
static PyObject *NMFace_item(BPy_NMFace *self, int i)
|
||||
{
|
||||
return PySequence_GetItem(self->v, i); // new ref
|
||||
}
|
||||
|
||||
static PyObject *NMFace_slice(C_NMFace *self, int begin, int end)
|
||||
static PyObject *NMFace_slice(BPy_NMFace *self, int begin, int end)
|
||||
{
|
||||
return PyList_GetSlice(self->v, begin, end); // new ref
|
||||
}
|
||||
@ -352,7 +352,7 @@ PyTypeObject NMFace_Type =
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
"NMFace", /*tp_name*/
|
||||
sizeof(C_NMFace), /*tp_basicsize*/
|
||||
sizeof(BPy_NMFace), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
/* methods */
|
||||
(destructor) NMFace_dealloc, /*tp_dealloc*/
|
||||
@ -367,9 +367,9 @@ PyTypeObject NMFace_Type =
|
||||
0, /*tp_hash*/
|
||||
};
|
||||
|
||||
static C_NMVert *newvert(float *co)
|
||||
static BPy_NMVert *newvert(float *co)
|
||||
{
|
||||
C_NMVert *mv = PyObject_NEW(C_NMVert, &NMVert_Type);
|
||||
BPy_NMVert *mv = PyObject_NEW(BPy_NMVert, &NMVert_Type);
|
||||
|
||||
mv->co[0] = co[0]; mv->co[1] = co[1]; mv->co[2] = co[2];
|
||||
|
||||
@ -397,7 +397,7 @@ static void NMVert_dealloc(PyObject *self)
|
||||
|
||||
static PyObject *NMVert_getattr(PyObject *self, char *name)
|
||||
{
|
||||
C_NMVert *mv = (C_NMVert *)self;
|
||||
BPy_NMVert *mv = (BPy_NMVert *)self;
|
||||
|
||||
if (!strcmp(name, "co") || !strcmp(name, "loc"))
|
||||
return newVectorObject(mv->co, 3);
|
||||
@ -411,7 +411,7 @@ static PyObject *NMVert_getattr(PyObject *self, char *name)
|
||||
|
||||
static int NMVert_setattr(PyObject *self, char *name, PyObject *v)
|
||||
{
|
||||
C_NMVert *mv = (C_NMVert *)self;
|
||||
BPy_NMVert *mv = (BPy_NMVert *)self;
|
||||
int i;
|
||||
|
||||
if (strcmp(name,"index") == 0) {
|
||||
@ -431,12 +431,12 @@ static int NMVert_setattr(PyObject *self, char *name, PyObject *v)
|
||||
return EXPP_ReturnIntError (PyExc_AttributeError, name);
|
||||
}
|
||||
|
||||
static int NMVert_len(C_NMVert *self)
|
||||
static int NMVert_len(BPy_NMVert *self)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
static PyObject *NMVert_item(C_NMVert *self, int i)
|
||||
static PyObject *NMVert_item(BPy_NMVert *self, int i)
|
||||
{
|
||||
if (i < 0 || i >= 3)
|
||||
return EXPP_ReturnPyObjError (PyExc_IndexError,
|
||||
@ -445,7 +445,7 @@ static PyObject *NMVert_item(C_NMVert *self, int i)
|
||||
return Py_BuildValue("f", self->co[i]);
|
||||
}
|
||||
|
||||
static PyObject *NMVert_slice(C_NMVert *self, int begin, int end)
|
||||
static PyObject *NMVert_slice(BPy_NMVert *self, int begin, int end)
|
||||
{
|
||||
PyObject *list;
|
||||
int count;
|
||||
@ -462,7 +462,7 @@ static PyObject *NMVert_slice(C_NMVert *self, int begin, int end)
|
||||
return list;
|
||||
}
|
||||
|
||||
static int NMVert_ass_item(C_NMVert *self, int i, PyObject *ob)
|
||||
static int NMVert_ass_item(BPy_NMVert *self, int i, PyObject *ob)
|
||||
{
|
||||
if (i < 0 || i >= 3)
|
||||
return EXPP_ReturnIntError (PyExc_IndexError,
|
||||
@ -477,7 +477,7 @@ static int NMVert_ass_item(C_NMVert *self, int i, PyObject *ob)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int NMVert_ass_slice(C_NMVert *self, int begin, int end, PyObject *seq)
|
||||
static int NMVert_ass_slice(BPy_NMVert *self, int begin, int end, PyObject *seq)
|
||||
{
|
||||
int count;
|
||||
|
||||
@ -523,7 +523,7 @@ PyTypeObject NMVert_Type =
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
"NMVert", /*tp_name*/
|
||||
sizeof(C_NMVert), /*tp_basicsize*/
|
||||
sizeof(BPy_NMVert), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
/* methods */
|
||||
(destructor) NMVert_dealloc, /*tp_dealloc*/
|
||||
@ -538,7 +538,7 @@ PyTypeObject NMVert_Type =
|
||||
|
||||
static void NMesh_dealloc(PyObject *self)
|
||||
{
|
||||
C_NMesh *me = (C_NMesh *)self;
|
||||
BPy_NMesh *me = (BPy_NMesh *)self;
|
||||
|
||||
Py_DECREF(me->name);
|
||||
Py_DECREF(me->verts);
|
||||
@ -549,7 +549,7 @@ static void NMesh_dealloc(PyObject *self)
|
||||
|
||||
static PyObject *NMesh_getSelectedFaces(PyObject *self, PyObject *args)
|
||||
{
|
||||
C_NMesh *nm = (C_NMesh *)self;
|
||||
BPy_NMesh *nm = (BPy_NMesh *)self;
|
||||
Mesh *me = nm->mesh;
|
||||
int flag = 0;
|
||||
|
||||
@ -581,15 +581,15 @@ static PyObject *NMesh_getSelectedFaces(PyObject *self, PyObject *args)
|
||||
|
||||
static PyObject *NMesh_getActiveFace(PyObject *self, PyObject *args)
|
||||
{
|
||||
if (((C_NMesh *)self)->sel_face < 0)
|
||||
if (((BPy_NMesh *)self)->sel_face < 0)
|
||||
return EXPP_incr_ret(Py_None);
|
||||
|
||||
return Py_BuildValue("i", ((C_NMesh *)self)->sel_face);
|
||||
return Py_BuildValue("i", ((BPy_NMesh *)self)->sel_face);
|
||||
}
|
||||
|
||||
static PyObject *NMesh_hasVertexUV(PyObject *self, PyObject *args)
|
||||
{
|
||||
C_NMesh *me = (C_NMesh *)self;
|
||||
BPy_NMesh *me = (BPy_NMesh *)self;
|
||||
int flag;
|
||||
|
||||
if (args) {
|
||||
@ -607,7 +607,7 @@ static PyObject *NMesh_hasVertexUV(PyObject *self, PyObject *args)
|
||||
|
||||
static PyObject *NMesh_hasFaceUV(PyObject *self, PyObject *args)
|
||||
{
|
||||
C_NMesh *me = (C_NMesh *)self;
|
||||
BPy_NMesh *me = (BPy_NMesh *)self;
|
||||
int flag = -1;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|i", &flag))
|
||||
@ -633,7 +633,7 @@ static PyObject *NMesh_hasFaceUV(PyObject *self, PyObject *args)
|
||||
|
||||
static PyObject *NMesh_hasVertexColours(PyObject *self, PyObject *args)
|
||||
{
|
||||
C_NMesh *me= (C_NMesh *)self;
|
||||
BPy_NMesh *me= (BPy_NMesh *)self;
|
||||
int flag = -1;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "|i", &flag))
|
||||
@ -659,7 +659,7 @@ static PyObject *NMesh_hasVertexColours(PyObject *self, PyObject *args)
|
||||
|
||||
static PyObject *NMesh_update(PyObject *self, PyObject *args)
|
||||
{
|
||||
C_NMesh *nmesh = (C_NMesh *)self;
|
||||
BPy_NMesh *nmesh = (BPy_NMesh *)self;
|
||||
Mesh *mesh = nmesh->mesh;
|
||||
|
||||
if (mesh) {
|
||||
@ -696,7 +696,7 @@ static PyObject *NMesh_getVertexInfluences(PyObject *self, PyObject *args)
|
||||
PyObject* influence_list = NULL;
|
||||
|
||||
/* Get a reference to the mesh object wrapped in here. */
|
||||
Mesh *me = ((C_NMesh*)self)->mesh;
|
||||
Mesh *me = ((BPy_NMesh*)self)->mesh;
|
||||
|
||||
/* Parse the parameters: only on integer (vertex index) */
|
||||
if (!PyArg_ParseTuple(args, "i", &index))
|
||||
@ -741,7 +741,7 @@ static PyObject *NMesh_getVertexInfluences(PyObject *self, PyObject *args)
|
||||
return influence_list; /* No need to incref it */
|
||||
}
|
||||
|
||||
Mesh *Mesh_fromNMesh(C_NMesh *nmesh)
|
||||
Mesh *Mesh_fromNMesh(BPy_NMesh *nmesh)
|
||||
{
|
||||
Mesh *mesh = NULL;
|
||||
mesh = add_mesh(); /* us == 1, should we zero it for all added objs ? */
|
||||
@ -758,7 +758,7 @@ Mesh *Mesh_fromNMesh(C_NMesh *nmesh)
|
||||
|
||||
PyObject *NMesh_link(PyObject *self, PyObject *args)
|
||||
{/*
|
||||
C_Object *bl_obj;
|
||||
BPy_Object *bl_obj;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!", &Object_Type, &bl_obj))
|
||||
return EXPP_ReturnPyErrorObj (PyExc_TypeError,
|
||||
@ -786,7 +786,7 @@ static struct PyMethodDef NMesh_methods[] =
|
||||
|
||||
static PyObject *NMesh_getattr(PyObject *self, char *name)
|
||||
{
|
||||
C_NMesh *me = (C_NMesh *)self;
|
||||
BPy_NMesh *me = (BPy_NMesh *)self;
|
||||
|
||||
if (strcmp(name, "name") == 0)
|
||||
return EXPP_incr_ret(me->name);
|
||||
@ -817,7 +817,7 @@ static PyObject *NMesh_getattr(PyObject *self, char *name)
|
||||
|
||||
static int NMesh_setattr(PyObject *self, char *name, PyObject *v)
|
||||
{
|
||||
C_NMesh *me = (C_NMesh *)self;
|
||||
BPy_NMesh *me = (BPy_NMesh *)self;
|
||||
|
||||
if (!strcmp(name, "verts") || !strcmp(name, "faces") ||
|
||||
!strcmp(name, "materials")) {
|
||||
@ -853,7 +853,7 @@ PyTypeObject NMesh_Type =
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /*ob_size*/
|
||||
"NMesh", /*tp_name*/
|
||||
sizeof(C_NMesh), /*tp_basicsize*/
|
||||
sizeof(BPy_NMesh), /*tp_basicsize*/
|
||||
0, /*tp_itemsize*/
|
||||
/* methods */
|
||||
(destructor) NMesh_dealloc, /*tp_dealloc*/
|
||||
@ -862,10 +862,10 @@ PyTypeObject NMesh_Type =
|
||||
(setattrfunc) NMesh_setattr, /*tp_setattr*/
|
||||
};
|
||||
|
||||
static C_NMFace *nmface_from_data(C_NMesh *mesh, int vidxs[4],
|
||||
static BPy_NMFace *nmface_from_data(BPy_NMesh *mesh, int vidxs[4],
|
||||
char mat_nr, char flag, TFace *tface, MCol *col)
|
||||
{
|
||||
C_NMFace *newf = PyObject_NEW (C_NMFace, &NMFace_Type);
|
||||
BPy_NMFace *newf = PyObject_NEW (BPy_NMFace, &NMFace_Type);
|
||||
int i, len;
|
||||
|
||||
if (vidxs[3]) len = 4;
|
||||
@ -916,7 +916,7 @@ static C_NMFace *nmface_from_data(C_NMesh *mesh, int vidxs[4],
|
||||
return newf;
|
||||
}
|
||||
|
||||
static C_NMFace *nmface_from_shortdata(C_NMesh *mesh,
|
||||
static BPy_NMFace *nmface_from_shortdata(BPy_NMesh *mesh,
|
||||
MFace *face, TFace *tface, MCol *col)
|
||||
{
|
||||
int vidxs[4];
|
||||
@ -928,7 +928,7 @@ static C_NMFace *nmface_from_shortdata(C_NMesh *mesh,
|
||||
return nmface_from_data(mesh, vidxs, face->mat_nr, face->flag, tface, col);
|
||||
}
|
||||
|
||||
static C_NMFace *nmface_from_intdata(C_NMesh *mesh,
|
||||
static BPy_NMFace *nmface_from_intdata(BPy_NMesh *mesh,
|
||||
MFaceInt *face, TFace *tface, MCol *col)
|
||||
{
|
||||
int vidxs[4];
|
||||
@ -940,10 +940,10 @@ static C_NMFace *nmface_from_intdata(C_NMesh *mesh,
|
||||
return nmface_from_data(mesh, vidxs, face->mat_nr, face->flag, tface, col);
|
||||
}
|
||||
|
||||
static C_NMVert *nmvert_from_data(C_NMesh *me,
|
||||
static BPy_NMVert *nmvert_from_data(BPy_NMesh *me,
|
||||
MVert *vert, MSticky *st, float *co, int idx)
|
||||
{
|
||||
C_NMVert *mv = PyObject_NEW(C_NMVert, &NMVert_Type);
|
||||
BPy_NMVert *mv = PyObject_NEW(BPy_NMVert, &NMVert_Type);
|
||||
|
||||
mv->co[0] = co[0]; mv->co[1] = co[1]; mv->co[2] = co[2];
|
||||
|
||||
@ -982,7 +982,7 @@ static int get_active_faceindex(Mesh *me)
|
||||
static PyObject *new_NMesh_internal(Mesh *oldmesh,
|
||||
DispListMesh *dlm, float *extverts)
|
||||
{
|
||||
C_NMesh *me = PyObject_NEW (C_NMesh, &NMesh_Type);
|
||||
BPy_NMesh *me = PyObject_NEW (BPy_NMesh, &NMesh_Type);
|
||||
me->flags = 0;
|
||||
|
||||
if (!oldmesh) {
|
||||
@ -1125,12 +1125,12 @@ static PyObject *M_NMesh_GetRawFromObject(PyObject *self, PyObject *args)
|
||||
else
|
||||
nmesh = new_NMesh(me);
|
||||
}
|
||||
((C_NMesh *) nmesh)->mesh = 0; // hack: to mark that (deformed) mesh is readonly,
|
||||
((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;
|
||||
}
|
||||
|
||||
static void mvert_from_data(MVert *mv, MSticky *st, C_NMVert *from)
|
||||
static void mvert_from_data(MVert *mv, MSticky *st, BPy_NMVert *from)
|
||||
{
|
||||
mv->co[0] = from->co[0]; mv->co[1] = from->co[1]; mv->co[2] = from->co[2];
|
||||
|
||||
@ -1151,7 +1151,7 @@ static void mvert_from_data(MVert *mv, MSticky *st, C_NMVert *from)
|
||||
* RGBA/BRGA confusion, it just works, but will never work with
|
||||
* a restructured Blender */
|
||||
|
||||
static void assign_perFaceColors(TFace *tf, C_NMFace *from)
|
||||
static void assign_perFaceColors(TFace *tf, BPy_NMFace *from)
|
||||
{
|
||||
MCol *col;
|
||||
int i;
|
||||
@ -1164,8 +1164,8 @@ static void assign_perFaceColors(TFace *tf, C_NMFace *from)
|
||||
if(len > 4) len = 4;
|
||||
|
||||
for (i = 0; i < len; i++, col++) {
|
||||
C_NMCol *mc = (C_NMCol *)PySequence_GetItem(from->col, i);
|
||||
if(!C_NMCol_Check(mc)) {
|
||||
BPy_NMCol *mc = (BPy_NMCol *)PySequence_GetItem(from->col, i);
|
||||
if(!BPy_NMCol_Check(mc)) {
|
||||
Py_DECREF(mc);
|
||||
continue;
|
||||
}
|
||||
@ -1180,7 +1180,7 @@ static void assign_perFaceColors(TFace *tf, C_NMFace *from)
|
||||
}
|
||||
}
|
||||
|
||||
static int assignFaceUV(TFace *tf, C_NMFace *nmface)
|
||||
static int assignFaceUV(TFace *tf, BPy_NMFace *nmface)
|
||||
{
|
||||
PyObject *fuv, *tmp;
|
||||
int i;
|
||||
@ -1210,29 +1210,29 @@ static int assignFaceUV(TFace *tf, C_NMFace *nmface)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void mface_from_data(MFace *mf, TFace *tf, MCol *col, C_NMFace *from)
|
||||
static void mface_from_data(MFace *mf, TFace *tf, MCol *col, BPy_NMFace *from)
|
||||
{
|
||||
C_NMVert *nmv;
|
||||
BPy_NMVert *nmv;
|
||||
|
||||
int i = PyList_Size(from->v);
|
||||
if(i >= 1) {
|
||||
nmv = (C_NMVert *)PyList_GetItem(from->v, 0);
|
||||
if (C_NMVert_Check(nmv) && nmv->index != -1) mf->v1 = nmv->index;
|
||||
nmv = (BPy_NMVert *)PyList_GetItem(from->v, 0);
|
||||
if (BPy_NMVert_Check(nmv) && nmv->index != -1) mf->v1 = nmv->index;
|
||||
else mf->v1 = 0;
|
||||
}
|
||||
if(i >= 2) {
|
||||
nmv = (C_NMVert *)PyList_GetItem(from->v, 1);
|
||||
if (C_NMVert_Check(nmv) && nmv->index != -1) mf->v2 = nmv->index;
|
||||
nmv = (BPy_NMVert *)PyList_GetItem(from->v, 1);
|
||||
if (BPy_NMVert_Check(nmv) && nmv->index != -1) mf->v2 = nmv->index;
|
||||
else mf->v2 = 0;
|
||||
}
|
||||
if(i >= 3) {
|
||||
nmv = (C_NMVert *)PyList_GetItem(from->v, 2);
|
||||
if (C_NMVert_Check(nmv) && nmv->index != -1) mf->v3 = nmv->index;
|
||||
nmv = (BPy_NMVert *)PyList_GetItem(from->v, 2);
|
||||
if (BPy_NMVert_Check(nmv) && nmv->index != -1) mf->v3 = nmv->index;
|
||||
else mf->v3= 0;
|
||||
}
|
||||
if(i >= 4) {
|
||||
nmv = (C_NMVert *)PyList_GetItem(from->v, 3);
|
||||
if (C_NMVert_Check(nmv) && nmv->index != -1) mf->v4 = nmv->index;
|
||||
nmv = (BPy_NMVert *)PyList_GetItem(from->v, 3);
|
||||
if (BPy_NMVert_Check(nmv) && nmv->index != -1) mf->v4 = nmv->index;
|
||||
else mf->v4= 0;
|
||||
}
|
||||
|
||||
@ -1264,8 +1264,8 @@ static void mface_from_data(MFace *mf, TFace *tf, MCol *col, C_NMFace *from)
|
||||
if(len > 4) len = 4;
|
||||
|
||||
for (i = 0; i < len; i++, col++) {
|
||||
C_NMCol *mc = (C_NMCol *) PySequence_GetItem(from->col, i);
|
||||
if(!C_NMCol_Check(mc)) {
|
||||
BPy_NMCol *mc = (BPy_NMCol *) PySequence_GetItem(from->col, i);
|
||||
if(!BPy_NMCol_Check(mc)) {
|
||||
Py_DECREF(mc);
|
||||
continue;
|
||||
}
|
||||
@ -1281,15 +1281,15 @@ static void mface_from_data(MFace *mf, TFace *tf, MCol *col, C_NMFace *from)
|
||||
}
|
||||
|
||||
/* check for a valid UV sequence */
|
||||
static int check_validFaceUV(C_NMesh *nmesh)
|
||||
static int check_validFaceUV(BPy_NMesh *nmesh)
|
||||
{
|
||||
PyObject *faces;
|
||||
C_NMFace *nmface;
|
||||
BPy_NMFace *nmface;
|
||||
int i, n;
|
||||
|
||||
faces = nmesh->faces;
|
||||
for (i = 0; i < PySequence_Length(faces); i++) {
|
||||
nmface = (C_NMFace *)PyList_GetItem(faces, i);
|
||||
nmface = (BPy_NMFace *)PyList_GetItem(faces, i);
|
||||
n = PySequence_Length(nmface->uv);
|
||||
if (n != PySequence_Length(nmface->v))
|
||||
{
|
||||
@ -1315,7 +1315,7 @@ static int unlink_existingMeshData(Mesh *mesh)
|
||||
return 1;
|
||||
}
|
||||
|
||||
Material **nmesh_updateMaterials(C_NMesh *nmesh)
|
||||
Material **nmesh_updateMaterials(BPy_NMesh *nmesh)
|
||||
{
|
||||
Material **matlist;
|
||||
Mesh *mesh = nmesh->mesh;
|
||||
@ -1338,7 +1338,7 @@ Material **nmesh_updateMaterials(C_NMesh *nmesh)
|
||||
return matlist;
|
||||
}
|
||||
|
||||
PyObject *NMesh_assignMaterials_toObject(C_NMesh *nmesh, Object *ob)
|
||||
PyObject *NMesh_assignMaterials_toObject(BPy_NMesh *nmesh, Object *ob)
|
||||
{
|
||||
BPy_Material *pymat;
|
||||
Material *ma;
|
||||
@ -1370,7 +1370,7 @@ PyObject *NMesh_assignMaterials_toObject(C_NMesh *nmesh, Object *ob)
|
||||
return EXPP_incr_ret (Py_None);
|
||||
}
|
||||
|
||||
static int convert_NMeshToMesh (Mesh *mesh, C_NMesh *nmesh)
|
||||
static int convert_NMeshToMesh (Mesh *mesh, BPy_NMesh *nmesh)
|
||||
{
|
||||
MFace *newmf;
|
||||
TFace *newtf;
|
||||
@ -1425,12 +1425,12 @@ static int convert_NMeshToMesh (Mesh *mesh, C_NMesh *nmesh)
|
||||
* index. - Zr
|
||||
*/
|
||||
for (i = 0; i < mesh->totface; i++) {
|
||||
C_NMFace *mf = (C_NMFace *)PySequence_GetItem(nmesh->faces, i);
|
||||
BPy_NMFace *mf = (BPy_NMFace *)PySequence_GetItem(nmesh->faces, i);
|
||||
|
||||
j = PySequence_Length(mf->v);
|
||||
while (j--) {
|
||||
C_NMVert *mv = (C_NMVert *)PySequence_GetItem(mf->v, j);
|
||||
if (C_NMVert_Check(mv)) mv->index = -1;
|
||||
BPy_NMVert *mv = (BPy_NMVert *)PySequence_GetItem(mf->v, j);
|
||||
if (BPy_NMVert_Check(mv)) mv->index = -1;
|
||||
Py_DECREF(mv);
|
||||
}
|
||||
|
||||
@ -1438,7 +1438,7 @@ static int convert_NMeshToMesh (Mesh *mesh, C_NMesh *nmesh)
|
||||
}
|
||||
|
||||
for (i = 0; i < mesh->totvert; i++) {
|
||||
C_NMVert *mv = (C_NMVert *)PySequence_GetItem(nmesh->verts, i);
|
||||
BPy_NMVert *mv = (BPy_NMVert *)PySequence_GetItem(nmesh->verts, i);
|
||||
mv->index = i;
|
||||
Py_DECREF(mv);
|
||||
}
|
||||
@ -1447,7 +1447,7 @@ static int convert_NMeshToMesh (Mesh *mesh, C_NMesh *nmesh)
|
||||
newst = mesh->msticky;
|
||||
for (i = 0; i < mesh->totvert; i++) {
|
||||
PyObject *mv = PySequence_GetItem (nmesh->verts, i);
|
||||
mvert_from_data(newmv, newst, (C_NMVert *)mv);
|
||||
mvert_from_data(newmv, newst, (BPy_NMVert *)mv);
|
||||
Py_DECREF(mv);
|
||||
|
||||
newmv++;
|
||||
@ -1466,7 +1466,7 @@ static int convert_NMeshToMesh (Mesh *mesh, C_NMesh *nmesh)
|
||||
newtf = mesh->tface;
|
||||
for (i = 0; i<mesh->totface; i++) {
|
||||
PyObject *mf = PySequence_GetItem(nmesh->faces, i);
|
||||
mface_from_data(newmf, newtf, newmc, (C_NMFace *) mf);
|
||||
mface_from_data(newmf, newtf, newmc, (BPy_NMFace *) mf);
|
||||
Py_DECREF(mf);
|
||||
|
||||
newtf++;
|
||||
@ -1482,7 +1482,7 @@ static int convert_NMeshToMesh (Mesh *mesh, C_NMesh *nmesh)
|
||||
|
||||
for (i = 0; i < mesh->totface; i++) {
|
||||
PyObject *mf = PySequence_GetItem(nmesh->faces, i);
|
||||
mface_from_data(newmf, 0, newmc, (C_NMFace *) mf);
|
||||
mface_from_data(newmf, 0, newmc, (BPy_NMFace *) mf);
|
||||
Py_DECREF(mf);
|
||||
|
||||
newmf++;
|
||||
@ -1497,7 +1497,7 @@ static PyObject *M_NMesh_PutRaw(PyObject *self, PyObject *args)
|
||||
char *name = NULL;
|
||||
Mesh *mesh = NULL;
|
||||
Object *ob = NULL;
|
||||
C_NMesh *nmesh;
|
||||
BPy_NMesh *nmesh;
|
||||
int recalc_normals = 1;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "O!|si",
|
||||
@ -1608,7 +1608,7 @@ static PyObject *M_NMesh_FaceModesDict (void)
|
||||
PyObject *FM = M_constant_New();
|
||||
|
||||
if (FM) {
|
||||
C_constant *d = (C_constant *)FM;
|
||||
BPy_constant *d = (BPy_constant *)FM;
|
||||
|
||||
constant_insert(d, "BILLBOARD", PyInt_FromLong(TF_BILLBOARD2));
|
||||
constant_insert(d, "ALL", PyInt_FromLong(0xffff));
|
||||
@ -1633,7 +1633,7 @@ static PyObject *M_NMesh_FaceFlagsDict (void)
|
||||
PyObject *FF = M_constant_New();
|
||||
|
||||
if (FF) {
|
||||
C_constant *d = (C_constant *)FF;
|
||||
BPy_constant *d = (BPy_constant *)FF;
|
||||
|
||||
EXPP_ADDCONST(d, SELECT);
|
||||
EXPP_ADDCONST(d, HIDE);
|
||||
@ -1648,7 +1648,7 @@ static PyObject *M_NMesh_FaceTranspModesDict (void)
|
||||
PyObject *FTM = M_constant_New();
|
||||
|
||||
if (FTM) {
|
||||
C_constant *d = (C_constant *)FTM;
|
||||
BPy_constant *d = (BPy_constant *)FTM;
|
||||
|
||||
EXPP_ADDCONST(d, SOLID);
|
||||
EXPP_ADDCONST(d, ADD);
|
||||
@ -1698,7 +1698,7 @@ int NMesh_CheckPyObject (PyObject *pyobj)
|
||||
Mesh *NMesh_FromPyObject (PyObject *pyobj)
|
||||
{
|
||||
if (pyobj->ob_type == &NMesh_Type)
|
||||
return Mesh_fromNMesh ((C_NMesh *)pyobj);
|
||||
return Mesh_fromNMesh ((BPy_NMesh *)pyobj);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -81,10 +81,10 @@ static PyObject *g_nmeshmodule = NULL;
|
||||
|
||||
/* Type checking for EXPP PyTypes */
|
||||
|
||||
#define C_NMesh_Check(v) ((v)->ob_type == &NMesh_Type)
|
||||
#define C_NMFace_Check(v) ((v)->ob_type == &NMFace_Type)
|
||||
#define C_NMVert_Check(v) ((v)->ob_type == &NMVert_Type)
|
||||
#define C_NMCol_Check(v) ((v)->ob_type == &NMCol_Type)
|
||||
#define BPy_NMesh_Check(v) ((v)->ob_type == &NMesh_Type)
|
||||
#define BPy_NMFace_Check(v) ((v)->ob_type == &NMFace_Type)
|
||||
#define BPy_NMVert_Check(v) ((v)->ob_type == &NMVert_Type)
|
||||
#define BPy_NMCol_Check(v) ((v)->ob_type == &NMCol_Type)
|
||||
|
||||
static char M_NMesh_doc[] =
|
||||
"The Blender.NMesh module";
|
||||
@ -164,7 +164,7 @@ typedef struct {
|
||||
PyObject_HEAD
|
||||
unsigned char r, g, b, a;
|
||||
|
||||
} C_NMCol; /* an NMesh color: [r,g,b,a] */
|
||||
} BPy_NMCol; /* an NMesh color: [r,g,b,a] */
|
||||
|
||||
typedef struct {
|
||||
PyObject_VAR_HEAD
|
||||
@ -173,7 +173,7 @@ typedef struct {
|
||||
float uvco[3];
|
||||
int index;
|
||||
|
||||
} C_NMVert; /* an NMesh vertex */
|
||||
} BPy_NMVert; /* an NMesh vertex */
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
@ -186,7 +186,7 @@ typedef struct {
|
||||
Image *image;
|
||||
char mat_nr, smooth;
|
||||
|
||||
} C_NMFace; /* an NMesh face */
|
||||
} BPy_NMFace; /* an NMesh face */
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
@ -202,17 +202,17 @@ typedef struct {
|
||||
#define NMESH_HASVERTUV 1<<1
|
||||
#define NMESH_HASFACEUV 1<<2
|
||||
|
||||
} C_NMesh;
|
||||
} BPy_NMesh;
|
||||
|
||||
/* PROTOS */
|
||||
extern void test_object_materials(ID *id); /* declared in BKE_material.h */
|
||||
static int unlink_existingMeshData(Mesh *mesh);
|
||||
static int convert_NMeshToMesh(Mesh *mesh, C_NMesh *nmesh);
|
||||
static int convert_NMeshToMesh(Mesh *mesh, BPy_NMesh *nmesh);
|
||||
void mesh_update(Mesh *mesh);
|
||||
PyObject *new_NMesh(Mesh *oldmesh);
|
||||
Mesh *Mesh_fromNMesh(C_NMesh *nmesh);
|
||||
PyObject *NMesh_assignMaterials_toObject(C_NMesh *nmesh, Object *ob);
|
||||
Material **nmesh_updateMaterials(C_NMesh *nmesh);
|
||||
Mesh *Mesh_fromNMesh(BPy_NMesh *nmesh);
|
||||
PyObject *NMesh_assignMaterials_toObject(BPy_NMesh *nmesh, Object *ob);
|
||||
Material **nmesh_updateMaterials(BPy_NMesh *nmesh);
|
||||
Material **newMaterialList_fromPyList (PyObject *list);
|
||||
void mesh_update(Mesh *mesh);
|
||||
|
||||
|
@ -76,37 +76,37 @@ struct PyMethodDef M_Object_methods[] = {
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_Object methods declarations: */
|
||||
/* Python BPy_Object methods declarations: */
|
||||
/*****************************************************************************/
|
||||
static PyObject *Object_clrParent (C_Object *self, PyObject *args);
|
||||
static PyObject *Object_getData (C_Object *self);
|
||||
static PyObject *Object_getDeformData (C_Object *self);
|
||||
static PyObject *Object_getDeltaLocation (C_Object *self);
|
||||
static PyObject *Object_getDrawMode (C_Object *self);
|
||||
static PyObject *Object_getDrawType (C_Object *self);
|
||||
static PyObject *Object_getEuler (C_Object *self);
|
||||
static PyObject *Object_getInverseMatrix (C_Object *self);
|
||||
static PyObject *Object_getLocation (C_Object *self, PyObject *args);
|
||||
static PyObject *Object_getMaterials (C_Object *self);
|
||||
static PyObject *Object_getMatrix (C_Object *self);
|
||||
static PyObject *Object_getParent (C_Object *self);
|
||||
static PyObject *Object_getTracked (C_Object *self);
|
||||
static PyObject *Object_getType (C_Object *self);
|
||||
static PyObject *Object_link (C_Object *self, PyObject *args);
|
||||
static PyObject *Object_makeParent (C_Object *self, PyObject *args);
|
||||
static PyObject *Object_materialUsage (C_Object *self, PyObject *args);
|
||||
static PyObject *Object_setDeltaLocation (C_Object *self, PyObject *args);
|
||||
static PyObject *Object_setDrawMode (C_Object *self, PyObject *args);
|
||||
static PyObject *Object_setDrawType (C_Object *self, PyObject *args);
|
||||
static PyObject *Object_setEuler (C_Object *self, PyObject *args);
|
||||
static PyObject *Object_setLocation (C_Object *self, PyObject *args);
|
||||
static PyObject *Object_setMaterials (C_Object *self, PyObject *args);
|
||||
static PyObject *Object_shareFrom (C_Object *self, PyObject *args);
|
||||
static PyObject *Object_clrParent (BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_getData (BPy_Object *self);
|
||||
static PyObject *Object_getDeformData (BPy_Object *self);
|
||||
static PyObject *Object_getDeltaLocation (BPy_Object *self);
|
||||
static PyObject *Object_getDrawMode (BPy_Object *self);
|
||||
static PyObject *Object_getDrawType (BPy_Object *self);
|
||||
static PyObject *Object_getEuler (BPy_Object *self);
|
||||
static PyObject *Object_getInverseMatrix (BPy_Object *self);
|
||||
static PyObject *Object_getLocation (BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_getMaterials (BPy_Object *self);
|
||||
static PyObject *Object_getMatrix (BPy_Object *self);
|
||||
static PyObject *Object_getParent (BPy_Object *self);
|
||||
static PyObject *Object_getTracked (BPy_Object *self);
|
||||
static PyObject *Object_getType (BPy_Object *self);
|
||||
static PyObject *Object_link (BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_makeParent (BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_materialUsage (BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_setDeltaLocation (BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_setDrawMode (BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_setDrawType (BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_setEuler (BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_setLocation (BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_setMaterials (BPy_Object *self, PyObject *args);
|
||||
static PyObject *Object_shareFrom (BPy_Object *self, PyObject *args);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_Object methods table: */
|
||||
/* Python BPy_Object methods table: */
|
||||
/*****************************************************************************/
|
||||
static PyMethodDef C_Object_methods[] = {
|
||||
static PyMethodDef BPy_Object_methods[] = {
|
||||
/* name, method, flags, doc */
|
||||
{"clrParent", (PyCFunction)Object_clrParent, METH_VARARGS,
|
||||
"Clears parent object. Optionally specify:\n\
|
||||
@ -182,11 +182,12 @@ works only if self and the object specified are of the same type."},
|
||||
/*****************************************************************************/
|
||||
/* PythonTypeObject callback function prototypes */
|
||||
/*****************************************************************************/
|
||||
static void ObjectDeAlloc (C_Object *obj);
|
||||
static int ObjectPrint (C_Object *obj, FILE *fp, int flags);
|
||||
static PyObject* ObjectGetAttr (C_Object *obj, char *name);
|
||||
static int ObjectSetAttr (C_Object *obj, char *name, PyObject *v);
|
||||
static PyObject* ObjectRepr (C_Object *obj);
|
||||
static void Object_dealloc (BPy_Object *obj);
|
||||
static int Object_print (BPy_Object *obj, FILE *fp, int flags);
|
||||
static PyObject* Object_getAttr (BPy_Object *obj, char *name);
|
||||
static int Object_setAttr (BPy_Object *obj, char *name, PyObject *v);
|
||||
static PyObject* Object_repr (BPy_Object *obj);
|
||||
static int Object_compare (BPy_Object *a, BPy_Object *b);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python TypeObject structure definition. */
|
||||
@ -195,16 +196,16 @@ PyTypeObject Object_Type =
|
||||
{
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
"Object", /* tp_name */
|
||||
sizeof (C_Object), /* tp_basicsize */
|
||||
"Blender Object", /* tp_name */
|
||||
sizeof (BPy_Object), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
/* methods */
|
||||
(destructor)ObjectDeAlloc, /* tp_dealloc */
|
||||
(printfunc)ObjectPrint, /* tp_print */
|
||||
(getattrfunc)ObjectGetAttr, /* tp_getattr */
|
||||
(setattrfunc)ObjectSetAttr, /* tp_setattr */
|
||||
0, /* tp_compare */
|
||||
(reprfunc)ObjectRepr, /* tp_repr */
|
||||
(destructor)Object_dealloc, /* tp_dealloc */
|
||||
(printfunc)Object_print, /* tp_print */
|
||||
(getattrfunc)Object_getAttr, /* tp_getattr */
|
||||
(setattrfunc)Object_setAttr, /* tp_setattr */
|
||||
(cmpfunc)Object_compare, /* tp_compare */
|
||||
(reprfunc)Object_repr, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
@ -212,7 +213,7 @@ PyTypeObject Object_Type =
|
||||
0,0,0,0,0,0,
|
||||
0, /* tp_doc */
|
||||
0,0,0,0,0,0,
|
||||
C_Object_methods, /* tp_methods */
|
||||
BPy_Object_methods, /* tp_methods */
|
||||
0, /* tp_members */
|
||||
};
|
||||
|
||||
@ -223,13 +224,11 @@ PyTypeObject Object_Type =
|
||||
PyObject *M_Object_New(PyObject *self, PyObject *args)
|
||||
{
|
||||
struct Object * object;
|
||||
C_Object * blen_object;
|
||||
BPy_Object * blen_object;
|
||||
int type;
|
||||
char * str_type;
|
||||
char * name = NULL;
|
||||
|
||||
printf ("In Object_New()\n");
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s|s", &str_type, &name))
|
||||
{
|
||||
PythonReturnErrorObject (PyExc_TypeError,
|
||||
@ -365,7 +364,7 @@ PyObject *M_Object_New(PyObject *self, PyObject *args)
|
||||
G.totobj++;
|
||||
|
||||
/* Create a Python object from it. */
|
||||
blen_object = (C_Object*)PyObject_NEW (C_Object, &Object_Type);
|
||||
blen_object = (BPy_Object*)PyObject_NEW (BPy_Object, &Object_Type);
|
||||
blen_object->object = object;
|
||||
blen_object->data = NULL;
|
||||
blen_object->parent = NULL;
|
||||
@ -382,13 +381,11 @@ PyObject *M_Object_Get(PyObject *self, PyObject *args)
|
||||
struct Object * object;
|
||||
char * name = NULL;
|
||||
|
||||
printf ("In Object_Get()\n");
|
||||
|
||||
PyArg_ParseTuple(args, "|s", &name);
|
||||
|
||||
if (name != NULL)
|
||||
{
|
||||
C_Object * blen_object;
|
||||
BPy_Object * blen_object;
|
||||
|
||||
object = GetObjectByName (name);
|
||||
|
||||
@ -398,7 +395,7 @@ PyObject *M_Object_Get(PyObject *self, PyObject *args)
|
||||
return (PythonReturnErrorObject (PyExc_AttributeError,
|
||||
"Unknown object specified."));
|
||||
}
|
||||
blen_object = (C_Object*)PyObject_NEW (C_Object, &Object_Type);
|
||||
blen_object = (BPy_Object*)PyObject_NEW (BPy_Object, &Object_Type);
|
||||
blen_object->object = object;
|
||||
blen_object->parent = NULL;
|
||||
blen_object->data = NULL;
|
||||
@ -446,7 +443,7 @@ PyObject *M_Object_Get(PyObject *self, PyObject *args)
|
||||
/*****************************************************************************/
|
||||
static PyObject *M_Object_GetSelected (PyObject *self, PyObject *args)
|
||||
{
|
||||
C_Object * blen_object;
|
||||
BPy_Object * blen_object;
|
||||
PyObject * list;
|
||||
Base * base_iter;
|
||||
|
||||
@ -458,7 +455,7 @@ static PyObject *M_Object_GetSelected (PyObject *self, PyObject *args)
|
||||
(G.scene->basact->lay & G.vd->lay)))
|
||||
{
|
||||
/* Active object is first in the list. */
|
||||
blen_object = (C_Object*)PyObject_NEW (C_Object, &Object_Type);
|
||||
blen_object = (BPy_Object*)PyObject_NEW (BPy_Object, &Object_Type);
|
||||
if (blen_object == NULL)
|
||||
{
|
||||
Py_DECREF (list);
|
||||
@ -477,7 +474,7 @@ static PyObject *M_Object_GetSelected (PyObject *self, PyObject *args)
|
||||
(base_iter->lay & G.vd->lay)) &&
|
||||
(base_iter != G.scene->basact))
|
||||
{
|
||||
blen_object = (C_Object*)PyObject_NEW (C_Object, &Object_Type);
|
||||
blen_object = (BPy_Object*)PyObject_NEW (BPy_Object, &Object_Type);
|
||||
if (blen_object == NULL)
|
||||
{
|
||||
Py_DECREF (list);
|
||||
@ -496,23 +493,21 @@ static PyObject *M_Object_GetSelected (PyObject *self, PyObject *args)
|
||||
/*****************************************************************************/
|
||||
/* Function: initObject */
|
||||
/*****************************************************************************/
|
||||
PyObject *M_Object_Init (void)
|
||||
PyObject *Object_Init (void)
|
||||
{
|
||||
PyObject * module;
|
||||
|
||||
printf ("In initObject()\n");
|
||||
|
||||
Object_Type.ob_type = &PyType_Type;
|
||||
|
||||
module = Py_InitModule3("Object", M_Object_methods, M_Object_doc);
|
||||
module = Py_InitModule3("Blender.Object", M_Object_methods, M_Object_doc);
|
||||
|
||||
return (module);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_Object methods: */
|
||||
/* Python BPy_Object methods: */
|
||||
/*****************************************************************************/
|
||||
static PyObject *Object_clrParent (C_Object *self, PyObject *args)
|
||||
static PyObject *Object_clrParent (BPy_Object *self, PyObject *args)
|
||||
{
|
||||
int mode=0;
|
||||
int fast=0;
|
||||
@ -541,7 +536,7 @@ static PyObject *Object_clrParent (C_Object *self, PyObject *args)
|
||||
return (Py_None);
|
||||
}
|
||||
|
||||
static PyObject *Object_getData (C_Object *self)
|
||||
static PyObject *Object_getData (BPy_Object *self)
|
||||
{
|
||||
PyObject * data_object;
|
||||
//# int obj_id;
|
||||
@ -569,7 +564,7 @@ static PyObject *Object_getData (C_Object *self)
|
||||
switch (self->object->type)//#obj_id)
|
||||
{
|
||||
case OB_ARMATURE://#ID_AR:
|
||||
data_object = M_ArmatureCreatePyObject (self->object->data);
|
||||
data_object = Armature_CreatePyObject (self->object->data);
|
||||
break;
|
||||
case OB_CAMERA://#ID_CA:
|
||||
data_object = Camera_CreatePyObject (self->object->data);
|
||||
@ -591,7 +586,7 @@ static PyObject *Object_getData (C_Object *self)
|
||||
data_object = NMesh_CreatePyObject (self->object->data);
|
||||
break;
|
||||
case ID_OB:
|
||||
data_object = M_ObjectCreatePyObject (self->object->data);
|
||||
data_object = Object_CreatePyObject (self->object->data);
|
||||
break;
|
||||
case ID_SCE:
|
||||
break;
|
||||
@ -615,13 +610,13 @@ static PyObject *Object_getData (C_Object *self)
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *Object_getDeformData (C_Object *self)
|
||||
static PyObject *Object_getDeformData (BPy_Object *self)
|
||||
{
|
||||
return (PythonReturnErrorObject (PyExc_NotImplementedError,
|
||||
"getDeformData: not yet implemented"));
|
||||
}
|
||||
|
||||
static PyObject *Object_getDeltaLocation (C_Object *self)
|
||||
static PyObject *Object_getDeltaLocation (BPy_Object *self)
|
||||
{
|
||||
PyObject *attr = Py_BuildValue ("fff",
|
||||
self->object->dloc[0],
|
||||
@ -634,7 +629,7 @@ static PyObject *Object_getDeltaLocation (C_Object *self)
|
||||
"couldn't get Object.dloc attributes"));
|
||||
}
|
||||
|
||||
static PyObject *Object_getDrawMode (C_Object *self)
|
||||
static PyObject *Object_getDrawMode (BPy_Object *self)
|
||||
{
|
||||
PyObject *attr = Py_BuildValue ("b", self->object->dtx);
|
||||
|
||||
@ -644,7 +639,7 @@ static PyObject *Object_getDrawMode (C_Object *self)
|
||||
"couldn't get Object.drawMode attribute"));
|
||||
}
|
||||
|
||||
static PyObject *Object_getDrawType (C_Object *self)
|
||||
static PyObject *Object_getDrawType (BPy_Object *self)
|
||||
{
|
||||
PyObject *attr = Py_BuildValue ("b", self->object->dt);
|
||||
|
||||
@ -654,7 +649,7 @@ static PyObject *Object_getDrawType (C_Object *self)
|
||||
"couldn't get Object.drawType attribute"));
|
||||
}
|
||||
|
||||
static PyObject *Object_getEuler (C_Object *self)
|
||||
static PyObject *Object_getEuler (BPy_Object *self)
|
||||
{
|
||||
PyObject *attr = Py_BuildValue ("fff",
|
||||
self->object->drot[0],
|
||||
@ -667,7 +662,7 @@ static PyObject *Object_getEuler (C_Object *self)
|
||||
"couldn't get Object.drot attributes"));
|
||||
}
|
||||
|
||||
static PyObject *Object_getInverseMatrix (C_Object *self)
|
||||
static PyObject *Object_getInverseMatrix (BPy_Object *self)
|
||||
{
|
||||
Object * ob;
|
||||
float inverse[4][4];
|
||||
@ -678,7 +673,7 @@ static PyObject *Object_getInverseMatrix (C_Object *self)
|
||||
return (newMatrixObject (inverse));
|
||||
}
|
||||
|
||||
static PyObject *Object_getLocation (C_Object *self, PyObject *args)
|
||||
static PyObject *Object_getLocation (BPy_Object *self, PyObject *args)
|
||||
{
|
||||
PyObject *attr = Py_BuildValue ("fff",
|
||||
self->object->loc[0],
|
||||
@ -691,14 +686,14 @@ static PyObject *Object_getLocation (C_Object *self, PyObject *args)
|
||||
"couldn't get Object.loc attributes"));
|
||||
}
|
||||
|
||||
static PyObject *Object_getMaterials (C_Object *self)
|
||||
static PyObject *Object_getMaterials (BPy_Object *self)
|
||||
{
|
||||
/* TODO: Implement when the Material module is implemented. */
|
||||
return (PythonReturnErrorObject (PyExc_NotImplementedError,
|
||||
"getMaterials: not yet implemented"));
|
||||
}
|
||||
|
||||
static PyObject *Object_getMatrix (C_Object *self)
|
||||
static PyObject *Object_getMatrix (BPy_Object *self)
|
||||
{
|
||||
Object * ob;
|
||||
|
||||
@ -707,7 +702,7 @@ static PyObject *Object_getMatrix (C_Object *self)
|
||||
return (newMatrixObject (ob->obmat));
|
||||
}
|
||||
|
||||
static PyObject *Object_getParent (C_Object *self)
|
||||
static PyObject *Object_getParent (BPy_Object *self)
|
||||
{
|
||||
PyObject *attr;
|
||||
|
||||
@ -721,11 +716,11 @@ static PyObject *Object_getParent (C_Object *self)
|
||||
{
|
||||
return (EXPP_incr_ret (Py_None));
|
||||
}
|
||||
attr = M_ObjectCreatePyObject (self->object->parent);
|
||||
attr = Object_CreatePyObject (self->object->parent);
|
||||
|
||||
if (attr)
|
||||
{
|
||||
self->parent = (struct C_Object*)attr;
|
||||
self->parent = (struct BPy_Object*)attr;
|
||||
return (attr);
|
||||
}
|
||||
|
||||
@ -733,7 +728,7 @@ static PyObject *Object_getParent (C_Object *self)
|
||||
"couldn't get Object.parent attribute"));
|
||||
}
|
||||
|
||||
static PyObject *Object_getTracked (C_Object *self)
|
||||
static PyObject *Object_getTracked (BPy_Object *self)
|
||||
{
|
||||
PyObject *attr;
|
||||
|
||||
@ -744,11 +739,11 @@ static PyObject *Object_getTracked (C_Object *self)
|
||||
}
|
||||
|
||||
/* TODO: what if self->object->track==NULL? Should we return Py_None? */
|
||||
attr = M_ObjectCreatePyObject (self->object->track);
|
||||
attr = Object_CreatePyObject (self->object->track);
|
||||
|
||||
if (attr)
|
||||
{
|
||||
self->track = (struct C_Object*)attr;
|
||||
self->track = (struct BPy_Object*)attr;
|
||||
return (attr);
|
||||
}
|
||||
|
||||
@ -756,7 +751,7 @@ static PyObject *Object_getTracked (C_Object *self)
|
||||
"couldn't get Object.track attribute"));
|
||||
}
|
||||
|
||||
static PyObject *Object_getType (C_Object *self)
|
||||
static PyObject *Object_getType (BPy_Object *self)
|
||||
{
|
||||
switch (self->object->type)
|
||||
{
|
||||
@ -776,7 +771,7 @@ static PyObject *Object_getType (C_Object *self)
|
||||
}
|
||||
}
|
||||
|
||||
static PyObject *Object_link (C_Object *self, PyObject *args)
|
||||
static PyObject *Object_link (BPy_Object *self, PyObject *args)
|
||||
{
|
||||
PyObject * py_data;
|
||||
ID * id;
|
||||
@ -844,11 +839,11 @@ static PyObject *Object_link (C_Object *self, PyObject *args)
|
||||
return (Py_None);
|
||||
}
|
||||
|
||||
static PyObject *Object_makeParent (C_Object *self, PyObject *args)
|
||||
static PyObject *Object_makeParent (BPy_Object *self, PyObject *args)
|
||||
{
|
||||
PyObject * list;
|
||||
PyObject * py_child;
|
||||
C_Object * py_obj_child;
|
||||
BPy_Object * py_obj_child;
|
||||
Object * child;
|
||||
Object * parent;
|
||||
int noninverse;
|
||||
@ -872,8 +867,8 @@ static PyObject *Object_makeParent (C_Object *self, PyObject *args)
|
||||
{
|
||||
child = NULL;
|
||||
py_child = PySequence_GetItem (list, i);
|
||||
if (M_ObjectCheckPyObject (py_child))
|
||||
child = (Object*) M_ObjectFromPyObject (py_child);
|
||||
if (Object_CheckPyObject (py_child))
|
||||
child = (Object*) Object_FromPyObject (py_child);
|
||||
|
||||
if (child == NULL)
|
||||
{
|
||||
@ -889,8 +884,8 @@ static PyObject *Object_makeParent (C_Object *self, PyObject *args)
|
||||
}
|
||||
child->partype = PAROBJECT;
|
||||
child->parent = parent;
|
||||
py_obj_child = (C_Object *) py_child;
|
||||
py_obj_child->parent = (struct C_Object *)self;
|
||||
py_obj_child = (BPy_Object *) py_child;
|
||||
py_obj_child->parent = (struct BPy_Object *)self;
|
||||
if (noninverse == 1)
|
||||
{
|
||||
/* Parent inverse = unity */
|
||||
@ -915,13 +910,13 @@ static PyObject *Object_makeParent (C_Object *self, PyObject *args)
|
||||
return (Py_None);
|
||||
}
|
||||
|
||||
static PyObject *Object_materialUsage (C_Object *self, PyObject *args)
|
||||
static PyObject *Object_materialUsage (BPy_Object *self, PyObject *args)
|
||||
{
|
||||
return (PythonReturnErrorObject (PyExc_NotImplementedError,
|
||||
"materialUsage: not yet implemented"));
|
||||
}
|
||||
|
||||
static PyObject *Object_setDeltaLocation (C_Object *self, PyObject *args)
|
||||
static PyObject *Object_setDeltaLocation (BPy_Object *self, PyObject *args)
|
||||
{
|
||||
float dloc1;
|
||||
float dloc2;
|
||||
@ -941,7 +936,7 @@ static PyObject *Object_setDeltaLocation (C_Object *self, PyObject *args)
|
||||
return (Py_None);
|
||||
}
|
||||
|
||||
static PyObject *Object_setDrawMode (C_Object *self, PyObject *args)
|
||||
static PyObject *Object_setDrawMode (BPy_Object *self, PyObject *args)
|
||||
{
|
||||
char dt;
|
||||
|
||||
@ -956,7 +951,7 @@ static PyObject *Object_setDrawMode (C_Object *self, PyObject *args)
|
||||
return (Py_None);
|
||||
}
|
||||
|
||||
static PyObject *Object_setDrawType (C_Object *self, PyObject *args)
|
||||
static PyObject *Object_setDrawType (BPy_Object *self, PyObject *args)
|
||||
{
|
||||
char dtx;
|
||||
|
||||
@ -971,7 +966,7 @@ static PyObject *Object_setDrawType (C_Object *self, PyObject *args)
|
||||
return (Py_None);
|
||||
}
|
||||
|
||||
static PyObject *Object_setEuler (C_Object *self, PyObject *args)
|
||||
static PyObject *Object_setEuler (BPy_Object *self, PyObject *args)
|
||||
{
|
||||
float drot1;
|
||||
float drot2;
|
||||
@ -991,7 +986,7 @@ static PyObject *Object_setEuler (C_Object *self, PyObject *args)
|
||||
return (Py_None);
|
||||
}
|
||||
|
||||
static PyObject *Object_setLocation (C_Object *self, PyObject *args)
|
||||
static PyObject *Object_setLocation (BPy_Object *self, PyObject *args)
|
||||
{
|
||||
float loc1;
|
||||
float loc2;
|
||||
@ -1011,7 +1006,7 @@ static PyObject *Object_setLocation (C_Object *self, PyObject *args)
|
||||
return (Py_None);
|
||||
}
|
||||
|
||||
static PyObject *Object_setMaterials (C_Object *self, PyObject *args)
|
||||
static PyObject *Object_setMaterials (BPy_Object *self, PyObject *args)
|
||||
{
|
||||
#if 0
|
||||
PyObject * list;
|
||||
@ -1075,9 +1070,9 @@ static PyObject *Object_setMaterials (C_Object *self, PyObject *args)
|
||||
"setMaterials: not yet implemented"));
|
||||
}
|
||||
|
||||
static PyObject *Object_shareFrom (C_Object *self, PyObject *args)
|
||||
static PyObject *Object_shareFrom (BPy_Object *self, PyObject *args)
|
||||
{
|
||||
C_Object * object;
|
||||
BPy_Object * object;
|
||||
ID * id;
|
||||
ID * oldid;
|
||||
|
||||
@ -1087,7 +1082,7 @@ static PyObject *Object_shareFrom (C_Object *self, PyObject *args)
|
||||
"expected an object argument");
|
||||
return (NULL);
|
||||
}
|
||||
if (!M_ObjectCheckPyObject ((PyObject*)object))
|
||||
if (!Object_CheckPyObject ((PyObject*)object))
|
||||
{
|
||||
PythonReturnErrorObject (PyExc_TypeError,
|
||||
"argument 1 is not of type 'Object'");
|
||||
@ -1135,17 +1130,15 @@ static PyObject *Object_shareFrom (C_Object *self, PyObject *args)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_ObjectCreatePyObject */
|
||||
/* Function: Object_CreatePyObject */
|
||||
/* Description: This function will create a new BlenObject from an existing */
|
||||
/* Object structure. */
|
||||
/*****************************************************************************/
|
||||
PyObject* M_ObjectCreatePyObject (struct Object *obj)
|
||||
PyObject* Object_CreatePyObject (struct Object *obj)
|
||||
{
|
||||
C_Object * blen_object;
|
||||
BPy_Object * blen_object;
|
||||
|
||||
printf ("In M_ObjectCreatePyObject\n");
|
||||
|
||||
blen_object = (C_Object*)PyObject_NEW (C_Object, &Object_Type);
|
||||
blen_object = (BPy_Object*)PyObject_NEW (BPy_Object, &Object_Type);
|
||||
|
||||
if (blen_object == NULL)
|
||||
{
|
||||
@ -1156,45 +1149,45 @@ PyObject* M_ObjectCreatePyObject (struct Object *obj)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_ObjectCheckPyObject */
|
||||
/* Function: Object_CheckPyObject */
|
||||
/* Description: This function returns true when the given PyObject is of the */
|
||||
/* type Object. Otherwise it will return false. */
|
||||
/*****************************************************************************/
|
||||
int M_ObjectCheckPyObject (PyObject *py_obj)
|
||||
int Object_CheckPyObject (PyObject *py_obj)
|
||||
{
|
||||
return (py_obj->ob_type == &Object_Type);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_ObjectFromPyObject */
|
||||
/* Function: Object_FromPyObject */
|
||||
/* Description: This function returns the Blender object from the given */
|
||||
/* PyObject. */
|
||||
/*****************************************************************************/
|
||||
struct Object* M_ObjectFromPyObject (PyObject *py_obj)
|
||||
struct Object* Object_FromPyObject (PyObject *py_obj)
|
||||
{
|
||||
C_Object * blen_obj;
|
||||
BPy_Object * blen_obj;
|
||||
|
||||
blen_obj = (C_Object*)py_obj;
|
||||
blen_obj = (BPy_Object*)py_obj;
|
||||
return (blen_obj->object);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: ObjectDeAlloc */
|
||||
/* Function: Object_dealloc */
|
||||
/* Description: This is a callback function for the BlenObject type. It is */
|
||||
/* the destructor function. */
|
||||
/*****************************************************************************/
|
||||
static void ObjectDeAlloc (C_Object *obj)
|
||||
static void Object_dealloc (BPy_Object *obj)
|
||||
{
|
||||
PyObject_DEL (obj);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: ObjectGetAttr */
|
||||
/* Function: Object_getAttr */
|
||||
/* Description: This is a callback function for the BlenObject type. It is */
|
||||
/* the function that retrieves any value from Blender and */
|
||||
/* passes it to Python. */
|
||||
/*****************************************************************************/
|
||||
static PyObject* ObjectGetAttr (C_Object *obj, char *name)
|
||||
static PyObject* Object_getAttr (BPy_Object *obj, char *name)
|
||||
{
|
||||
struct Object * object;
|
||||
struct Ika * ika;
|
||||
@ -1277,9 +1270,9 @@ static PyObject* ObjectGetAttr (C_Object *obj, char *name)
|
||||
if (StringEqual (name, "Layer"))
|
||||
return (PyInt_FromLong(object->lay));
|
||||
if (StringEqual (name, "parent"))
|
||||
return (M_ObjectCreatePyObject (object->parent));
|
||||
return (Object_CreatePyObject (object->parent));
|
||||
if (StringEqual (name, "track"))
|
||||
return (M_ObjectCreatePyObject (object->track));
|
||||
return (Object_CreatePyObject (object->track));
|
||||
if (StringEqual (name, "data"))
|
||||
return (Object_getData (obj));
|
||||
if (StringEqual (name, "ipo"))
|
||||
@ -1302,16 +1295,16 @@ static PyObject* ObjectGetAttr (C_Object *obj, char *name)
|
||||
return (Py_BuildValue ("b", object->dtx));
|
||||
|
||||
/* not an attribute, search the methods table */
|
||||
return Py_FindMethod(C_Object_methods, (PyObject *)obj, name);
|
||||
return Py_FindMethod(BPy_Object_methods, (PyObject *)obj, name);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: ObjectSetAttr */
|
||||
/* Function: Object_setAttr */
|
||||
/* Description: This is a callback function for the BlenObject type. It is */
|
||||
/* the function that retrieves any value from Python and sets */
|
||||
/* it accordingly in Blender. */
|
||||
/*****************************************************************************/
|
||||
static int ObjectSetAttr (C_Object *obj, char *name, PyObject *value)
|
||||
static int Object_setAttr (BPy_Object *obj, char *name, PyObject *value)
|
||||
{
|
||||
struct Object * object;
|
||||
struct Ika * ika;
|
||||
@ -1469,22 +1462,36 @@ static int ObjectSetAttr (C_Object *obj, char *name, PyObject *value)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: ObjectPrint */
|
||||
/* Description: This is a callback function for the C_Object type. It */
|
||||
/* Function: Object_compare */
|
||||
/* Description: This is a callback function for the BPy_Object type. It */
|
||||
/* compares two Object_Type objects. Only the "==" and "!=" */
|
||||
/* comparisons are meaninful. Returns 0 for equality and -1 if */
|
||||
/* they don't point to the same Blender Object struct. */
|
||||
/* In Python it becomes 1 if they are equal, 0 otherwise. */
|
||||
/*****************************************************************************/
|
||||
static int Object_compare (BPy_Object *a, BPy_Object *b)
|
||||
{
|
||||
Object *pa = a->object, *pb = b->object;
|
||||
return (pa == pb) ? 0:-1;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: Object_print */
|
||||
/* Description: This is a callback function for the BPy_Object type. It */
|
||||
/* builds a meaninful string to 'print' object objects. */
|
||||
/*****************************************************************************/
|
||||
static int ObjectPrint(C_Object *self, FILE *fp, int flags)
|
||||
static int Object_print(BPy_Object *self, FILE *fp, int flags)
|
||||
{
|
||||
fprintf(fp, "[Object \"%s\"]", self->object->id.name+2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: ObjectRepr */
|
||||
/* Description: This is a callback function for the C_Object type. It */
|
||||
/* Function: Object_repr */
|
||||
/* Description: This is a callback function for the BPy_Object type. It */
|
||||
/* builds a meaninful string to represent object objects. */
|
||||
/*****************************************************************************/
|
||||
static PyObject *ObjectRepr (C_Object *self)
|
||||
static PyObject *Object_repr (BPy_Object *self)
|
||||
{
|
||||
return PyString_FromString(self->object->id.name+2);
|
||||
}
|
||||
|
@ -60,13 +60,13 @@
|
||||
/* The Object PyType Object defined in Object.c */
|
||||
extern PyTypeObject Object_Type;
|
||||
|
||||
#define C_Object_Check(v) \
|
||||
#define BPy_Object_Check(v) \
|
||||
((v)->ob_type == &Object_Type) /* for type checking */
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_Object structure definition. */
|
||||
/* Python BPy_Object structure definition. */
|
||||
/*****************************************************************************/
|
||||
struct C_Object;
|
||||
struct BPy_Object;
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
@ -78,11 +78,11 @@ typedef struct {
|
||||
|
||||
/* points to the parent object. This is only set when there's a valid */
|
||||
/* PyObject (already created at some point). */
|
||||
struct C_Object * parent;
|
||||
struct BPy_Object * parent;
|
||||
|
||||
/* points to the object that is tracking this object. This is only set */
|
||||
/* when there's a valid PyObject (already created at some point). */
|
||||
struct C_Object * track;
|
||||
} C_Object;
|
||||
struct BPy_Object * track;
|
||||
} BPy_Object;
|
||||
|
||||
#endif /* EXPP_OBJECT_H */
|
||||
|
@ -254,9 +254,9 @@ PyObject *M_Particle_Get(PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_Particle_Init */
|
||||
/* Function: Particle_Init */
|
||||
/*****************************************************************************/
|
||||
PyObject *M_Particle_Init (void)
|
||||
PyObject *Particle_Init (void)
|
||||
{
|
||||
PyObject *submodule;
|
||||
Particle_Type.ob_type = &PyType_Type;
|
||||
|
@ -162,12 +162,12 @@ static PyMethodDef BPy_Scene_methods[] = {
|
||||
/*****************************************************************************/
|
||||
/* Python Scene_Type callback function prototypes: */
|
||||
/*****************************************************************************/
|
||||
static void Scene_DeAlloc (BPy_Scene *self);
|
||||
static int Scene_Print (BPy_Scene *self, FILE *fp, int flags);
|
||||
static int Scene_SetAttr (BPy_Scene *self, char *name, PyObject *v);
|
||||
static int Scene_Compare (BPy_Scene *a, BPy_Scene *b);
|
||||
static PyObject *Scene_GetAttr (BPy_Scene *self, char *name);
|
||||
static PyObject *Scene_Repr (BPy_Scene *self);
|
||||
static void Scene_dealloc (BPy_Scene *self);
|
||||
static int Scene_print (BPy_Scene *self, FILE *fp, int flags);
|
||||
static int Scene_setAttr (BPy_Scene *self, char *name, PyObject *v);
|
||||
static int Scene_compare (BPy_Scene *a, BPy_Scene *b);
|
||||
static PyObject *Scene_getAttr (BPy_Scene *self, char *name);
|
||||
static PyObject *Scene_repr (BPy_Scene *self);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python Scene_Type structure definition: */
|
||||
@ -180,12 +180,12 @@ PyTypeObject Scene_Type =
|
||||
sizeof (BPy_Scene), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
/* methods */
|
||||
(destructor)Scene_DeAlloc, /* tp_dealloc */
|
||||
(printfunc)Scene_Print, /* tp_print */
|
||||
(getattrfunc)Scene_GetAttr, /* tp_getattr */
|
||||
(setattrfunc)Scene_SetAttr, /* tp_setattr */
|
||||
(cmpfunc)Scene_Compare, /* tp_compare */
|
||||
(reprfunc)Scene_Repr, /* tp_repr */
|
||||
(destructor)Scene_dealloc, /* tp_dealloc */
|
||||
(printfunc)Scene_print, /* tp_print */
|
||||
(getattrfunc)Scene_getAttr, /* tp_getattr */
|
||||
(setattrfunc)Scene_setAttr, /* tp_setattr */
|
||||
(cmpfunc)Scene_compare, /* tp_compare */
|
||||
(reprfunc)Scene_repr, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
0, /* tp_as_mapping */
|
||||
@ -204,8 +204,6 @@ static PyObject *M_Scene_New(PyObject *self, PyObject *args, PyObject *kword)
|
||||
PyObject *pyscene; /* for the Scene object wrapper in Python */
|
||||
Scene *blscene; /* for the actual Scene we create in Blender */
|
||||
|
||||
printf ("In Scene_New()\n");
|
||||
|
||||
if (!PyArg_ParseTupleAndKeywords(args, kword, "|s", kw, &name))
|
||||
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"expected a string or an empty argument list"));
|
||||
@ -315,8 +313,6 @@ PyObject *Scene_Init (void)
|
||||
{
|
||||
PyObject *submodule;
|
||||
|
||||
printf ("In M_Scene_Init()\n");
|
||||
|
||||
Scene_Type.ob_type = &PyType_Type;
|
||||
|
||||
submodule = Py_InitModule3("Blender.Scene",
|
||||
@ -464,7 +460,7 @@ static PyObject *Scene_update (BPy_Scene *self)
|
||||
static PyObject *Scene_link (BPy_Scene *self, PyObject *args)
|
||||
{
|
||||
Scene *scene = self->scene;
|
||||
C_Object *bpy_obj; /* XXX Change to BPy or whatever is chosen */
|
||||
BPy_Object *bpy_obj; /* XXX Change to BPy or whatever is chosen */
|
||||
|
||||
if (!scene)
|
||||
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
@ -511,7 +507,7 @@ static PyObject *Scene_link (BPy_Scene *self, PyObject *args)
|
||||
|
||||
static PyObject *Scene_unlink (BPy_Scene *self, PyObject *args)
|
||||
{
|
||||
C_Object *bpy_obj = NULL;
|
||||
BPy_Object *bpy_obj = NULL;
|
||||
Object *object;
|
||||
Scene *scene = self->scene;
|
||||
Base *base;
|
||||
@ -638,7 +634,7 @@ static PyObject *Scene_getCurrentCamera (BPy_Scene *self)
|
||||
static PyObject *Scene_setCurrentCamera (BPy_Scene *self, PyObject *args)
|
||||
{
|
||||
Object *object;
|
||||
C_Object *cam_obj;
|
||||
BPy_Object *cam_obj;
|
||||
Scene *scene = self->scene;
|
||||
|
||||
if (!scene)
|
||||
@ -663,12 +659,12 @@ static PyObject *Scene_setCurrentCamera (BPy_Scene *self, PyObject *args)
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
static void Scene_DeAlloc (BPy_Scene *self)
|
||||
static void Scene_dealloc (BPy_Scene *self)
|
||||
{
|
||||
PyObject_DEL (self);
|
||||
}
|
||||
|
||||
static PyObject *Scene_GetAttr (BPy_Scene *self, char *name)
|
||||
static PyObject *Scene_getAttr (BPy_Scene *self, char *name)
|
||||
{
|
||||
PyObject *attr = Py_None;
|
||||
|
||||
@ -689,7 +685,7 @@ static PyObject *Scene_GetAttr (BPy_Scene *self, char *name)
|
||||
return Py_FindMethod(BPy_Scene_methods, (PyObject *)self, name);
|
||||
}
|
||||
|
||||
static int Scene_SetAttr (BPy_Scene *self, char *name, PyObject *value)
|
||||
static int Scene_setAttr (BPy_Scene *self, char *name, PyObject *value)
|
||||
{
|
||||
PyObject *valtuple;
|
||||
PyObject *error = NULL;
|
||||
@ -728,19 +724,19 @@ static int Scene_SetAttr (BPy_Scene *self, char *name, PyObject *value)
|
||||
return 0; /* normal exit */
|
||||
}
|
||||
|
||||
static int Scene_Compare (BPy_Scene *a, BPy_Scene *b)
|
||||
static int Scene_compare (BPy_Scene *a, BPy_Scene *b)
|
||||
{
|
||||
Scene *pa = a->scene, *pb = b->scene;
|
||||
return (pa == pb) ? 0:-1;
|
||||
}
|
||||
|
||||
static int Scene_Print(BPy_Scene *self, FILE *fp, int flags)
|
||||
static int Scene_print(BPy_Scene *self, FILE *fp, int flags)
|
||||
{
|
||||
fprintf(fp, "[Scene \"%s\"]", self->scene->id.name+2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyObject *Scene_Repr (BPy_Scene *self)
|
||||
static PyObject *Scene_repr (BPy_Scene *self)
|
||||
{
|
||||
return PyString_FromString(self->scene->id.name+2);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ typedef struct {
|
||||
/* Python Scene_Type helper functions needed by Blender (the Init function) */
|
||||
/* and Object modules. */
|
||||
/*****************************************************************************/
|
||||
PyObject *M_Scene_Init (void);
|
||||
PyObject *Scene_Init (void);
|
||||
PyObject *Scene_CreatePyObject (Scene *cam);
|
||||
Scene *Scene_FromPyObject (PyObject *pyobj);
|
||||
int Scene_CheckPyObject (PyObject *pyobj);
|
||||
|
87
source/blender/python/api2_2x/Sys.c
Normal file
87
source/blender/python/api2_2x/Sys.c
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
*
|
||||
* ***** 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): Willian P. Germano
|
||||
*
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#include "Sys.h"
|
||||
|
||||
static PyObject *g_sysmodule = Py_None; /* pointer to Blender.sys module */
|
||||
|
||||
PyObject *sys_Init (void)
|
||||
{
|
||||
PyObject *submodule, *dict, *sep;
|
||||
|
||||
submodule = Py_InitModule3("Blender.sys", M_sys_methods, M_sys_doc);
|
||||
|
||||
g_sysmodule = submodule;
|
||||
|
||||
dict = PyModule_GetDict(submodule);
|
||||
|
||||
#ifdef WIN32
|
||||
sep = Py_BuildValue("s", "\\");
|
||||
#else
|
||||
sep = Py_BuildValue("s", "/");
|
||||
#endif
|
||||
|
||||
if (sep) {
|
||||
Py_INCREF(sep);
|
||||
PyDict_SetItemString(dict, "dirsep" , sep);
|
||||
PyDict_SetItemString(dict, "sep" , sep);
|
||||
}
|
||||
|
||||
return submodule;
|
||||
}
|
||||
|
||||
static PyObject *M_sys_dirname (PyObject *self, PyObject *args)
|
||||
{
|
||||
PyObject *c;
|
||||
|
||||
char *name, dirname[256];
|
||||
char sep;
|
||||
int n;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s", &name))
|
||||
return EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
"expected string argument");
|
||||
|
||||
c = PyObject_GetAttrString (g_sysmodule, "dirsep");
|
||||
sep = PyString_AsString(c)[0];
|
||||
Py_DECREF(c);
|
||||
|
||||
n = strrchr(name, sep) - name;
|
||||
if (n > 255) {
|
||||
PyErr_SetString(PyExc_RuntimeError, "path too long");
|
||||
return 0;
|
||||
}
|
||||
|
||||
strncpy(dirname, name, n);
|
||||
dirname[n] = 0;
|
||||
|
||||
return Py_BuildValue("s", dirname);
|
||||
}
|
66
source/blender/python/api2_2x/Sys.h
Normal file
66
source/blender/python/api2_2x/Sys.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
*
|
||||
* ***** 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): Willian P. Germano
|
||||
*
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#ifndef EXPP_sys_H
|
||||
#define EXPP_sys_H
|
||||
|
||||
#include <Python.h>
|
||||
#include <BLI_blenlib.h> /* for BLI_last_slash() */
|
||||
#include "gen_utils.h"
|
||||
#include "modules.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python API function prototypes for the sys module. */
|
||||
/*****************************************************************************/
|
||||
static PyObject *M_sys_dirname (PyObject *self, PyObject *args);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* The following string definitions are used for documentation strings. */
|
||||
/* In Python these will be written to the console when doing a */
|
||||
/* Blender.sys.__doc__ */
|
||||
/*****************************************************************************/
|
||||
static char M_sys_doc[] =
|
||||
"The Blender.sys submodule\n\
|
||||
\n\
|
||||
This is a minimal sys module kept for compatibility. It may also still be\n\
|
||||
useful for users without full Python installations.\n";
|
||||
|
||||
static char M_sys_dirname_doc[] = "";
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python method structure definition for Blender.sys module: */
|
||||
/*****************************************************************************/
|
||||
struct PyMethodDef M_sys_methods[] = {
|
||||
{"dirname", M_sys_dirname, METH_VARARGS, M_sys_dirname_doc},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
#endif /* EXPP_sys_H */
|
@ -400,9 +400,8 @@ static void Text_dealloc (BPy_Text *self)
|
||||
static PyObject *Text_getAttr (BPy_Text *self, char *name)
|
||||
{
|
||||
PyObject *attr = Py_None;
|
||||
Text *text = self->text;
|
||||
|
||||
if (!text || !Text_IsLinked(text))
|
||||
if (!self->text || !Text_IsLinked(self))
|
||||
return EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
"Text was already deleted!");
|
||||
|
||||
@ -439,9 +438,8 @@ static int Text_setAttr (BPy_Text *self, char *name, PyObject *value)
|
||||
{
|
||||
PyObject *valtuple;
|
||||
PyObject *error = NULL;
|
||||
Text *text = self->text;
|
||||
|
||||
if (!text || !Text_IsLinked(text))
|
||||
if (!self->text || !Text_IsLinked(self))
|
||||
return EXPP_ReturnIntError (PyExc_RuntimeError,
|
||||
"Text was already deleted!");
|
||||
|
||||
@ -494,7 +492,7 @@ static int Text_compare (BPy_Text *a, BPy_Text *b)
|
||||
/*****************************************************************************/
|
||||
static int Text_print(BPy_Text *self, FILE *fp, int flags)
|
||||
{
|
||||
if (self->text && Text_IsLinked(self->text))
|
||||
if (self->text && Text_IsLinked(self))
|
||||
fprintf(fp, "[Text \"%s\"]", self->text->id.name+2);
|
||||
else
|
||||
fprintf(fp, "[Text <deleted>]");
|
||||
@ -509,23 +507,25 @@ static int Text_print(BPy_Text *self, FILE *fp, int flags)
|
||||
/*****************************************************************************/
|
||||
static PyObject *Text_repr (BPy_Text *self)
|
||||
{
|
||||
if (self->text && Text_IsLinked(self->text))
|
||||
if (self->text && Text_IsLinked(self))
|
||||
return PyString_FromString(self->text->id.name+2);
|
||||
else
|
||||
return PyString_FromString("<deleted>");
|
||||
}
|
||||
|
||||
/* internal function to confirm if a Text wasn't unlinked */
|
||||
static int Text_IsLinked(Text *text)
|
||||
/* Internal function to confirm if a Text wasn't unlinked.
|
||||
* This is necessary because without it, if a script writer
|
||||
* referenced an already unlinked Text obj, Blender would crash. */
|
||||
static int Text_IsLinked(BPy_Text *self)
|
||||
{
|
||||
Text *txt_iter = G.main->text.first;
|
||||
|
||||
while (txt_iter) {
|
||||
if (text == txt_iter) return 1;
|
||||
if (self->text == txt_iter) return 1; /* ok, still linked */
|
||||
|
||||
txt_iter = txt_iter->id.next;
|
||||
}
|
||||
|
||||
/* uh-oh, it was already deleted */
|
||||
self->text = NULL; /* so we invalidate the pointer */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -178,6 +178,6 @@ PyTypeObject Text_Type =
|
||||
0, /* tp_members */
|
||||
};
|
||||
|
||||
static int Text_IsLinked(Text *text);
|
||||
static int Text_IsLinked(BPy_Text *self);
|
||||
|
||||
#endif /* EXPP_TEXT_H */
|
||||
|
@ -166,8 +166,6 @@ int type = EFF_WAVE;
|
||||
BPy_Effect *pyeffect;
|
||||
Effect *bleffect = 0;
|
||||
|
||||
printf ("In Effect_New()\n");
|
||||
|
||||
bleffect = add_effect(type);
|
||||
if (bleffect == NULL)
|
||||
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
|
||||
@ -198,7 +196,7 @@ PyObject *M_Wave_Get(PyObject *self, PyObject *args)
|
||||
Effect *eff;
|
||||
BPy_Wave *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"));
|
||||
@ -237,12 +235,12 @@ PyObject *M_Wave_Get(PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_Wave_Init */
|
||||
/* Function: Wave_Init */
|
||||
/*****************************************************************************/
|
||||
PyObject *M_Wave_Init (void)
|
||||
PyObject *Wave_Init (void)
|
||||
{
|
||||
PyObject *submodule;
|
||||
printf ("In M_Wave_Init()\n");
|
||||
|
||||
Wave_Type.ob_type = &PyType_Type;
|
||||
submodule = Py_InitModule3("Blender.Wave",M_Wave_methods, M_Wave_doc);
|
||||
return (submodule);
|
||||
@ -548,7 +546,6 @@ PyObject* WaveCreatePyObject (struct Effect *wave)
|
||||
{
|
||||
BPy_Wave * blen_object;
|
||||
|
||||
printf ("In WaveCreatePyObject\n");
|
||||
|
||||
blen_object = (BPy_Wave*)PyObject_NEW (BPy_Wave, &Wave_Type);
|
||||
|
||||
|
@ -175,7 +175,7 @@ static PyObject *M_Window_ImageSelector(PyObject *self, PyObject *args)
|
||||
static PyObject *M_Window_DrawProgressBar(PyObject *self, PyObject *args)
|
||||
{
|
||||
float done;
|
||||
char *info = 0;
|
||||
char *info = NULL;
|
||||
int retval;
|
||||
|
||||
if(!PyArg_ParseTuple(args, "fs", &done, &info))
|
||||
@ -194,8 +194,6 @@ PyObject *Window_Init (void)
|
||||
{
|
||||
PyObject *submodule, *Types;
|
||||
|
||||
printf ("In M_Window_Init()\n");
|
||||
|
||||
submodule = Py_InitModule3("Blender.Window", M_Window_methods, M_Window_doc);
|
||||
|
||||
Types = Py_BuildValue("{s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h,s:h}",
|
||||
|
@ -107,7 +107,7 @@ def my_function(filename):\n\
|
||||
Blender.Window.ImageSelector(my_function, 'LOAD IMAGE')\n";
|
||||
|
||||
char M_Window_DrawProgressBar_doc[] =
|
||||
"(done, text) - Draw a progressbar.\n\
|
||||
"(done, text) - Draw a progress bar.\n\
|
||||
'done' is a float value <= 1.0, 'text' contains info about what is\n\
|
||||
currently being done.";
|
||||
|
||||
|
@ -209,12 +209,10 @@ static PyObject *M_World_Get(PyObject *self, PyObject *args)
|
||||
* \return PyObject*: The initialized submodule.
|
||||
*/
|
||||
|
||||
PyObject *M_World_Init (void)
|
||||
PyObject *World_Init (void)
|
||||
{
|
||||
PyObject *submodule;
|
||||
|
||||
printf ("In M_World_Init()\n");
|
||||
|
||||
World_Type.ob_type = &PyType_Type;
|
||||
|
||||
submodule = Py_InitModule3("Blender.World",
|
||||
|
@ -175,7 +175,7 @@ static PyMethodDef BPy_World_methods[] = {
|
||||
/* Python World_Type helper functions needed by Blender (the Init function) */
|
||||
/* and Object modules. */
|
||||
/*****************************************************************************/
|
||||
PyObject *M_World_Init (void);
|
||||
PyObject *World_Init (void);
|
||||
PyObject *World_CreatePyObject (World *cam);
|
||||
World *World_FromPyObject (PyObject *pyobj);
|
||||
int World_CheckPyObject (PyObject *pyobj);
|
||||
|
@ -37,12 +37,12 @@
|
||||
/*****************************************************************************/
|
||||
/* Python constant_Type callback function prototypes: */
|
||||
/*****************************************************************************/
|
||||
static void constantDeAlloc (C_constant *cam);
|
||||
static PyObject *constantGetAttr (C_constant *cam, char *name);
|
||||
static PyObject *constantRepr (C_constant *cam);
|
||||
static int constantLength(C_constant *self);
|
||||
static PyObject *constantSubscript(C_constant *self, PyObject *key);
|
||||
static int constantAssSubscript(C_constant *self, PyObject *who,
|
||||
static void constant_dealloc (BPy_constant *cam);
|
||||
static PyObject *constant_getAttr (BPy_constant *cam, char *name);
|
||||
static PyObject *constant_repr (BPy_constant *cam);
|
||||
static int constantLength(BPy_constant *self);
|
||||
static PyObject *constantSubscript(BPy_constant *self, PyObject *key);
|
||||
static int constantAssSubscript(BPy_constant *self, PyObject *who,
|
||||
PyObject *cares);
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -62,16 +62,16 @@ PyTypeObject constant_Type =
|
||||
{
|
||||
PyObject_HEAD_INIT(NULL)
|
||||
0, /* ob_size */
|
||||
"constant", /* tp_name */
|
||||
sizeof (C_constant), /* tp_basicsize */
|
||||
"Blender constant", /* tp_name */
|
||||
sizeof (BPy_constant), /* tp_basicsize */
|
||||
0, /* tp_itemsize */
|
||||
/* methods */
|
||||
(destructor)constantDeAlloc, /* tp_dealloc */
|
||||
(destructor)constant_dealloc, /* tp_dealloc */
|
||||
0, /* tp_print */
|
||||
(getattrfunc)constantGetAttr, /* tp_getattr */
|
||||
(getattrfunc)constant_getAttr, /* tp_getattr */
|
||||
0, /* tp_setattr */
|
||||
0, /* tp_compare */
|
||||
(reprfunc)constantRepr, /* tp_repr */
|
||||
(reprfunc)constant_repr, /* tp_repr */
|
||||
0, /* tp_as_number */
|
||||
0, /* tp_as_sequence */
|
||||
&constantAsMapping, /* tp_as_mapping */
|
||||
@ -95,13 +95,11 @@ PyObject *M_constant_New(void) /* can't be static, we call it in other files */
|
||||
|
||||
static PyObject *new_const(void)
|
||||
{ /* this is the static one */
|
||||
C_constant *constant;
|
||||
BPy_constant *constant;
|
||||
|
||||
constant_Type.ob_type = &PyType_Type;
|
||||
|
||||
printf ("In constant_New()\n");
|
||||
|
||||
constant = (C_constant *)PyObject_NEW(C_constant, &constant_Type);
|
||||
constant = (BPy_constant *)PyObject_NEW(BPy_constant, &constant_Type);
|
||||
|
||||
if (constant == NULL)
|
||||
return (PythonReturnErrorObject (PyExc_MemoryError,
|
||||
@ -115,31 +113,31 @@ static PyObject *new_const(void)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_constant methods: */
|
||||
/* Python BPy_constant methods: */
|
||||
/*****************************************************************************/
|
||||
int constant_insert (C_constant *self, char *name, PyObject *value)
|
||||
int constant_insert (BPy_constant *self, char *name, PyObject *value)
|
||||
{
|
||||
return PyDict_SetItemString (self->dict, name, value);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: constantDeAlloc */
|
||||
/* Description: This is a callback function for the C_constant type. It is */
|
||||
/* Function: constant_dealloc */
|
||||
/* Description: This is a callback function for the BPy_constant type. It is */
|
||||
/* the destructor function. */
|
||||
/*****************************************************************************/
|
||||
static void constantDeAlloc (C_constant *self)
|
||||
static void constant_dealloc (BPy_constant *self)
|
||||
{
|
||||
Py_DECREF(self->dict);
|
||||
PyObject_DEL (self);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: constantGetAttr */
|
||||
/* Description: This is a callback function for the C_constant type. It is */
|
||||
/* the function that accesses C_constant member variables and */
|
||||
/* Function: constant_getAttr */
|
||||
/* Description: This is a callback function for the BPy_constant type. It is */
|
||||
/* the function that accesses BPy_constant member variables and */
|
||||
/* methods. */
|
||||
/*****************************************************************************/
|
||||
static PyObject *constantGetAttr (C_constant *self, char *name)
|
||||
static PyObject *constant_getAttr (BPy_constant *self, char *name)
|
||||
{
|
||||
if (self->dict)
|
||||
{
|
||||
@ -166,12 +164,12 @@ static PyObject *constantGetAttr (C_constant *self, char *name)
|
||||
/* These functions provide code to access constant objects as */
|
||||
/* mappings. */
|
||||
/*****************************************************************************/
|
||||
static int constantLength(C_constant *self)
|
||||
static int constantLength(BPy_constant *self)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyObject *constantSubscript(C_constant *self, PyObject *key)
|
||||
static PyObject *constantSubscript(BPy_constant *self, PyObject *key)
|
||||
{
|
||||
if (self->dict) {
|
||||
PyObject *v = PyDict_GetItem(self->dict, key);
|
||||
@ -185,7 +183,7 @@ static PyObject *constantSubscript(C_constant *self, PyObject *key)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int constantAssSubscript(C_constant *self, PyObject *who,
|
||||
static int constantAssSubscript(BPy_constant *self, PyObject *who,
|
||||
PyObject *cares)
|
||||
{
|
||||
/* no user assignments allowed */
|
||||
@ -193,11 +191,11 @@ static int constantAssSubscript(C_constant *self, PyObject *who,
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: constantRepr */
|
||||
/* Description: This is a callback function for the C_constant type. It */
|
||||
/* Function: constant_repr */
|
||||
/* Description: This is a callback function for the BPy_constant type. It */
|
||||
/* builds a meaninful string to represent constant objects. */
|
||||
/*****************************************************************************/
|
||||
static PyObject *constantRepr (C_constant *self)
|
||||
static PyObject *constant_repr (BPy_constant *self)
|
||||
{
|
||||
PyObject *repr = PyObject_Repr(self->dict);
|
||||
return repr;
|
||||
|
@ -46,17 +46,17 @@
|
||||
PyObject *M_constant_New (void);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_constant structure definition: */
|
||||
/* Python BPy_constant structure definition: */
|
||||
/*****************************************************************************/
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *dict;
|
||||
|
||||
} C_constant;
|
||||
} BPy_constant;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Python C_constant methods declarations: */
|
||||
/* Python BPy_constant methods declarations: */
|
||||
/*****************************************************************************/
|
||||
int constant_insert(C_constant *self, char *name, PyObject *value);
|
||||
int constant_insert(BPy_constant *self, char *name, PyObject *value);
|
||||
|
||||
#endif /* EXPP_constant_H */
|
||||
|
@ -1,18 +1,26 @@
|
||||
# Blender.BGL module (OpenGL wrapper)
|
||||
|
||||
"""
|
||||
The Blender.BGL submodule (the OpenGL wrapper).
|
||||
|
||||
The Blender.BGL submodule
|
||||
=========================
|
||||
|
||||
This module wraps OpenGL constants and functions, making them available from
|
||||
within Blender Python. The complete list can be retrieved from the module
|
||||
itself, by listing its contents: dir(Blender.BGL). There are too many to be
|
||||
documented here, but a simple search on the net can point to more than enough
|
||||
material to teach OpenGL programming, from books to many collections of
|
||||
tutorials. The I{red book}: "OpenGL Programming Guide", is a very good
|
||||
resource, even for newcomers.
|
||||
within Blender Python.
|
||||
|
||||
The complete list can be retrieved from the module itself, by listing its
|
||||
contents: dir(Blender.BGL). There are too many to be documented here, but
|
||||
a simple search on the net can point to more than enough material to teach
|
||||
OpenGL programming, from books to many collections of tutorials.
|
||||
|
||||
The "red book": "I{OpenGL Programming Guide: The Official Guide to Learning
|
||||
OpenGL}" and the online NeHe tutorials are two of the best resources.
|
||||
|
||||
@see: U{www.opengl.org}
|
||||
|
||||
Example::
|
||||
|
||||
import Blender
|
||||
from Blender.BGL import *
|
||||
from Blender import Draw
|
||||
@ -44,7 +52,7 @@ Example::
|
||||
Draw.Redraw(1) # make changes visible.
|
||||
#
|
||||
def ev(evt, val): # this is a callback for Draw.Register()
|
||||
global R,G,B,A # it handles input events
|
||||
global R,G,B,A # ... it handles input events
|
||||
if evt == Draw.ESCKEY or evt == Draw.QKEY:
|
||||
Draw.Exit() # this quits the script
|
||||
elif evt == Draw.LEFTMOUSE: R = 1 - R
|
||||
|
@ -7,16 +7,30 @@
|
||||
# Blender.py Camera.py Lamp.py BGL.py etc.
|
||||
|
||||
"""
|
||||
Here goes the Introduction to Blender Python
|
||||
This is the main Blender module.
|
||||
|
||||
Blender Python
|
||||
==============
|
||||
|
||||
Submodules:
|
||||
-----------
|
||||
|
||||
- L{Camera}
|
||||
- L{Lamp}
|
||||
- L{BGL}
|
||||
- L{Window}
|
||||
- L{Text}
|
||||
|
||||
Introduction:
|
||||
-------------
|
||||
- What scripting is, why have it
|
||||
- What Python is, links
|
||||
- More about what scripting can give us
|
||||
- Overview of the Blender Python modules
|
||||
- Links to Blender, Blender Python, later: script lists
|
||||
|
||||
Let's see::
|
||||
- What scripting is, why have it
|
||||
- What Python is, links
|
||||
- More about what scripting can give us
|
||||
- Overview of the Blender Python modules
|
||||
- Links to Blender, Blender Python, later: script lists
|
||||
@author: The Blender Python Team
|
||||
@requires: Blender 2.28 or newer, Python 2.? (2.0, 2.1, 2.2 ???) or newer
|
||||
@requires: Blender 2.28 or newer.
|
||||
@version: 0.1
|
||||
@see: U{www.blender.org<http://www.blender.org>}
|
||||
@see: U{projects.blender.org<http://projects.blender.org>}
|
||||
|
@ -1,7 +1,10 @@
|
||||
# Blender.Camera module and the Camera PyType object
|
||||
|
||||
"""
|
||||
The Blender.Camera submodule
|
||||
The Blender.Camera submodule.
|
||||
|
||||
Camera Data
|
||||
===========
|
||||
|
||||
This module provides access to B{Camera Data} objects in Blender.
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
# Blender.Lamp module and the Lamp PyType object
|
||||
|
||||
"""
|
||||
The Blender.Lamp submodule
|
||||
The Blender.Lamp submodule.
|
||||
|
||||
Lamp Data
|
||||
=========
|
||||
|
||||
This module provides control over B{Lamp Data} objects in Blender.
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
# Blender.Text module and the Text PyType object
|
||||
|
||||
"""
|
||||
The Blender.Text submodule
|
||||
The Blender.Text submodule.
|
||||
|
||||
Text Objects
|
||||
============
|
||||
|
||||
This module provides access to B{Text} objects in Blender.
|
||||
|
||||
|
117
source/blender/python/api2_2x/doc/Window.py
Normal file
117
source/blender/python/api2_2x/doc/Window.py
Normal file
@ -0,0 +1,117 @@
|
||||
# Blender.Window module and the Window PyType object
|
||||
|
||||
"""
|
||||
The Blender.Window submodule.
|
||||
|
||||
Window
|
||||
======
|
||||
|
||||
This module provides access to B{Window} functions in Blender.
|
||||
|
||||
Example:
|
||||
--------
|
||||
|
||||
FileSelector::
|
||||
|
||||
import Blender
|
||||
from Blender import Window
|
||||
#
|
||||
def my_callback(filename): # callback for the FileSelector
|
||||
print "You chose the file:", filename # do something with the chosen file
|
||||
#
|
||||
Window.FileSelector (my_callback, "Choose one!")
|
||||
|
||||
Example:
|
||||
--------
|
||||
|
||||
DrawProgressBar::
|
||||
|
||||
import Blender
|
||||
from Blender.Window import DrawProgressBar
|
||||
#
|
||||
# substitute the bogus_*() function calls for your own, of course.
|
||||
#
|
||||
DrawProgressBar (0.0, "Importing data ...")
|
||||
bogus_importData()
|
||||
DrawProgressBar (0.3, "Building something")
|
||||
bogus_build()
|
||||
DrawProgressBar (0.8, "Updating Blender")
|
||||
bogus_update()
|
||||
DrawProgressBar (1.0, "Finished")
|
||||
#
|
||||
# another example:
|
||||
#
|
||||
number = 1
|
||||
while number < 20:
|
||||
file = filename + "00%d" % number
|
||||
DrawProgressBar (number / 20.0, "Loading texture: %s" % file)
|
||||
Blender.Image.Load(file)
|
||||
number += 1
|
||||
|
||||
DrawProgressBar (1.0, "Finished loading")
|
||||
|
||||
"""
|
||||
|
||||
def Redraw ():
|
||||
"""
|
||||
Force a redraw of a specific Window Type (see Window.Types).
|
||||
"""
|
||||
|
||||
def RedrawAll ():
|
||||
"""
|
||||
Redraw all windows.
|
||||
"""
|
||||
|
||||
def QRedrawAll ():
|
||||
"""
|
||||
Redraw all windows by queue event.
|
||||
"""
|
||||
|
||||
def FileSelector (callback, title = 'SELECT FILE'):
|
||||
"""
|
||||
Open the file selector window in Blender. After the user selects a filename,
|
||||
it is passed as parameter to the function callback given to FileSelector().
|
||||
Example::
|
||||
import Blender
|
||||
#
|
||||
def my_function(filename):
|
||||
print 'The selected file was:', filename
|
||||
#
|
||||
Blender.Window.FileSelector (my_function, 'SAVE FILE')
|
||||
@type callback: function that accepts a string: f(str)
|
||||
@param callback: The function that must be provided to FileSelector() and
|
||||
will receive the selected filename as parameter.
|
||||
@type title: string
|
||||
@param title: The string that appears in the button to confirm the selection
|
||||
and return from the file selection window.
|
||||
"""
|
||||
|
||||
def ImageSelector (callback, title = 'SELECT IMAGE'):
|
||||
"""
|
||||
Open the image selector window in Blender. After the user selects a filename,
|
||||
it is passed as parameter to the function callback given to ImageSelector().
|
||||
Example::
|
||||
import Blender
|
||||
#
|
||||
def my_function(imagename):
|
||||
print 'The selected image was:', imagename
|
||||
#
|
||||
Blender.Window.ImageSelector (my_function, 'LOAD IMAGE')
|
||||
@type callback: function that accepts a string: f(str)
|
||||
@param callback: The function that must be provided to ImageSelector() and
|
||||
will receive the selected filename as parameter.
|
||||
@type title: string
|
||||
@param title: The string that appears in the button to confirm the selection
|
||||
and return from the image selection window.
|
||||
"""
|
||||
|
||||
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.
|
||||
@type done: float
|
||||
@param done: A float in [0, 1] that tells the advance in the progress
|
||||
bar.
|
||||
@type text: string
|
||||
@param text: Info about what is currently being done "behind the scenes".
|
||||
"""
|
@ -56,13 +56,16 @@ extern PyObject *g_blenderdict;
|
||||
/* Module Init functions and Data Object helper functions (used by the */
|
||||
/* Object module to work with its .data field for the various Data objs */
|
||||
/*****************************************************************************/
|
||||
void M_Blender_Init (void);
|
||||
void M_Blender_Init (void);
|
||||
|
||||
/* sys */
|
||||
PyObject * sys_Init (void);
|
||||
|
||||
/* Object itself */
|
||||
PyObject * M_Object_Init (void);
|
||||
PyObject * M_ObjectCreatePyObject (struct Object *obj);
|
||||
int M_ObjectCheckPyObject (PyObject *py_obj);
|
||||
struct Object * M_ObjectFromPyObject (PyObject *py_obj);
|
||||
PyObject * Object_Init (void);
|
||||
PyObject * Object_CreatePyObject (struct Object *obj);
|
||||
Object * Object_FromPyObject (PyObject *py_obj);
|
||||
int Object_CheckPyObject (PyObject *py_obj);
|
||||
|
||||
/* Scene */
|
||||
PyObject * Scene_Init (void);
|
||||
@ -95,34 +98,34 @@ Lamp * Lamp_FromPyObject (PyObject *pyobj);
|
||||
int Lamp_CheckPyObject (PyObject *pyobj);
|
||||
|
||||
/* Curve Data */
|
||||
PyObject * M_Curve_Init (void);
|
||||
PyObject * CurveCreatePyObject (struct Curve *curve);
|
||||
struct Curve * CurveFromPyObject (PyObject *py_obj);
|
||||
int CurveCheckPyObject (PyObject *py_obj);
|
||||
PyObject * Curve_Init (void);
|
||||
PyObject * CurveCreatePyObject (struct Curve *curve);
|
||||
Curve * CurveFromPyObject (PyObject *py_obj);
|
||||
int CurveCheckPyObject (PyObject *py_obj);
|
||||
|
||||
/* Armature Data */
|
||||
PyObject * M_Armature_Init (void);
|
||||
PyObject * M_ArmatureCreatePyObject (bArmature *armature);
|
||||
bArmature* M_ArmatureFromPyObject (PyObject *py_obj);
|
||||
int M_ArmatureCheckPyObject (PyObject *py_obj);
|
||||
PyObject * Armature_Init (void);
|
||||
PyObject * Armature_CreatePyObject (bArmature *armature);
|
||||
bArmature * Armature_FromPyObject (PyObject *py_obj);
|
||||
int Armature_CheckPyObject (PyObject *py_obj);
|
||||
|
||||
/* Ipo Data */
|
||||
PyObject * M_Ipo_Init (void);
|
||||
PyObject * Ipo_CreatePyObject (struct Ipo *ipo);
|
||||
struct Ipo * Ipo_FromPyObject (PyObject *py_obj);
|
||||
int Ipo_CheckPyObject (PyObject *py_obj);
|
||||
PyObject * Ipo_Init (void);
|
||||
PyObject * Ipo_CreatePyObject (struct Ipo *ipo);
|
||||
Ipo * Ipo_FromPyObject (PyObject *py_obj);
|
||||
int Ipo_CheckPyObject (PyObject *py_obj);
|
||||
|
||||
/* Metaball Data */
|
||||
PyObject * M_Metaball_Init (void);
|
||||
PyObject * Metaball_CreatePyObject (MetaBall *metaball);
|
||||
struct MetaBall * Metaball_FromPyObject (PyObject *py_obj);
|
||||
int Metaball_CheckPyObject (PyObject *py_obj);
|
||||
PyObject * Metaball_Init (void);
|
||||
PyObject * Metaball_CreatePyObject (MetaBall *metaball);
|
||||
MetaBall * Metaball_FromPyObject (PyObject *py_obj);
|
||||
int Metaball_CheckPyObject (PyObject *py_obj);
|
||||
|
||||
/* Particle Effects Data */
|
||||
PyObject * M_Effect_Init (void);
|
||||
PyObject * Effect_CreatePyObject (struct Effect *effect);
|
||||
struct Effect * Effect_FromPyObject (PyObject *py_obj);
|
||||
int Effect_CheckPyObject (PyObject *py_obj);
|
||||
PyObject * Effect_Init (void);
|
||||
PyObject * Effect_CreatePyObject (struct Effect *effect);
|
||||
Effect * Effect_FromPyObject (PyObject *py_obj);
|
||||
int Effect_CheckPyObject (PyObject *py_obj);
|
||||
|
||||
/* Image */
|
||||
PyObject * Image_Init (void);
|
||||
@ -137,6 +140,6 @@ PyObject * Text_CreatePyObject (Text *txt);
|
||||
PyObject * Window_Init (void);
|
||||
PyObject * Draw_Init (void);
|
||||
PyObject * BGL_Init (void);
|
||||
PyObject * M_World_Init (void);
|
||||
PyObject * World_Init (void);
|
||||
|
||||
#endif /* EXPP_modules_h */
|
||||
|
Loading…
x
Reference in New Issue
Block a user