Revision: 16481
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16481
Author:   khughes
Date:     2008-09-12 07:02:06 +0200 (Fri, 12 Sep 2008)

Log Message:
-----------
Python API
----------
Patch #17481: added Material attributes for missing colorbands controls:
 * material.colorbandDiffuseInput
 * material.colorbandDiffuseMethod
 * material.colorbandDiffuseFactor
 * material.colorbandSpecularInput
 * material.colorbandSpecularMethod
 * material.colorbandSpecularFactor

Contributed by Emilio Jos?\195?\169 Encinas Mir (asfhy).  Thanks!

Modified Paths:
--------------
    trunk/blender/source/blender/python/api2_2x/Material.c
    trunk/blender/source/blender/python/api2_2x/doc/Material.py

Modified: trunk/blender/source/blender/python/api2_2x/Material.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Material.c      2008-09-12 
02:23:52 UTC (rev 16480)
+++ trunk/blender/source/blender/python/api2_2x/Material.c      2008-09-12 
05:02:06 UTC (rev 16481)
@@ -155,6 +155,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() */
 
@@ -403,19 +405,62 @@
        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 );
@@ -424,6 +469,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 );
@@ -652,6 +701,21 @@
 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);
+
+
+
 /*****************************************************************************/
 /* Python BPy_Material methods table: */
 /*****************************************************************************/
@@ -1176,7 +1240,31 @@
         (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,
@@ -3312,3 +3400,75 @@
        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');
+}
+

Modified: trunk/blender/source/blender/python/api2_2x/doc/Material.py
===================================================================
--- trunk/blender/source/blender/python/api2_2x/doc/Material.py 2008-09-12 
02:23:52 UTC (rev 16480)
+++ trunk/blender/source/blender/python/api2_2x/doc/Material.py 2008-09-12 
05:02:06 UTC (rev 16481)
@@ -80,6 +80,35 @@
                - 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.
+
[EMAIL PROTECTED] ColorbandMethod: readonly dictionary
[EMAIL PROTECTED] 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.
+
[EMAIL PROTECTED] ColorbandInput: readonly dictionary
[EMAIL PROTECTED] 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.

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to