Index: source/blender/python/api2_2x/doc/Material.py =================================================================== --- source/blender/python/api2_2x/doc/Material.py (revision 20343) +++ source/blender/python/api2_2x/doc/Material.py (working copy) @@ -69,6 +69,11 @@ - NMAP_TS - Tangent space normal mapping. - GROUP_EXCLUSIVE - Light from this group even if the lights are on a hidden Layer. +@type ShadeModes: readonly dictionary +@var ShadeModes: The available Material Shade Modes. + - CUBIC - Use cubic interpolation of diffuse values, for smoother transitions. + - OBCOLOR - Modulate result with a per object color. + @type Shaders: readonly dictionary @var Shaders: The available Material Shaders. - DIFFUSE_LAMBERT - Make Material use the lambert diffuse shader. @@ -246,6 +251,8 @@ @ivar mode: Mode mode bitfield. See L{the Modes dictionary} keys and descriptions. @type mode: int + @ivar shadeMode: Shade mode bitfield. See L{the ShadeModes dictionary} keys and descriptions. + @type shadeMode: int @ivar nFlares: Number of subflares with halo. Value is clamped to the range [1,32]. @type nFlares: int @@ -1146,4 +1153,4 @@ """ import id_generics -Material.__doc__ += id_generics.attributes +Material.__doc__ += id_generics.attributes \ No newline at end of file Index: source/blender/python/api2_2x/Material.c =================================================================== --- source/blender/python/api2_2x/Material.c (revision 20343) +++ source/blender/python/api2_2x/Material.c (working copy) @@ -335,6 +335,20 @@ } } +static PyObject *Material_ShadeModesDict( void ) +{ + PyObject *ShadeModes = PyConstant_New( ); + + if( ShadeModes ) { + BPy_constant *c = ( BPy_constant * ) ShadeModes; + + PyConstant_Insert(c, "CUBIC", PyInt_FromLong(MA_CUBIC)); + PyConstant_Insert(c, "OBCOLOR", PyInt_FromLong(MA_OBCOLOR)); + } + + return ShadeModes; +} + static PyObject *Material_ModesDict( void ) { PyObject *Modes = PyConstant_New( ); @@ -454,12 +468,13 @@ /*****************************************************************************/ PyObject *Material_Init( void ) { - PyObject *submodule, *Modes, *Shaders, *ColorbandInput, *ColorbandMethod; + PyObject *submodule, *Modes, *ShadeModes, *Shaders, *ColorbandInput, *ColorbandMethod; if( PyType_Ready( &Material_Type ) < 0) return NULL; Modes = Material_ModesDict( ); + ShadeModes = Material_ShadeModesDict( ); Shaders = Material_ShadersDict( ); ColorbandMethod = Material_ColorRampMethodsDict( ); ColorbandInput = Material_ColorRampInputDict( ); @@ -469,6 +484,8 @@ if( Modes ) PyModule_AddObject( submodule, "Modes", Modes ); + if( ShadeModes ) + PyModule_AddObject( submodule, "ShadeModes", ShadeModes ); if( Shaders ) PyModule_AddObject( submodule, "Shaders", Shaders ); if( ColorbandMethod ) @@ -541,6 +558,7 @@ static int Material_setIpo( BPy_Material * self, PyObject * value ); static int Material_setMode( BPy_Material * self, PyObject * value ); +static int Material_setShadeMode( BPy_Material * self, PyObject * value ); static int Material_setRGBCol( BPy_Material * self, PyObject * value ); static int Material_setSpecCol( BPy_Material * self, PyObject * value ); static int Material_setMirCol( BPy_Material * self, PyObject * value ); @@ -620,6 +638,7 @@ /*****************************************************************************/ static PyObject *Material_getIpo( BPy_Material * self ); static PyObject *Material_getMode( BPy_Material * self ); +static PyObject *Material_getShadeMode( BPy_Material * self ); static PyObject *Material_getRGBCol( BPy_Material * self ); /*static PyObject *Material_getAmbCol(BPy_Material *self);*/ static PyObject *Material_getSpecCol( BPy_Material * self ); @@ -1098,6 +1117,10 @@ (getter)Material_getMode, (setter)Material_setMode, "Material mode bitmask", NULL}, + {"shadeMode", + (getter)Material_getShadeMode, (setter)Material_setShadeMode, + "Material shade mode bitmask", + NULL}, {"nFlares", (getter)Material_getNFlares, (setter)Material_setNFlares, "Number of subflares with halo", @@ -1495,6 +1518,11 @@ return PyInt_FromLong( ( long ) self->material->mode ); } +static PyObject *Material_getShadeMode( BPy_Material * self ) +{ + return PyInt_FromLong( ( long ) self->material->shade_flag ); +} + static PyObject *Material_getRGBCol( BPy_Material * self ) { return rgbTuple_getCol( self->col ); @@ -1970,6 +1998,24 @@ return 0; } +static int Material_setShadeMode( BPy_Material * self, PyObject * value ) +{ + int param; + + if( !PyInt_Check( value ) ) { + char errstr[128]; + sprintf ( errstr , "expected int bitmask of 0x%08x", MA_MODE_MASK ); + return EXPP_ReturnIntError( PyExc_TypeError, errstr ); + } + param = PyInt_AS_LONG ( value ); + if ( ( param & (MA_CUBIC | MA_OBCOLOR) ) != param ) + return EXPP_ReturnIntError( PyExc_ValueError, + "invalid bit(s) set in mask" ); + self->material->mode |= param; + + return 0; +} + static int Material_setRGBCol( BPy_Material * self, PyObject * value ) { return rgbTuple_setCol( self->col, value ); @@ -3475,5 +3521,4 @@ { return EXPP_setIValueClamped(value, &self->material->rampin_spec, MA_RAMP_IN_SHADER, MA_RAMP_IN_RESULT, 'b'); -} - +} \ No newline at end of file