[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20752] trunk/blender: [#18847] Material. c Python API calls

Campbell Barton ideasman42 at gmail.com
Tue Jun 9 14:18:20 CEST 2009


Revision: 20752
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20752
Author:   campbellbarton
Date:     2009-06-09 14:18:20 +0200 (Tue, 09 Jun 2009)

Log Message:
-----------
[#18847] Material.c Python API calls
Adds access to...
- Anisotropy
- Mirr Threshold
- Trans Threshold

Breaks rule of no additions but python data access is quite safe, vray exporter needed these attributes.

[#18891] BGE Convert script Python 2.5 compatible

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

Modified: trunk/blender/release/scripts/textplugin_convert_ge.py
===================================================================
--- trunk/blender/release/scripts/textplugin_convert_ge.py	2009-06-09 11:53:37 UTC (rev 20751)
+++ trunk/blender/release/scripts/textplugin_convert_ge.py	2009-06-09 12:18:20 UTC (rev 20752)
@@ -718,7 +718,7 @@
 				try:
 					# Convert!
 					func(lines, row, match.start(1), match.end(1), closure)
-				except ConversionError as e:
+				except ConversionError, e:
 					# Insert a comment saying the conversion failed.
 					print "ERROR: %sline %d, %s: %s\n" % (
 						fileIdStr, row + 1, attrName, e)

Modified: trunk/blender/source/blender/python/api2_2x/Material.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Material.c	2009-06-09 11:53:37 UTC (rev 20751)
+++ trunk/blender/source/blender/python/api2_2x/Material.c	2009-06-09 12:18:20 UTC (rev 20752)
@@ -139,6 +139,12 @@
 #define EXPP_MAT_RAYTRANSPGLOSS_MAX			 1.0
 #define EXPP_MAT_RAYTRANSPGLOSSSAMPLES_MIN	 0
 #define EXPP_MAT_RAYTRANSPGLOSSSAMPLES_MAX	 1024
+#define EXPP_MAT_ANISO_GLOSS_MIR_MIN			0.0
+#define EXPP_MAT_ANISO_GLOSS_MIR_MAX			1.0
+#define EXPP_MAT_ADAPT_THRESH_MIR_MIN			0.0
+#define EXPP_MAT_ADAPT_THRESH_MIR_MAX			1.0
+#define EXPP_MAT_ADAPT_THRESH_TRA_MIN			0.0
+#define EXPP_MAT_ADAPT_THRESH_TRA_MAX			1.0
 #define EXPP_MAT_FILTER_MIN			0.0
 #define EXPP_MAT_FILTER_MAX			1.0
 #define EXPP_MAT_TRANSLUCENCY_MIN			0.0
@@ -598,6 +604,9 @@
 static int Material_setGlossMirrSamples( BPy_Material * self, PyObject * value );
 static int Material_setGlossTrans( BPy_Material * self, PyObject * value );
 static int Material_setGlossTransSamples( BPy_Material * self, PyObject * value );
+static int Material_setAniso( BPy_Material * self, PyObject * value );
+static int Material_setThreshMirr( BPy_Material * self, PyObject * value );
+static int Material_setThreshTrans( BPy_Material * self, PyObject * value );
 static int Material_setRigidBodyFriction( BPy_Material * self, PyObject * value );
 static int Material_setRigidBodyRestitution( BPy_Material * self, PyObject * value );
 
@@ -689,6 +698,9 @@
 static PyObject *Material_getGlossMirrSamples( BPy_Material * self );
 static PyObject *Material_getGlossTrans( BPy_Material * self );
 static PyObject *Material_getGlossTransSamples( BPy_Material * self );
+static PyObject *Material_getAniso( BPy_Material * self );
+static PyObject *Material_getThreshMirr( BPy_Material * self );
+static PyObject *Material_getThreshTrans( BPy_Material * self );
 static PyObject *Material_getRigidBodyFriction( BPy_Material * self );
 static PyObject *Material_getRigidBodyRestitution( BPy_Material * self );
 
@@ -1169,6 +1181,18 @@
 	 (getter)Material_getGlossMirrSamples, (setter)Material_setGlossMirrSamples,
 	 "Refraction glossiness",
 	 NULL},
+	{"anisotropy",
+	 (getter)Material_getAniso, (setter)Material_setAniso,
+	 "Anisotropy",
+	 NULL},
+	{"threshMir",
+	 (getter)Material_getThreshMirr, (setter)Material_setThreshMirr,
+	 "Reflections threshold",
+	 NULL},
+	{"threshTra",
+	 (getter)Material_getThreshTrans, (setter)Material_setThreshTrans,
+	 "Refractions threshold",
+	 NULL},
 	{"rgbCol",
 	 (getter)Material_getRGBCol, (setter)Material_setRGBCol,
 	 "Diffuse RGB color triplet",
@@ -1804,6 +1828,21 @@
 	return PyInt_FromLong( ( long ) self->material->samp_gloss_tra );
 }
 
+static PyObject *Material_getAniso( BPy_Material * self )
+{
+	return PyFloat_FromDouble( ( double ) self->material->aniso_gloss_mir );
+}
+
+static PyObject *Material_getThreshMirr( BPy_Material * self )
+{
+	return PyFloat_FromDouble( ( double ) self->material->adapt_thresh_mir );
+}
+
+static PyObject *Material_getThreshTrans( BPy_Material * self )
+{
+	return PyFloat_FromDouble( ( double ) self->material->adapt_thresh_tra );
+}
+
 static PyObject* Material_getRigidBodyFriction( BPy_Material * self )
 {
 	return PyFloat_FromDouble( ( double ) self->material->friction );
@@ -2379,6 +2418,27 @@
 								EXPP_MAT_RAYTRANSPGLOSSSAMPLES_MAX, 'h' );
 }
 
+static int Material_setAniso( BPy_Material * self, PyObject * value )
+{
+	return EXPP_setFloatClamped ( value, &self->material->aniso_gloss_mir,
+								EXPP_MAT_ANISO_GLOSS_MIR_MIN,
+								EXPP_MAT_ANISO_GLOSS_MIR_MAX );
+}
+
+static int Material_setThreshMirr( BPy_Material * self, PyObject * value )
+{
+	return EXPP_setFloatClamped ( value, &self->material->adapt_thresh_mir,
+								EXPP_MAT_ADAPT_THRESH_MIR_MIN,
+								EXPP_MAT_ADAPT_THRESH_MIR_MAX );
+}
+
+static int Material_setThreshTrans( BPy_Material * self, PyObject * value )
+{
+	return EXPP_setFloatClamped ( value, &self->material->adapt_thresh_tra,
+								EXPP_MAT_ADAPT_THRESH_TRA_MIN,
+								EXPP_MAT_ADAPT_THRESH_TRA_MAX );
+}
+
 static int Material_setRigidBodyFriction( BPy_Material * self, PyObject * value )
 {
 	return EXPP_setFloatClamped ( value, &self->material->friction,

Modified: trunk/blender/source/blender/python/api2_2x/doc/Material.py
===================================================================
--- trunk/blender/source/blender/python/api2_2x/doc/Material.py	2009-06-09 11:53:37 UTC (rev 20751)
+++ trunk/blender/source/blender/python/api2_2x/doc/Material.py	2009-06-09 12:18:20 UTC (rev 20752)
@@ -285,6 +285,15 @@
 	@ivar sampGlossTra: Refraction glossy samples.
 	Value is clamped to the range [1,1024].
 	@type sampGlossTra: int
+	@ivar anisotropy: The shape of the reflection, from 0.0 (circular) to 1.0 (fully stretched along the tangent).
+	Value is clamped to the range [0.0,1.0].
+	@type anisotropy: float
+	@ivar threshMir: Threshold below which reflections will not be computed.
+	Value is clamped to the range [0.0,1.0].
+	@type threshMir: float
+	@ivar threshTra: threshold below which refractions will not be computed.
+	Value is clamped to the range [0.0,1.0].
+	@type threshTra: float
 	@ivar rayMirrDepth:  Amount of raytrace inter-reflections.
 	Value is clamped to the range [0,10].
 	@type rayMirrDepth:  int





More information about the Bf-blender-cvs mailing list