--- ../../../../../Original/blender-2.46/source/blender/python/api2_2x/Material.c 2008-08-15 01:01:18.000000000 +0200 +++ ./Material.c 2008-08-30 02:24:40.000000000 +0200 @@ -195,6 +195,10 @@ #define EXPP_MAT_SSS_BACK_MIN 0.0 #define EXPP_MAT_SSS_BACK_MAX 10.0 +/* ColorRamp Settings */ +#define EXPP_MAT_COLORBAND_FACTOR_MIN 0.0 +#define EXPP_MAT_COLORBAND_FACTOR_MAX 1.0 + /*****************************************************************************/ /* Python API function prototypes for the Material module. */ @@ -402,19 +406,63 @@ 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 @@ 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 ); @@ -647,6 +699,22 @@ int Material_setColorband( BPy_Material * self, PyObject * value, void * type); static PyObject *Material_copy( BPy_Material * self ); +//RampCol Factor: +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 ); +//RampCol Method: +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); +//RampCol Input: +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); + /*****************************************************************************/ /* Python BPy_Material methods table: */ @@ -1158,6 +1226,30 @@ (getter)Material_getColorband, (setter)Material_setColorband, "The specular colorband for this material", (void *) 1}, + {"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", @@ -3133,3 +3225,54 @@ 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, 'i'); +} +static int Material_setColorBandSpecularMethod ( BPy_Material * self, PyObject * value) +{ + return EXPP_setIValueClamped(value, &self->material->rampblend_spec, MA_RAMP_BLEND, MA_RAMP_COLOR, 'i'); +} +//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, 'i'); +} +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, 'i'); +}