soc-2008-mxcurioni: merged changes to revision 16789

This commit is contained in:
Maxime Curioni
2008-09-28 17:07:08 +00:00
622 changed files with 56125 additions and 27181 deletions

View File

@@ -94,13 +94,13 @@ extern "C" {
int BPY_menu_do_python( short menutype, int event );
int BPY_menu_do_shortcut( short menutype, unsigned short key, unsigned short modifiers );
int BPY_menu_invoke( struct BPyMenu *pym, short menutype );
void BPY_run_python_script( char *filename );
void BPY_run_python_script( const char *filename );
int BPY_run_script(struct Script *script);
void BPY_free_compiled_text( struct Text *text );
void BPY_clear_bad_scriptlinks( struct Text *byebye );
int BPY_has_onload_script( void );
void BPY_do_all_scripts( short event );
void BPY_do_all_scripts( short event, short anim );
int BPY_check_all_scriptlinks( struct Text *text );
void BPY_do_pyscript( struct ID *id, short event );
void BPY_free_scriptlink( struct ScriptLink *slink );
@@ -112,7 +112,7 @@ extern "C" {
int BPY_has_spacehandler(struct Text *text, struct ScrArea *sa);
void BPY_screen_free_spacehandlers(struct bScreen *sc);
int BPY_do_spacehandlers(struct ScrArea *sa, unsigned short event,
unsigned short space_event);
short eventValue, unsigned short space_event);
void BPY_pydriver_update(void);
float BPY_pydriver_eval(struct IpoDriver *driver);

View File

@@ -720,13 +720,23 @@ int BPY_txt_do_python_Text( struct Text *text )
* automatically. The script can be a file or a Blender Text in the current
* .blend.
****************************************************************************/
void BPY_run_python_script( char *fn )
void BPY_run_python_script( const char *fn )
{
char filename[FILE_MAXDIR + FILE_MAXFILE];
Text *text = NULL;
int is_blender_text = 0;
if (!BLI_exists(fn)) { /* if there's no such filename ... */
text = G.main->text.first; /* try an already existing Blender Text */
BLI_strncpy(filename, fn, FILE_MAXDIR + FILE_MAXFILE);
if (!BLI_exists(filename))
BLI_convertstringcwd(filename);
if (!BLI_exists(filename)) { /* if there's no such filename ... */
/* try an already existing Blender Text.
* use 'fn' rather then filename for this since were looking for
* internal text
*/
text = G.main->text.first;
while (text) {
if (!strcmp(fn, text->id.name + 2)) break;
@@ -741,11 +751,14 @@ void BPY_run_python_script( char *fn )
}
else {
text = add_text(fn);
/* use filename here since we know it exists,
* 'fn' may have been a relative path
*/
text = add_text(filename);
if (text == NULL) {
printf("\nError in BPY_run_python_script:\n"
"couldn't create Blender text from %s\n", fn);
"couldn't create Blender text from \"%s\"\n", filename);
/* Chris: On Windows if I continue I just get a segmentation
* violation. To get a baseline file I exit here. */
exit(2);
@@ -762,13 +775,8 @@ void BPY_run_python_script( char *fn )
/* We can't simply free the text, since the script might have called
* Blender.Load() to load a new .blend, freeing previous data.
* So we check if the pointer is still valid. */
Text *txtptr = G.main->text.first;
while (txtptr) {
if (txtptr == text) {
free_libblock(&G.main->text, text);
break;
}
txtptr = txtptr->id.next;
if (BLI_findindex(&G.main->text, text) != -1) {
free_libblock(&G.main->text, text);
}
}
}
@@ -778,9 +786,6 @@ int BPY_run_script(Script *script)
PyObject *py_dict, *py_res, *pyarg;
Text *text = NULL;
BPy_constant *info;
int len;
FILE *fp = NULL;
PyGILState_STATE gilstate = PyGILState_Ensure();
@@ -825,12 +830,8 @@ int BPY_run_script(Script *script)
Py_INCREF( Py_None );
pyarg = Py_None;
} else {
if (BLI_exists(script->scriptname)) {
fp = fopen( script->scriptname, "rb" );
}
if( !fp ) {
printf( "Error loading script: couldn't open file %s\n", script->scriptname );
if (!BLI_exists(script->scriptname)) {
printf( "Script does not exit %s\n", script->scriptname );
free_libblock( &G.main->script, script );
PyGILState_Release(gilstate);
return 0;
@@ -875,51 +876,17 @@ int BPY_run_script(Script *script)
if (text) {
py_res = RunPython( text, py_dict );
} else {
char pystring[sizeof(script->scriptname) + 15];
sprintf(pystring, "execfile(r'%s')", script->scriptname);
py_res = PyRun_String( pystring, Py_file_input, py_dict, py_dict );
}
if( !py_res ) { /* Failed execution of the script */
/* Previously we used PyRun_File to run directly the code on a FILE
* object, but as written in the Python/C API Ref Manual, chapter 2,
* 'FILE structs for different C libraries can be different and
* incompatible'.
* So now we load the script file data to a buffer */
char *buffer=NULL, *buffer_ofs=NULL, *b_to, *b_from;
fseek( fp, 0L, SEEK_END );
len = ftell( fp );
fseek( fp, 0L, SEEK_SET );
buffer = buffer_ofs = MEM_mallocN( len + 2, "pyfilebuf" ); /* len+2 to add '\n\0' */
len = fread( buffer, 1, len, fp );
buffer[len] = '\n'; /* fix syntax error in files w/o eol */
buffer[len + 1] = '\0';
/* fast clean-up of dos cr/lf line endings, remove convert '\r\n's to '\n' */
if (*buffer_ofs == '\r' && *(buffer_ofs+1) == '\n') {
buffer_ofs++;
}
b_from = b_to = buffer_ofs;
while(*b_from != '\0') {
if (*b_from == '\r' && *( b_from+1 ) == '\n') {
b_from++;
}
if (b_from != b_to) {
*b_to = *b_from;
}
b_to++;
b_from++;
}
*b_to = '\0';
/* done cleaning the string */
fclose( fp );
py_res = PyRun_String( buffer_ofs, Py_file_input, py_dict, py_dict );
MEM_freeN( buffer );
}
if( !py_res ) { /* Failed execution of the script */
BPY_Err_Handle( script->id.name + 2 );
ReleaseGlobalDictionary( py_dict );
script->py_globaldict = NULL;
@@ -2196,8 +2163,14 @@ void BPY_clear_bad_scriptlinks( struct Text *byebye )
* For the scene, only the current active scene the scripts are
* executed (if any).
*****************************************************************************/
void BPY_do_all_scripts( short event )
void BPY_do_all_scripts( short event, short anim )
{
/* during stills rendering we disable FRAMECHANGED events */
static char disable_frame_changed = 0;
if ((event == SCRIPT_FRAMECHANGED) && disable_frame_changed)
return;
DoAllScriptsFromList( &( G.main->object ), event );
DoAllScriptsFromList( &( G.main->lamp ), event );
DoAllScriptsFromList( &( G.main->camera ), event );
@@ -2213,9 +2186,12 @@ void BPY_do_all_scripts( short event )
* "import sys; sys.setcheckinterval(sys.maxint)" */
if (event == SCRIPT_RENDER) {
_Py_CheckInterval = PyInt_GetMax();
if (!anim)
disable_frame_changed = 1;
}
else if (event == SCRIPT_POSTRENDER) {
_Py_CheckInterval = 100; /* Python default */
disable_frame_changed = 0;
}
return;
@@ -2499,7 +2475,7 @@ int BPY_add_spacehandler(Text *text, ScrArea *sa, char spacetype)
}
int BPY_do_spacehandlers( ScrArea *sa, unsigned short event,
unsigned short space_event )
short eventValue, unsigned short space_event )
{
ScriptLink *scriptlink;
int retval = 0;
@@ -2539,8 +2515,9 @@ int BPY_do_spacehandlers( ScrArea *sa, unsigned short event,
PyDict_SetItemString(g_blenderdict, "bylink", Py_True);
/* unlike normal scriptlinks, here Blender.link is int (space event type) */
EXPP_dict_set_item_str(g_blenderdict, "link", PyInt_FromLong(space_event));
/* note: DRAW space_events set event to 0 */
/* note: DRAW space_events set event and val to 0 */
EXPP_dict_set_item_str(g_blenderdict, "event", PyInt_FromLong(event));
EXPP_dict_set_item_str(g_blenderdict, "eventValue", PyInt_FromLong(eventValue));
/* now run all assigned space handlers for this space and space_event */
for( index = 0; index < scriptlink->totscript; index++ ) {

View File

@@ -323,8 +323,13 @@ typedef struct _Buffer {
#define ret_def_GLstring const unsigned char *ret_str;
#define ret_set_GLstring ret_str=
#define ret_ret_GLstring return PyString_FromString(ret_str);
#define ret_ret_GLstring \
if (ret_str) {\
return PyString_FromString(ret_str);\
} else {\
PyErr_SetString(PyExc_AttributeError, "could not get opengl string");\
return NULL;\
}
#endif /* EXPP_BGL_H */

View File

@@ -36,7 +36,9 @@
#include "BKE_utildefines.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h" /* for M_PI */
#include "DNA_userdef_types.h"
#include "BSE_editipo.h"
#include "BIF_keyframing.h"
#include "BIF_space.h"
#include "mydevice.h"
#include "gen_utils.h"
@@ -1031,18 +1033,21 @@ static PyObject *Camera_repr( BPy_Camera * self )
static PyObject *Camera_insertIpoKey( BPy_Camera * self, PyObject * args )
{
int key = 0;
int key = 0, flag = 0;
if( !PyArg_ParseTuple( args, "i", &( key ) ) )
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
"expected int argument" ) );
/* flag should be initialised with the 'autokeying' flags like for normal keying */
if (IS_AUTOKEY_FLAG(INSERTNEEDED)) flag |= INSERTKEY_NEEDED;
if (key == IPOKEY_LENS){
insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_LENS, 0);
insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_LENS, flag);
}
else if (key == IPOKEY_CLIPPING){
insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_STA, 0);
insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_END, 0);
insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_STA, flag);
insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_END, flag);
}
allspace(REMAKEIPO, 0);

View File

@@ -44,6 +44,7 @@
#include "BKE_constraint.h"
#include "BLI_blenlib.h"
#include "BIF_editconstraint.h"
#include "BIF_keyframing.h"
#include "BIF_poseobject.h"
#include "BSE_editipo.h"
#include "MEM_guardedalloc.h"
@@ -441,7 +442,7 @@ static PyObject *Constraint_insertKey( BPy_Constraint * self, PyObject * value )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"constraint doesn't belong to anything" );
}
icu= verify_ipocurve((ID *)ob, ID_CO, actname, con->name, NULL, CO_ENFORCE);
icu= verify_ipocurve((ID *)ob, ID_CO, actname, con->name, NULL, CO_ENFORCE, 1);
if (!icu)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,

View File

@@ -928,6 +928,11 @@ static PyObject *Method_Register( PyObject * self, PyObject * args )
Script *script;
int startspace = 0;
if (G.background) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Can't run Draw.Register() in background mode." );
}
if( !PyArg_ParseTuple
( args, "O|OO", &newdrawc, &neweventc, &newbuttonc ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
@@ -1008,6 +1013,10 @@ static PyObject *Method_Redraw( PyObject * self, PyObject * args )
{
int after = 0;
if (G.background) {
Py_RETURN_NONE;
}
if( !PyArg_ParseTuple( args, "|i", &after ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected int argument (or nothing)" );
@@ -1022,6 +1031,10 @@ static PyObject *Method_Redraw( PyObject * self, PyObject * args )
static PyObject *Method_Draw( PyObject * self )
{
if (G.background) {
Py_RETURN_NONE;
}
/*@ If forced drawing is disable queue a redraw event instead */
if( EXPP_disable_force_draw ) {
scrarea_queue_winredraw( curarea );
@@ -1089,6 +1102,11 @@ static PyObject *Method_UIBlock( PyObject * self, PyObject * args )
PyObject *result = NULL;
ListBase listb= {NULL, NULL};
if (G.background) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Can't run Draw.UIBlock() in background mode." );
}
if ( !PyArg_ParseTuple( args, "O", &val ) || !PyCallable_Check( val ) )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"expected 1 python function and 2 ints" );
@@ -1201,6 +1219,11 @@ static PyObject *Method_Button( PyObject * self, PyObject * args )
int x, y, w, h;
PyObject *callback=NULL;
if (G.background) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Can't run Draw.Button() in background mode." );
}
if( !PyArg_ParseTuple( args, "siiiii|sO", &name, &event,
&x, &y, &w, &h, &tip, &callback ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
@@ -1225,6 +1248,11 @@ static PyObject *Method_Menu( PyObject * self, PyObject * args )
Button *but;
PyObject *callback=NULL;
if (G.background) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Can't run Draw.Menu() in background mode." );
}
if( !PyArg_ParseTuple( args, "siiiiii|sO", &name, &event,
&x, &y, &w, &h, &def, &tip, &callback ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
@@ -1255,6 +1283,11 @@ static PyObject *Method_Toggle( PyObject * self, PyObject * args )
Button *but;
PyObject *callback=NULL;
if (G.background) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Can't run Draw.Toggle() in background mode." );
}
if( !PyArg_ParseTuple( args, "siiiiii|sO", &name, &event,
&x, &y, &w, &h, &def, &tip, &callback ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
@@ -1322,6 +1355,11 @@ static PyObject *Method_Slider( PyObject * self, PyObject * args )
PyObject *mino, *maxo, *inio;
PyObject *callback=NULL;
if (G.background) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Can't run Draw.Sider() in background mode." );
}
if( !PyArg_ParseTuple( args, "siiiiiOOO|isO", &name, &event,
&x, &y, &w, &h, &inio, &mino, &maxo, &realtime,
&tip, &callback ) )
@@ -1395,6 +1433,11 @@ static PyObject *Method_Scrollbar( PyObject * self, PyObject * args )
float ini, min, max;
uiBut *ubut;
if (G.background) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Can't run Draw.Scrollbar() in background mode." );
}
if( !PyArg_ParseTuple( args, "iiiiiOOO|isO", &event, &x, &y, &w, &h,
&inio, &mino, &maxo, &realtime, &tip ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
@@ -1454,6 +1497,11 @@ static PyObject *Method_ColorPicker( PyObject * self, PyObject * args )
short x, y, w, h;
PyObject *callback=NULL;
if (G.background) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Can't run Draw.ColorPicker() in background mode." );
}
if( !PyArg_ParseTuple( args, "ihhhhO!|sO", &event,
&x, &y, &w, &h, &PyTuple_Type, &inio, &tip, &callback ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
@@ -1504,6 +1552,11 @@ static PyObject *Method_Normal( PyObject * self, PyObject * args )
short x, y, w, h;
PyObject *callback=NULL;
if (G.background) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Can't run Draw.Normal() in background mode." );
}
if( !PyArg_ParseTuple( args, "ihhhhO!|sO", &event,
&x, &y, &w, &h, &PyTuple_Type, &inio, &tip, &callback ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
@@ -1546,6 +1599,11 @@ static PyObject *Method_Number( PyObject * self, PyObject * args )
PyObject *callback=NULL;
uiBut *ubut= NULL;
if (G.background) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Can't run Draw.Number() in background mode." );
}
if( !PyArg_ParseTuple( args, "siiiiiOOO|sO", &name, &event,
&x, &y, &w, &h, &inio, &mino, &maxo, &tip, &callback ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
@@ -1617,6 +1675,11 @@ static PyObject *Method_String( PyObject * self, PyObject * args )
Button *but;
PyObject *callback=NULL;
if (G.background) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Can't run Draw.String() in background mode." );
}
if( !PyArg_ParseTuple( args, "siiiiisi|sO", &info_arg, &event,
&x, &y, &w, &h, &newstr, &len, &tip, &callback ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
@@ -1693,6 +1756,11 @@ static PyObject *Method_Text( PyObject * self, PyObject * args )
char *font_str = NULL;
struct BMF_Font *font;
if (G.background) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Can't run Draw.Text() in background mode." );
}
if( !PyArg_ParseTuple( args, "s|s", &text, &font_str ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected one or two string arguments" );
@@ -1724,6 +1792,11 @@ static PyObject *Method_Label( PyObject * self, PyObject * args )
char *text;
int x, y, w, h;
if (G.background) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Can't run Draw.Label() in background mode." );
}
if( !PyArg_ParseTuple( args, "siiii", &text, &x, &y, &w, &h ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected a string and four ints" );
@@ -1740,7 +1813,12 @@ static PyObject *Method_PupMenu( PyObject * self, PyObject * args )
char *text;
int maxrow = -1;
PyObject *ret;
if (G.background) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Can't run Draw.PupMenu() in background mode." );
}
if( !PyArg_ParseTuple( args, "s|i", &text, &maxrow ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected a string and optionally an int as arguments" );
@@ -1827,6 +1905,11 @@ static PyObject *Method_PupTreeMenu( PyObject * self, PyObject * args )
ListBase storage = {NULL, NULL};
TBitem *tb;
if (G.background) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Can't run Draw.PupMenuTree() in background mode." );
}
if( !PyArg_ParseTuple( args, "O!", &PyList_Type, &current_menu ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"Expected a list" );
@@ -1857,6 +1940,11 @@ static PyObject *Method_PupIntInput( PyObject * self, PyObject * args )
short var = 0;
PyObject *ret = NULL;
if (G.background) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Can't run Draw.PupIntInput() in background mode." );
}
if( !PyArg_ParseTuple( args, "s|hii", &text, &var, &min, &max ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected 1 string and 3 int arguments" );
@@ -1879,6 +1967,11 @@ static PyObject *Method_PupFloatInput( PyObject * self, PyObject * args )
float min = 0, max = 1, var = 0, a1 = 10, a2 = 2;
PyObject *ret = NULL;
if (G.background) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Can't run Draw.PupFloatInput() in background mode." );
}
if( !PyArg_ParseTuple
( args, "s|fffff", &text, &var, &min, &max, &a1, &a2 ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
@@ -1903,6 +1996,11 @@ static PyObject *Method_PupStrInput( PyObject * self, PyObject * args )
char max = 20;
PyObject *ret = NULL;
if (G.background) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Can't run Draw.PupStrInput() in background mode." );
}
if( !PyArg_ParseTuple( args, "ss|b", &textMsg, &text, &max ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected 2 strings and 1 int" );
@@ -1937,6 +2035,11 @@ static PyObject *Method_PupBlock( PyObject * self, PyObject * args )
int len, i;
char *title;
if (G.background) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Can't run Draw.PupBlock() in background mode." );
}
if (!PyArg_ParseTuple( args, "sO", &title, &pyList ) || !PySequence_Check( pyList ))
return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a string and a sequence" );
@@ -2070,6 +2173,11 @@ static PyObject *Method_Image( PyObject * self, PyObject * args )
int clipX = 0, clipY = 0, clipW = -1, clipH = -1;
/*GLfloat scissorBox[4];*/
if (G.background) {
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Can't run Draw.Image() in background mode." );
}
/* parse the arguments passed-in from Python */
if( !PyArg_ParseTuple( args, "O!ff|ffiiii", &Image_Type, &pyObjImage,
&originX, &originY, &zoomX, &zoomY,

View File

@@ -36,6 +36,7 @@
#include "BKE_object.h"
#include "BKE_ipo.h"
#include "BLI_blenlib.h"
#include "BIF_keyframing.h"
#include "BIF_space.h"
#include "BSE_editipo.h"
#include "MEM_guardedalloc.h"

View File

@@ -35,6 +35,7 @@
#include "BKE_depsgraph.h"
#include "BKE_ipo.h"
#include "BKE_utildefines.h"
#include "BIF_keyframing.h"
#include "BIF_space.h"
#include "BSE_editipo.h"
#include "MEM_guardedalloc.h"

View File

@@ -31,7 +31,7 @@
#define EXPP_IPOCURVE_H
#include <Python.h>
#include "DNA_curve_types.h" /* declaration of IpoCurve */
#include "DNA_ipo_types.h" /* declaration of IpoCurve */
/*****************************************************************************/
/* Python C_IpoCurve structure definition: */

View File

@@ -34,15 +34,20 @@
#include "BKE_global.h"
#include "BKE_object.h"
#include "BKE_library.h"
#include "BKE_texture.h"
#include "BLI_blenlib.h"
#include "BIF_keyframing.h"
#include "BIF_space.h"
#include "BSE_editipo.h"
#include "mydevice.h"
#include "Ipo.h"
#include "MTex.h"
#include "constant.h"
#include "gen_utils.h"
#include "gen_library.h"
#include "BKE_utildefines.h"
#include "DNA_userdef_types.h"
#include "MEM_guardedalloc.h"
/*****************************************************************************/
/* Python BPy_Lamp defaults: */
@@ -206,6 +211,7 @@ static PyObject *Lamp_getQuad2( BPy_Lamp * self );
static PyObject *Lamp_getCol( BPy_Lamp * self );
static PyObject *Lamp_getIpo( BPy_Lamp * self );
static PyObject *Lamp_getComponent( BPy_Lamp * self, void * closure );
static PyObject *Lamp_getTextures( BPy_Lamp * self );
static PyObject *Lamp_clearIpo( BPy_Lamp * self );
static PyObject *Lamp_insertIpoKey( BPy_Lamp * self, PyObject * args );
static PyObject *Lamp_oldsetIpo( BPy_Lamp * self, PyObject * args );
@@ -253,6 +259,7 @@ static int Lamp_setHaloInt( BPy_Lamp * self, PyObject * args );
static int Lamp_setQuad1( BPy_Lamp * self, PyObject * args );
static int Lamp_setQuad2( BPy_Lamp * self, PyObject * args );
static int Lamp_setCol( BPy_Lamp * self, PyObject * args );
static int Lamp_setTextures( BPy_Lamp * self, PyObject * value );
static PyObject *Lamp_getScriptLinks( BPy_Lamp * self, PyObject * value );
static PyObject *Lamp_addScriptLink( BPy_Lamp * self, PyObject * args );
static PyObject *Lamp_clearScriptLinks( BPy_Lamp * self, PyObject * args );
@@ -500,6 +507,10 @@ static PyGetSetDef BPy_Lamp_getseters[] = {
(getter)Lamp_getComponent, (setter)Lamp_setComponent,
"Lamp color blue component",
(void *)EXPP_LAMP_COMP_B},
{"textures",
(getter)Lamp_getTextures, (setter)Lamp_setTextures,
"The Lamp's texture list as a tuple",
NULL},
{"Modes",
(getter)Lamp_getModesConst, (setter)NULL,
"Dictionary of values for 'mode' attribute",
@@ -1326,7 +1337,7 @@ static int Lamp_setIpo( BPy_Lamp * self, PyObject * value )
static PyObject *Lamp_insertIpoKey( BPy_Lamp * self, PyObject * args )
{
int key = 0, map;
int key = 0, flag = 0, map;
if( !PyArg_ParseTuple( args, "i", &( key ) ) )
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
@@ -1334,26 +1345,29 @@ static PyObject *Lamp_insertIpoKey( BPy_Lamp * self, PyObject * args )
map = texchannel_to_adrcode(self->lamp->texact);
/* flag should be initialised with the 'autokeying' flags like for normal keying */
if (IS_AUTOKEY_FLAG(INSERTNEEDED)) flag |= INSERTKEY_NEEDED;
if (key == IPOKEY_RGB ) {
insertkey((ID *)self->lamp, ID_LA, NULL, NULL, LA_COL_R, 0);
insertkey((ID *)self->lamp, ID_LA, NULL, NULL,LA_COL_G, 0);
insertkey((ID *)self->lamp, ID_LA, NULL, NULL,LA_COL_B, 0);
insertkey((ID *)self->lamp, ID_LA, NULL, NULL, LA_COL_R, flag);
insertkey((ID *)self->lamp, ID_LA, NULL, NULL,LA_COL_G, flag);
insertkey((ID *)self->lamp, ID_LA, NULL, NULL,LA_COL_B, flag);
}
if (key == IPOKEY_ENERGY ) {
insertkey((ID *)self->lamp, ID_LA, NULL, NULL,LA_ENERGY, 0);
insertkey((ID *)self->lamp, ID_LA, NULL, NULL,LA_ENERGY, flag);
}
if (key == IPOKEY_SPOTSIZE ) {
insertkey((ID *)self->lamp, ID_LA, NULL, NULL,LA_SPOTSI, 0);
insertkey((ID *)self->lamp, ID_LA, NULL, NULL,LA_SPOTSI, flag);
}
if (key == IPOKEY_OFFSET ) {
insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_OFS_X, 0);
insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_OFS_Y, 0);
insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_OFS_Z, 0);
insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_OFS_X, flag);
insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_OFS_Y, flag);
insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_OFS_Z, flag);
}
if (key == IPOKEY_SIZE ) {
insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_SIZE_X, 0);
insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_SIZE_Y, 0);
insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_SIZE_Z, 0);
insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_SIZE_X, flag);
insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_SIZE_Y, flag);
insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_SIZE_Z, flag);
}
allspace(REMAKEIPO, 0);
@@ -1393,6 +1407,100 @@ static PyObject *Lamp_getTypesConst( void )
"Photon", EXPP_LAMP_TYPE_YF_PHOTON );
}
static PyObject *Lamp_getTextures( BPy_Lamp * self )
{
int i;
PyObject *tuple;
/* build a texture list */
tuple = PyTuple_New( MAX_MTEX );
if( !tuple )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create PyTuple" );
for( i = 0; i < MAX_MTEX; ++i ) {
struct MTex *mtex = self->lamp->mtex[i];
if( mtex ) {
PyTuple_SET_ITEM( tuple, i, MTex_CreatePyObject( mtex, ID_LA ) );
} else {
Py_INCREF( Py_None );
PyTuple_SET_ITEM( tuple, i, Py_None );
}
}
return tuple;
}
static int Lamp_setTextures( BPy_Lamp * self, PyObject * value )
{
int i;
if( !PyList_Check( value ) && !PyTuple_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected tuple or list of integers" );
/* don't allow more than MAX_MTEX items */
if( PySequence_Size(value) > MAX_MTEX )
return EXPP_ReturnIntError( PyExc_AttributeError,
"size of sequence greater than number of allowed textures" );
/* get a fast sequence; in Python 2.5, this just return the original
* list or tuple and INCREFs it, so we must DECREF */
value = PySequence_Fast( value, "" );
/* check the list for valid entries */
for( i= 0; i < PySequence_Size(value) ; ++i ) {
PyObject *item = PySequence_Fast_GET_ITEM( value, i );
if( item == Py_None || ( BPy_MTex_Check( item ) &&
((BPy_MTex *)item)->type == ID_LA ) ) {
continue;
} else {
Py_DECREF(value);
return EXPP_ReturnIntError( PyExc_TypeError,
"expected tuple or list containing lamp MTex objects and NONE" );
}
}
/* for each MTex object, copy to this structure */
for( i= 0; i < PySequence_Size(value) ; ++i ) {
PyObject *item = PySequence_Fast_GET_ITEM( value, i );
struct MTex *mtex = self->lamp->mtex[i];
if( item != Py_None ) {
BPy_MTex *obj = (BPy_MTex *)item;
/* if MTex is already at this location, just skip it */
if( obj->mtex == mtex ) continue;
/* create a new entry if needed, otherwise update reference count
* for texture that is being replaced */
if( !mtex )
mtex = self->lamp->mtex[i] = add_mtex( );
else
mtex->tex->id.us--;
/* copy the data */
mtex->tex = obj->mtex->tex;
id_us_plus( &mtex->tex->id );
mtex->texco = obj->mtex->texco;
mtex->mapto = obj->mtex->mapto;
}
}
/* now go back and free any entries now marked as None */
for( i= 0; i < PySequence_Size(value) ; ++i ) {
PyObject *item = PySequence_Fast_GET_ITEM( value, i );
struct MTex *mtex = self->lamp->mtex[i];
if( item == Py_None && mtex ) {
mtex->tex->id.us--;
MEM_freeN( mtex );
self->lamp->mtex[i] = NULL;
}
}
Py_DECREF(value);
return 0;
}
/* #####DEPRECATED###### */
static PyObject *Lamp_oldsetSamples( BPy_Lamp * self, PyObject * args )

View File

@@ -22,10 +22,11 @@
*
* This is a new part of Blender.
*
* Contributor(s): Alex Mole, Yehoshua Sapir
* Contributor(s): Alex Mole, Yehoshua Sapir, Ken Hughes
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "MTex.h" /*This must come first*/
#include "BKE_utildefines.h"
@@ -35,7 +36,8 @@
#include "gen_utils.h"
#include "gen_library.h"
#include <DNA_material_types.h>
#include "DNA_material_types.h"
#include "DNA_world_types.h"
/*****************************************************************************/
/* Python BPy_MTex methods declarations: */
@@ -94,6 +96,7 @@ MTEXGETSET(ProjX)
MTEXGETSET(ProjY)
MTEXGETSET(ProjZ)
MTEXGETSET(MapToFlag)
MTEXGETSET(WorldMapToFlag)
/*****************************************************************************/
/* Python get/set methods table */
@@ -154,8 +157,14 @@ static PyGetSetDef MTex_getseters[] = {
"Projection of Y axis to Texture space", NULL },
{ "zproj", (getter) MTex_getProjZ, (setter) MTex_setProjZ,
"Projection of Z axis to Texture space", NULL },
/* MapTo for Material and Lamp MTex */
{ "mtCol", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
"How texture maps to color", (void*) MAP_COL },
/* MapTo for Material MTex */
{ "mtNor", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
"How texture maps to normals", (void*) MAP_NORM },
{ "mtCsp", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
@@ -182,6 +191,18 @@ static PyGetSetDef MTex_getseters[] = {
"How texture maps to displacement", (void*) MAP_DISPLACE },
{ "mtWarp", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
"How texture maps to warp", (void*) MAP_WARP },
/* MapTo for World MTex */
{ "mtBlend", (getter) MTex_getWorldMapToFlag, (setter) MTex_setWorldMapToFlag,
"Texture affects color progression of background", (void*) WOMAP_BLEND },
{ "mtHoriz", (getter) MTex_getWorldMapToFlag, (setter) MTex_setWorldMapToFlag,
"Texture affects color of the horizon", (void*) WOMAP_HORIZ },
{ "mtZenUp", (getter) MTex_getWorldMapToFlag, (setter) MTex_setWorldMapToFlag,
"Texture affects color of the zenith above", (void*) WOMAP_ZENUP },
{ "mtZenDown", (getter) MTex_getWorldMapToFlag, (setter) MTex_setWorldMapToFlag,
"Texture affects color of the zenith below", (void*) WOMAP_ZENDOWN },
{ NULL, NULL, NULL, NULL, NULL }
};
@@ -252,7 +273,7 @@ PyObject *MTex_Init( void )
return submodule;
}
PyObject *MTex_CreatePyObject( MTex * mtex )
PyObject *MTex_CreatePyObject( MTex * mtex, unsigned short type )
{
BPy_MTex *pymtex;
@@ -262,6 +283,7 @@ PyObject *MTex_CreatePyObject( MTex * mtex )
"couldn't create BPy_MTex PyObject" );
pymtex->mtex = mtex;
pymtex->type = type;
return ( PyObject * ) pymtex;
}
@@ -286,7 +308,12 @@ static int MTex_compare( BPy_MTex * a, BPy_MTex * b )
static PyObject *MTex_repr( BPy_MTex * self )
{
return PyString_FromFormat( "[MTex]" );
if( self->type == ID_MA )
return PyString_FromFormat( "[MTex (Material)]" );
else if( self->type == ID_LA )
return PyString_FromFormat( "[MTex (Lamp)]" );
else
return PyString_FromFormat( "[MTex (World)]" );
}
@@ -316,19 +343,37 @@ static int MTex_setTexCo( BPy_MTex *self, PyObject *value, void *closure)
{
int texco;
if( !PyInt_Check( value ) ) {
if( !PyInt_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"Value must be a member of Texture.TexCo dictionary" );
}
texco = PyInt_AsLong( value ) ;
if (texco != TEXCO_ORCO && texco != TEXCO_REFL && texco != TEXCO_NORM &&
texco != TEXCO_GLOB && texco != TEXCO_UV && texco != TEXCO_OBJECT &&
texco != TEXCO_STRESS && texco != TEXCO_TANGENT && texco != TEXCO_WINDOW &&
texco != TEXCO_VIEW && texco != TEXCO_STICKY )
return EXPP_ReturnIntError( PyExc_ValueError,
"Value must be a member of Texture.TexCo dictionary" );
switch ( self->type ) {
case ID_MA :
if( texco != TEXCO_ORCO && texco != TEXCO_REFL &&
texco != TEXCO_NORM && texco != TEXCO_GLOB &&
texco != TEXCO_UV && texco != TEXCO_OBJECT &&
texco != TEXCO_STRESS && texco != TEXCO_TANGENT &&
texco != TEXCO_WINDOW && texco != TEXCO_VIEW &&
texco != TEXCO_STICKY )
return EXPP_ReturnIntError( PyExc_ValueError,
"Value must be a member of Texture.TexCo dictionary" );
break;
case ID_LA :
if( texco != TEXCO_VIEW && texco != TEXCO_GLOB &&
texco != TEXCO_OBJECT )
return EXPP_ReturnIntError( PyExc_ValueError,
"Value must be a member of Texture.TexCo dictionary" );
break;
default: /* ID_WO */
if( texco != TEXCO_VIEW && texco != TEXCO_GLOB &&
texco != TEXCO_ANGMAP && texco != TEXCO_OBJECT &&
texco != TEXCO_H_SPHEREMAP && texco != TEXCO_H_TUBEMAP )
return EXPP_ReturnIntError( PyExc_ValueError,
"Value must be a member of Texture.TexCo dictionary" );
break;
}
self->mtex->texco = (short)texco;
@@ -350,6 +395,10 @@ static int MTex_setObject( BPy_MTex *self, PyObject *value, void *closure)
static PyObject *MTex_getUVLayer( BPy_MTex *self, void *closure )
{
if( self->type != ID_MA )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"not a Material MTex object" );
return PyString_FromString(self->mtex->uvname);
}
@@ -364,6 +413,10 @@ static int MTex_setUVLayer( BPy_MTex *self, PyObject *value, void *closure)
static PyObject *MTex_getMapTo( BPy_MTex *self, void *closure )
{
if( self->type != ID_MA )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"not a Material MTex object" );
return PyInt_FromLong( self->mtex->mapto );
}
@@ -371,18 +424,20 @@ static int MTex_setMapTo( BPy_MTex *self, PyObject *value, void *closure)
{
int mapto;
if( !PyInt_Check( value ) ) {
if( self->type != ID_MA )
return EXPP_ReturnIntError( PyExc_AttributeError,
"not a material MTex object" );
if( !PyInt_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected an int" );
}
"expected an int" );
mapto = PyInt_AsLong( value );
/* This method is deprecated anyway. */
if ( mapto < 0 || mapto > 16383 ) {
if ( mapto < 0 || mapto > 16383 )
return EXPP_ReturnIntError( PyExc_ValueError,
"Value must be a sum of values from Texture.MapTo dictionary" );
}
self->mtex->mapto = (short)mapto;
@@ -400,11 +455,9 @@ static int MTex_setCol( BPy_MTex *self, PyObject *value, void *closure)
float rgb[3];
int i;
if( !PyArg_ParseTuple( value, "fff",
&rgb[0], &rgb[1], &rgb[2] ) )
if( !PyArg_ParseTuple( value, "fff", &rgb[0], &rgb[1], &rgb[2] ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected tuple of 3 floats" );
"expected tuple of 3 floats" );
for( i = 0; i < 3; ++i )
if( rgb[i] < 0 || rgb[i] > 1 )
@@ -453,18 +506,13 @@ static int MTex_setBlendMode( BPy_MTex *self, PyObject *value, void *closure)
if ( !PyInt_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"Value must be member of Texture.BlendModes dictionary" );
"Value must be member of Texture.BlendModes dictionary" );
n = PyInt_AsLong(value);
/* if (n != MTEX_BLEND && n != MTEX_MUL && n != MTEX_ADD &&
n != MTEX_SUB && n != MTEX_DIV && n != MTEX_DARK &&
n != MTEX_DIFF && n != MTEX_LIGHT && n != MTEX_SCREEN)*/
if (n < 0 || n > 8)
{
return EXPP_ReturnIntError( PyExc_ValueError,
"Value must be member of Texture.BlendModes dictionary" );
}
"Value must be member of Texture.BlendModes dictionary" );
self->mtex->blendtype = (short)n;
@@ -478,117 +526,84 @@ static PyObject *MTex_getColFac( BPy_MTex *self, void *closure )
static int MTex_setColFac( BPy_MTex *self, PyObject *value, void *closure)
{
float f;
if ( !PyFloat_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a float" );
f = (float)PyFloat_AsDouble(value);
if (f < 0 || f > 1)
return EXPP_ReturnIntError( PyExc_ValueError,
"values must be in range [0,1]" );
self->mtex->colfac = f;
return 0;
return EXPP_setFloatRange( value, &self->mtex->colfac, 0.0f, 1.0f );
}
static PyObject *MTex_getNorFac( BPy_MTex *self, void *closure )
{
if( self->type == ID_LA )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"not a material or world MTex object" );
return PyFloat_FromDouble(self->mtex->norfac);
}
static int MTex_setNorFac( BPy_MTex *self, PyObject *value, void *closure)
{
float f;
if ( !PyFloat_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a float" );
f = (float)PyFloat_AsDouble(value);
if (f < 0 || f > 25)
return EXPP_ReturnIntError( PyExc_ValueError,
"values must be in range [0,25]" );
self->mtex->norfac = f;
return 0;
switch( self->type )
{
case ID_WO:
return EXPP_setFloatRange( value, &self->mtex->norfac, 0.0f, 1.0f );
case ID_MA:
return EXPP_setFloatRange( value, &self->mtex->norfac, 0.0f, 25.0f );
default:
return EXPP_ReturnIntError( PyExc_AttributeError,
"not a material or world MTex object" );
}
}
static PyObject *MTex_getVarFac( BPy_MTex *self, void *closure )
{
if( self->type == ID_LA )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"not a material or world MTex object" );
return PyFloat_FromDouble(self->mtex->varfac);
}
static int MTex_setVarFac( BPy_MTex *self, PyObject *value, void *closure)
{
float f;
if( self->type == ID_LA )
return EXPP_ReturnIntError( PyExc_AttributeError,
"not a material or world MTex object" );
if ( !PyFloat_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a float" );
f = (float)PyFloat_AsDouble(value);
if (f < 0 || f > 1)
return EXPP_ReturnIntError( PyExc_ValueError,
"values must be in range [0,1]" );
self->mtex->varfac = f;
return 0;
return EXPP_setFloatRange( value, &self->mtex->varfac, 0.0f, 1.0f );
}
static PyObject *MTex_getDispFac( BPy_MTex *self, void *closure )
{
if( self->type != ID_MA )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"not a material MTex object" );
return PyFloat_FromDouble(self->mtex->dispfac);
}
static int MTex_setDispFac( BPy_MTex *self, PyObject *value, void *closure)
{
float f;
if( self->type != ID_MA )
return EXPP_ReturnIntError( PyExc_AttributeError,
"not a material MTex object" );
if ( !PyFloat_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a float" );
f = (float)PyFloat_AsDouble(value);
if (f < 0 || f > 1)
return EXPP_ReturnIntError( PyExc_ValueError,
"values must be in range [0,1]" );
self->mtex->dispfac = f;
return 0;
return EXPP_setFloatRange( value, &self->mtex->dispfac, 0.0f, 1.0f );
}
static PyObject *MTex_getWarpFac( BPy_MTex *self, void *closure )
{
if( self->type != ID_MA )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"not a material MTex object" );
return PyFloat_FromDouble(self->mtex->warpfac);
}
static int MTex_setWarpFac( BPy_MTex *self, PyObject *value, void *closure)
{
float f;
if( self->type != ID_MA )
return EXPP_ReturnIntError( PyExc_AttributeError,
"not a material MTex object" );
if ( !PyFloat_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a float" );
f = (float)PyFloat_AsDouble(value);
if (f < 0 || f > 1)
return EXPP_ReturnIntError( PyExc_ValueError,
"values must be in range [0,1]" );
self->mtex->warpfac = f;
return 0;
return EXPP_setFloatRange( value, &self->mtex->warpfac, 0.0f, 1.0f );
}
static PyObject *MTex_getOfs( BPy_MTex *self, void *closure )
@@ -601,16 +616,24 @@ static int MTex_setOfs( BPy_MTex *self, PyObject *value, void *closure)
{
float f[3];
int i;
float max;
if( !PyArg_ParseTuple( value, "fff", &f[0], &f[1], &f[2] ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected tuple of 3 floats" );
if( self->type == ID_MA )
max = 10.0f;
else
max = 20.0f;
for( i = 0; i < 3; ++i )
if( f[i] < -10 || f[i] > 10 )
return EXPP_ReturnIntError( PyExc_ValueError,
"values must be in range [-10,10]" );
if( f[i] < -max || f[i] > max ) {
char errstr[64];
sprintf( errstr, "values must be in range [-%6.0f,%6.0f]",
max, max );
return EXPP_ReturnIntError( PyExc_ValueError, errstr );
}
self->mtex->ofs[0] = f[0];
self->mtex->ofs[1] = f[1];
@@ -649,6 +672,10 @@ static int MTex_setSize( BPy_MTex *self, PyObject *value, void *closure)
static PyObject *MTex_getMapping( BPy_MTex *self, void *closure )
{
if( self->type != ID_MA )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"not a material MTex object" );
return PyInt_FromLong( self->mtex->mapping );
}
@@ -656,6 +683,11 @@ static int MTex_setMapping( BPy_MTex *self, PyObject *value, void *closure)
{
int n;
if( self->type != ID_MA )
return EXPP_ReturnIntError( PyExc_AttributeError,
"not a material MTex object" );
if ( !PyInt_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"Value must be member of Texture.Mappings dictionary" );
@@ -664,8 +696,7 @@ static int MTex_setMapping( BPy_MTex *self, PyObject *value, void *closure)
/* if (n != MTEX_FLAT && n != MTEX_TUBE && n != MTEX_CUBE &&
n != MTEX_SPHERE) */
if (n < 0 || n > 3)
{
if (n < 0 || n > 3) {
return EXPP_ReturnIntError( PyExc_ValueError,
"Value must be member of Texture.Mappings dictionary" );
}
@@ -677,25 +708,43 @@ static int MTex_setMapping( BPy_MTex *self, PyObject *value, void *closure)
static PyObject *MTex_getFlag( BPy_MTex *self, void *closure )
{
return PyBool_FromLong( self->mtex->texflag & (GET_INT_FROM_POINTER(closure)) );
int flag = GET_INT_FROM_POINTER(closure);
if( self->type != ID_MA &&
flag & ( MTEX_VIEWSPACE | MTEX_DUPLI_MAPTO | MTEX_OB_DUPLI_ORIG ) )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"attribute only vaild for material MTex object" );
return PyBool_FromLong( self->mtex->texflag & flag );
}
static int MTex_setFlag( BPy_MTex *self, PyObject *value, void *closure)
{
int flag = GET_INT_FROM_POINTER(closure);
if( self->type != ID_MA &&
flag & ( MTEX_VIEWSPACE | MTEX_DUPLI_MAPTO | MTEX_OB_DUPLI_ORIG ) )
return EXPP_ReturnIntError( PyExc_AttributeError,
"attribute only vaild for material MTex object" );
if ( !PyBool_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a bool");
if ( value == Py_True )
self->mtex->texflag |= GET_INT_FROM_POINTER(closure);
self->mtex->texflag |= flag;
else
self->mtex->texflag &= ~(GET_INT_FROM_POINTER(closure));
self->mtex->texflag &= ~flag;
return 0;
}
static PyObject *MTex_getProjX( BPy_MTex *self, void *closure )
{
if( self->type != ID_MA )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"not a material MTex object" );
return PyInt_FromLong( self->mtex->projx );
}
@@ -703,6 +752,10 @@ static int MTex_setProjX( BPy_MTex *self, PyObject *value, void *closure)
{
int proj;
if( self->type != ID_MA )
return EXPP_ReturnIntError( PyExc_AttributeError,
"not a material MTex object" );
if( !PyInt_Check( value ) ) {
return EXPP_ReturnIntError( PyExc_TypeError,
"Value must be a member of Texture.Proj dictionary" );
@@ -722,6 +775,10 @@ static int MTex_setProjX( BPy_MTex *self, PyObject *value, void *closure)
static PyObject *MTex_getProjY( BPy_MTex *self, void *closure )
{
if( self->type != ID_MA )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"not a material MTex object" );
return PyInt_FromLong( self->mtex->projy );
}
@@ -729,6 +786,10 @@ static int MTex_setProjY( BPy_MTex *self, PyObject *value, void *closure )
{
int proj;
if( self->type != ID_MA )
return EXPP_ReturnIntError( PyExc_AttributeError,
"not a material MTex object" );
if( !PyInt_Check( value ) ) {
return EXPP_ReturnIntError( PyExc_TypeError,
"Value must be a member of Texture.Proj dictionary" );
@@ -748,6 +809,10 @@ static int MTex_setProjY( BPy_MTex *self, PyObject *value, void *closure )
static PyObject *MTex_getProjZ( BPy_MTex *self, void *closure )
{
if( self->type != ID_MA )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"not a material MTex object" );
return PyInt_FromLong( self->mtex->projz );
}
@@ -755,6 +820,10 @@ static int MTex_setProjZ( BPy_MTex *self, PyObject *value, void *closure)
{
int proj;
if( self->type != ID_MA )
return EXPP_ReturnIntError( PyExc_AttributeError,
"not a material MTex object" );
if( !PyInt_Check( value ) ) {
return EXPP_ReturnIntError( PyExc_TypeError,
"Value must be a member of Texture.Proj dictionary" );
@@ -776,12 +845,25 @@ static PyObject *MTex_getMapToFlag( BPy_MTex *self, void *closure )
{
int flag = GET_INT_FROM_POINTER(closure);
if( self->type == ID_LA && flag != MAP_COL )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"attribute not available for a lamp MTex" );
if ( self->mtex->mapto & flag )
{
return PyInt_FromLong( ( self->mtex->maptoneg & flag ) ? -1 : 1 );
} else {
else
return PyInt_FromLong( 0 );
}
}
static PyObject *MTex_getWorldMapToFlag( BPy_MTex *self, void *closure )
{
int flag = GET_INT_FROM_POINTER(closure);
if( self->type != ID_WO )
return EXPP_ReturnPyObjError( PyExc_AttributeError,
"not a world MTex object" );
return PyInt_FromLong( (long)( (self->mtex->mapto & flag) != 0 ) );
}
static int MTex_setMapToFlag( BPy_MTex *self, PyObject *value, void *closure)
@@ -789,14 +871,17 @@ static int MTex_setMapToFlag( BPy_MTex *self, PyObject *value, void *closure)
int flag = GET_INT_FROM_POINTER(closure);
int intVal;
if( self->type == ID_LA && flag != MAP_COL )
return EXPP_ReturnIntError( PyExc_AttributeError,
"attribute not available for a lamp MTex" );
if ( !PyInt_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected an int");
intVal = PyInt_AsLong( value );
intVal = PyInt_AsLong( value ) ;
if (flag == MAP_COL || flag == MAP_COLSPEC || flag == MAP_COLMIR ||
flag == MAP_WARP) {
if( flag & ( MAP_COL | MAP_COLSPEC | MAP_COLMIR | MAP_WARP ) ) {
if (intVal < 0 || intVal > 1) {
return EXPP_ReturnIntError( PyExc_ValueError,
"value for that mapping must be 0 or 1" );
@@ -828,3 +913,31 @@ static int MTex_setMapToFlag( BPy_MTex *self, PyObject *value, void *closure)
return 0;
}
static int MTex_setWorldMapToFlag( BPy_MTex *self, PyObject *value, void *closure)
{
int flag = GET_INT_FROM_POINTER(closure);
if( self->type != ID_WO )
return EXPP_ReturnIntError( PyExc_AttributeError,
"attribute only available for a world MTex" );
if ( !PyInt_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected an int");
switch( PyInt_AsLong( value ) ) {
case 0:
self->mtex->mapto &= ~flag;
break;
case 1:
self->mtex->mapto |= flag;
break;
default:
return EXPP_ReturnIntError( PyExc_ValueError,
"value for mapping must be 0 or 1" );
}
return 0;
}

View File

@@ -38,22 +38,26 @@
/* Python BPy_MTex structure definition */
/*****************************************************************************/
#define MATERIAL_MTEX_TYPE 1
#define WORLD_MTEX_TYPE 2
#define LAMP_MTEX_TYPE 3
typedef struct {
PyObject_HEAD
MTex * mtex;
unsigned short type;
} BPy_MTex;
extern PyTypeObject MTex_Type;
#define BPy_MTex_Check(v) ((v)->ob_type == &MTex_Type)
/*****************************************************************************/
/* Module Blender.Texture.MTex - public functions */
/*****************************************************************************/
PyObject *MTex_Init( void );
PyObject *MTex_CreatePyObject( struct MTex *obj );
PyObject *MTex_CreatePyObject( struct MTex *obj, unsigned short type );
MTex *MTex_FromPyObject( PyObject * py_obj );

View File

@@ -32,16 +32,19 @@
#include "DNA_space_types.h"
#include "DNA_material_types.h"
#include "DNA_userdef_types.h"
#include "BKE_main.h"
#include "BKE_global.h"
#include "BKE_library.h"
#include "BKE_material.h"
#include "BKE_texture.h"
#include "BKE_node.h"
#include "BKE_idprop.h"
#include "BKE_utildefines.h" /* for CLAMP */
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BSE_editipo.h"
#include "BIF_keyframing.h"
#include "BIF_space.h"
#include "mydevice.h"
#include "constant.h"
@@ -154,6 +157,8 @@
#define EXPP_MAT_SPECTRANS_MAX 1.0
#define EXPP_MAT_MIRRTRANSADD_MIN 0.0
#define EXPP_MAT_MIRRTRANSADD_MAX 1.0
#define EXPP_MAT_COLORBAND_FACTOR_MIN 0.0
#define EXPP_MAT_COLORBAND_FACTOR_MAX 1.0
/* closure values for getColorComponent()/setColorComponent() */
@@ -402,19 +407,62 @@ static PyObject *Material_ShadersDict( void )
return Shaders;
}
static PyObject *Material_ColorRampMethodsDict( void )
{
PyObject *Methods = PyConstant_New( );
if( Methods ) {
BPy_constant *c = (BPy_constant * ) Methods;
PyConstant_Insert(c, "BLEND", PyInt_FromLong(MA_RAMP_BLEND));
PyConstant_Insert(c, "MIX", PyInt_FromLong(MA_RAMP_BLEND)); /* This one is added to solve confusion between Blend-Mix name. */
PyConstant_Insert(c, "ADD", PyInt_FromLong(MA_RAMP_ADD));
PyConstant_Insert(c, "MULT", PyInt_FromLong(MA_RAMP_MULT));
PyConstant_Insert(c, "SUB", PyInt_FromLong(MA_RAMP_SUB));
PyConstant_Insert(c, "SCREEN", PyInt_FromLong(MA_RAMP_SCREEN));
PyConstant_Insert(c, "DIV", PyInt_FromLong(MA_RAMP_DIV));
PyConstant_Insert(c, "DIFF", PyInt_FromLong(MA_RAMP_DIFF));
PyConstant_Insert(c, "DARK", PyInt_FromLong(MA_RAMP_DARK));
PyConstant_Insert(c, "LIGHT", PyInt_FromLong(MA_RAMP_LIGHT));
PyConstant_Insert(c, "OVERLAY", PyInt_FromLong(MA_RAMP_OVERLAY));
PyConstant_Insert(c, "DODGE", PyInt_FromLong(MA_RAMP_DODGE));
PyConstant_Insert(c, "BURN", PyInt_FromLong(MA_RAMP_BURN));
PyConstant_Insert(c, "HUE", PyInt_FromLong(MA_RAMP_HUE));
PyConstant_Insert(c, "SAT", PyInt_FromLong(MA_RAMP_SAT));
PyConstant_Insert(c, "VAL", PyInt_FromLong(MA_RAMP_VAL));
PyConstant_Insert(c, "COLOR", PyInt_FromLong(MA_RAMP_COLOR));
}
return Methods;
}
static PyObject *Material_ColorRampInputDict( void )
{
PyObject *Inputs = PyConstant_New( );
if( Inputs ) {
BPy_constant *c = (BPy_constant * ) Inputs;
PyConstant_Insert(c, "SHADER", PyInt_FromLong(MA_RAMP_IN_SHADER));
PyConstant_Insert(c, "ENERGY", PyInt_FromLong(MA_RAMP_IN_ENERGY));
PyConstant_Insert(c, "NORMAL", PyInt_FromLong(MA_RAMP_IN_NOR));
PyConstant_Insert(c, "RESULT", PyInt_FromLong(MA_RAMP_IN_RESULT));
}
return Inputs;
}
/*****************************************************************************/
/* Function: Material_Init */
/*****************************************************************************/
PyObject *Material_Init( void )
{
PyObject *submodule, *Modes, *Shaders;
PyObject *submodule, *Modes, *Shaders, *ColorbandInput, *ColorbandMethod;
if( PyType_Ready( &Material_Type ) < 0)
return NULL;
Modes = Material_ModesDict( );
Shaders = Material_ShadersDict( );
ColorbandMethod = Material_ColorRampMethodsDict( );
ColorbandInput = Material_ColorRampInputDict( );
submodule = Py_InitModule3( "Blender.Material",
M_Material_methods, M_Material_doc );
@@ -423,6 +471,10 @@ PyObject *Material_Init( void )
PyModule_AddObject( submodule, "Modes", Modes );
if( Shaders )
PyModule_AddObject( submodule, "Shaders", Shaders );
if( ColorbandMethod )
PyModule_AddObject( submodule, "ColorbandMethod", ColorbandMethod );
if( ColorbandInput )
PyModule_AddObject( submodule, "ColorbandInput", ColorbandInput );
PyModule_AddIntConstant( submodule, "RGB", IPOKEY_RGB );
PyModule_AddIntConstant( submodule, "ALPHA", IPOKEY_ALPHA );
@@ -555,6 +607,7 @@ static int Material_setSssFront( BPy_Material * self, PyObject * value );
static int Material_setSssBack( BPy_Material * self, PyObject * value );
static int Material_setSssBack( BPy_Material * self, PyObject * value );
static int Material_setTexChannel( BPy_Material * self, PyObject * value );
static int Material_setTextures( BPy_Material * self, PyObject * value );
static PyObject *Material_getColorComponent( BPy_Material * self,
void * closure );
@@ -648,6 +701,21 @@ static PyObject *Material_insertIpoKey( BPy_Material * self, PyObject * args );
static PyObject *Material_getColorband( BPy_Material * self, void * type);
int Material_setColorband( BPy_Material * self, PyObject * value, void * type);
static PyObject *Material_copy( BPy_Material * self );
static PyObject *Material_freeNodes( BPy_Material * self );
static PyObject *Material_getColorbandDiffuseFactor( BPy_Material * self );
static PyObject *Material_getColorbandSpecularFactor( BPy_Material * self );
static int Material_setColorbandDiffuseFactor ( BPy_Material * self, PyObject * value );
static int Material_setColorbandSpecularFactor ( BPy_Material * self, PyObject * value );
static PyObject *Material_getColorbandDiffuseMethod( BPy_Material * self );
static PyObject *Material_getColorbandSpecularMethod ( BPy_Material * self );
static int Material_setColorbandDiffuseMethod ( BPy_Material * self, PyObject * value);
static int Material_setColorbandSpecularMethod ( BPy_Material * self, PyObject * value);
static PyObject *Material_getColorbandDiffuseInput( BPy_Material * self );
static PyObject *Material_getColorbandSpecularInput( BPy_Material * self );
static int Material_setColorbandDiffuseInput ( BPy_Material * self, PyObject * value);
static int Material_setColorbandSpecularInput ( BPy_Material * self, PyObject * value);
/*****************************************************************************/
@@ -886,6 +954,8 @@ static PyMethodDef BPy_Material_methods[] = {
"() - Return a copy of the material."},
{"copy", ( PyCFunction ) Material_copy, METH_NOARGS,
"() - Return a copy of the material."},
{"freeNodes", ( PyCFunction ) Material_freeNodes, METH_NOARGS,
"() - Free this materials nodes."},
{NULL, NULL, 0, NULL}
};
@@ -1168,7 +1238,35 @@ static PyGetSetDef BPy_Material_getseters[] = {
(getter)Material_getColorband, (setter)Material_setColorband,
"The specular colorband for this material",
(void *) 1},
{"textures",
(getter)Material_getTextures, (setter)Material_setTextures,
"The Material's texture list as a tuple",
NULL},
{"colorbandSpecularFactor",
(getter)Material_getColorbandSpecularFactor, (setter)Material_setColorbandSpecularFactor,
"The specular colorband factor for this material",
NULL},
{"colorbandSpecularMethod",
(getter)Material_getColorbandSpecularMethod, (setter)Material_setColorbandSpecularMethod,
"The specular colorband method for this material",
NULL},
{"colorbandSpecularInput",
(getter)Material_getColorbandSpecularInput, (setter)Material_setColorbandSpecularInput,
"The specular colorband input for this material",
NULL},
{"colorbandDiffuseFactor",
(getter)Material_getColorbandDiffuseFactor, (setter)Material_setColorbandDiffuseFactor,
"The diffuse colorband factor for this material",
NULL},
{"colorbandDiffuseMethod",
(getter)Material_getColorbandDiffuseMethod, (setter)Material_setColorbandDiffuseMethod,
"The diffuse colorband method for this material",
NULL},
{"colorbandDiffuseInput",
(getter)Material_getColorbandDiffuseInput, (setter)Material_setColorbandDiffuseInput,
"The diffuse colorband input for this material",
NULL},
/* SSS settings */
{"enableSSS",
(getter)Material_getSssEnable, (setter)Material_setSssEnable,
@@ -1737,27 +1835,23 @@ static PyObject* Material_getSssBack( BPy_Material * self )
static PyObject *Material_getTextures( BPy_Material * self )
{
int i;
struct MTex *mtex;
PyObject *t[MAX_MTEX];
PyObject *tuple;
/* build a texture list */
for( i = 0; i < MAX_MTEX; ++i ) {
mtex = self->material->mtex[i];
if( mtex ) {
t[i] = MTex_CreatePyObject( mtex );
} else {
Py_INCREF( Py_None );
t[i] = Py_None;
}
}
/* turn the array into a tuple */
tuple = Py_BuildValue( "NNNNNNNNNNNNNNNNNN", t[0], t[1], t[2], t[3], t[4], t[5], t[6], t[7], t[8], t[9], t[10], t[11], t[12], t[13], t[14], t[15], t[16], t[17] );
tuple = PyTuple_New( MAX_MTEX );
if( !tuple )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
"Material_getTextures: couldn't create PyTuple" );
"couldn't create PyTuple" );
for( i = 0; i < MAX_MTEX; ++i ) {
struct MTex *mtex = self->material->mtex[i];
if( mtex ) {
PyTuple_SET_ITEM( tuple, i, MTex_CreatePyObject( mtex, ID_MA ) );
} else {
Py_INCREF( Py_None );
PyTuple_SET_ITEM( tuple, i, Py_None );
}
}
return tuple;
}
@@ -1780,7 +1874,7 @@ static int Material_setIpo( BPy_Material * self, PyObject * value )
static PyObject *Material_insertIpoKey( BPy_Material * self, PyObject * args )
{
int key = 0, map;
int key = 0, flag = 0, map;
if( !PyArg_ParseTuple( args, "i", &( key ) ) )
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
@@ -1788,59 +1882,62 @@ static PyObject *Material_insertIpoKey( BPy_Material * self, PyObject * args )
map = texchannel_to_adrcode(self->material->texact);
/* flag should be initialised with the 'autokeying' flags like for normal keying */
if (IS_AUTOKEY_FLAG(INSERTNEEDED)) flag |= INSERTKEY_NEEDED;
if(key==IPOKEY_RGB || key==IPOKEY_ALLCOLOR) {
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_COL_R, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_COL_G, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_COL_B, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_COL_R, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_COL_G, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_COL_B, flag);
}
if(key==IPOKEY_ALPHA || key==IPOKEY_ALLCOLOR) {
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_ALPHA, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_ALPHA, flag);
}
if(key==IPOKEY_HALOSIZE || key==IPOKEY_ALLCOLOR) {
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_HASIZE, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_HASIZE, flag);
}
if(key==IPOKEY_MODE || key==IPOKEY_ALLCOLOR) {
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_MODE, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_MODE, flag);
}
if(key==IPOKEY_ALLCOLOR) {
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC_R, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC_G, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC_B, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_REF, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_EMIT, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_AMB, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_HARD, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_MODE, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_TRANSLU, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_ADD, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC_R, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC_G, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC_B, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_REF, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_EMIT, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_AMB, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_HARD, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_MODE, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_TRANSLU, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_ADD, flag);
}
if(key==IPOKEY_ALLMIRROR) {
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_RAYM, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESMIR, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESMIRI, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESTRA, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESTRAI, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_RAYM, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESMIR, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESMIRI, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESTRA, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESTRAI, flag);
}
if(key==IPOKEY_OFS || key==IPOKEY_ALLMAPPING) {
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_OFS_X, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_OFS_Y, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_OFS_Z, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_OFS_X, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_OFS_Y, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_OFS_Z, flag);
}
if(key==IPOKEY_SIZE || key==IPOKEY_ALLMAPPING) {
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_SIZE_X, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_SIZE_Y, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_SIZE_Z, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_SIZE_X, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_SIZE_Y, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_SIZE_Z, flag);
}
if(key==IPOKEY_ALLMAPPING) {
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_R, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_G, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_B, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_DVAR, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_COLF, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_NORF, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_VARF, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_DISP, 0);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_R, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_G, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_B, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_DVAR, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_COLF, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_NORF, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_VARF, flag);
insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_DISP, flag);
}
allspace(REMAKEIPO, 0);
@@ -2432,14 +2529,86 @@ static PyObject *Material_setTexture( BPy_Material * self, PyObject * args )
Py_RETURN_NONE;
}
static int Material_setTextures( BPy_Material * self, PyObject * value )
{
int i;
if( !PyList_Check( value ) && !PyTuple_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected tuple or list of integers" );
/* don't allow more than MAX_MTEX items */
if( PySequence_Size(value) > MAX_MTEX )
return EXPP_ReturnIntError( PyExc_AttributeError,
"size of sequence greater than number of allowed textures" );
/* get a fast sequence; in Python 2.5, this just return the original
* list or tuple and INCREFs it, so we must DECREF */
value = PySequence_Fast( value, "" );
/* check the list for valid entries */
for( i= 0; i < PySequence_Size(value) ; ++i ) {
PyObject *item = PySequence_Fast_GET_ITEM( value, i );
if( item == Py_None || ( BPy_MTex_Check( item ) &&
((BPy_MTex *)item)->type == ID_MA ) ) {
continue;
} else {
Py_DECREF(value);
return EXPP_ReturnIntError( PyExc_TypeError,
"expected tuple or list containing material MTex objects and NONE" );
}
}
/* for each MTex object, copy to this structure */
for( i= 0; i < PySequence_Size(value) ; ++i ) {
PyObject *item = PySequence_Fast_GET_ITEM( value, i );
struct MTex *mtex = self->material->mtex[i];
if( item != Py_None ) {
BPy_MTex *obj = (BPy_MTex *)item;
/* if MTex is already at this location, just skip it */
if( obj->mtex == mtex ) continue;
/* create a new entry if needed, otherwise update reference count
* for texture that is being replaced */
if( !mtex )
mtex = self->material->mtex[i] = add_mtex( );
else
mtex->tex->id.us--;
/* copy the data */
mtex->tex = obj->mtex->tex;
id_us_plus( &mtex->tex->id );
mtex->texco = obj->mtex->texco;
mtex->mapto = obj->mtex->mapto;
}
}
/* now go back and free any entries now marked as None */
for( i= 0; i < PySequence_Size(value) ; ++i ) {
PyObject *item = PySequence_Fast_GET_ITEM( value, i );
struct MTex *mtex = self->material->mtex[i];
if( item == Py_None && mtex ) {
mtex->tex->id.us--;
MEM_freeN( mtex );
self->material->mtex[i] = NULL;
}
}
Py_DECREF(value);
return 0;
}
static PyObject *Material_clearTexture( BPy_Material * self, PyObject * value )
{
int texnum = (int)PyInt_AsLong(value);
struct MTex *mtex;
/* non ints will be -1 */
if( ( texnum < 0 ) || ( texnum >= MAX_MTEX ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected int in [0,9]" );
if( ( texnum < 0 ) || ( texnum >= MAX_MTEX ) ) {
char errstr[64];
sprintf( errstr, "expected int in [0,%d]", MAX_MTEX );
return EXPP_ReturnPyObjError( PyExc_TypeError, errstr );
}
mtex = self->material->mtex[texnum];
if( mtex ) {
@@ -2518,6 +2687,22 @@ static PyObject *Material_copy( BPy_Material * self )
return ( PyObject * ) pymat;
}
/* mat.freeNodes() */
static PyObject *Material_freeNodes( BPy_Material * self )
{
if (self->material->nodetree) {
if(self->material->nodetree) {
ntreeFreeTree(self->material->nodetree);
MEM_freeN(self->material->nodetree);
}
self->material->nodetree = NULL;
self->material->use_nodes = 0;
Py_RETURN_TRUE;
} else {
Py_RETURN_FALSE;
}
}
/* mat_a==mat_b or mat_a!=mat_b*/
static int Material_compare( BPy_Material * a, BPy_Material * b )
{
@@ -3220,3 +3405,75 @@ static PyObject *Material_clearIpo( BPy_Material * self )
return EXPP_incr_ret_False(); /* no ipo found */
}
/* RampCol Factor */
static PyObject *Material_getColorbandDiffuseFactor( BPy_Material * self )
{
return PyFloat_FromDouble( (double) self->material->rampfac_col);
}
static PyObject *Material_getColorbandSpecularFactor( BPy_Material * self )
{
return PyFloat_FromDouble( (double) self->material->rampfac_spec);
}
static int Material_setColorbandDiffuseFactor ( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped(value, &self->material->rampfac_col,
EXPP_MAT_COLORBAND_FACTOR_MIN, EXPP_MAT_COLORBAND_FACTOR_MAX);
}
static int Material_setColorbandSpecularFactor ( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped(value, &self->material->rampfac_spec,
EXPP_MAT_COLORBAND_FACTOR_MIN, EXPP_MAT_COLORBAND_FACTOR_MAX);
}
/* RampCol Method */
static PyObject *Material_getColorbandDiffuseMethod( BPy_Material * self )
{
return PyInt_FromLong( (long) self->material->rampblend_col);
}
static PyObject *Material_getColorbandSpecularMethod ( BPy_Material * self )
{
return PyInt_FromLong( (long) self->material->rampblend_spec);
}
static int Material_setColorbandDiffuseMethod ( BPy_Material * self, PyObject * value)
{
return EXPP_setIValueClamped(value, &self->material->rampblend_col,
MA_RAMP_BLEND, MA_RAMP_COLOR, 'b');
}
static int Material_setColorbandSpecularMethod ( BPy_Material * self, PyObject * value)
{
return EXPP_setIValueClamped(value, &self->material->rampblend_spec,
MA_RAMP_BLEND, MA_RAMP_COLOR, 'b');
}
/* RampCol Input */
static PyObject *Material_getColorbandDiffuseInput( BPy_Material * self )
{
return PyInt_FromLong( (long) self->material->rampin_col);
}
static PyObject *Material_getColorbandSpecularInput( BPy_Material * self )
{
return PyInt_FromLong( (long) self->material->rampin_spec);
}
static int Material_setColorbandDiffuseInput ( BPy_Material * self, PyObject * value)
{
return EXPP_setIValueClamped(value, &self->material->rampin_col,
MA_RAMP_IN_SHADER, MA_RAMP_IN_RESULT, 'b');
}
static int Material_setColorbandSpecularInput ( BPy_Material * self, PyObject * value)
{
return EXPP_setIValueClamped(value, &self->material->rampin_spec,
MA_RAMP_IN_SHADER, MA_RAMP_IN_RESULT, 'b');
}

View File

@@ -83,7 +83,12 @@ enum mod_constants {
EXPP_MOD_UV,
/*ARMATURE SPECIFIC*/
EXPP_MOD_VGROUPS,
EXPP_MOD_ENVELOPES,
EXPP_MOD_QUATERNION,
EXPP_MOD_B_BONE_REST,
EXPP_MOD_INVERT_VERTGROUP,
EXPP_MOD_MULTIMODIFIER,
/*ARRAY SPECIFIC*/
EXPP_MOD_OBJECT_OFFSET,
@@ -376,12 +381,23 @@ static PyObject *armature_getter( BPy_Modifier * self, int type )
case EXPP_MOD_OBJECT:
return Object_CreatePyObject( md->object );
case EXPP_MOD_VERTGROUP:
return PyBool_FromLong( ( long )( md->deformflag & 1 ) ) ;
return PyString_FromString( md->defgrp_name ) ;
case EXPP_MOD_VGROUPS:
return EXPP_getBitfield( &md->deformflag, ARM_DEF_VGROUP, 'h' );
case EXPP_MOD_ENVELOPES:
return PyBool_FromLong( ( long )( md->deformflag & 2 ) ) ;
return EXPP_getBitfield( &md->deformflag, ARM_DEF_ENVELOPE, 'h' );
case EXPP_MOD_QUATERNION:
return EXPP_getBitfield( &md->deformflag, ARM_DEF_QUATERNION, 'h' );
case EXPP_MOD_B_BONE_REST:
return EXPP_getBitfield( &md->deformflag, ARM_DEF_B_BONE_REST, 'h' );
case EXPP_MOD_INVERT_VERTGROUP:
return EXPP_getBitfield( &md->deformflag, ARM_DEF_INVERT_VGROUP, 'h' );
case EXPP_MOD_MULTIMODIFIER:
return EXPP_getBitfield( &md->multi, 1, 'h' );
default:
return EXPP_ReturnPyObjError( PyExc_KeyError, "key not found" );
}
return 0;
}
static int armature_setter( BPy_Modifier *self, int type, PyObject *value )
@@ -391,13 +407,30 @@ static int armature_setter( BPy_Modifier *self, int type, PyObject *value )
switch( type ) {
case EXPP_MOD_OBJECT:
return GenericLib_assignData(value, (void **) &md->object, 0, 0, ID_OB, OB_ARMATURE);
case EXPP_MOD_VERTGROUP:
return EXPP_setBitfield( value, &md->deformflag, 1, 'h' );
case EXPP_MOD_VERTGROUP: {
char *defgrp_name = PyString_AsString( value );
if( !defgrp_name )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected string arg" );
BLI_strncpy( md->defgrp_name, defgrp_name, sizeof( md->defgrp_name ) );
break;
}
case EXPP_MOD_VGROUPS:
return EXPP_setBitfield( value, &md->deformflag, ARM_DEF_VGROUP, 'h' );
case EXPP_MOD_ENVELOPES:
return EXPP_setBitfield( value, &md->deformflag, 2, 'h' );
return EXPP_setBitfield( value, &md->deformflag, ARM_DEF_ENVELOPE, 'h' );
case EXPP_MOD_QUATERNION:
return EXPP_setBitfield( value, &md->deformflag, ARM_DEF_QUATERNION, 'h' );
case EXPP_MOD_B_BONE_REST:
return EXPP_setBitfield( value, &md->deformflag, ARM_DEF_B_BONE_REST, 'h' );
case EXPP_MOD_INVERT_VERTGROUP:
return EXPP_setBitfield( value, &md->deformflag, ARM_DEF_INVERT_VGROUP, 'h' );
case EXPP_MOD_MULTIMODIFIER:
return EXPP_setBitfield( value, &md->multi, 1, 'h' );
default:
return EXPP_ReturnIntError( PyExc_KeyError, "key not found" );
}
return 0;
}
static PyObject *lattice_getter( BPy_Modifier * self, int type )
@@ -1595,8 +1628,18 @@ for var in st.replace(',','').split('\n'):
PyInt_FromLong( EXPP_MOD_OPTIMAL ) );
PyConstant_Insert( d, "UV",
PyInt_FromLong( EXPP_MOD_UV ) );
PyConstant_Insert( d, "VGROUPS",
PyInt_FromLong( EXPP_MOD_VGROUPS ) );
PyConstant_Insert( d, "ENVELOPES",
PyInt_FromLong( EXPP_MOD_ENVELOPES ) );
PyConstant_Insert( d, "QUATERNION",
PyInt_FromLong( EXPP_MOD_QUATERNION ) );
PyConstant_Insert( d, "B_BONE_REST",
PyInt_FromLong( EXPP_MOD_B_BONE_REST ) );
PyConstant_Insert( d, "INVERT_VERTGROUP",
PyInt_FromLong( EXPP_MOD_INVERT_VERTGROUP ) );
PyConstant_Insert( d, "MULTIMODIFIER",
PyInt_FromLong( EXPP_MOD_MULTIMODIFIER ) );
PyConstant_Insert( d, "OBJECT_OFFSET",
PyInt_FromLong( EXPP_MOD_OBJECT_OFFSET ) );
PyConstant_Insert( d, "OBJECT_CURVE",

View File

@@ -81,6 +81,7 @@ struct rctf;
#include "BIF_editarmature.h"
#include "BIF_editaction.h"
#include "BIF_editnla.h"
#include "BIF_keyframing.h"
#include "BLI_arithb.h"
#include "BLI_blenlib.h"
@@ -2567,7 +2568,7 @@ static int Object_setMatrix( BPy_Object * self, MatrixObject * mat )
static PyObject *Object_insertIpoKey( BPy_Object * self, PyObject * args )
{
Object *ob= self->object;
int key = 0;
int key = 0, flag = 0;
char *actname= NULL;
if( !PyArg_ParseTuple( args, "i", &key ) )
@@ -2577,35 +2578,39 @@ static PyObject *Object_insertIpoKey( BPy_Object * self, PyObject * args )
if(ob->ipoflag & OB_ACTION_OB)
actname= "Object";
/* flag should be initialised with the 'autokeying' flags like for normal keying */
if (IS_AUTOKEY_FLAG(AUTOMATKEY)) flag |= INSERTKEY_MATRIX;
if (IS_AUTOKEY_FLAG(INSERTNEEDED)) flag |= INSERTKEY_NEEDED;
if (key == IPOKEY_LOC || key == IPOKEY_LOCROT || key == IPOKEY_LOCROTSIZE){
insertkey((ID *)ob, ID_OB, actname, NULL,OB_LOC_X, 0);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_LOC_Y, 0);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_LOC_Z, 0);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_LOC_X, flag);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_LOC_Y, flag);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_LOC_Z, flag);
}
if (key == IPOKEY_ROT || key == IPOKEY_LOCROT || key == IPOKEY_LOCROTSIZE){
insertkey((ID *)ob, ID_OB, actname, NULL,OB_ROT_X, 0);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_ROT_Y, 0);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_ROT_Z, 0);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_ROT_X, flag);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_ROT_Y, flag);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_ROT_Z, flag);
}
if (key == IPOKEY_SIZE || key == IPOKEY_LOCROTSIZE ){
insertkey((ID *)ob, ID_OB, actname, NULL,OB_SIZE_X, 0);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_SIZE_Y, 0);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_SIZE_Z, 0);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_SIZE_X, flag);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_SIZE_Y, flag);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_SIZE_Z, flag);
}
if (key == IPOKEY_LAYER ){
insertkey((ID *)ob, ID_OB, actname, NULL,OB_LAY, 0);
insertkey((ID *)ob, ID_OB, actname, NULL,OB_LAY, flag);
}
if (key == IPOKEY_PI_STRENGTH ){
insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_FSTR, 0);
insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_FSTR, flag);
} else if (key == IPOKEY_PI_FALLOFF ){
insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_FFALL, 0);
insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_FFALL, flag);
} else if (key == IPOKEY_PI_SURFACEDAMP ){
insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_SDAMP, 0);
insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_SDAMP, flag);
} else if (key == IPOKEY_PI_RANDOMDAMP ){
insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_RDAMP, 0);
insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_RDAMP, flag);
} else if (key == IPOKEY_PI_PERM ){
insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_PERM, 0);
insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_PERM, flag);
}
allspace(REMAKEIPO, 0);
@@ -2629,6 +2634,7 @@ static PyObject *Object_insertPoseKey( BPy_Object * self, PyObject * args )
BPy_Action *sourceact;
char *chanName;
int actframe;
int flag=0;
/* for doing the time trick, similar to editaction bake_action_with_client() */
@@ -2647,17 +2653,21 @@ static PyObject *Object_insertPoseKey( BPy_Object * self, PyObject * args )
/* XXX: must check chanName actually exists, otherwise segfaults! */
//achan = get_action_channel(sourceact->action, chanName);
/* flag should be initialised with the 'autokeying' flags like for normal keying */
if (IS_AUTOKEY_FLAG(AUTOMATKEY)) flag |= INSERTKEY_MATRIX;
if (IS_AUTOKEY_FLAG(INSERTNEEDED)) flag |= INSERTKEY_NEEDED;
insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_X, 0);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Y, 0);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Z, 0);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_X, 0);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Y, 0);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Z, 0);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_W, 0);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_X, 0);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Y, 0);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Z, 0);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_X, flag);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Y, flag);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Z, flag);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_X, flag);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Y, flag);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Z, flag);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_W, flag);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_X, flag);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Y, flag);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Z, flag);
G.scene->r.cfra = oldframe;
@@ -2679,6 +2689,7 @@ static PyObject *Object_insertPoseKey( BPy_Object * self, PyObject * args )
static PyObject *Object_insertCurrentPoseKey( BPy_Object * self, PyObject * args )
{
Object *ob= self->object;
int flag = 0;
char *chanName;
/* for doing the time trick, similar to editaction bake_action_with_client() */
@@ -2694,16 +2705,20 @@ static PyObject *Object_insertCurrentPoseKey( BPy_Object * self, PyObject * args
/* XXX: must check chanName actually exists, otherwise segfaults! */
insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_X, 0);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Y, 0);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Z, 0);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_X, 0);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Y, 0);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Z, 0);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_W, 0);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_X, 0);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Y, 0);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Z, 0);
/* flag should be initialised with the 'autokeying' flags like for normal keying */
if (IS_AUTOKEY_FLAG(AUTOMATKEY)) flag |= INSERTKEY_MATRIX;
if (IS_AUTOKEY_FLAG(INSERTNEEDED)) flag |= INSERTKEY_NEEDED;
insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_X, flag);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Y, flag);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Z, flag);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_X, flag);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Y, flag);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Z, flag);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_W, flag);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_X, flag);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Y, flag);
insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Z, flag);
G.scene->r.cfra = oldframe;
@@ -2734,7 +2749,7 @@ static PyObject *Object_setConstraintInfluenceForBone( BPy_Object * self,
"expects bonename, constraintname, influenceval" );
icu = verify_ipocurve((ID *)self->object, ID_CO, boneName, constName, NULL,
CO_ENFORCE);
CO_ENFORCE, 1);
if (!icu)
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
@@ -2987,7 +3002,7 @@ static PyObject *Object_getProperty( BPy_Object * self, PyObject * args )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected a string" );
prop = get_property( self->object, prop_name );
prop = get_ob_property( self->object, prop_name );
if( prop )
return Property_CreatePyObject( prop );
@@ -3003,7 +3018,7 @@ static PyObject *Object_addProperty( BPy_Object * self, PyObject * args )
char *prop_type = NULL;
short type = -1;
BPy_Property *py_prop = NULL;
int argslen = PyObject_Length( args );
int argslen = PyTuple_Size( args );
if( argslen == 3 || argslen == 2 ) {
if( !PyArg_ParseTuple( args, "sO|s", &prop_name, &prop_data,
@@ -3114,7 +3129,7 @@ static PyObject *Object_removeProperty( BPy_Object * self, PyObject * args )
py_prop->property = NULL;
}
} else {
prop = get_property( self->object, prop_name );
prop = get_ob_property( self->object, prop_name );
if( prop ) {
BLI_remlink( &self->object->prop, prop );
free_property( prop );
@@ -3133,18 +3148,22 @@ static PyObject *Object_copyAllPropertiesTo( BPy_Object * self,
PyObject * args )
{
PyObject *dest;
Object *dest_ob;
bProperty *prop = NULL;
bProperty *propn = NULL;
if( !PyArg_ParseTuple( args, "O!", &Object_Type, &dest ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected an Object" );
if (dest == (PyObject *)self) {
Py_RETURN_NONE;
}
dest_ob = ( ( BPy_Object * ) dest )->object;
/*make a copy of all its properties*/
prop = self->object->prop.first;
while( prop ) {
propn = copy_property( prop );
BLI_addtail( &( ( BPy_Object * ) dest )->object->prop, propn );
set_ob_property( dest_ob, prop );
prop = prop->next;
}
@@ -3304,6 +3323,33 @@ static PyObject *Object_insertShapeKey(BPy_Object * self)
Py_RETURN_NONE;
}
static PyObject *Object_getColor( BPy_Object *self, void *type )
{
return Py_BuildValue( "(ffff)", self->object->col[0], self->object->col[1], self->object->col[2], self->object->col[3] );
}
static int Object_setColor( BPy_Object *self, PyObject *value )
{
int i;
float color[4];
struct Object *object = self->object;
value = PySequence_Tuple( value );
if( !value || !PyArg_ParseTuple( value, "ffff", &color[0], &color[1], &color[2], &color[3] ) ) {
Py_XDECREF( value );
return EXPP_ReturnIntError( PyExc_TypeError,
"expected a list or tuple of 3 floats" );
}
Py_DECREF( value );
for( i = 0; i < 4; ++i ) {
object->col[i] = MAX2(MIN2(color[i], 1.0), 0);
}
return 0;
}
/* __copy__() */
static PyObject *Object_copy(BPy_Object * self)
{
@@ -3518,8 +3564,8 @@ static int Object_setRBMass( BPy_Object * self, PyObject * args )
/* this is too low level, possible to add helper methods */
#define GAMEFLAG_MASK ( OB_DYNAMIC | OB_CHILD | OB_ACTOR | OB_DO_FH | \
OB_ROT_FH | OB_ANISOTROPIC_FRICTION | OB_GHOST | OB_RIGID_BODY | \
#define GAMEFLAG_MASK ( OB_COLLISION | OB_DYNAMIC | OB_CHILD | OB_ACTOR | OB_DO_FH | \
OB_ROT_FH | OB_ANISOTROPIC_FRICTION | OB_GHOST | OB_RIGID_BODY | OB_SOFT_BODY | \
OB_BOUNDS | OB_COLLISION_RESPONSE | OB_SECTOR | OB_PROP | \
OB_MAINACTOR )
@@ -5188,7 +5234,10 @@ static PyGetSetDef BPy_Object_getseters[] = {
(getter)Object_getDrawModeBits, (setter)Object_setDrawModeBits,
"Transparent materials for the active object (mesh only) enabled",
(void *)OB_DRAWTRANSP},
{"color",
(getter)Object_getColor, (setter)Object_setColor,
"Object color used by the game engine and optionally for materials",
NULL},
{"enableNLAOverride",
(getter)Object_getNLAflagBits, (setter)Object_setNLAflagBits,
"Toggles Action-NLA based animation",
@@ -5496,6 +5545,7 @@ static PyObject *M_Object_RBFlagsDict( void )
if( M ) {
BPy_constant *d = ( BPy_constant * ) M;
PyConstant_Insert( d, "COLLISION", PyInt_FromLong( OB_COLLISION ) );
PyConstant_Insert( d, "DYNAMIC", PyInt_FromLong( OB_DYNAMIC ) );
PyConstant_Insert( d, "CHILD", PyInt_FromLong( OB_CHILD ) );
PyConstant_Insert( d, "ACTOR", PyInt_FromLong( OB_ACTOR ) );
@@ -5505,6 +5555,7 @@ static PyObject *M_Object_RBFlagsDict( void )
PyInt_FromLong( OB_ANISOTROPIC_FRICTION ) );
PyConstant_Insert( d, "GHOST", PyInt_FromLong( OB_GHOST ) );
PyConstant_Insert( d, "RIGIDBODY", PyInt_FromLong( OB_RIGID_BODY ) );
PyConstant_Insert( d, "SOFTBODY", PyInt_FromLong( OB_SOFT_BODY ) );
PyConstant_Insert( d, "BOUNDS", PyInt_FromLong( OB_BOUNDS ) );
PyConstant_Insert( d, "COLLISION_RESPONSE",
PyInt_FromLong( OB_COLLISION_RESPONSE ) );

View File

@@ -526,15 +526,18 @@ throws NameError if name not found
PyObject *M_ParticleSys_Get( PyObject * self, PyObject * args )
{
#if 1
return EXPP_ReturnPyObjError( PyExc_NotImplementedError,
"Particle.Get() not implemented" );
#else
ParticleSettings *psys_iter;
char *name = NULL;
#if 0
ParticleSystem *blparticlesys = 0;
Object *ob;
PyObject *partsyslist,*current;
#endif
if( !PyArg_ParseTuple( args, "|s", &name ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument" );
@@ -577,7 +580,6 @@ PyObject *M_ParticleSys_Get( PyObject * self, PyObject * args )
}
while( psys_iter ){
#if 0
pyobj = ParticleSystem_CreatePyObject( psys_iter);
if( !pyobj){
Py_DECREF( pylist );
@@ -586,7 +588,6 @@ PyObject *M_ParticleSys_Get( PyObject * self, PyObject * args )
"could not create ParticleSystem PyObject");
}
PyList_SET_ITEM( pylist, index, pyobj);
#endif
printf("name is %s\n", psys_iter->id.name+2);
psys_iter = psys_iter->id.next;
index++;
@@ -596,10 +597,6 @@ PyObject *M_ParticleSys_Get( PyObject * self, PyObject * args )
}
#if 0
for( ob = G.main->particlesystem.first; ob; ob = ob->id.next )
if( !strcmp( name, ob->id.name + 2 ) )
break;
@@ -626,7 +623,6 @@ PyObject *M_ParticleSys_Get( PyObject * self, PyObject * args )
}
return partsyslist;
#endif
}

View File

@@ -43,6 +43,7 @@
#include "DNA_scene_types.h"
#include "DNA_space_types.h" //1 - this order
#include "BSE_editipo.h" //2
#include "BIF_keyframing.h"
#include "BLI_blenlib.h"
#include "BLI_arithb.h"
#include "Mathutils.h"
@@ -413,16 +414,17 @@ static PyObject *PoseBone_insertKey(BPy_PoseBone *self, PyObject *args)
{
PyObject *parent_object = NULL;
PyObject *constants = NULL, *item = NULL;
int frame = 1, oldframe, length, x, numeric_value = 0, oldflag, no_ipo_update = 0;
int frame = 1, oldframe, length, x, numeric_value = 0, oldflag, no_ipo_update = 0, flag = 0;
bPoseChannel *pchan = NULL;
if (!PyArg_ParseTuple(args, "O!i|Oi", &Object_Type, &parent_object, &frame, &constants, &no_ipo_update ))
goto AttributeError;
/* incase we ever have a value other then 1 for fast */
if (no_ipo_update)
no_ipo_update = 1;
/* flag should be initialised with the 'autokeying' flags like for normal keying */
if (no_ipo_update) flag |= INSERTKEY_FAST;
if (IS_AUTOKEY_FLAG(AUTOMATKEY)) flag |= INSERTKEY_MATRIX;
if (IS_AUTOKEY_FLAG(INSERTNEEDED)) flag |= INSERTKEY_NEEDED;
//verify that this pchannel is part of the object->pose
for (pchan = ((BPy_Object*)parent_object)->object->pose->chanbase.first;
@@ -492,29 +494,29 @@ static PyObject *PoseBone_insertKey(BPy_PoseBone *self, PyObject *args)
//insert the pose keys
if (self->posechannel->flag & POSE_ROT){
insertkey(&((BPy_Object*)parent_object)->object->id,
ID_PO, self->posechannel->name, NULL, AC_QUAT_X, no_ipo_update);
ID_PO, self->posechannel->name, NULL, AC_QUAT_X, flag);
insertkey(&((BPy_Object*)parent_object)->object->id,
ID_PO, self->posechannel->name, NULL, AC_QUAT_Y, no_ipo_update);
ID_PO, self->posechannel->name, NULL, AC_QUAT_Y, flag);
insertkey(&((BPy_Object*)parent_object)->object->id,
ID_PO, self->posechannel->name, NULL, AC_QUAT_Z, no_ipo_update);
ID_PO, self->posechannel->name, NULL, AC_QUAT_Z, flag);
insertkey(&((BPy_Object*)parent_object)->object->id,
ID_PO, self->posechannel->name, NULL, AC_QUAT_W, no_ipo_update);
ID_PO, self->posechannel->name, NULL, AC_QUAT_W, flag);
}
if (self->posechannel->flag & POSE_LOC){
insertkey(&((BPy_Object*)parent_object)->object->id,
ID_PO, self->posechannel->name, NULL, AC_LOC_X, no_ipo_update);
ID_PO, self->posechannel->name, NULL, AC_LOC_X, flag);
insertkey(&((BPy_Object*)parent_object)->object->id,
ID_PO, self->posechannel->name, NULL, AC_LOC_Y, no_ipo_update);
ID_PO, self->posechannel->name, NULL, AC_LOC_Y, flag);
insertkey(&((BPy_Object*)parent_object)->object->id,
ID_PO, self->posechannel->name, NULL, AC_LOC_Z, no_ipo_update);
ID_PO, self->posechannel->name, NULL, AC_LOC_Z, flag);
}
if (self->posechannel->flag & POSE_SIZE){
insertkey(&((BPy_Object*)parent_object)->object->id,
ID_PO, self->posechannel->name, NULL, AC_SIZE_X, no_ipo_update);
ID_PO, self->posechannel->name, NULL, AC_SIZE_X, flag);
insertkey(&((BPy_Object*)parent_object)->object->id,
ID_PO, self->posechannel->name, NULL, AC_SIZE_Y, no_ipo_update);
ID_PO, self->posechannel->name, NULL, AC_SIZE_Y, flag);
insertkey(&((BPy_Object*)parent_object)->object->id,
ID_PO, self->posechannel->name, NULL, AC_SIZE_Z, no_ipo_update);
ID_PO, self->posechannel->name, NULL, AC_SIZE_Z, flag);
}
//flip the frame back

View File

@@ -641,20 +641,18 @@ static PyObject *M_Scene_Get( PyObject * self, PyObject * args )
if( !PyArg_ParseTuple( args, "|s", &name ) )
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument (or nothing)" ) );
scene_iter = G.main->scene.first;
if( name ) { /* (name) - Search scene by name */
PyObject *wanted_scene = NULL;
while( ( scene_iter ) && ( wanted_scene == NULL ) ) {
if( strcmp( name, scene_iter->id.name + 2 ) == 0 )
wanted_scene =
Scene_CreatePyObject( scene_iter );
scene_iter = scene_iter->id.next;
for(;scene_iter; scene_iter = scene_iter->id.next) {
if( strcmp( name, scene_iter->id.name + 2 ) == 0 ) {
wanted_scene = Scene_CreatePyObject( scene_iter );
break;
}
}
if( wanted_scene == NULL ) { /* Requested scene doesn't exist */
@@ -678,19 +676,14 @@ static PyObject *M_Scene_Get( PyObject * self, PyObject * args )
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create PyList" ) );
while( scene_iter ) {
for(; scene_iter; scene_iter = scene_iter->id.next, index++) {
pyobj = Scene_CreatePyObject( scene_iter );
if( !pyobj ) {
Py_DECREF(sce_pylist);
return ( EXPP_ReturnPyObjError
( PyExc_MemoryError,
"couldn't create PyString" ) );
return NULL; /* Scene_CreatePyObject sets an error */
}
PyList_SET_ITEM( sce_pylist, index, pyobj );
scene_iter = scene_iter->id.next;
index++;
}
return sce_pylist;

View File

@@ -47,6 +47,10 @@
#define EXPP_TEXT_MODE_FOLLOW TXT_FOLLOW
/* checks for the group being removed */
#define TEXT_DEL_CHECK_PY(bpy_text) if (!(bpy_text->text)) return ( EXPP_ReturnPyObjError( PyExc_RuntimeError, "Text has been removed" ) )
#define TEXT_DEL_CHECK_INT(bpy_text) if (!(bpy_text->text)) return ( EXPP_ReturnIntError( PyExc_RuntimeError, "Text has been removed" ) )
/*****************************************************************************/
/* Python API function prototypes for the Text module. */
/*****************************************************************************/
@@ -109,6 +113,8 @@ static PyObject *Text_markSelection( BPy_Text * self, PyObject * args );
static PyObject *Text_suggest( BPy_Text * self, PyObject * args );
static PyObject *Text_showDocs( BPy_Text * self, PyObject * args );
static void text_reset_internal( BPy_Text * self ); /* internal func */
/*****************************************************************************/
/* Python BPy_Text methods table: */
/*****************************************************************************/
@@ -377,8 +383,7 @@ PyObject *Text_CreatePyObject( Text * txt )
"couldn't create BPy_Text PyObject" );
pytxt->text = txt;
pytxt->iol = NULL;
pytxt->ioc = -1;
text_reset_internal(pytxt);
return ( PyObject * ) pytxt;
}
@@ -388,6 +393,7 @@ PyObject *Text_CreatePyObject( Text * txt )
/*****************************************************************************/
static PyObject *Text_getFilename( BPy_Text * self )
{
TEXT_DEL_CHECK_PY(self);
if( self->text->name )
return PyString_FromString( self->text->name );
@@ -398,7 +404,9 @@ static PyObject *Text_getNLines( BPy_Text * self )
{ /* text->nlines isn't updated in Blender (?) */
int nlines = 0;
TextLine *line;
TEXT_DEL_CHECK_PY(self);
line = self->text->lines.first;
while( line ) { /* so we have to count them ourselves */
@@ -415,9 +423,7 @@ static PyObject *Text_clear( BPy_Text * self)
{
int oldstate;
if( !self->text )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"This object isn't linked to a Blender Text Object" );
TEXT_DEL_CHECK_PY(self);
oldstate = txt_get_undostate( );
txt_set_undostate( 1 );
@@ -428,11 +434,15 @@ static PyObject *Text_clear( BPy_Text * self)
Py_RETURN_NONE;
}
static PyObject *Text_reset( BPy_Text * self )
static void text_reset_internal( BPy_Text * self )
{
self->iol = NULL;
self->ioc = -1;
}
static PyObject *Text_reset( BPy_Text * self )
{
text_reset_internal(self);
Py_RETURN_NONE;
}
@@ -440,9 +450,7 @@ static PyObject *Text_readline( BPy_Text * self )
{
PyObject *tmpstr;
if( !self->text )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"This object isn't linked to a Blender Text Object" );
TEXT_DEL_CHECK_PY(self);
/* Reset */
if (!self->iol && self->ioc == -1) {
@@ -476,20 +484,18 @@ static PyObject *Text_write( BPy_Text * self, PyObject * value )
char *str = PyString_AsString(value);
int oldstate;
if( !self->text )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"This object isn't linked to a Blender Text Object" );
if( !str )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument" );
TEXT_DEL_CHECK_PY(self);
oldstate = txt_get_undostate( );
txt_insert_buf( self->text, str );
txt_move_eof( self->text, 0 );
txt_set_undostate( oldstate );
Text_reset( self );
text_reset_internal( self );
Py_RETURN_NONE;
}
@@ -499,19 +505,17 @@ static PyObject *Text_insert( BPy_Text * self, PyObject * value )
char *str = PyString_AsString(value);
int oldstate;
if( !self->text )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"This object isn't linked to a Blender Text Object" );
if( !str )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected string argument" );
TEXT_DEL_CHECK_PY(self);
oldstate = txt_get_undostate( );
txt_insert_buf( self->text, str );
txt_set_undostate( oldstate );
Text_reset( self );
text_reset_internal( self );
Py_RETURN_NONE;
}
@@ -521,11 +525,10 @@ static PyObject *Text_delete( BPy_Text * self, PyObject * value )
int num = PyInt_AsLong(value);
int oldstate;
if( !self->text )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"This object isn't linked to a Blender Text Object" );
if( !num )
TEXT_DEL_CHECK_PY(self);
/* zero num is invalid and -1 is an error value */
if( !num || (num==-1 && PyErr_Occurred()))
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected non-zero int argument" );
@@ -540,7 +543,7 @@ static PyObject *Text_delete( BPy_Text * self, PyObject * value )
}
txt_set_undostate( oldstate );
Text_reset( self );
text_reset_internal( self );
Py_RETURN_NONE;
}
@@ -550,6 +553,8 @@ static PyObject *Text_set( BPy_Text * self, PyObject * args )
int ival;
char *attr;
TEXT_DEL_CHECK_PY(self);
if( !PyArg_ParseTuple( args, "si", &attr, &ival ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected a string and an int as arguments" );
@@ -570,9 +575,7 @@ static PyObject *Text_asLines( BPy_Text * self, PyObject * args )
PyObject *list, *tmpstr;
int start=0, end=-1, i;
if( !self->text )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"This object isn't linked to a Blender Text Object" );
TEXT_DEL_CHECK_PY(self);
if( !PyArg_ParseTuple( args, "|ii", &start, &end ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
@@ -608,10 +611,9 @@ static PyObject *Text_getCursorPos( BPy_Text * self )
TextLine *linep;
int row, col;
TEXT_DEL_CHECK_PY(self);
text = self->text;
if( !text )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"This object isn't linked to a Blender Text Object" );
for (row=0,linep=text->lines.first; linep!=text->curl; linep=linep->next)
row++;
@@ -625,9 +627,7 @@ static PyObject *Text_setCursorPos( BPy_Text * self, PyObject * args )
int row, col;
SpaceText *st;
if (!self->text)
return EXPP_ReturnPyObjError(PyExc_RuntimeError,
"This object isn't linked to a Blender Text Object");
TEXT_DEL_CHECK_PY(self);
if (!PyArg_ParseTuple(args, "ii", &row, &col))
return EXPP_ReturnPyObjError(PyExc_TypeError,
@@ -649,10 +649,9 @@ static PyObject *Text_getSelectPos( BPy_Text * self )
TextLine *linep;
int row, col;
TEXT_DEL_CHECK_PY(self);
text = self->text;
if( !text )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"This object isn't linked to a Blender Text Object" );
for (row=0,linep=text->lines.first; linep!=text->sell; linep=linep->next)
row++;
@@ -666,9 +665,7 @@ static PyObject *Text_setSelectPos( BPy_Text * self, PyObject * args )
int row, col;
SpaceText *st;
if (!self->text)
return EXPP_ReturnPyObjError(PyExc_RuntimeError,
"This object isn't linked to a Blender Text Object");
TEXT_DEL_CHECK_PY(self);
if (!PyArg_ParseTuple(args, "ii", &row, &col))
return EXPP_ReturnPyObjError(PyExc_TypeError,
@@ -690,10 +687,9 @@ static PyObject *Text_markSelection( BPy_Text * self, PyObject * args )
Text *text;
char color[4];
TEXT_DEL_CHECK_PY(self);
text = self->text;
if (!text)
return EXPP_ReturnPyObjError(PyExc_RuntimeError,
"This object isn't linked to a Blender Text Object");
if (!PyArg_ParseTuple(args, "i(iii)i", &group, &r, &g, &b, &flags))
return EXPP_ReturnPyObjError(PyExc_TypeError,
@@ -723,9 +719,7 @@ static PyObject *Text_suggest( BPy_Text * self, PyObject * args )
char *prefix = NULL, *name, type;
SpaceText *st;
if (!self->text)
return EXPP_ReturnPyObjError(PyExc_RuntimeError,
"This object isn't linked to a Blender Text Object");
TEXT_DEL_CHECK_PY(self);
/* Parse args for a list of strings/tuples */
if (!PyArg_ParseTuple(args, "O!|s", &PyList_Type, &list, &prefix))
@@ -782,10 +776,8 @@ static PyObject *Text_showDocs( BPy_Text * self, PyObject * args )
{
char *docs;
SpaceText *st;
if (!self->text)
return EXPP_ReturnPyObjError(PyExc_RuntimeError,
"This object isn't linked to a Blender Text Object");
TEXT_DEL_CHECK_PY(self);
if (!PyArg_ParseTuple(args, "s", &docs))
return EXPP_ReturnPyObjError( PyExc_TypeError,
@@ -839,6 +831,7 @@ static PyObject *Text_repr( BPy_Text * self )
/*****************************************************************************/
static PyObject *Text_getMode(BPy_Text * self)
{
TEXT_DEL_CHECK_PY(self);
return PyInt_FromLong( self->text->flags );
}

View File

@@ -42,6 +42,7 @@
#include "DNA_material_types.h"
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
#include "DNA_world_types.h"
#include "MTex.h"
#include "Image.h"
@@ -1142,6 +1143,11 @@ static PyObject *M_Texture_TexCoDict( void )
PyConstant_Insert(d, "STICK", PyInt_FromLong(TEXCO_STICKY));
PyConstant_Insert(d, "STRESS", PyInt_FromLong(TEXCO_STRESS));
PyConstant_Insert(d, "TANGENT", PyInt_FromLong(TEXCO_TANGENT));
/* World TexCo Settings */
PyConstant_Insert(d, "ANGMAP", PyInt_FromLong(TEXCO_ANGMAP));
PyConstant_Insert(d, "HSPHERE", PyInt_FromLong(TEXCO_H_SPHEREMAP));
PyConstant_Insert(d, "HTUBE", PyInt_FromLong(TEXCO_H_TUBEMAP));
}
return TexCo;
}
@@ -2126,7 +2132,7 @@ static PyObject *Texture_getFlags( BPy_Texture *self )
static PyObject *Texture_getHFracDim( BPy_Texture *self )
{
return PyInt_FromLong( (long)self->texture->mg_H );
return PyFloat_FromDouble( self->texture->mg_H );
}
static PyObject *Texture_getImageFlags( BPy_Texture *self, void *type )

View File

@@ -1249,9 +1249,10 @@ static PyObject *M_Window_TestBreak( PyObject * self )
static PyObject *M_Window_GetMouseCoords( PyObject * self )
{
short mval[2];
short mval[2] = {0, 0};
getmouse( mval );
if (!G.background)
getmouse( mval );
return Py_BuildValue( "hh", mval[0], mval[1] );
}
@@ -1283,16 +1284,12 @@ static PyObject *M_Window_SetMouseCoords( PyObject * self, PyObject * args )
static PyObject *M_Window_GetMouseButtons( PyObject * self )
{
short mbut = get_mbut( );
return Py_BuildValue( "h", mbut );
return PyInt_FromLong(G.background ? 0 : (int)get_mbut() );
}
static PyObject *M_Window_GetKeyQualifiers( PyObject * self )
{
short qual = get_qual( );
return Py_BuildValue( "h", qual );
return PyInt_FromLong( (int)get_qual() );
}
static PyObject *M_Window_SetKeyQualifiers( PyObject * self, PyObject * args )

View File

@@ -43,17 +43,22 @@
#include "World.h" /*This must come first*/
#include "DNA_scene_types.h" /* for G.scene */
#include "DNA_userdef_types.h"
#include "BKE_global.h"
#include "BKE_world.h"
#include "BKE_main.h"
#include "BKE_library.h"
#include "BKE_texture.h"
#include "BLI_blenlib.h"
#include "BSE_editipo.h"
#include "BIF_keyframing.h"
#include "BIF_space.h"
#include "mydevice.h"
#include "Ipo.h"
#include "MTex.h"
#include "gen_utils.h"
#include "gen_library.h"
#include "MEM_guardedalloc.h"
#define IPOKEY_ZENITH 0
#define IPOKEY_HORIZON 1
@@ -99,6 +104,8 @@ static PyObject *World_getScriptLinks( BPy_World * self, PyObject * value );
static PyObject *World_addScriptLink( BPy_World * self, PyObject * args );
static PyObject *World_clearScriptLinks( BPy_World * self, PyObject * args );
static PyObject *World_setCurrent( BPy_World * self );
static PyObject *World_getTextures( BPy_World * self );
static int World_setTextures( BPy_World * self, PyObject * value );
static PyObject *World_copy( BPy_World * self );
@@ -250,6 +257,9 @@ static PyGetSetDef BPy_World_getseters[] = {
"world mist settings", NULL},
{"ipo", (getter)World_getIpo, (setter)World_setIpo,
"world ipo", NULL},
{"textures", (getter)World_getTextures, (setter)World_setTextures,
"The World's texture list as a tuple",
NULL},
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
};
@@ -979,7 +989,7 @@ World *World_FromPyObject( PyObject * py_obj )
static PyObject *World_insertIpoKey( BPy_World * self, PyObject * args )
{
int key = 0, map;
int key = 0, flag = 0, map;
if( !PyArg_ParseTuple( args, "i", &( key ) ) )
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
@@ -987,38 +997,41 @@ static PyObject *World_insertIpoKey( BPy_World * self, PyObject * args )
map = texchannel_to_adrcode(self->world->texact);
/* flag should be initialised with the 'autokeying' flags like for normal keying */
if (IS_AUTOKEY_FLAG(INSERTNEEDED)) flag |= INSERTKEY_NEEDED;
if(key == IPOKEY_ZENITH) {
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_ZEN_R, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_ZEN_G, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_ZEN_B, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_ZEN_R, flag);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_ZEN_G, flag);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_ZEN_B, flag);
}
if(key == IPOKEY_HORIZON) {
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_HOR_R, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_HOR_G, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_HOR_B, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_HOR_R, flag);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_HOR_G, flag);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_HOR_B, flag);
}
if(key == IPOKEY_MIST) {
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_MISI, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_MISTDI, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_MISTSTA, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_MISTHI, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_MISI, flag);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_MISTDI, flag);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_MISTSTA, flag);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_MISTHI, flag);
}
if(key == IPOKEY_STARS) {
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STAR_R, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STAR_G, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STAR_B, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STARDIST, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STARSIZE, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STAR_R, flag);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STAR_G, flag);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STAR_B, flag);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STARDIST, flag);
insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STARSIZE, flag);
}
if(key == IPOKEY_OFFSET) {
insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_OFS_X, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_OFS_Y, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_OFS_Z, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_OFS_X, flag);
insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_OFS_Y, flag);
insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_OFS_Z, flag);
}
if(key == IPOKEY_SIZE) {
insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_SIZE_X, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_SIZE_Y, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_SIZE_Z, 0);
insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_SIZE_X, flag);
insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_SIZE_Y, flag);
insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_SIZE_Z, flag);
}
allspace(REMAKEIPO, 0);
@@ -1029,3 +1042,97 @@ static PyObject *World_insertIpoKey( BPy_World * self, PyObject * args )
Py_RETURN_NONE;
}
static PyObject *World_getTextures( BPy_World * self )
{
int i;
PyObject *tuple;
/* build a texture list */
tuple = PyTuple_New( MAX_MTEX );
if( !tuple )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create PyTuple" );
for( i = 0; i < MAX_MTEX; ++i ) {
struct MTex *mtex = self->world->mtex[i];
if( mtex ) {
PyTuple_SET_ITEM( tuple, i, MTex_CreatePyObject( mtex, ID_WO ) );
} else {
Py_INCREF( Py_None );
PyTuple_SET_ITEM( tuple, i, Py_None );
}
}
return tuple;
}
static int World_setTextures( BPy_World * self, PyObject * value )
{
int i;
if( !PyList_Check( value ) && !PyTuple_Check( value ) )
return EXPP_ReturnIntError( PyExc_TypeError,
"expected tuple or list of integers" );
/* don't allow more than MAX_MTEX items */
if( PySequence_Size(value) > MAX_MTEX )
return EXPP_ReturnIntError( PyExc_AttributeError,
"size of sequence greater than number of allowed textures" );
/* get a fast sequence; in Python 2.5, this just return the original
* list or tuple and INCREFs it, so we must DECREF */
value = PySequence_Fast( value, "" );
/* check the list for valid entries */
for( i= 0; i < PySequence_Size(value) ; ++i ) {
PyObject *item = PySequence_Fast_GET_ITEM( value, i );
if( item == Py_None || ( BPy_MTex_Check( item ) &&
((BPy_MTex *)item)->type == ID_WO ) ) {
continue;
} else {
Py_DECREF(value);
return EXPP_ReturnIntError( PyExc_TypeError,
"expected tuple or list containing world MTex objects and NONE" );
}
}
/* for each MTex object, copy to this structure */
for( i= 0; i < PySequence_Size(value) ; ++i ) {
PyObject *item = PySequence_Fast_GET_ITEM( value, i );
struct MTex *mtex = self->world->mtex[i];
if( item != Py_None ) {
BPy_MTex *obj = (BPy_MTex *)item;
/* if MTex is already at this location, just skip it */
if( obj->mtex == mtex ) continue;
/* create a new entry if needed, otherwise update reference count
* for texture that is being replaced */
if( !mtex )
mtex = self->world->mtex[i] = add_mtex( );
else
mtex->tex->id.us--;
/* copy the data */
mtex->tex = obj->mtex->tex;
id_us_plus( &mtex->tex->id );
mtex->texco = obj->mtex->texco;
mtex->mapto = obj->mtex->mapto;
}
}
/* now go back and free any entries now marked as None */
for( i= 0; i < PySequence_Size(value) ; ++i ) {
PyObject *item = PySequence_Fast_GET_ITEM( value, i );
struct MTex *mtex = self->world->mtex[i];
if( item == Py_None && mtex ) {
mtex->tex->id.us--;
MEM_freeN( mtex );
self->world->mtex[i] = NULL;
}
}
Py_DECREF(value);
return 0;
}

View File

@@ -263,9 +263,12 @@ PyObject *LibBlockSeq_getActive(BPy_LibBlockSeq *self)
}
break;
case ID_TXT: {
SpaceText *st= curarea->spacedata.first;
SpaceText *st = NULL;
if (st->spacetype!=SPACE_TEXT || st->text==NULL) {
if (curarea)
st = curarea->spacedata.first;
if (st==NULL || st->spacetype!=SPACE_TEXT || st->text==NULL) {
Py_RETURN_NONE;
} else {
return Text_CreatePyObject( st->text );
@@ -330,9 +333,15 @@ static int LibBlockSeq_setActive(BPy_LibBlockSeq *self, PyObject *value)
return EXPP_ReturnIntError(PyExc_TypeError,
"Must be a text" );
} else {
SpaceText *st= curarea->spacedata.first;
SpaceText *st= NULL;
Text *data = ((BPy_Text *)value)->text;
if (curarea==NULL) {
return 0;
} else {
st= curarea->spacedata.first;
}
if( !data )
return EXPP_ReturnIntError( PyExc_RuntimeError,
"This object isn't linked to a Blender Text Object" );

View File

@@ -61,6 +61,14 @@ The Blender Python API Reference
- L{World}
- L{sys<Sys>}
Additional information:
-----------------------
- L{API_related}:
- Calling scripts from command line
- Script links and space handlers
- How to register scripts in menus
- Recommended ways to document and support configuration options
Introduction:
=============

View File

@@ -226,6 +226,7 @@ Introduction:
import Blender
from Blender import Draw
evt = Blender.event
val = Blender.eventValue
return_it = False
if evt == Draw.LEFTMOUSE:
@@ -233,7 +234,7 @@ Introduction:
elif evt == Draw.AKEY:
print "Swallowing an 'a' character"
else:
print "Let the 3D View itself process this event:", evt
print "Let the 3D View itself process this event: %d with value %d" % (evt, val)
return_it = True
# if Blender should not process itself the passed event:
@@ -249,8 +250,14 @@ Introduction:
tells what space this handler belongs to and the handler's type
(EVENT, DRAW);
- B{event}:
- EVENT handlers: an input event (check keys and mouse events in L{Draw})
to be processed or ignored.
- EVENT handlers: an input event (check keys and mouse events in
L{Draw}) to be processed or ignored;
- DRAW handlers: 0 always;
- B{eventValue}:
- EVENT handlers: the event value, it indicates mouse button or key
presses (since we don't pass releases) as 1 and mouse movements
(Draw.MOUSE.X and Draw.MOUSE.Y) as the current x or y coordinate,
for example;
- DRAW handlers: 0 always.
B{Guidelines (important)}:

View File

@@ -10,8 +10,8 @@
"""
The main Blender module.
B{New}: L{Run}, L{UpdateMenus}, new options to L{Get}, L{ShowHelp},
L{SpaceHandlers} dictionary.
B{New}: new var L{eventValue} for space handlers, L{Run}, L{UpdateMenus},
new options to L{Get}, L{ShowHelp}, L{SpaceHandlers} dictionary.
L{UnpackModes} dictionary.
Blender
@@ -34,7 +34,11 @@ Blender
- for normal L{GUI<Draw.Register>} scripts I{during the events callback},
it holds the ascii value of the current event, if it is a valid one.
Users interested in this should also check the builtin 'ord' and 'chr'
Python functions.
Python functions.
@type eventValue: int
@var eventValue: used only for EVENT space handlers, it holds the event value:
- for mouse button and key presses it's 1, for mouse movement
(Draw.MOUSEX and Draw.MOUSEY) it has the new x or y coordinate, resp.
@type mode: string
@var mode: Blender's current mode:
- 'interactive': normal mode, with an open window answering to user input;

View File

@@ -161,6 +161,8 @@ class Lamp:
@type type: int
@ivar falloffType: Lamp falloff type. See L{Falloffs} for values.
@type falloffType: int
@type textures: a tuple of Blender MTex objects.
@ivar textures: The Lamp's texture list. Empty texture channels contains None.
@warning: Most member variables assume values in some [Min, Max] interval.
When trying to set them, the given parameter will be clamped to lie in

View File

@@ -80,6 +80,35 @@ Example::
- SPEC_BLINN - Make Material use the Blinn specular shader.
- SPEC_TOON - Make Material use the toon specular shader.
- SPEC_WARDISO - Make Material use the Ward-iso specular shader.
@type ColorbandMethod: readonly dictionary
@var ColorbandMethod: The available Colorband mixing methods.
- ADD - Make Material use the Add method.
- BLEND - Make Material use the Blend/Mix method.
- BURN - Make Material use the Burn method.
- COLOR - Make Material use the Color method.
- DARK - Make Material use the Darken method.
- DIFF - Make Material use the Difference method.
- DIV - Make Material use the Divide method.
- DODGE - Make Material use the Dodge method.
- HUE - Make Material use the Hue method.
- LIGHT - Make Material use the Lighten method.
- MIX - Make Material use the Blend/Mix method.
- MULT - Make Material use the Multiply method.
- OVERLAY - Make Material use the Overlay method.
- SAT - Make Material use the Saturation method.
- SCREEN - Make Material use the Screen method.
- SUB - Make Material use the Substract method.
- VAL - Make Material use the Value method.
@type ColorbandInput: readonly dictionary
@var ColorbandInput: The available Colorband Input sources.
- ENERGY - Make Material use the Energy input.
- NORMAL - Make Material use the Normal input.
- RESULT - Make Material use the Result input.
- SHADER - Make Material use the Shader input.
"""
def New (name = 'Mat'):
@@ -323,6 +352,28 @@ class Material:
each color a list of 5 floats [0 - 1], [r,g,b,a,pos].
The colorband can have between 1 and 31 colors.
@type colorbandSpecular: list
@ivar colorbandDiffuseInput: Material Diffuse colorband input.
The integer result must be compared with L{ColorbandInput}
dictionary.
@type colorbandDiffuseInput: int
@ivar colorbandDiffuseMethod: Material Diffuse colorband method.
The integer result must be compared with L{ColorbandMethod}
dictionary.
@type colorbandDiffuseMethod: int
@ivar colorbandDiffuseFactor: Material Diffuse colorband factor.
Value is clamped to the range [0.0,1.0].
@type colorbandDiffuseFactor: float
@ivar colorbandSpecularInput: Material Specular colorband input.
The integer result must be compared with L{ColorbandInput}
dictionary.
@type colorbandSpecularInput: int
@ivar colorbandSpecularMethod: Material Specular colorband method.
The integer result must be compared with L{ColorbandMethod}
dictionary.
@type colorbandSpecularMethod: int
@ivar colorbandSpecularFactor: Material Specular colorband factor.
Value is clamped to the range [0.0,1.0].
@type colorbandSpecularFactor: float
@type enabledTextures: list of integers
@ivar enabledTextures: The texture channels enabled in this material.
The attribute returns is list of integers in the range [0, 9], each
@@ -338,7 +389,9 @@ class Material:
ch.append(4)
mat.enabledTextures = ch
print mat.enabledTextures # will print: [0, 4, 6]
@type textures: a tuple of Blender MTex objects.
@ivar textures: the Material's Texture list. Empty texture channels contains None.
@ivar enableSSS: If True, subsurface scattering will be rendered on this material.
@type enableSSS: bool
@ivar sssScale: If True, subsurface scattering will be rendered on this material.
@@ -1085,5 +1138,12 @@ class Material:
@return: a copy of this material
"""
def freeNodes ():
"""
Removes the node tree from this material.
@rtype: bool
@return: true if nodes were freed from this material.
"""
import id_generics
Material.__doc__ += id_generics.attributes

View File

@@ -636,7 +636,7 @@ class MFaceSeq:
This object provides sequence and iterator access to the mesh's faces.
"""
def extend(vertseq,ignoreDups=True,indexList=True):
def extend(vertseq,ignoreDups=True,indexList=True,smooth=False):
"""
Add zero or more faces and edges to the mesh. Faces which already exist
in the mesh, or faces which contain the same vertex multiple times are

View File

@@ -93,7 +93,12 @@ Example::
- SCALE_VEC - Used for Array only (3d Vector)
- MERGE_DIST - Used for Array only (float)
- INVERT_VERTGROUP - Used for Armature only (bool)
- ENVELOPES - Used for Armature only (bool)
- VGROUPS - Used for Armature only (bool)
- QUATERNION - Used for Armature only (bool)
- B_BONE_REST - Used for Armature only (bool)
- MULTIMODIFIER - Used for Armature only (bool)
- START - Used for Build only (int)
- SEED - Used for Build only (int)

View File

@@ -552,6 +552,8 @@ class Object:
@ivar transp: Enable transparent materials for the active object
(mesh only). Also see B{TRANSP} bit in L{drawMode} attribute.
@type transp: boolean
@ivar color: Object color used by the game engine and optionally for materials, 4 floats for RGBA object color.
@type color: tuple of 4 floats between 0 and 1
@ivar drawMode: The object's drawing mode bitfield.
See L{DrawModes} constant dict for values.
@type drawMode: int

View File

@@ -195,20 +195,23 @@ Example::
- DN_CELLNOISE - Steven Worley's cellular basis algorithm (1996)
@var TexCo: Flags for MTex.texco.
- ORCO - Use the original coordinates of the mesh
- REFL - Use reflection vector as texture coordinates
- NOR - Use normal vector as texture coordinates
- ORCO - Use the original coordinates of the mesh (material texture only)
- REFL - Use reflection vector as texture coordinates (material texture only)
- NOR - Use normal vector as texture coordinates (material texture only)
- GLOB - Use global coordinates for the texture coordinates
- UV - Use UV coordinates for texture coordinates
- UV - Use UV coordinates for texture coordinates (material texture only)
- OBJECT - Use linked object's coordinates for texture coordinates
- WIN - Use screen coordinates as texture coordinates
- VIEW - Pass camera view vector on to the texture (World texture only!)
- STICK - Use mesh sticky coordinates for the texture coordinates
- STRESS - Use mesh stress coordinates for the texture coordinates
- TANGENT - Use mesh tangent coordinates for the texture coordinates
- WIN - Use screen coordinates as texture coordinates (material texture only)
- VIEW - Use view coordinates for the texture (world and lamp texture only)
- STICK - Use mesh sticky coordinates for the texture coordinates (material texture only)
- STRESS - Use mesh stress coordinates for the texture coordinates (material texture only)
- TANGENT - Use mesh tangent coordinates for the texture coordinates (material texture only)
- ANGMAP - Uses 360 degree angular coordinates, e.g. for spherical light probes (world texture only)
- HSPHERE - For 360 degree panorama sky, spherical mapped, only top half (world texture only)
- HTUBE - For 360 degree panorama sky, cylindrical mapped, only top half (world texture only)
@type TexCo: readonly dictionary
@var MapTo: Flags for MTex.mapto.
@var MapTo: Flags for MTex.mapto
- COL - Make the texture affect the basic color of the material
- NOR - Make the texture affect the rendered normal
- CSP - Make the texture affect the specularity color
@@ -500,48 +503,92 @@ class MTex:
This object links a material to a texture. It allows the same texture to be
used in several different ways.
@ivar tex: The Texture this is linked to.
@type tex: Blender Texture
@ivar texco: Texture coordinates ("Map input"). See L{TexCo}
@ivar mapto: "Map to" field of texture. OR'd values of L{MapTo}
@ivar object: Object whose space to use when texco is Object
@type object: Blender Object
@ivar col: Color that the texture blends with
@ivar dvar: Value that the texture blends with when not blending colors
@ivar blendmode: Texture blending mode. L{BlendModes}
@ivar colfac: Factor by which texture affects color
@ivar norfac: Factor by which texture affects normal
@ivar varfac: Factor by which texture affects most variables
@ivar dispfac: Factor by which texture affects displacement
@ivar warpfac: Factor by which texture affects warp
@ivar ofs: Offset to adjust texture space
@ivar size: Size to scale texture space
@ivar mapping: Mapping of texture coordinates (flat, cube, etc.). L{Mappings}
@ivar stencil: Stencil mode
@ivar neg: Negate texture values mode
@ivar noRGB: Convert texture RGB values to intensity values
@ivar correctNor: Correct normal mapping for Texture space and Object space
@ivar fromDupli: Dupli's instanced from verts, faces or particles, inherit texture coordinate from their parent
@ivar fromOrig: Dupli's derive their object coordinates from the original objects transformation
@ivar xproj: Projection of X axis to Texture space. L{Proj}
@ivar yproj: Projection of Y axis to Texture space. L{Proj}
@ivar zproj: Projection of Z axis to Texture space. L{Proj}
@ivar mtCol: How texture maps to color
@ivar mtNor: How texture maps to normals
@ivar mtCsp: How texture maps to specularity color
@ivar mtCmir: How texture maps to mirror color
@ivar mtRef: How texture maps to reflectivity
@ivar mtSpec: How texture maps to specularity
@ivar mtEmit: How texture maps to emit value
@ivar mtAlpha: How texture maps to alpha value
@ivar mtHard: How texture maps to hardness
@ivar mtRayMir: How texture maps to RayMir value
@ivar mtTranslu: How texture maps to translucency
@ivar mtAmb: How texture maps to ambient value
@ivar mtDisp: How texture maps to displacement
@ivar mtWarp: How texture maps to warp
@ivar uvlayer: The name of the UV Layer this texture is mapped to (when left blank uses render layer)
@type uvlayer: string
@ivar blendmode: Texture blending mode. See L{BlendModes}
@type blendmode: int
@ivar col: Color that the texture blends with.
@type col: tuple
@ivar colfac: Factor by which texture affects color.
@type colfac: float
@ivar correctNor: Correct normal mapping for Texture space and Object space (material only).
@type correctNor: boolean
@ivar dispfac: Factor by which texture affects displacement (material only).
@type dispfac: float
@ivar dvar: Value that the texture blends with when not blending colors.
@type dvar: float
@ivar fromDupli: Duplis instanced from verts, faces or particles, inherit texture coordinate from their parent (material only).
@type fromDupli: boolean
@ivar fromOrig: Duplis derive their object coordinates from the original objects transformation (material only).
@type fromOrig: boolean
@ivar mapping: Mapping of texture coordinates (flat, cube, etc.) (material only). See L{Mappings}.
@type mapping: int
@ivar mapto: "Map to" field of texture (material only). OR'd values of L{MapTo}.
@type mapto: int
@ivar mtCol: How texture maps to color (material and lamp only).
@type mtCol: int
@ivar mtAlpha: How texture maps to alpha value (material only).
@type mtAlpha: int
@ivar mtAmb: How texture maps to ambient value (material only).
@type mtAmb: int
@ivar mtCmir: How texture maps to mirror color (material only).
@type mtCmir: int
@ivar mtCsp: How texture maps to specularity color (material only).
@type mtCsp: int
@ivar mtDisp: How texture maps to displacement (material only).
@type mtDisp: int
@ivar mtEmit: How texture maps to emit value (material only).
@type mtEmit: int
@ivar mtHard: How texture maps to hardness (material only).
@type mtHard: int
@ivar mtNor: How texture maps to normals (material only).
@type mtNor: int
@ivar mtRayMir: How texture maps to RayMir value (material only).
@type mtRayMir: int
@ivar mtRef: How texture maps to reflectivity (material only).
@type mtRef: int
@ivar mtSpec: How texture maps to specularity (material only).
@type mtSpec: int
@ivar mtTranslu: How texture maps to translucency (material only).
@type mtTranslu: int
@ivar mtWarp: How texture maps to warp (material only).
@type mtWarp: int
@ivar mtBlend: Texture affects color progression of background (world only).
@type mtBlend: int
@ivar mtHoriz: Texture affects color of the horizon (world only).
@type mtHoriz: int
@ivar mtZenUp: Texture affects color of the zenith above (world only).
@type mtZenUp: int
@ivar mtZenDown: Texture affects color of the zenith below (world only).
@type mtZenDown: int
@ivar neg: Negate texture values mode.
@type neg: boolean
@ivar norfac: Factor by which texture affects normal (material and world only).
@type norfac: float
@ivar noRGB: Convert texture RGB values to intensity values.
@type noRGB: boolean
@ivar object: Object whose space to use when texco is Object.
@type object: Blender Object or None
@ivar ofs: Offset to adjust texture space.
@type ofs: tuple
@ivar size: Size to scale texture space.
@type size: tuple
@ivar stencil: Stencil mode.
@type stencil: boolean
@ivar tex: The Texture this is linked to.
@type tex: Blender Texture
@ivar texco: Texture coordinates ("Map input"). See L{TexCo}.
@type texco: int
@ivar uvlayer: The name of the UV Layer this texture is mapped to (when left blank uses render layer) (material only).
@type uvlayer: string
@ivar varfac: Factor by which texture affects most variables (material and world only).
@type varfac: float
@ivar warpfac: Factor by which texture affects warp (material only).
@type warpfac: float
@ivar xproj: Projection of X axis to Texture space (material only). See L{Proj}
@type xproj: int
@ivar yproj: Projection of Y axis to Texture space (material only). See L{Proj}
@type yproj: int
@ivar zproj: Projection of Z axis to Texture space (material only). See L{Proj}
@type zproj: int
"""
def getIpo():

View File

@@ -82,6 +82,8 @@ class World:
@ivar mist: the mist parameters of a world object. See getMist for the semantics of these parameters.
@type ipo: Blender Ipo
@ivar ipo: The world type ipo linked to this world object.
@type textures: a tuple of Blender MTex objects.
@ivar textures: The World's texture list. Empty texture channels contains None.
"""
def getRange():

View File

@@ -481,7 +481,6 @@ PyObject *RenderData_Render( BPy_RenderData * self )
set_scene( oldsce );
}
else { /* background mode (blender -b file.blend -P script) */
int slink_flag = 0;
Render *re= RE_NewRender(G.scene->id.name);
int end_frame = G.scene->r.efra;
@@ -492,20 +491,14 @@ PyObject *RenderData_Render( BPy_RenderData * self )
G.scene->r.efra = G.scene->r.sfra;
if (G.f & G_DOSCRIPTLINKS) {
BPY_do_all_scripts(SCRIPT_RENDER);
G.f &= ~G_DOSCRIPTLINKS; /* avoid FRAMECHANGED events*/
slink_flag = 1;
}
if (G.f & G_DOSCRIPTLINKS)
BPY_do_all_scripts(SCRIPT_RENDER, 0);
tstate = PyEval_SaveThread();
RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra, G.scene->frame_step);
if (slink_flag) {
G.f |= G_DOSCRIPTLINKS;
BPY_do_all_scripts(SCRIPT_POSTRENDER);
}
BPY_do_all_scripts(SCRIPT_POSTRENDER, 0);
G.scene->r.efra = end_frame;
}
@@ -603,13 +596,13 @@ PyObject *RenderData_RenderAnim( BPy_RenderData * self )
"start frame must be less or equal to end frame");
if (G.f & G_DOSCRIPTLINKS)
BPY_do_all_scripts(SCRIPT_RENDER);
BPY_do_all_scripts(SCRIPT_RENDER, 1);
tstate = PyEval_SaveThread();
RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra);
RE_BlenderAnim(re, G.scene, G.scene->r.sfra, G.scene->r.efra, G.scene->frame_step);
if (G.f & G_DOSCRIPTLINKS)
BPY_do_all_scripts(SCRIPT_POSTRENDER);
BPY_do_all_scripts(SCRIPT_POSTRENDER, 1);
}
PyEval_RestoreThread(tstate);