Page Menu
Home
Search
Configure Global Search
Log In
Files
F2754
mtex.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Yehoshua Sapir (sapir)
Nov 13 2013, 1:06 PM
Size
45 KB
Subscribers
None
mtex.patch
View Options
Index: source/blender/python/api2_2x/MTex.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/MTex.c,v
retrieving revision 1.6
diff -u -p -r1.6 MTex.c
--- source/blender/python/api2_2x/MTex.c 18 Jul 2005 03:50:37 -0000 1.6
+++ source/blender/python/api2_2x/MTex.c 26 Jul 2005 11:56:49 -0000
@@ -25,7 +25,7 @@
*
* This is a new part of Blender.
*
- * Contributor(s): Alex Mole
+ * Contributor(s): Alex Mole, Yehoshua Sapir
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
@@ -33,13 +33,15 @@
#include "BKE_utildefines.h"
#include "Texture.h"
+#include "Object.h"
#include "gen_utils.h"
+#include <DNA_material_types.h>
/*****************************************************************************/
/* Python BPy_MTex methods declarations: */
/*****************************************************************************/
-static PyObject *MTex_setTex( BPy_MTex * self, PyObject * args );
+static PyObject *MTex_setTexMethod( BPy_MTex * self, PyObject * args );
/*****************************************************************************/
/* Python method structure definition for Blender.Texture.MTex module: */
@@ -53,7 +55,7 @@ struct PyMethodDef M_MTex_methods[] = {
/*****************************************************************************/
static PyMethodDef BPy_MTex_methods[] = {
/* name, method, flags, doc */
- {"setTex", ( PyCFunction ) MTex_setTex, METH_VARARGS,
+ {"setTex", ( PyCFunction ) MTex_setTexMethod, METH_VARARGS,
"(i) - Set MTex Texture"},
{NULL, NULL, 0, NULL}
};
@@ -62,15 +64,126 @@ static PyMethodDef BPy_MTex_methods[] =
/* Python MTex_Type callback function prototypes: */
/*****************************************************************************/
static void MTex_dealloc( BPy_MTex * self );
-static int MTex_setAttr( BPy_MTex * self, char *name, PyObject * v );
static int MTex_compare( BPy_MTex * a, BPy_MTex * b );
-static PyObject *MTex_getAttr( BPy_MTex * self, char *name );
static PyObject *MTex_repr( BPy_MTex * self );
+#define MTEXGET(x) \
+ static PyObject *MTex_get##x( BPy_MTex *self, void *closure );
+#define MTEXSET(x) \
+ static int MTex_set##x( BPy_MTex *self, PyObject *value, void *closure);
+#define MTEXGETSET(x) \
+ MTEXGET(x) \
+ MTEXSET(x)
+
+MTEXGETSET(Tex)
+MTEXGETSET(TexCo)
+MTEXGETSET(Object)
+MTEXGETSET(MapTo)
+MTEXGETSET(Col)
+MTEXGETSET(DVar)
+MTEXGETSET(BlendMode)
+MTEXGETSET(ColFac)
+MTEXGETSET(NorFac)
+MTEXGETSET(VarFac)
+MTEXGETSET(DispFac)
+MTEXGETSET(WarpFac)
+MTEXGETSET(Ofs)
+MTEXGETSET(Size)
+MTEXGETSET(Mapping)
+MTEXGETSET(Flag)
+MTEXGETSET(ProjX)
+MTEXGETSET(ProjY)
+MTEXGETSET(ProjZ)
+MTEXGETSET(MapToFlag)
+
+/*****************************************************************************/
+/* Python get/set methods table */
+/*****************************************************************************/
+
+static PyGetSetDef MTex_getseters[] = {
+ { "tex", (getter) MTex_getTex, (setter) MTex_setTex,
+ "Texture whose mapping this MTex describes", NULL },
+ { "texco", (getter) MTex_getTexCo, (setter) MTex_setTexCo,
+ "Texture coordinate space (UV, Global, etc.)", NULL },
+ { "object", (getter) MTex_getObject, (setter) MTex_setObject,
+ "Object whose space to use when texco is Object", NULL },
+ { "mapto", (getter) MTex_getMapTo, (setter) MTex_setMapTo,
+ "What values the texture affects", NULL },
+ { "col", (getter) MTex_getCol, (setter) MTex_setCol,
+ "Color that the texture blends with", NULL },
+ { "dvar", (getter) MTex_getDVar, (setter) MTex_setDVar,
+ "Value that the texture blends with when not blending colors", NULL },
+ { "blendmode", (getter) MTex_getBlendMode, (setter) MTex_setBlendMode,
+ "Texture blending mode", NULL },
+ { "colfac", (getter) MTex_getColFac, (setter) MTex_setColFac,
+ "Factor by which texture affects color", NULL },
+ { "norfac", (getter) MTex_getNorFac, (setter) MTex_setNorFac,
+ "Factor by which texture affects normal", NULL },
+ { "varfac", (getter) MTex_getVarFac, (setter) MTex_setVarFac,
+ "Factor by which texture affects most variables", NULL },
+ { "dispfac", (getter) MTex_getDispFac, (setter) MTex_setDispFac,
+ "Factor by which texture affects displacement", NULL },
+ { "warpfac", (getter) MTex_getWarpFac, (setter) MTex_setWarpFac,
+ "Factor by which texture affects warp", NULL },
+ { "ofs", (getter) MTex_getOfs, (setter) MTex_setOfs,
+ "Offset to adjust texture space", NULL },
+ { "size", (getter) MTex_getSize, (setter) MTex_setSize,
+ "Size to scale texture space", NULL },
+ { "mapping", (getter) MTex_getMapping, (setter) MTex_setMapping,
+ "Mapping of texture coordinates (flat, cube, etc.)", NULL },
+ { "stencil", (getter) MTex_getFlag, (setter) MTex_setFlag,
+ "Stencil mode", (void*) MTEX_STENCIL },
+ { "neg", (getter) MTex_getFlag, (setter) MTex_setFlag,
+ "Negate texture values mode", (void*) MTEX_NEGATIVE },
+ { "noRGB", (getter) MTex_getFlag, (setter) MTex_setFlag,
+ "Convert texture RGB values to intensity values",
+ (void*) MTEX_RGBTOINT },
+ { "correctNor", (getter) MTex_getFlag, (setter) MTex_setFlag,
+ "Correct normal mapping for Texture space and Object space",
+ (void*) MTEX_VIEWSPACE },
+ { "xproj", (getter) MTex_getProjX, (setter) MTex_setProjX,
+ "Projection of X axis to Texture space", NULL },
+ { "yproj", (getter) MTex_getProjY, (setter) MTex_setProjY,
+ "Projection of Y axis to Texture space", NULL },
+ { "zproj", (getter) MTex_getProjZ, (setter) MTex_setProjZ,
+ "Projection of Z axis to Texture space", NULL },
+ { "mtCol", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to color", (void*) MAP_COL },
+ { "mtNor", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to normals", (void*) MAP_NORM },
+ { "mtCsp", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to specularity color", (void*) MAP_COLSPEC },
+ { "mtCmir", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to mirror color", (void*) MAP_COLMIR },
+ { "mtRef", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to reflectivity", (void*) MAP_REF },
+ { "mtSpec", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to specularity", (void*) MAP_SPEC },
+ { "mtEmit", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to emit value", (void*) MAP_EMIT },
+ { "mtAlpha", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to alpha value", (void*) MAP_ALPHA },
+ { "mtHard", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to hardness", (void*) MAP_HAR },
+ { "mtRayMir", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to RayMir value", (void*) MAP_RAYMIRR },
+ { "mtTranslu", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to translucency", (void*) MAP_TRANSLU },
+ { "mtAmb", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to ambient value", (void*) MAP_AMB },
+ { "mtDisp", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to displacement", (void*) MAP_DISPLACE },
+ { "mtWarp", (getter) MTex_getMapToFlag, (setter) MTex_setMapToFlag,
+ "How texture maps to warp", (void*) MAP_WARP },
+ { NULL, NULL, NULL, NULL, NULL }
+};
+
+
/*****************************************************************************/
/* Python MTex_Type structure definition: */
/*****************************************************************************/
+
PyTypeObject MTex_Type = {
PyObject_HEAD_INIT( NULL )
0, /* ob_size */
@@ -80,27 +193,55 @@ PyTypeObject MTex_Type = {
/* methods */
( destructor ) MTex_dealloc, /* tp_dealloc */
0, /* tp_print */
- ( getattrfunc ) MTex_getAttr, /* tp_getattr */
- ( setattrfunc ) MTex_setAttr, /* tp_setattr */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
( cmpfunc ) MTex_compare, /* tp_compare */
( reprfunc ) MTex_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_as_hash */
- 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0,
+ /*** Flags to define presence of optional/expanded features ***/
+ Py_TPFLAGS_DEFAULT, /* long tp_flags; */
0, /* tp_doc */
0, 0, 0, 0, 0, 0,
- 0, /* tp_methods */
+ BPy_MTex_methods, /* tp_methods */
0, /* tp_members */
+ MTex_getseters, /* struct PyGetSetDef *tp_getset; */
+ 0, /* struct _typeobject *tp_base; */
+ 0, /* PyObject *tp_dict; */
+ 0, /* descrgetfunc tp_descr_get; */
+ 0, /* descrsetfunc tp_descr_set; */
+ 0, /* long tp_dictoffset; */
+ 0, /* initproc tp_init; */
+ 0, /* allocfunc tp_alloc; */
+ 0, /* newfunc tp_new; */
+ /* Low-level free-memory routine */
+ 0, /* freefunc tp_free; */
+ /* For PyObject_IS_GC */
+ 0, /* inquiry tp_is_gc; */
+ 0, /* PyObject *tp_bases; */
+ /* method resolution order */
+ 0, /* PyObject *tp_mro; */
+ 0, /* PyObject *tp_cache; */
+ 0, /* PyObject *tp_subclasses; */
+ 0, /* PyObject *tp_weaklist; */
+ 0
};
PyObject *MTex_Init( void )
{
PyObject *submodule;
+ PyObject *dict;
+
+ /* call PyType_Ready() to init dictionaries & such */
+ if( PyType_Ready( &MTex_Type) < 0)
+ return NULL;
- MTex_Type.ob_type = &PyType_Type;
+ /* So do we need this? */
+/* MTex_Type.ob_type = &PyType_Type;*/
submodule = Py_InitModule( "Blender.Texture.MTex", M_MTex_methods );
@@ -136,17 +277,27 @@ int MTex_CheckPyObject( PyObject * pyobj
/* Python BPy_MTex methods: */
/*****************************************************************************/
-static PyObject *MTex_setTex( BPy_MTex * self, PyObject * args )
+static PyObject *MTex_setTexMethod( BPy_MTex * self, PyObject * args )
{
- BPy_Texture *pytex = NULL;
- if( !PyArg_ParseTuple( args, "O!", &Texture_Type, &pytex ) )
+ Tex *tex;
+
+ if( args == Py_None )
+ {
+ tex = NULL;
+ } else if( Texture_CheckPyObject( args ) ) {
+ tex = Texture_FromPyObject( args );
+ } else {
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected Texture argument" );
-
+ }
+
if( self->mtex->tex )
self->mtex->tex->id.us--;
- self->mtex->tex = Texture_FromPyObject( ( PyObject * ) pytex );
+ self->mtex->tex = tex;
+
+ if( self->mtex->tex )
+ self->mtex->tex->id.us++;
Py_INCREF( Py_None );
return Py_None;
@@ -157,83 +308,561 @@ static void MTex_dealloc( BPy_MTex * sel
PyObject_DEL( self );
}
-static PyObject *MTex_getAttr( BPy_MTex * self, char *name )
+static int MTex_compare( BPy_MTex * a, BPy_MTex * b )
{
- if( STREQ( name, "tex" ) ) {
- if( self->mtex->tex )
- return Texture_CreatePyObject( self->mtex->tex );
- else {
- Py_INCREF( Py_None );
- return Py_None;
- }
- } else if( STREQ( name, "texco" ) )
- return PyInt_FromLong( self->mtex->texco );
- else if( STREQ( name, "mapto" ) )
- return PyInt_FromLong( self->mtex->mapto );
-
- else if( STREQ( name, "__members__" ) )
- return Py_BuildValue( "[s,s,s]", "tex", "texco", "mapto" );
-
- /* not an attribute, search the methods table */
- return Py_FindMethod( BPy_MTex_methods, ( PyObject * ) self, name );
-}
-
-static int MTex_setAttr( BPy_MTex * self, char *name, PyObject * value )
-{
- PyObject *valtuple;
- PyObject *error = NULL;
-
- /* Put "value" in a tuple, because we want to pass it to functions *
- * that only accept PyTuples. */
- valtuple = Py_BuildValue( "(O)", value );
- if( !valtuple )
- return EXPP_ReturnIntError( PyExc_MemoryError,
- "MTex_setAttr: couldn't create PyTuple" );
-
- if( STREQ( name, "tex" ) )
- error = MTex_setTex( self, valtuple );
- else if( STREQ( name, "texco" ) ) {
- if( PyInt_Check( value ) ) {
- int texco = PyInt_AsLong( value );
- /* TODO: sanity-check this input! */
- self->mtex->texco = (short)texco;
- Py_INCREF( Py_None ); /* because we decref it below */
- error = Py_None;
- }
- } else if( STREQ( name, "mapto" ) ) {
- if( PyInt_Check( value ) ) {
- int mapto = PyInt_AsLong( value );
- /* TODO: sanity-check this input! */
- self->mtex->mapto = (short)mapto;
- Py_INCREF( Py_None ); /* because we decref it below */
- error = Py_None;
- }
+ return ( a->mtex == b->mtex ) ? 0 : -1;
+}
+
+static PyObject *MTex_repr( BPy_MTex * self )
+{
+ return PyString_FromFormat( "[MTex]" );
+}
+
+
+/*****************************************************************************/
+/* Python BPy_MTex get and set functions: */
+/*****************************************************************************/
+
+static PyObject *MTex_getTex( BPy_MTex *self, void *closure )
+{
+ if( self->mtex->tex )
+ return Texture_CreatePyObject( self->mtex->tex );
+ else {
+ Py_INCREF( Py_None );
+ return Py_None;
+ }
+}
+
+static int MTex_setTex( BPy_MTex *self, PyObject *value, void *closure)
+{
+ Tex *tex;
+
+ if( value == Py_None )
+ {
+ tex = NULL;
+ } else if( Texture_CheckPyObject( value ) ) {
+ tex = Texture_FromPyObject( value );
+ } else {
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected Texture argument" );
+ }
+
+ if( self->mtex->tex )
+ self->mtex->tex->id.us--;
+
+ self->mtex->tex = tex;
+
+ if( self->mtex->tex )
+ self->mtex->tex->id.us++;
+
+ return 0;
+}
+
+static PyObject *MTex_getTexCo( BPy_MTex *self, void *closure )
+{
+ return PyInt_FromLong( self->mtex->texco );
+}
+
+static int MTex_setTexCo( BPy_MTex *self, PyObject *value, void *closure)
+{
+ if( !PyInt_Check( value ) ) {
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "Value must be a member of Texture.TexCo dictionary" );
}
+ int 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_WINDOW && texco != TEXCO_VIEW && texco != TEXCO_STICKY )
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "Value must be a member of Texture.TexCo dictionary" );
+
+ self->mtex->texco = texco;
+
+ return 0;
+}
+
+static PyObject *MTex_getObject( BPy_MTex *self, void *closure )
+{
+ if( self->mtex->object )
+ return Object_CreatePyObject( self->mtex->object );
else {
- /* Error */
- Py_DECREF( valtuple );
- return EXPP_ReturnIntError( PyExc_KeyError,
- "attribute not found" );
+ Py_INCREF( Py_None );
+ return Py_None;
}
+}
+
+static int MTex_setObject( BPy_MTex *self, PyObject *value, void *closure)
+{
+ Object *obj;
- Py_DECREF( valtuple );
+ if( value == Py_None )
+ {
+ obj = NULL;
+ } else if( Object_CheckPyObject( value ) ) {
+ obj = Object_FromPyObject( value );
+ } else {
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected Object argument" );
+ }
+
+ if( self->mtex->object )
+ self->mtex->object->id.us--;
- if( error != Py_None )
- return -1;
+ self->mtex->object = obj;
- /* Py_None was INCREF'd by the set*() function, so we need to DECREF it */
- Py_DECREF( Py_None );
+ if( self->mtex->object )
+ self->mtex->object->id.us++;
return 0;
}
-static int MTex_compare( BPy_MTex * a, BPy_MTex * b )
+static PyObject *MTex_getMapTo( BPy_MTex *self, void *closure )
{
- return ( a->mtex == b->mtex ) ? 0 : -1;
+ return PyInt_FromLong( self->mtex->mapto );
}
-static PyObject *MTex_repr( BPy_MTex * self )
+static int MTex_setMapTo( BPy_MTex *self, PyObject *value, void *closure)
{
- return PyString_FromFormat( "[MTex]" );
+ int mapto;
+
+ if( !PyInt_Check( value ) ) {
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected an int" );
+ }
+
+ mapto = PyInt_AsLong( value );
+
+ /* This method is deprecated anyway. */
+ if ( mapto < 0 || mapto > 16383 ) {
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "Value must be a sum of values from Texture.MapTo dictionary" );
+ }
+
+ self->mtex->mapto = mapto;
+
+ return 0;
+}
+
+static PyObject *MTex_getCol( BPy_MTex *self, void *closure )
+{
+ return Py_BuildValue( "(f,f,f)", self->mtex->r, self->mtex->g,
+ self->mtex->b );
+}
+
+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] ) )
+
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected tuple of 3 floats" );
+
+ for( i = 0; i < 3; ++i )
+ if( rgb[i] < 0 || rgb[i] > 1 )
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "values must be in range [0,1]" );
+
+ self->mtex->r = rgb[0];
+ self->mtex->g = rgb[1];
+ self->mtex->b = rgb[2];
+
+ return 0;
+}
+
+static PyObject *MTex_getDVar( BPy_MTex *self, void *closure )
+{
+ return PyFloat_FromDouble(self->mtex->def_var);
+}
+
+static int MTex_setDVar( BPy_MTex *self, PyObject *value, void *closure)
+{
+ if ( !PyFloat_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected a float" );
+
+ float f = PyFloat_AsDouble(value);
+
+ if (f < 0 || f > 1)
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "values must be in range [0,1]" );
+
+ self->mtex->def_var = f;
+
+ return 0;
+}
+
+static PyObject *MTex_getBlendMode( BPy_MTex *self, void *closure )
+{
+ return PyInt_FromLong(self->mtex->blendtype);
+}
+
+static int MTex_setBlendMode( BPy_MTex *self, PyObject *value, void *closure)
+{
+ int n;
+
+ if ( !PyInt_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "Value must be member of Texture.BlendMode 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.BlendMode dictionary" );
+ }
+
+ self->mtex->blendtype = n;
+
+ return 0;
+}
+
+static PyObject *MTex_getColFac( BPy_MTex *self, void *closure )
+{
+ return PyFloat_FromDouble(self->mtex->colfac);
+}
+
+static int MTex_setColFac( BPy_MTex *self, PyObject *value, void *closure)
+{
+ if ( !PyFloat_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected a float" );
+
+ float f = 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;
+}
+
+static PyObject *MTex_getNorFac( BPy_MTex *self, void *closure )
+{
+ return PyFloat_FromDouble(self->mtex->norfac);
+}
+
+static int MTex_setNorFac( BPy_MTex *self, PyObject *value, void *closure)
+{
+ if ( !PyFloat_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected a float" );
+
+ float f = 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;
+}
+
+static PyObject *MTex_getVarFac( BPy_MTex *self, void *closure )
+{
+ return PyFloat_FromDouble(self->mtex->varfac);
+}
+
+static int MTex_setVarFac( BPy_MTex *self, PyObject *value, void *closure)
+{
+ if ( !PyFloat_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected a float" );
+
+ float f = 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;
+}
+
+static PyObject *MTex_getDispFac( BPy_MTex *self, void *closure )
+{
+ return PyFloat_FromDouble(self->mtex->dispfac);
+}
+
+static int MTex_setDispFac( BPy_MTex *self, PyObject *value, void *closure)
+{
+ if ( !PyFloat_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected a float" );
+
+ float f = 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;
+}
+
+static PyObject *MTex_getWarpFac( BPy_MTex *self, void *closure )
+{
+ return PyFloat_FromDouble(self->mtex->warpfac);
+}
+
+static int MTex_setWarpFac( BPy_MTex *self, PyObject *value, void *closure)
+{
+ if ( !PyFloat_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected a float" );
+
+ float f = 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;
+}
+
+static PyObject *MTex_getOfs( BPy_MTex *self, void *closure )
+{
+ return Py_BuildValue( "(f,f,f)", self->mtex->ofs[0], self->mtex->ofs[1],
+ self->mtex->ofs[2] );
+}
+
+static int MTex_setOfs( BPy_MTex *self, PyObject *value, void *closure)
+{
+ float f[3];
+ int i;
+
+ if( !PyArg_ParseTuple( value, "fff", &f[0], &f[1], &f[2] ) )
+
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected tuple of 3 floats" );
+
+ 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]" );
+
+ self->mtex->ofs[0] = f[0];
+ self->mtex->ofs[1] = f[1];
+ self->mtex->ofs[2] = f[2];
+
+ return 0;
+}
+
+static PyObject *MTex_getSize( BPy_MTex *self, void *closure )
+{
+ return Py_BuildValue( "(f,f,f)", self->mtex->size[0], self->mtex->size[1],
+ self->mtex->size[2] );
+}
+
+static int MTex_setSize( BPy_MTex *self, PyObject *value, void *closure)
+{
+ float f[3];
+ int i;
+
+ if( !PyArg_ParseTuple( value, "fff", &f[0], &f[1], &f[2] ) )
+
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected tuple of 3 floats" );
+
+ for( i = 0; i < 3; ++i )
+ if( f[i] < -100 || f[i] > 100 )
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "values must be in range [-100,100]" );
+
+ self->mtex->size[0] = f[0];
+ self->mtex->size[1] = f[1];
+ self->mtex->size[2] = f[2];
+
+ return 0;
+}
+
+static PyObject *MTex_getMapping( BPy_MTex *self, void *closure )
+{
+ return PyInt_FromLong( self->mtex->mapping );
+}
+
+static int MTex_setMapping( BPy_MTex *self, PyObject *value, void *closure)
+{
+ int n;
+
+ if ( !PyInt_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "Value must be member of Texture.Mapping dictionary" );
+
+ n = PyInt_AsLong(value);
+
+/* if (n != MTEX_FLAT && n != MTEX_TUBE && n != MTEX_CUBE &&
+ n != MTEX_SPHERE) */
+ if (n < 0 || n > 3)
+ {
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "Value must be member of Texture.Mapping dictionary" );
+ }
+
+ self->mtex->mapping = n;
+
+ return 0;
+}
+
+static PyObject *MTex_getFlag( BPy_MTex *self, void *closure )
+{
+ return PyBool_FromLong( self->mtex->texflag & ((int) closure) );
+}
+
+static int MTex_setFlag( BPy_MTex *self, PyObject *value, void *closure)
+{
+ if ( !PyBool_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected a bool");
+
+ if ( value == Py_True )
+ self->mtex->texflag |= (int)closure;
+ else
+ self->mtex->texflag &= ~((int) closure);
+
+ return 0;
+}
+
+static PyObject *MTex_getProjX( BPy_MTex *self, void *closure )
+{
+ return PyInt_FromLong( self->mtex->projx );
+}
+
+static int MTex_setProjX( BPy_MTex *self, PyObject *value, void *closure)
+{
+ if( !PyInt_Check( value ) ) {
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "Value must be a member of Texture.Proj dictionary" );
+ }
+
+ int proj = PyInt_AsLong( value ) ;
+
+ /* valid values are from PROJ_N to PROJ_Z = 0 to 3 */
+ if (proj < 0 || proj > 3)
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "Value must be a member of Texture.Proj dictionary" );
+
+ self->mtex->projx = proj;
+
+ return 0;
+}
+
+static PyObject *MTex_getProjY( BPy_MTex *self, void *closure )
+{
+ return PyInt_FromLong( self->mtex->projy );
+}
+
+static int MTex_setProjY( BPy_MTex *self, PyObject *value, void *closure )
+{
+ if( !PyInt_Check( value ) ) {
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "Value must be a member of Texture.Proj dictionary" );
+ }
+
+ int proj = PyInt_AsLong( value ) ;
+
+ /* valid values are from PROJ_N to PROJ_Z = 0 to 3 */
+ if (proj < 0 || proj > 3)
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "Value must be a member of Texture.Proj dictionary" );
+
+ self->mtex->projy = proj;
+
+ return 0;
+}
+
+static PyObject *MTex_getProjZ( BPy_MTex *self, void *closure )
+{
+ return PyInt_FromLong( self->mtex->projz );
+}
+
+static int MTex_setProjZ( BPy_MTex *self, PyObject *value, void *closure)
+{
+ if( !PyInt_Check( value ) ) {
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "Value must be a member of Texture.Proj dictionary" );
+ }
+
+ int proj = PyInt_AsLong( value ) ;
+
+ /* valid values are from PROJ_N to PROJ_Z = 0 to 3 */
+ if (proj < 0 || proj > 3)
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "Value must be a member of Texture.Proj dictionary" );
+
+ self->mtex->projz = proj;
+
+ return 0;
+}
+
+static PyObject *MTex_getMapToFlag( BPy_MTex *self, void *closure )
+{
+ int flag = (int) closure;
+
+ if ( self->mtex->mapto & flag )
+ {
+ return PyInt_FromLong( ( self->mtex->maptoneg & flag ) ? -1 : 1 );
+ } else {
+ return PyInt_FromLong( 0 );
+ }
+}
+
+static int MTex_setMapToFlag( BPy_MTex *self, PyObject *value, void *closure)
+{
+ int flag = (int) closure;
+ int intVal;
+
+ if ( !PyInt_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected an int");
+
+ intVal = PyInt_AsLong( value );
+
+ if (flag == MAP_COL || flag == MAP_COLSPEC || flag == MAP_COLMIR ||
+ flag == MAP_WARP) {
+ if (intVal < 0 || intVal > 1) {
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "value for that mapping must be 0 or 1" );
+ }
+ } else {
+ if (intVal < -1 || intVal > 1) {
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "value for that mapping must be -1, 0 or 1" );
+ }
+ }
+
+ switch (intVal)
+ {
+ case 0:
+ self->mtex->mapto &= ~flag;
+ self->mtex->maptoneg &= ~flag;
+ break;
+
+ case 1:
+ self->mtex->mapto |= flag;
+ self->mtex->maptoneg &= ~flag;
+ break;
+
+ case -1:
+ self->mtex->mapto |= flag;
+ self->mtex->maptoneg |= flag;
+ break;
+ }
+
+ return 0;
}
Index: source/blender/python/api2_2x/Texture.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Texture.c,v
retrieving revision 1.12
diff -u -p -r1.12 Texture.c
--- source/blender/python/api2_2x/Texture.c 18 Jul 2005 03:50:37 -0000 1.12
+++ source/blender/python/api2_2x/Texture.c 26 Jul 2005 11:56:50 -0000
@@ -151,6 +151,7 @@
#define EXPP_TEX_MAPTO_DISP MAP_DISPLACE
#define EXPP_TEX_MAPTO_TRANSLU MAP_TRANSLU
#define EXPP_TEX_MAPTO_AMB MAP_AMB
+#define EXPP_TEX_MAPTO_WARP MAP_WARP
#define EXPP_TEX_STYPE_DN_BLENDER TEX_BLENDER
#define EXPP_TEX_STYPE_DN_PERLIN TEX_STDPERLIN
@@ -171,6 +172,30 @@
#define EXPP_TEX_STYPE_VN_TEX_MINKOVSKY_FOUR TEX_MINKOVSKY_FOUR
#define EXPP_TEX_STYPE_VN_TEX_MINKOVSKY TEX_MINKOVSKY
+#define EXPP_TEX_WAVETYPE_SIN TEX_SIN
+#define EXPP_TEX_WAVETYPE_SAW TEX_SAW
+#define EXPP_TEX_WAVETYPE_TRI TEX_TRI
+
+#define EXPP_TEX_BLENDMODE_MIX MTEX_BLEND
+#define EXPP_TEX_BLENDMODE_MULTIPLY MTEX_MUL
+#define EXPP_TEX_BLENDMODE_ADD MTEX_ADD
+#define EXPP_TEX_BLENDMODE_SUBTRACT MTEX_SUB
+#define EXPP_TEX_BLENDMODE_DIVIDE MTEX_DIV
+#define EXPP_TEX_BLENDMODE_DARKEN MTEX_DARK
+#define EXPP_TEX_BLENDMODE_DIFFERENCE MTEX_DIFF
+#define EXPP_TEX_BLENDMODE_LIGHTEN MTEX_LIGHT
+#define EXPP_TEX_BLENDMODE_SCREEN MTEX_SCREEN
+
+#define EXPP_TEX_MAPPING_FLAT MTEX_FLAT
+#define EXPP_TEX_MAPPING_CUBE MTEX_CUBE
+#define EXPP_TEX_MAPPING_TUBE MTEX_TUBE
+#define EXPP_TEX_MAPPING_SPHERE MTEX_SPHERE
+
+#define EXPP_TEX_PROJ_NONE PROJ_N
+#define EXPP_TEX_PROJ_X PROJ_X
+#define EXPP_TEX_PROJ_Y PROJ_Y
+#define EXPP_TEX_PROJ_Z PROJ_Z
+
/****************************************************************************/
/* Texture String->Int maps */
/****************************************************************************/
@@ -195,7 +220,7 @@ static const EXPP_map_pair tex_type_map[
static const EXPP_map_pair tex_flag_map[] = {
/* we don't support this yet! */
-/* { "ColorBand", EXPP_TEX_FLAG_COLORBAND }, */
+ /* {"ColorBand", EXPP_TEX_FLAG_COLORBAND}, */
{"FlipBlend", EXPP_TEX_FLAG_FLIPBLEND},
{"NegAlpha", EXPP_TEX_FLAG_NEGALPHA},
{NULL, 0}
@@ -384,8 +409,10 @@ struct PyMethodDef M_Texture_methods[] =
GETFUNC( getExtend );
GETFUNC( getImage );
GETFUNC( getName );
+GETFUNC( getNoiseBasis );
GETFUNC( getType );
GETFUNC( getSType );
+GETFUNC( getWaveType );
GETFUNC( getIpo );
GETFUNC( clearIpo );
SETFUNC( setIpo );
@@ -421,24 +448,30 @@ SETFUNC( setIntType ); /* special case
SETFUNC( setTurbulence );
SETFUNC( setDistMetric );
SETFUNC( setDistAmnt );
+SETFUNC( setWaveType );
/*****************************************************************************/
/* Python BPy_Texture methods table: */
/*****************************************************************************/
static PyMethodDef BPy_Texture_methods[] = {
- /* name, method, flags, doc */
+ /* name, method, flags, doc#undef EXPP_ADDCONST
+ */
{"getExtend", ( PyCFunction ) Texture_getExtend, METH_NOARGS,
"() - Return Texture extend mode"},
{"getImage", ( PyCFunction ) Texture_getImage, METH_NOARGS,
"() - Return Texture Image"},
{"getName", ( PyCFunction ) Texture_getName, METH_NOARGS,
"() - Return Texture name"},
+ {"getNoiseBasis", ( PyCFunction ) Texture_getNoiseBasis, METH_NOARGS,
+ "() - Return Texture noise basis"},
{"getSType", ( PyCFunction ) Texture_getSType, METH_NOARGS,
"() - Return Texture stype as string"},
{"getType", ( PyCFunction ) Texture_getType, METH_NOARGS,
"() - Return Texture type as string"},
{"getIpo", ( PyCFunction ) Texture_getIpo, METH_NOARGS,
"() - Return Texture Ipo"},
+ {"getWaveType", ( PyCFunction ) Texture_getWaveType, METH_NOARGS,
+ "() - Return Texture wavetype"},
{"setIpo", ( PyCFunction ) Texture_setIpo, METH_VARARGS,
"(Blender Ipo) - Set Texture Ipo"},
{"clearIpo", ( PyCFunction ) Texture_clearIpo, METH_NOARGS,
@@ -463,6 +496,8 @@ static PyMethodDef BPy_Texture_methods[]
"(s) - Set Dist Noise"},
{"setDistMetric", ( PyCFunction ) Texture_setDistMetric, METH_VARARGS,
"(s) - Set Dist Metric"},
+ {"setWaveType", ( PyCFunction ) Texture_setWaveType, METH_VARARGS,
+ "(s) - Set Texture wavetype"},
{NULL, NULL, 0, NULL}
};
@@ -738,6 +773,7 @@ static PyObject *M_Texture_MapToDict( vo
EXPP_ADDCONST( AMB );
EXPP_ADDCONST( TRANSLU );
EXPP_ADDCONST( DISP );
+ EXPP_ADDCONST( WARP );
}
return MapTo;
}
@@ -805,6 +841,111 @@ static PyObject *M_Texture_ImageFlagsDic
}
+#undef EXPP_ADDCONST
+#define EXPP_ADDCONST(name) \
+ constant_insert(d, #name, PyInt_FromLong(TEX_##name))
+
+static PyObject *M_Texture_NoiseBasisDict( void )
+{
+ PyObject *NoiseBasis = M_constant_New( );
+ if( NoiseBasis ) {
+ BPy_constant *d = ( BPy_constant * ) NoiseBasis;
+
+ EXPP_ADDCONST( BLENDER );
+ EXPP_ADDCONST( STDPERLIN );
+ EXPP_ADDCONST( NEWPERLIN );
+ EXPP_ADDCONST( VORONOI_F1 );
+ EXPP_ADDCONST( VORONOI_F2 );
+ EXPP_ADDCONST( VORONOI_F3 );
+ EXPP_ADDCONST( VORONOI_F4 );
+ EXPP_ADDCONST( VORONOI_F2F1 );
+ EXPP_ADDCONST( VORONOI_CRACKLE );
+ EXPP_ADDCONST( CELLNOISE );
+ }
+ return NoiseBasis;
+}
+
+
+#undef EXPP_ADDCONST
+#define EXPP_ADDCONST(name) \
+ constant_insert(d, #name, PyInt_FromLong(EXPP_TEX_WAVETYPE_##name))
+
+static PyObject *M_Texture_WaveTypeDict( void )
+{
+ PyObject *WaveType = M_constant_New( );
+ if( WaveType ) {
+ BPy_constant *d = ( BPy_constant * ) WaveType;
+
+ EXPP_ADDCONST( SIN );
+ EXPP_ADDCONST( SAW );
+ EXPP_ADDCONST( TRI );
+ }
+ return WaveType;
+}
+
+
+#undef EXPP_ADDCONST
+#define EXPP_ADDCONST(name) \
+ constant_insert(d, #name, PyInt_FromLong(EXPP_TEX_BLENDMODE_##name))
+
+static PyObject *M_Texture_BlendModeDict( void )
+{
+ PyObject *BlendMode = M_constant_New( );
+ if( BlendMode ) {
+ BPy_constant *d = ( BPy_constant * ) BlendMode;
+
+ EXPP_ADDCONST( MIX );
+ EXPP_ADDCONST( MULTIPLY );
+ EXPP_ADDCONST( ADD );
+ EXPP_ADDCONST( SUBTRACT );
+ EXPP_ADDCONST( DIVIDE );
+ EXPP_ADDCONST( DARKEN );
+ EXPP_ADDCONST( DIFFERENCE );
+ EXPP_ADDCONST( LIGHTEN );
+ EXPP_ADDCONST( SCREEN );
+ }
+ return BlendMode;
+}
+
+
+#undef EXPP_ADDCONST
+#define EXPP_ADDCONST(name) \
+ constant_insert(d, #name, PyInt_FromLong(EXPP_TEX_MAPPING_##name))
+
+static PyObject *M_Texture_MappingDict( void )
+{
+ PyObject *Mapping = M_constant_New( );
+ if( Mapping ) {
+ BPy_constant *d = ( BPy_constant * ) Mapping;
+
+ EXPP_ADDCONST( FLAT );
+ EXPP_ADDCONST( CUBE );
+ EXPP_ADDCONST( TUBE );
+ EXPP_ADDCONST( SPHERE );
+ }
+ return Mapping;
+}
+
+
+#undef EXPP_ADDCONST
+#define EXPP_ADDCONST(name) \
+ constant_insert(d, #name, PyInt_FromLong(EXPP_TEX_PROJ_##name))
+
+static PyObject *M_Texture_ProjDict( void )
+{
+ PyObject *Proj = M_constant_New( );
+ if( Proj ) {
+ BPy_constant *d = ( BPy_constant * ) Proj;
+
+ EXPP_ADDCONST( NONE );
+ EXPP_ADDCONST( X );
+ EXPP_ADDCONST( Y );
+ EXPP_ADDCONST( Z );
+ }
+ return Proj;
+}
+
+
PyObject *Texture_Init( void )
{
PyObject *submodule;
@@ -818,6 +959,11 @@ PyObject *Texture_Init( void )
PyObject *Flags = M_Texture_FlagsDict( );
PyObject *ExtendModes = M_Texture_ExtendModesDict( );
PyObject *ImageFlags = M_Texture_ImageFlagsDict( );
+ PyObject *NoiseBasis = M_Texture_NoiseBasisDict( );
+ PyObject *WaveType = M_Texture_WaveTypeDict( );
+ PyObject *BlendMode = M_Texture_BlendModeDict( );
+ PyObject *Mapping = M_Texture_MappingDict( );
+ PyObject *Proj = M_Texture_ProjDict( );
Texture_Type.ob_type = &PyType_Type;
@@ -838,6 +984,16 @@ PyObject *Texture_Init( void )
PyModule_AddObject( submodule, "ExtendModes", ExtendModes );
if( ImageFlags )
PyModule_AddObject( submodule, "ImageFlags", ImageFlags );
+ if( NoiseBasis )
+ PyModule_AddObject( submodule, "NoiseBasis", NoiseBasis );
+ if( WaveType )
+ PyModule_AddObject( submodule, "WaveType", WaveType );
+ if( BlendMode )
+ PyModule_AddObject( submodule, "BlendMode", BlendMode );
+ if( Mapping )
+ PyModule_AddObject( submodule, "Mapping", Mapping );
+ if( Proj )
+ PyModule_AddObject( submodule, "Proj", Proj );
/* Add the MTex submodule to this module */
dict = PyModule_GetDict( submodule );
@@ -913,6 +1069,41 @@ static PyObject *Texture_getName( BPy_Te
return attr;
}
+static PyObject *Texture_getNoiseBasis( BPy_Texture * self )
+{
+ PyObject *attr = NULL;
+
+ if (self->texture->type == EXPP_TEX_TYPE_CLOUDS ||
+ self->texture->type == EXPP_TEX_TYPE_WOOD ||
+ self->texture->type == EXPP_TEX_TYPE_MARBLE ||
+ self->texture->type == EXPP_TEX_TYPE_STUCCI ||
+ self->texture->type == EXPP_TEX_TYPE_MUSGRAVE)
+ {
+ attr = PyInt_FromLong( self->texture->noisebasis );
+ } else if (self->texture->type == EXPP_TEX_TYPE_DISTNOISE) {
+ attr = PyInt_FromLong( self->texture->noisebasis2 );
+ } else {
+ /* for other texture modes, the noise basis doesn't exist */
+ Py_INCREF( Py_None );
+ return Py_None;
+ }
+
+ return attr;
+}
+
+static PyObject *Texture_getWaveType( BPy_Texture * self )
+{
+ if (self->texture->type == EXPP_TEX_TYPE_WOOD ||
+ self->texture->type == EXPP_TEX_TYPE_MARBLE)
+
+ return PyInt_FromLong( self->texture->noisebasis2 );
+ else {
+ /* for other texture modes, the wavetype doesn't exist */
+ Py_INCREF( Py_None );
+ return Py_None;
+ }
+}
+
static PyObject *Texture_getSType( BPy_Texture * self )
{
PyObject *attr = NULL;
@@ -949,6 +1140,23 @@ static PyObject *Texture_getType( BPy_Te
return attr;
}
+static PyObject *Texture_setWaveType( BPy_Texture * self, PyObject * args )
+{
+ int wavetype;
+
+ if( !PyArg_ParseTuple( args, "i", &wavetype ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected an int" );
+
+ if (self->texture->type == EXPP_TEX_TYPE_WOOD ||
+ self->texture->type == EXPP_TEX_TYPE_MARBLE)
+
+ self->texture->noisebasis2 = wavetype;
+
+ Py_INCREF( Py_None );
+ return Py_None;
+}
+
static PyObject *Texture_setAnimFrames( BPy_Texture * self, PyObject * args )
{
int frames;
@@ -1363,19 +1571,22 @@ static PyObject *Texture_setNoiseType( B
static PyObject *Texture_setNoiseBasis( BPy_Texture * self, PyObject * args )
{
- char *nbasis;
+ int nbasis;
- if( !PyArg_ParseTuple( args, "s", &nbasis ) )
+ if( !PyArg_ParseTuple( args, "i", &nbasis ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
- if( self->texture->type == EXPP_TEX_TYPE_MUSGRAVE &&
- EXPP_map_getShortVal( tex_stype_map[EXPP_TEX_TYPE_DISTNOISE],
- nbasis, &self->texture->noisebasis ) );
- else if( self->texture->type == EXPP_TEX_TYPE_DISTNOISE &&
- !EXPP_map_getShortVal( tex_stype_map[EXPP_TEX_TYPE_DISTNOISE],
- nbasis, &self->texture->noisebasis2 ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "invalid noise basis" );
+ "expected an int" );
+
+ if (self->texture->type == EXPP_TEX_TYPE_CLOUDS ||
+ self->texture->type == EXPP_TEX_TYPE_WOOD ||
+ self->texture->type == EXPP_TEX_TYPE_MARBLE ||
+ self->texture->type == EXPP_TEX_TYPE_STUCCI ||
+ self->texture->type == EXPP_TEX_TYPE_MUSGRAVE)
+ {
+ self->texture->noisebasis = nbasis;
+ } else if (self->texture->type == EXPP_TEX_TYPE_DISTNOISE) {
+ self->texture->noisebasis2 = nbasis;
+ }
Py_INCREF( Py_None );
return Py_None;
@@ -1778,6 +1989,8 @@ static PyObject *Texture_getAttr( BPy_Te
attr = PyInt_FromLong( tex->imaflag );
else if( STREQ( name, "name" ) )
attr = PyString_FromString( tex->id.name + 2 );
+ else if( STREQ( name, "noiseBasis" ) )
+ attr = Texture_getNoiseBasis( self );
else if( STREQ( name, "noiseDepth" ) )
attr = PyInt_FromLong( tex->noisedepth );
else if( STREQ( name, "noiseSize" ) )
@@ -1807,10 +2020,12 @@ static PyObject *Texture_getAttr( BPy_Te
attr = PyFloat_FromDouble( tex->mg_lacunarity );
else if( STREQ( name, "octs" ) )
attr = PyFloat_FromDouble( tex->mg_octaves );
- else if( STREQ( name, "iSacale" ) )
+ else if( STREQ( name, "iScale" ) )
attr = PyFloat_FromDouble( tex->ns_outscale );
else if( STREQ( name, "exp" ) )
attr = PyFloat_FromDouble( tex->vn_mexp );
+ else if( STREQ( name, "wavetype" ) )
+ attr = Texture_getWaveType( self );
else if( STREQ( name, "weight1" ) )
attr = PyFloat_FromDouble( tex->vn_w1 );
else if( STREQ( name, "weight2" ) )
@@ -1825,16 +2040,17 @@ static PyObject *Texture_getAttr( BPy_Te
attr = PyInt_FromLong( tex->id.us );
else if( STREQ( name, "__members__" ) )
- attr = Py_BuildValue
- ( "[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s]",
+ attr = Py_BuildValue(
+"[s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s,s]",
"animFrames", "animLength", "animMontage",
"animOffset", "animStart", "brightness", "contrast",
"crop", "extend", "fieldsPerImage", "filterSize",
- "flags", "image", "imageFlags", "name", "noiseDepth",
- "noiseSize", "noiseType", "repeat", "rgbCol",
- "stype", "turbulence", "type", "hFracDim",
- "lacunarity", "octs", "iScale", "exp", "weight1",
- "weight2", "weight3", "weight4", "distAmnt", "users" );
+ "flags", "image", "imageFlags", "name", "noiseBasis",
+ "noiseDepth", "noiseSize", "noiseType", "repeat",
+ "rgbCol", "stype", "turbulence", "type", "hFracDim",
+ "lacunarity", "octs", "iScale", "exp", "wavetype",
+ "weight1", "weight2", "weight3", "weight4", "distAmnt",
+ "users" );
if( !attr )
return EXPP_ReturnPyObjError( PyExc_MemoryError,
@@ -1890,6 +2106,8 @@ static int Texture_setAttr( BPy_Texture
error = Texture_setIntImageFlags( self, valtuple );
else if( STREQ( name, "name" ) )
error = Texture_setName( self, valtuple );
+ else if( STREQ( name, "noiseBasis" ) )
+ error = Texture_setNoiseBasis( self, valtuple );
else if( STREQ( name, "noiseDepth" ) )
error = Texture_setNoiseDepth( self, valtuple );
else if( STREQ( name, "noiseSize" ) )
@@ -1916,6 +2134,8 @@ static int Texture_setAttr( BPy_Texture
error = Texture_setiScale( self, valtuple );
else if( STREQ( name, "exp" ) )
error = Texture_setExp( self, valtuple );
+ else if( STREQ( name, "wavetype" ) )
+ error = Texture_setWaveType( self, valtuple );
else if( STREQ( name, "weight1" ) )
error = Texture_setW1( self, valtuple );
else if( STREQ( name, "weight2" ) )
@@ -1926,7 +2146,6 @@ static int Texture_setAttr( BPy_Texture
error = Texture_setW4( self, valtuple );
else if( STREQ( name, "distAmnt" ) )
error = Texture_setDistAmnt( self, valtuple );
-
else {
/* Error */
Index: source/blender/python/api2_2x/doc/Texture.py
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/doc/Texture.py,v
retrieving revision 1.6
diff -u -p -r1.6 Texture.py
--- source/blender/python/api2_2x/doc/Texture.py 15 Jun 2005 06:22:26 -0000 1.6
+++ source/blender/python/api2_2x/doc/Texture.py 26 Jul 2005 11:56:50 -0000
@@ -131,13 +131,62 @@ Example::
- NOR - Make the texture affect the rendered normal
- CSP - Make the texture affect the specularity colour
- CMIR - Make the texture affect the mirror colour
- - REF - Make the texture affect the value of the material's reflectivity
- - SPEC - Make the texture affect the value of specularity
+ - REF - Make the texture affect the diffuse reflectivity value
+ - SPEC - Make the texture affect the specularity value
- HARD - Make the texture affect the hardness value
- ALPHA - Make the texture affect the alpha value
- - EMIT - Make the texture affext the emit value
+ - EMIT - Make the texture affect the emit value
+ - RAYMIR - Make the texture affect the mirror reflectivity value
+ - DISP - Make the texture displace the mesh
+ - TRANSLU - Make the texture affect the translucency value
+ - AMB - Make the texture affect the ambient value
+ - WARP - Make the texture affect texture coordinates for the following textures
@type MapTo: readonly dictionary
+@var NoiseBasis: The available noise basises:
+ - BLENDER - Blender Original
+ - STDPERLIN - Original Perlin
+ - NEWPERLIN - Improved Perlin
+ - VORONOI_F1 - Voronoi F1
+ - VORONOI_F2 - Voronoi F2
+ - VORONOI_F3 - Voronoi F3
+ - VORONOI_F4 - Voronoi F4
+ - VORONOI_F2F1 - Voronoi F2-F1
+ - VORONOI_CRACKLE - Voronoi Crackle
+ - CELLNOISE - CellNoise
+@type NoiseBasis: readonly dictionary
+
+@var WaveType: The available wave types:
+ - SIN - Sine wave
+ - SAW - Sawtooth wave
+ - TRI - Triangle wave
+@type WaveType: readonly dictionary
+
+@var BlendMode: The available texture blending modes:
+ - MIX - mix texture with value
+ - MULTIPLY - multiply texture with value
+ - ADD - add texture to value
+ - SUBTRACT - subtract texture from value
+ - DIVIDE - divide value by texture
+ - DARKEN - replace value with texture if texture is darker
+ - DIFFERENCE - difference of texture from value
+ - LIGHTEN - replace value with texture if texture is lighter
+ - SCREEN - 'screen' mode
+@type BlendMode: readonly dictionary
+
+@var Mapping: The available 2D texture coordinate mappings for images:
+ - FLAT - flat projection
+ - CUBE - cube projection
+ - TUBE - cylindrical projection
+ - SPHERE - spherical projection
+@type Mapping: readonly dictionary
+
+@var Proj: The available projections per axis:
+ - NONE - axis isn't used
+ - X - axis is used as final x axis
+ - Y - axis is used as final y axis
+ - Z - axis is used as final z axis
+@type Proj: readonly dictionary
"""
def New (name = 'Tex'):
@@ -175,6 +224,7 @@ class Texture:
@ivar imageFlags: The texture image flags (OR'd tegether).
See L{ImageFlags}
@ivar stype: Texture-type specific data. See L{STypes}
+ @ivar wavetype: Wave type. See L{WaveType}
@ivar image: The image associated with this texture, or None.
@type image: Blender Image
@ivar rgbCol: The texture's RGB color triplet.
@@ -186,6 +236,7 @@ class Texture:
like C{(xmin, ymin, xmax, ymax)}
@ivar repeat: Tuple of image repeat values as ints, like
C{(xrepeat, yrepeat)}
+ @ivar noiseBasis: The noise basis. See L{NoiseBasis}
@ivar noiseSize: The noise size.
@ivar noiseDepth: The noise depth.
@ivar noiseType: The noise type: 'soft' or 'hard'.
@@ -301,6 +352,40 @@ class MTex:
@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{BlendMode}
+ @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{Mapping}
+ @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 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
"""
def getIpo():
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
db/1d/7698186603b716f03d14c3a299ca
Event Timeline
Log In to Comment