Page Menu
Home
Search
Configure Global Search
Log In
Files
F3035
patch-Texture.txt
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Ken Hughes (khughes)
Nov 13 2013, 1:07 PM
Size
112 KB
Subscribers
None
patch-Texture.txt
View Options
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.13
diff -u -r1.13 Texture.c
--- source/blender/python/api2_2x/Texture.c 17 Aug 2005 14:26:00 -0000 1.13
+++ source/blender/python/api2_2x/Texture.c 23 Aug 2005 05:03:23 -0000
@@ -24,7 +24,7 @@
*
* This is a new part of Blender.
*
- * Contributor(s): Alex Mole, Nathan Letwory, Joilnen B. Leite
+ * Contributor(s): Alex Mole, Nathan Letwory, Joilnen B. Leite, Ken Hughes
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
@@ -41,6 +41,8 @@
#include "Image.h"
#include "Ipo.h"
#include "constant.h"
+#include "blendef.h"
+#include "render.h"
#include "gen_utils.h"
@@ -107,6 +109,8 @@
#define EXPP_TEX_FLAG_COLORBAND TEX_COLORBAND
#define EXPP_TEX_FLAG_FLIPBLEND TEX_FLIPBLEND
#define EXPP_TEX_FLAG_NEGALPHA TEX_NEGALPHA
+#define EXPP_TEX_FLAG_CHECKER_ODD TEX_CHECKER_ODD
+#define EXPP_TEX_FLAG_CHECKER_EVEN TEX_CHECKER_EVEN
#define EXPP_TEX_IMAGEFLAG_INTERPOL TEX_INTERPOL
#define EXPP_TEX_IMAGEFLAG_USEALPHA TEX_USEALPHA
@@ -124,9 +128,10 @@
#define EXPP_TEX_EXTEND_CLIP TEX_CLIP
#define EXPP_TEX_EXTEND_REPEAT TEX_REPEAT
#define EXPP_TEX_EXTEND_CLIPCUBE TEX_CLIPCUBE
+#define EXPP_TEX_EXTEND_CHECKER TEX_CHECKER
#define EXPP_TEX_EXTEND_MIN EXPP_TEX_EXTEND_EXTEND
-#define EXPP_TEX_EXTEND_MAX EXPP_TEX_EXTEND_CLIPCUBE
+#define EXPP_TEX_EXTEND_MAX EXPP_TEX_EXTEND_CHECKER
#define EXPP_TEX_TEXCO_ORCO TEXCO_ORCO
#define EXPP_TEX_TEXCO_REFL TEXCO_REFL
@@ -171,6 +176,22 @@
#define EXPP_TEX_STYPE_VN_TEX_MINKOVSKY_FOUR TEX_MINKOVSKY_FOUR
#define EXPP_TEX_STYPE_VN_TEX_MINKOVSKY TEX_MINKOVSKY
+#define EXPP_TEX_NOISE_SINE 0
+#define EXPP_TEX_NOISE_SAW 1
+#define EXPP_TEX_NOISE_TRI 2
+#define EXPP_TEX_NOISEBASIS2 0xffff
+
+#define EXPP_TEX_NOISE_BLENDER TEX_BLENDER
+#define EXPP_TEX_NOISE_PERLIN TEX_STDPERLIN
+#define EXPP_TEX_NOISE_IMPROVEPERLIN TEX_NEWPERLIN
+#define EXPP_TEX_NOISE_VORONOIF1 TEX_VORONOI_F1
+#define EXPP_TEX_NOISE_VORONOIF2 TEX_VORONOI_F2
+#define EXPP_TEX_NOISE_VORONOIF3 TEX_VORONOI_F3
+#define EXPP_TEX_NOISE_VORONOIF4 TEX_VORONOI_F4
+#define EXPP_TEX_NOISE_VORONOIF2F1 TEX_VORONOI_F2F1
+#define EXPP_TEX_NOISE_VORONOICRACKLE TEX_VORONOI_CRACKLE
+#define EXPP_TEX_NOISE_CELLNOISE TEX_CELLNOISE
+
/****************************************************************************/
/* Texture String->Int maps */
/****************************************************************************/
@@ -194,10 +215,14 @@
};
static const EXPP_map_pair tex_flag_map[] = {
- /* we don't support this yet! */
-/* { "ColorBand", EXPP_TEX_FLAG_COLORBAND }, */
+/* NOTE "CheckerOdd" and "CheckerEven" are new */
+#if 0
+ {"ColorBand", EXPP_TEX_FLAG_COLORBAND },
+#endif
{"FlipBlend", EXPP_TEX_FLAG_FLIPBLEND},
{"NegAlpha", EXPP_TEX_FLAG_NEGALPHA},
+ {"CheckerOdd",EXPP_TEX_FLAG_CHECKER_ODD},
+ {"CheckerEven",EXPP_TEX_FLAG_CHECKER_EVEN},
{NULL, 0}
};
@@ -221,6 +246,8 @@
{"Clip", EXPP_TEX_EXTEND_CLIP},
{"ClipCube", EXPP_TEX_EXTEND_CLIPCUBE},
{"Repeat", EXPP_TEX_EXTEND_REPEAT},
+/* NOTE "Checker" is new */
+ {"Checker", EXPP_TEX_EXTEND_CHECKER},
{NULL, 0}
};
@@ -339,7 +366,6 @@
tex_distance_voronoi_map
};
-
/*****************************************************************************/
/* Python API function prototypes for the Texture module. */
/*****************************************************************************/
@@ -378,17 +404,73 @@
/* Python BPy_Texture methods declarations: */
/*****************************************************************************/
#define GETFUNC(name) static PyObject *Texture_##name(BPy_Texture *self)
-#define SETFUNC(name) static PyObject *Texture_##name(BPy_Texture *self, \
+#define OLDSETFUNC(name) static PyObject *Texture_old##name(BPy_Texture *self, \
PyObject *args)
-
+#define SETFUNC(name) static int Texture_##name(BPy_Texture *self, \
+ PyObject *value)
+#if 0
GETFUNC( getExtend );
GETFUNC( getImage );
GETFUNC( getName );
GETFUNC( getType );
GETFUNC( getSType );
-GETFUNC( getIpo );
GETFUNC( clearIpo );
-SETFUNC( setIpo );
+#endif
+
+GETFUNC( oldgetSType );
+GETFUNC( oldgetType );
+
+GETFUNC( clearIpo );
+GETFUNC( getAnimFrames );
+GETFUNC( getAnimLength );
+GETFUNC( getAnimMontage );
+GETFUNC( getAnimOffset );
+GETFUNC( getAnimStart );
+GETFUNC( getBrightness );
+GETFUNC( getContrast );
+GETFUNC( getCrop );
+GETFUNC( getDistAmnt );
+GETFUNC( getDistMetric );
+GETFUNC( getExp );
+GETFUNC( getExtend );
+GETFUNC( getIntExtend );
+GETFUNC( getFieldsPerImage );
+GETFUNC( getFilterSize );
+GETFUNC( getFlags );
+GETFUNC( getHFracDim );
+GETFUNC( getImage );
+GETFUNC( getIpo );
+GETFUNC( getIScale );
+GETFUNC( getLacunarity );
+GETFUNC( getName );
+GETFUNC( getNoiseBasis );
+GETFUNC( getNoiseDepth );
+GETFUNC( getNoiseSize );
+GETFUNC( getNoiseType );
+GETFUNC( getOcts );
+GETFUNC( getRepeat );
+GETFUNC( getRGBCol );
+GETFUNC( getSType );
+GETFUNC( getTurbulence );
+GETFUNC( getType );
+GETFUNC( getWeight1 );
+GETFUNC( getWeight2 );
+GETFUNC( getWeight3 );
+GETFUNC( getWeight4 );
+GETFUNC( getUsers );
+
+OLDSETFUNC( setDistMetric );
+OLDSETFUNC( setDistNoise ); /* special case used for ".noisebasis = ... */
+OLDSETFUNC( setExtend );
+OLDSETFUNC( setFlags );
+OLDSETFUNC( setImage );
+OLDSETFUNC( setImageFlags );
+OLDSETFUNC( setIpo );
+OLDSETFUNC( setName );
+OLDSETFUNC( setNoiseBasis );
+OLDSETFUNC( setSType );
+OLDSETFUNC( setType );
+
SETFUNC( setAnimFrames );
SETFUNC( setAnimLength );
SETFUNC( setAnimMontage );
@@ -397,30 +479,40 @@
SETFUNC( setBrightness );
SETFUNC( setContrast );
SETFUNC( setCrop );
-SETFUNC( setExtend );
-SETFUNC( setIntExtend ); /* special case used for ".extend = ..." */
+SETFUNC( setDistAmnt );
+SETFUNC( setDistMetric );
+SETFUNC( setExp );
+SETFUNC( setIntExtend );
SETFUNC( setFieldsPerImage );
SETFUNC( setFilterSize );
SETFUNC( setFlags );
-SETFUNC( setIntFlags ); /* special case used for ".flags = ..." */
+SETFUNC( setHFracDim );
SETFUNC( setImage );
-SETFUNC( setImageFlags );
-SETFUNC( setIntImageFlags ); /* special case used for ".imageFlags = ..." */
+SETFUNC( setIpo );
+SETFUNC( setIScale );
+SETFUNC( setLacunarity );
SETFUNC( setName );
+SETFUNC( setNoiseBasis );
SETFUNC( setNoiseDepth );
SETFUNC( setNoiseSize );
SETFUNC( setNoiseType );
-SETFUNC( setNoiseBasis ); /* special case used for ".noisebasis or noisebasis2 = ... */
-SETFUNC( setDistNoise ); /* special case used for ".noisebasis = ... */
+SETFUNC( setOcts );
SETFUNC( setRepeat );
SETFUNC( setRGBCol );
SETFUNC( setSType );
-SETFUNC( setIntSType ); /* special case used for ".stype = ..." */
-SETFUNC( setType );
-SETFUNC( setIntType ); /* special case used for ".type = ..." */
SETFUNC( setTurbulence );
-SETFUNC( setDistMetric );
-SETFUNC( setDistAmnt );
+SETFUNC( setType );
+SETFUNC( setWeight1 );
+SETFUNC( setWeight2 );
+SETFUNC( setWeight3 );
+SETFUNC( setWeight4 );
+
+static PyObject *Texture_getImageFlags( BPy_Texture *self, int type );
+static PyObject *Texture_getNoiseBasis2( BPy_Texture *self, int type );
+static int Texture_setImageFlags( BPy_Texture *self, PyObject *args,
+ int type );
+static int Texture_setNoiseBasis2( BPy_Texture *self, PyObject *args,
+ int type );
/*****************************************************************************/
/* Python BPy_Texture methods table: */
@@ -433,74 +525,345 @@
"() - Return Texture Image"},
{"getName", ( PyCFunction ) Texture_getName, METH_NOARGS,
"() - Return Texture name"},
- {"getSType", ( PyCFunction ) Texture_getSType, METH_NOARGS,
+ {"getSType", ( PyCFunction ) Texture_oldgetSType, METH_NOARGS,
"() - Return Texture stype as string"},
- {"getType", ( PyCFunction ) Texture_getType, METH_NOARGS,
+ {"getType", ( PyCFunction ) Texture_oldgetType, METH_NOARGS,
"() - Return Texture type as string"},
{"getIpo", ( PyCFunction ) Texture_getIpo, METH_NOARGS,
"() - Return Texture Ipo"},
- {"setIpo", ( PyCFunction ) Texture_setIpo, METH_VARARGS,
+ {"setIpo", ( PyCFunction ) Texture_oldsetIpo, METH_VARARGS,
"(Blender Ipo) - Set Texture Ipo"},
{"clearIpo", ( PyCFunction ) Texture_clearIpo, METH_NOARGS,
"() - Unlink Ipo from this Texture."},
- {"setExtend", ( PyCFunction ) Texture_setExtend, METH_VARARGS,
+ {"setExtend", ( PyCFunction ) Texture_oldsetExtend, METH_VARARGS,
"(s) - Set Texture extend mode"},
- {"setFlags", ( PyCFunction ) Texture_setFlags, METH_VARARGS,
- "(f1,f2,f3) - Set Texture flags"},
- {"setImage", ( PyCFunction ) Texture_setImage, METH_VARARGS,
+ {"setFlags", ( PyCFunction ) Texture_oldsetFlags, METH_VARARGS,
+ "(f1,f2,f3,f4,f5) - Set Texture flags"},
+ {"setImage", ( PyCFunction ) Texture_oldsetImage, METH_VARARGS,
"(Blender Image) - Set Texture Image"},
- {"setImageFlags", ( PyCFunction ) Texture_setImageFlags, METH_VARARGS,
+ {"setImageFlags", ( PyCFunction ) Texture_oldsetImageFlags, METH_VARARGS,
"(s,s,s,s,...) - Set Texture image flags"},
- {"setName", ( PyCFunction ) Texture_setName, METH_VARARGS,
+ {"setName", ( PyCFunction ) Texture_oldsetName, METH_VARARGS,
"(s) - Set Texture name"},
- {"setSType", ( PyCFunction ) Texture_setSType, METH_VARARGS,
+ {"setSType", ( PyCFunction ) Texture_oldsetSType, METH_VARARGS,
"(s) - Set Texture stype"},
- {"setType", ( PyCFunction ) Texture_setType, METH_VARARGS,
+ {"setType", ( PyCFunction ) Texture_oldsetType, METH_VARARGS,
"(s) - Set Texture type"},
- {"setNoiseBasis", ( PyCFunction ) Texture_setNoiseBasis, METH_VARARGS,
+ {"setNoiseBasis", ( PyCFunction ) Texture_oldsetNoiseBasis, METH_VARARGS,
"(s) - Set Noise basis"},
- {"setDistNoise", ( PyCFunction ) Texture_setDistNoise, METH_VARARGS,
+ {"setDistNoise", ( PyCFunction ) Texture_oldsetDistNoise, METH_VARARGS,
"(s) - Set Dist Noise"},
- {"setDistMetric", ( PyCFunction ) Texture_setDistMetric, METH_VARARGS,
+ {"setDistMetric", ( PyCFunction ) Texture_oldsetDistMetric, METH_VARARGS,
"(s) - Set Dist Metric"},
{NULL, NULL, 0, NULL}
};
/*****************************************************************************/
+/* Python Texture_Type attributes get/set structure: */
+/*****************************************************************************/
+static PyGetSetDef BPy_Texture_getseters[] = {
+ {"animFrames",
+ (getter)Texture_getAnimFrames, (setter)Texture_setAnimFrames,
+ "Number of frames of a movie to use",
+ NULL},
+ {"animLength",
+ (getter)Texture_getAnimLength, (setter)Texture_setAnimLength,
+ "Number of frames of a movie to use (0 for all)",
+ NULL},
+ {"animMontage",
+ (getter)Texture_getAnimMontage, (setter)Texture_setAnimMontage,
+ "Montage mode, start frames and durations",
+ NULL},
+ {"animOffset",
+ (getter)Texture_getAnimOffset, (setter)Texture_setAnimOffset,
+ "Offsets the number of the first movie frame to use",
+ NULL},
+ {"animStart",
+ (getter)Texture_getAnimStart, (setter)Texture_setAnimStart,
+ "Starting frame of the movie to use",
+ NULL},
+ {"brightness",
+ (getter)Texture_getBrightness, (setter)Texture_setBrightness,
+ "Changes the brightness of a texture's color",
+ NULL},
+ {"contrast",
+ (getter)Texture_getContrast, (setter)Texture_setContrast,
+ "Changes the contrast of a texture's color",
+ NULL},
+ {"crop",
+ (getter)Texture_getCrop, (setter)Texture_setCrop,
+ "Sets the cropping extents (for image textures)",
+ NULL},
+ {"distAmnt",
+ (getter)Texture_getDistAmnt, (setter)Texture_setDistAmnt,
+ "Amount of distortion (for distorted noise textures)",
+ NULL},
+ {"distMetric",
+ (getter)Texture_getDistMetric, (setter)Texture_setDistMetric,
+ "The distance metric (for Voronoi textures)",
+ NULL},
+ {"exp",
+ (getter)Texture_getExp, (setter)Texture_setExp,
+ "Minkovsky exponent (for Minkovsky Voronoi textures)",
+ NULL},
+ {"extend",
+ (getter)Texture_getIntExtend, (setter)Texture_setIntExtend,
+ "Texture's 'Extend' mode (for image textures)",
+ NULL},
+ {"fieldsPerImage",
+ (getter)Texture_getFieldsPerImage, (setter)Texture_setFieldsPerImage,
+ "Number of fields per rendered frame",
+ NULL},
+ {"filterSize",
+ (getter)Texture_getFilterSize, (setter)Texture_setFilterSize,
+ "The filter size (for image and envmap textures)",
+ NULL},
+ {"flags",
+ (getter)Texture_getFlags, (setter)Texture_setFlags,
+ "Texture's 'Flag' bits",
+ NULL},
+ {"hFracDim",
+ (getter)Texture_getHFracDim, (setter)Texture_setHFracDim,
+ "Highest fractional dimension (for Musgrave textures)",
+ NULL},
+ {"imageFlags",
+ (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
+ "Texture's 'ImageFlags' bits",
+ NULL},
+ {"image",
+ (getter)Texture_getImage, (setter)Texture_setImage,
+ "Texture's image object",
+ NULL},
+ {"ipo",
+ (getter)Texture_getIpo, (setter)Texture_setIpo,
+ "Texture Ipo data",
+ NULL},
+ {"iScale",
+ (getter)Texture_getIScale, (setter)Texture_setIScale,
+ "Intensity output scale (for Musgrave and Voronoi textures)",
+ NULL},
+ {"lacunarity",
+ (getter)Texture_getLacunarity, (setter)Texture_setLacunarity,
+ "Gap between succesive frequencies (for Musgrave textures)",
+ NULL},
+ {"name",
+ (getter)Texture_getName, (setter)Texture_setName,
+ "Texture data name",
+ NULL},
+ {"noiseBasis",
+ (getter)Texture_getNoiseBasis, (setter)Texture_setNoiseBasis,
+ "Noise basis type (wood, stucci, marble, clouds, Musgrave, distorted noise)",
+ NULL},
+ {"noiseBasis2",
+ (getter)Texture_getNoiseBasis2, (setter)Texture_setNoiseBasis2,
+ "Additional noise basis type (wood, marble, distorted noise)",
+ (void *)EXPP_TEX_NOISEBASIS2},
+ {"noiseDepth",
+ (getter)Texture_getNoiseDepth, (setter)Texture_setNoiseDepth,
+ "Noise depth (magic, marble, clouds)",
+ NULL},
+ {"noiseSize",
+ (getter)Texture_getNoiseSize, (setter)Texture_setNoiseSize,
+ "Noise size (wood, stucci, marble, clouds, Musgrave, distorted noise, Voronoi)",
+ NULL},
+/* NOTE for API rewrite: should use dict constants instead of strings */
+ {"noiseType",
+ (getter)Texture_getNoiseType, (setter)Texture_setNoiseType,
+ "Noise type (for wood, stucci, marble, clouds textures)",
+ NULL},
+ {"octs",
+ (getter)Texture_getOcts, (setter)Texture_setOcts,
+ "Number of frequencies (for Musgrave textures)",
+ NULL},
+ {"repeat",
+ (getter)Texture_getRepeat, (setter)Texture_setRepeat,
+ "Repetition multiplier (for image textures)",
+ NULL},
+ {"rgbCol",
+ (getter)Texture_getRGBCol, (setter)Texture_setRGBCol,
+ "RGB color tuple",
+ NULL},
+ {"stype",
+ (getter)Texture_getSType, (setter)Texture_setSType,
+ "Texture's 'SType' mode",
+ NULL},
+ {"turbulence",
+ (getter)Texture_getTurbulence, (setter)Texture_setTurbulence,
+ "Turbulence (for magic, wood, stucci, marble textures)",
+ NULL},
+ {"type",
+ (getter)Texture_getType, (setter)Texture_setType,
+ "Texture's 'Type' mode",
+ NULL},
+ {"users",
+ (getter)Texture_getUsers, (setter)NULL,
+ "Number of texture users",
+ NULL},
+ {"weight1",
+ (getter)Texture_getWeight1, (setter)Texture_setWeight1,
+ "Weight 1 (for Voronoi textures)",
+ NULL},
+ {"weight2",
+ (getter)Texture_getWeight2, (setter)Texture_setWeight2,
+ "Weight 2 (for Voronoi textures)",
+ NULL},
+ {"weight3",
+ (getter)Texture_getWeight3, (setter)Texture_setWeight3,
+ "Weight 3 (for Voronoi textures)",
+ NULL},
+ {"weight4",
+ (getter)Texture_getWeight4, (setter)Texture_setWeight4,
+ "Weight 4 (for Voronoi textures)",
+ NULL},
+ {"sine",
+ (getter)Texture_getNoiseBasis2, (setter)Texture_setNoiseBasis2,
+ "Produce bands using sine wave (marble, wood textures)",
+ (void *)EXPP_TEX_NOISE_SINE},
+ {"saw",
+ (getter)Texture_getNoiseBasis2, (setter)Texture_setNoiseBasis2,
+ "Produce bands using saw wave (marble, wood textures)",
+ (void *)EXPP_TEX_NOISE_SAW},
+ {"tri",
+ (getter)Texture_getNoiseBasis2, (setter)Texture_setNoiseBasis2,
+ "Produce bands using triangle wave (marble, wood textures)",
+ (void *)EXPP_TEX_NOISE_TRI},
+ {"interpol",
+ (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
+ "Interpolate image's pixels to fit texture mapping enabled ('ImageFlags')",
+ (void *)EXPP_TEX_IMAGEFLAG_INTERPOL},
+ {"useAlpha",
+ (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
+ "Use of image's alpha channel enabled ('ImageFlags')",
+ (void *)EXPP_TEX_IMAGEFLAG_USEALPHA},
+ {"calcAlpha",
+ (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
+ "Calculation of image's alpha channel enabled ('ImageFlags')",
+ (void *)EXPP_TEX_IMAGEFLAG_CALCALPHA},
+ {"mipmap",
+ (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
+ "Mipmaps enabled ('ImageFlags')",
+ (void *)EXPP_TEX_IMAGEFLAG_MIPMAP},
+ {"fields",
+ (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
+ "Use of image's fields enabled ('ImageFlags')",
+ (void *)EXPP_TEX_IMAGEFLAG_FIELDS},
+ {"rot90",
+ (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
+ "X/Y flip for rendering enabled ('ImageFlags')",
+ (void *)EXPP_TEX_IMAGEFLAG_ROT90},
+ {"cyclic",
+ (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
+ "Looping of animated frames enabled ('ImageFlags')",
+ (void *)EXPP_TEX_IMAGEFLAG_CYCLIC},
+ {"movie",
+ (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
+ "Movie frames as images enabled ('ImageFlags')",
+ (void *)EXPP_TEX_IMAGEFLAG_MOVIE},
+ {"anti",
+ (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
+ "Image anti-aliasing enabled ('ImageFlags')",
+ (void *)EXPP_TEX_IMAGEFLAG_ANTI},
+ {"stField",
+ (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
+ "Standard field deinterlacing enabled ('ImageFlags')",
+ (void *)EXPP_TEX_IMAGEFLAG_STFIELD},
+ {"normalMap",
+ (getter)Texture_getImageFlags, (setter)Texture_setImageFlags,
+ "Use of image RGB values for normal mapping enabled ('ImageFlags')",
+ (void *)EXPP_TEX_IMAGEFLAG_NORMALMAP},
+ {NULL,NULL,NULL,NULL,NULL} /* Sentinel */
+};
+
+/*****************************************************************************/
/* Python Texture_Type callback function prototypes: */
/*****************************************************************************/
static void Texture_dealloc( BPy_Texture * self );
-static int Texture_setAttr( BPy_Texture * self, char *name, PyObject * v );
static int Texture_compare( BPy_Texture * a, BPy_Texture * b );
-static PyObject *Texture_getAttr( BPy_Texture * self, char *name );
static PyObject *Texture_repr( BPy_Texture * self );
-
/*****************************************************************************/
/* Python Texture_Type structure definition: */
/*****************************************************************************/
PyTypeObject Texture_Type = {
- PyObject_HEAD_INIT( NULL ) 0, /* ob_size */
- "Blender Texture", /* tp_name */
- sizeof( BPy_Texture ), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- ( destructor ) Texture_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- ( getattrfunc ) Texture_getAttr, /* tp_getattr */
- ( setattrfunc ) Texture_setAttr, /* tp_setattr */
- ( cmpfunc ) Texture_compare, /* tp_compare */
- ( reprfunc ) Texture_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, /* tp_doc */
- 0, 0, 0, 0, 0, 0,
- BPy_Texture_methods, /* tp_methods */
- 0, /* tp_members */
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ PyObject_HEAD_INIT( NULL ) /* required py macro */
+ 0, /* ob_size */
+ /* For printing, in format "<module>.<name>" */
+ "Blender Texture", /* char *tp_name; */
+ sizeof( BPy_Texture ), /* int tp_basicsize; */
+ 0, /* tp_itemsize; For allocation */
+
+ /* Methods to implement standard operations */
+
+ ( destructor ) Texture_dealloc,/* destructor tp_dealloc; */
+ NULL, /* printfunc tp_print; */
+ NULL, /* getattrfunc tp_getattr; */
+ NULL, /* setattrfunc tp_setattr; */
+ ( cmpfunc ) Texture_compare, /* cmpfunc tp_compare; */
+ ( reprfunc ) Texture_repr, /* reprfunc tp_repr; */
+
+ /* Method suites for standard classes */
+
+ NULL, /* PyNumberMethods *tp_as_number; */
+ NULL, /* PySequenceMethods *tp_as_sequence; */
+ NULL, /* PyMappingMethods *tp_as_mapping; */
+
+ /* More standard operations (here for binary compatibility) */
+
+ NULL, /* hashfunc tp_hash; */
+ NULL, /* ternaryfunc tp_call; */
+ NULL, /* reprfunc tp_str; */
+ NULL, /* getattrofunc tp_getattro; */
+ NULL, /* setattrofunc tp_setattro; */
+
+ /* Functions to access object as input/output buffer */
+ NULL, /* PyBufferProcs *tp_as_buffer; */
+
+ /*** Flags to define presence of optional/expanded features ***/
+ Py_TPFLAGS_DEFAULT, /* long tp_flags; */
+
+ NULL, /* char *tp_doc; Documentation string */
+ /*** Assigned meaning in release 2.0 ***/
+ /* call function for all accessible objects */
+ NULL, /* traverseproc tp_traverse; */
+
+ /* delete references to contained objects */
+ NULL, /* inquiry tp_clear; */
+
+ /*** Assigned meaning in release 2.1 ***/
+ /*** rich comparisons ***/
+ NULL, /* richcmpfunc tp_richcompare; */
+
+ /*** weak reference enabler ***/
+ 0, /* long tp_weaklistoffset; */
+
+ /*** Added in release 2.2 ***/
+ /* Iterators */
+ NULL, /* getiterfunc tp_iter; */
+ NULL, /* iternextfunc tp_iternext; */
+
+ /*** Attribute descriptor and subclassing stuff ***/
+ BPy_Texture_methods, /* struct PyMethodDef *tp_methods; */
+ NULL, /* struct PyMemberDef *tp_members; */
+ BPy_Texture_getseters, /* struct PyGetSetDef *tp_getset; */
+ NULL, /* struct _typeobject *tp_base; */
+ NULL, /* PyObject *tp_dict; */
+ NULL, /* descrgetfunc tp_descr_get; */
+ NULL, /* descrsetfunc tp_descr_set; */
+ 0, /* long tp_dictoffset; */
+ NULL, /* initproc tp_init; */
+ NULL, /* allocfunc tp_alloc; */
+ NULL, /* newfunc tp_new; */
+ /* Low-level free-memory routine */
+ NULL, /* freefunc tp_free; */
+ /* For PyObject_IS_GC */
+ NULL, /* inquiry tp_is_gc; */
+ NULL, /* PyObject *tp_bases; */
+ /* method resolution order */
+ NULL, /* PyObject *tp_mro; */
+ NULL, /* PyObject *tp_cache; */
+ NULL, /* PyObject *tp_subclasses; */
+ NULL, /* PyObject *tp_weaklist; */
+ NULL
};
static PyObject *M_Texture_New( PyObject * self, PyObject * args,
@@ -597,6 +960,21 @@
}
}
+static int Texture_compare( BPy_Texture * a, BPy_Texture * b )
+{
+ return ( a->texture == b->texture ) ? 0 : -1;
+}
+
+static PyObject *Texture_repr( BPy_Texture * self )
+{
+ return PyString_FromFormat( "[Texture \"%s\"]",
+ self->texture->id.name + 2 );
+}
+
+static void Texture_dealloc( BPy_Texture * self )
+{
+ PyObject_DEL( self );
+}
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(name) \
@@ -756,6 +1134,8 @@
EXPP_ADDCONST( COLORBAND );
EXPP_ADDCONST( FLIPBLEND );
EXPP_ADDCONST( NEGALPHA );
+ EXPP_ADDCONST( CHECKER_ODD );
+ EXPP_ADDCONST( CHECKER_EVEN );
}
return Flags;
}
@@ -779,7 +1159,6 @@
return ExtendModes;
}
-
#undef EXPP_ADDCONST
#define EXPP_ADDCONST(name) \
PyConstant_Insert(d, #name, PyInt_FromLong(EXPP_TEX_IMAGEFLAG_##name))
@@ -804,6 +1183,32 @@
return ImageFlags;
}
+#undef EXPP_ADDCONST
+#define EXPP_ADDCONST(name) \
+ PyConstant_Insert(d, #name, PyInt_FromLong(EXPP_TEX_NOISE_##name))
+
+static PyObject *M_Texture_NoiseDict( void )
+{
+ PyObject *Noise = PyConstant_New( );
+ if( Noise ) {
+ BPy_constant *d = ( BPy_constant * ) Noise;
+
+ EXPP_ADDCONST( SINE );
+ EXPP_ADDCONST( SAW );
+ EXPP_ADDCONST( TRI );
+ EXPP_ADDCONST( BLENDER );
+ EXPP_ADDCONST( PERLIN );
+ EXPP_ADDCONST( IMPROVEPERLIN );
+ EXPP_ADDCONST( VORONOIF1 );
+ EXPP_ADDCONST( VORONOIF2 );
+ EXPP_ADDCONST( VORONOIF3 );
+ EXPP_ADDCONST( VORONOIF4 );
+ EXPP_ADDCONST( VORONOIF2F1 );
+ EXPP_ADDCONST( VORONOICRACKLE );
+ EXPP_ADDCONST( CELLNOISE );
+ }
+ return Noise;
+}
PyObject *Texture_Init( void )
{
@@ -818,8 +1223,10 @@
PyObject *Flags = M_Texture_FlagsDict( );
PyObject *ExtendModes = M_Texture_ExtendModesDict( );
PyObject *ImageFlags = M_Texture_ImageFlagsDict( );
+ PyObject *Noise = M_Texture_NoiseDict( );
- Texture_Type.ob_type = &PyType_Type;
+ if( PyType_Ready( &Texture_Type ) < 0)
+ return NULL;
submodule = Py_InitModule3( "Blender.Texture",
M_Texture_methods, M_Texture_doc );
@@ -838,6 +1245,8 @@
PyModule_AddObject( submodule, "ExtendModes", ExtendModes );
if( ImageFlags )
PyModule_AddObject( submodule, "ImageFlags", ImageFlags );
+ if( Noise )
+ PyModule_AddObject( submodule, "Noise", Noise );
/* Add the MTex submodule to this module */
dict = PyModule_GetDict( submodule );
@@ -870,7 +1279,6 @@
return ( pyobj->ob_type == &Texture_Type );
}
-
/*****************************************************************************/
/* Python BPy_Texture methods: */
/*****************************************************************************/
@@ -913,16 +1321,23 @@
return attr;
}
-static PyObject *Texture_getSType( BPy_Texture * self )
+static PyObject *Texture_oldgetSType( BPy_Texture * self )
{
PyObject *attr = NULL;
const char *stype = NULL;
int n_stype;
- if( self->texture->type == EXPP_TEX_TYPE_ENVMAP )
+ if( self->texture->type == EXPP_TEX_TYPE_VORONOI )
+ n_stype = self->texture->vn_coltype;
+#if 0
+ else if( self->texture->type == EXPP_TEX_TYPE_MUSGRAVE )
+ n_stype = self->texture->noisebasis;
+#endif
+ else if( self->texture->type == EXPP_TEX_TYPE_ENVMAP )
n_stype = self->texture->env->stype;
- else
+ else
n_stype = self->texture->stype;
+
if( EXPP_map_getStrVal( tex_stype_map[self->texture->type],
n_stype, &stype ) )
attr = PyString_FromString( stype );
@@ -934,7 +1349,7 @@
return attr;
}
-static PyObject *Texture_getType( BPy_Texture * self )
+static PyObject *Texture_oldgetType( BPy_Texture * self )
{
PyObject *attr = NULL;
const char *type = NULL;
@@ -949,276 +1364,143 @@
return attr;
}
-static PyObject *Texture_setAnimFrames( BPy_Texture * self, PyObject * args )
+static int Texture_setAnimFrames( BPy_Texture * self, PyObject * value )
{
- int frames;
- if( !PyArg_ParseTuple( args, "i", &frames ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an int" );
-
- if( frames < 0 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "frames cannot be negative" );
-
- self->texture->frames = (short)frames;
-
- Py_INCREF( Py_None );
- return Py_None;
+ return EXPP_setShortClamped ( value, &self->texture->frames,
+ 0, (int)MAXFRAMEF );
}
-static PyObject *Texture_setAnimLength( BPy_Texture * self, PyObject * args )
+static int Texture_setAnimLength( BPy_Texture * self, PyObject * value )
{
- int length;
- if( !PyArg_ParseTuple( args, "i", &length ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an int" );
-
- if( length < 0 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "length cannot be negative" );
-
- self->texture->len = (short)length;
-
- Py_INCREF( Py_None );
- return Py_None;
+ return EXPP_setShortClamped ( value, &self->texture->len,
+ 0, 9000); /* ((int)MAXFRAMEF)/2 */
}
-
-static PyObject *Texture_setAnimMontage( BPy_Texture * self, PyObject * args )
+static int Texture_setAnimMontage( BPy_Texture * self, PyObject * value )
{
int fradur[4][2];
- int i, j;
- if( !PyArg_ParseTuple( args, "((ii)(ii)(ii)(ii))",
+ int i;
+
+ if( !PyArg_ParseTuple( value, "(ii)(ii)(ii)(ii)",
&fradur[0][0], &fradur[0][1],
&fradur[1][0], &fradur[1][1],
&fradur[2][0], &fradur[2][1],
&fradur[3][0], &fradur[3][1] ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
+ return EXPP_ReturnIntError( PyExc_TypeError,
"expected a tuple of tuples" );
- for( i = 0; i < 4; ++i )
- for( j = 0; j < 2; ++j )
- if( fradur[i][j] < 0 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "values must be greater than zero" );
-
- for( i = 0; i < 4; ++i )
- for( j = 0; j < 2; ++j )
- self->texture->fradur[i][j] = (short)fradur[i][j];
+ for( i = 0; i < 4; ++i ) {
+ self->texture->fradur[i][0] =
+ EXPP_ClampInt ( fradur[i][0], 0, (int)MAXFRAMEF );
+ self->texture->fradur[i][1] =
+ EXPP_ClampInt ( fradur[i][1], 0, 250 );
+ }
- Py_INCREF( Py_None );
- return Py_None;
+ return 0;
}
-
-static PyObject *Texture_setAnimOffset( BPy_Texture * self, PyObject * args )
+static int Texture_setAnimOffset( BPy_Texture * self, PyObject * value )
{
- int offset;
- if( !PyArg_ParseTuple( args, "i", &offset ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an int" );
-
- self->texture->offset = (short)offset;
-
- Py_INCREF( Py_None );
- return Py_None;
+ return EXPP_setShortClamped ( value, &self->texture->offset,
+ -9000, 9000); /* ((int)MAXFRAMEF)/2 */
}
-
-static PyObject *Texture_setAnimStart( BPy_Texture * self, PyObject * args )
+static int Texture_setAnimStart( BPy_Texture * self, PyObject * value )
{
- int sfra;
- if( !PyArg_ParseTuple( args, "i", &sfra ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an int" );
-
- if( sfra < 1 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "start must be greater than zero" );
-
- self->texture->sfra = (short)sfra;
-
- Py_INCREF( Py_None );
- return Py_None;
+ return EXPP_setShortClamped ( value, &self->texture->sfra,
+ 1, 9000); /* ((int)MAXFRAMEF)/2 */
}
-
-static PyObject *Texture_setBrightness( BPy_Texture * self, PyObject * args )
+static int Texture_setBrightness( BPy_Texture * self, PyObject * value )
{
- float bright;
- if( !PyArg_ParseTuple( args, "f", &bright ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a float" );
-
- if( bright < 0 || bright > 2 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "brightness must be in range [0,2]" );
-
- self->texture->bright = bright;
-
- Py_INCREF( Py_None );
- return Py_None;
+ return EXPP_setFloatClamped ( value, &self->texture->bright,
+ 0.0, 2.0);
}
-
-static PyObject *Texture_setContrast( BPy_Texture * self, PyObject * args )
+static int Texture_setContrast( BPy_Texture * self, PyObject * value )
{
- float contrast;
- if( !PyArg_ParseTuple( args, "f", &contrast ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a float" );
-
- if( contrast < 0 || contrast > 2 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "contrast must be in range [0,2]" );
-
- self->texture->contrast = contrast;
-
- Py_INCREF( Py_None );
- return Py_None;
+ return EXPP_setFloatClamped ( value, &self->texture->contrast,
+ 0.01, 5.0);
}
-
-static PyObject *Texture_setCrop( BPy_Texture * self, PyObject * args )
+static int Texture_setCrop( BPy_Texture * self, PyObject * value )
{
float crop[4];
- int i;
- if( !PyArg_ParseTuple( args, "(ffff)",
+
+ if( !PyArg_ParseTuple( value, "ffff",
&crop[0], &crop[1], &crop[2], &crop[3] ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
+ return EXPP_ReturnIntError( PyExc_TypeError,
"expected tuple of 4 floats" );
- for( i = 0; i < 4; ++i )
- if( crop[i] < -10 || crop[i] > 10 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "values must be in range [-10,10]" );
-
- self->texture->cropxmin = crop[0];
- self->texture->cropymin = crop[1];
- self->texture->cropxmax = crop[2];
- self->texture->cropymax = crop[3];
-
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-
-static PyObject *Texture_setExtend( BPy_Texture * self, PyObject * args )
-{
- char *extend = NULL;
- if( !PyArg_ParseTuple( args, "s", &extend ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
-
- if( !EXPP_map_getShortVal
- ( tex_extend_map, extend, &self->texture->extend ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "invalid extend mode" );
+ self->texture->cropxmin = EXPP_ClampFloat( crop[0], -10.0, 10.0 );
+ self->texture->cropymin = EXPP_ClampFloat( crop[1], -10.0, 10.0 );
+ self->texture->cropxmax = EXPP_ClampFloat( crop[2], -10.0, 10.0 );
+ self->texture->cropymax = EXPP_ClampFloat( crop[3], -10.0, 10.0 );
- Py_INCREF( Py_None );
- return Py_None;
+ return 0;
}
-static PyObject *Texture_setIntExtend( BPy_Texture * self, PyObject * args )
+static int Texture_setIntExtend( BPy_Texture * self, PyObject * value )
{
- int extend = 0;
- if( !PyArg_ParseTuple( args, "i", &extend ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument" );
-
- if( extend < EXPP_TEX_EXTEND_MIN || extend > EXPP_TEX_EXTEND_MAX )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "invalid extend mode" );
-
- self->texture->extend = (short)extend;
-
- Py_INCREF( Py_None );
- return Py_None;
+ return EXPP_setShortRange ( value, &self->texture->extend,
+ EXPP_TEX_EXTEND_MIN,
+ EXPP_TEX_EXTEND_MAX );
}
-static PyObject *Texture_setFieldsPerImage( BPy_Texture * self,
- PyObject * args )
+static int Texture_setFieldsPerImage( BPy_Texture * self,
+ PyObject * value )
{
- int fie_ima;
- if( !PyArg_ParseTuple( args, "i", &fie_ima ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an int" );
-
- if( fie_ima < 1 || fie_ima > 200 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "value must be in range [1,200]" );
-
- self->texture->fie_ima = (short)fie_ima;
-
- Py_INCREF( Py_None );
- return Py_None;
+ return EXPP_setShortClamped ( value, &self->texture->fie_ima,
+ 1, 200);
}
-static PyObject *Texture_setFilterSize( BPy_Texture * self, PyObject * args )
+static int Texture_setFilterSize( BPy_Texture * self, PyObject * value )
{
- float size;
- if( !PyArg_ParseTuple( args, "f", &size ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a float" );
-
- if( size < 0.1 || size > 25 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "filter size must be in range [0.1,25]" );
-
- self->texture->filtersize = size;
-
- Py_INCREF( Py_None );
- return Py_None;
+ return EXPP_setFloatClamped ( value, &self->texture->filtersize,
+ 0.1, 25 );
}
-static PyObject *Texture_setFlags( BPy_Texture * self, PyObject * args )
+static int Texture_setFlags( BPy_Texture * self, PyObject * value )
{
- char *sf[3] = { NULL, NULL, NULL };
- int i;
- short flags = 0;
- short thisflag;
- if( !PyArg_ParseTuple( args, "|sss", &sf[0], &sf[1], &sf[2] ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected 0-3 string arguments" );
-
- for( i = 0; i < 3; ++i ) {
- if( !sf[i] )
- break;
-
- if( !EXPP_map_getShortVal( tex_flag_map, sf[i], &thisflag ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "invalid texture flag name" );
+ int param;
+ int bitmask = EXPP_TEX_FLAG_FLIPBLEND
+#if 0
+ | EXPP_TEX_FLAG_COLORBAND
+#endif
+ | EXPP_TEX_FLAG_NEGALPHA
+ | EXPP_TEX_FLAG_CHECKER_ODD
+ | EXPP_TEX_FLAG_CHECKER_EVEN;
- flags |= thisflag;
+ if( !PyInt_CheckExact ( value ) ) {
+ char errstr[128];
+ sprintf ( errstr , "expected int bitmask of 0x%08x", bitmask );
+ return EXPP_ReturnIntError( PyExc_TypeError, errstr );
}
+ param = PyInt_AS_LONG ( value );
- self->texture->flag = flags;
+ if ( ( param & bitmask ) != param )
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "invalid bit(s) set in mask" );
- Py_INCREF( Py_None );
- return Py_None;
-}
+ self->texture->flag = param;
-static PyObject *Texture_setIntFlags( BPy_Texture * self, PyObject * args )
-{
- int flags = 0;
- if( !PyArg_ParseTuple( args, "i", &flags ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument" );
+#if 0
+ /* if Colorband enabled, make sure we allocate memory for it */
- self->texture->flag = (short)flags;
+ if ( ( param & EXPP_TEX_FLAG_COLORBAND ) && !self->texture->coba )
+ self->texture->coba = add_colorband();
+#endif
- Py_INCREF( Py_None );
- return Py_None;
+ return 0;
}
-
-static PyObject *Texture_setImage( BPy_Texture * self, PyObject * args )
+static int Texture_setImage( BPy_Texture * self, PyObject * value )
{
PyObject *pyimg;
Image *blimg = NULL;
- if( !PyArg_ParseTuple( args, "O!", &Image_Type, &pyimg ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
+ if( !PyArg_ParseTuple( value, "O!", &Image_Type, &pyimg ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
"expected an Image" );
blimg = Image_FromPyObject( pyimg );
@@ -1229,796 +1511,1112 @@
self->texture->ima = blimg;
id_us_plus( &blimg->id );
- Py_INCREF( Py_None );
- return Py_None;
+ return 0;
}
-
-static PyObject *Texture_setImageFlags( BPy_Texture * self, PyObject * args )
+static int Texture_setImageFlags( BPy_Texture * self, PyObject * value,
+ int type )
{
- char *sf[9] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
- int i;
- short flags = 0;
- short thisflag;
- if( !PyArg_ParseTuple
- ( args, "|sssssssss", &sf[0], &sf[1], &sf[2], &sf[3], &sf[4],
- &sf[5], &sf[6], &sf[7], &sf[8] ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected 0-9 string arguments" );
+ short param;
- for( i = 0; i < 9; ++i ) {
- if( !sf[i] )
- break;
-
- if( !EXPP_map_getShortVal
- ( tex_imageflag_map, sf[i], &thisflag ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "invalid texture image flag name" );
+ /*
+ * if type is non-zero, then attribute is "mipmap", "calcAlpha", etc.,
+ * so set/clear the bit in the bitfield based on the type
+ */
+
+ if( type ) {
+ int err;
+ param = self->texture->imaflag;
+ err = EXPP_setBitfield( value, ¶m, type, 'h' );
+ if( err )
+ return err;
+
+ /*
+ * if type is zero, then attribute is "imageFlags", so check
+ * value for a valid bitmap range.
+ */
+
+ } else {
+ int bitmask = EXPP_TEX_IMAGEFLAG_INTERPOL
+ | EXPP_TEX_IMAGEFLAG_USEALPHA
+ | EXPP_TEX_IMAGEFLAG_MIPMAP
+ | EXPP_TEX_IMAGEFLAG_FIELDS
+ | EXPP_TEX_IMAGEFLAG_ROT90
+ | EXPP_TEX_IMAGEFLAG_CALCALPHA
+ | EXPP_TEX_IMAGEFLAG_CYCLIC
+ | EXPP_TEX_IMAGEFLAG_MOVIE
+ | EXPP_TEX_IMAGEFLAG_ANTI
+ | EXPP_TEX_IMAGEFLAG_STFIELD
+ | EXPP_TEX_IMAGEFLAG_NORMALMAP;
+
+ if( !PyInt_CheckExact ( value ) ) {
+ char errstr[128];
+ sprintf ( errstr , "expected int bitmask of 0x%08x", bitmask );
+ return EXPP_ReturnIntError( PyExc_TypeError, errstr );
+ }
- flags |= thisflag;
+ param = PyInt_AS_LONG( value );
+ if( ( param & bitmask ) != param )
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "invalid bit(s) set in mask" );
}
- /* MIPMAP and FIELDS can't be used together */
- if( ( flags & EXPP_TEX_IMAGEFLAG_MIPMAP ) &&
- ( flags & EXPP_TEX_IMAGEFLAG_FIELDS ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "image flags MIPMAP and FIELDS cannot be used together" );
-
- self->texture->imaflag = flags;
-
- Py_INCREF( Py_None );
- return Py_None;
-}
-
-static PyObject *Texture_setIntImageFlags( BPy_Texture * self,
- PyObject * args )
-{
- int flags = 0;
- if( !PyArg_ParseTuple( args, "i", &flags ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument" );
+ /* "mipmap" and "fields" can't be set at the same time */
- /* MIPMAP and FIELDS can't be used together */
- if( ( flags & EXPP_TEX_IMAGEFLAG_MIPMAP ) &&
- ( flags & EXPP_TEX_IMAGEFLAG_FIELDS ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "image flags MIPMAP and FIELDS cannot be used together" );
+ if( ( param & EXPP_TEX_IMAGEFLAG_MIPMAP ) &&
+ ( param & EXPP_TEX_IMAGEFLAG_FIELDS ) )
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "image flags MIPMAP and FIELDS cannot be used together" );
- self->texture->imaflag = (short)flags;
+ /* everything is OK; save the new flag setting */
- Py_INCREF( Py_None );
- return Py_None;
+ self->texture->imaflag = param;
+ return 0;
}
-static PyObject *Texture_setName( BPy_Texture * self, PyObject * args )
+static int Texture_setName( BPy_Texture * self, PyObject * value )
{
char *name;
char buf[21];
- if( !PyArg_ParseTuple( args, "s", &name ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
+ name = PyString_AsString ( value );
+ if( !name )
+ return EXPP_ReturnIntError( PyExc_TypeError,
"expected string argument" );
PyOS_snprintf( buf, sizeof( buf ), "%s", name );
+
rename_id( &self->texture->id, buf );
- Py_INCREF( Py_None );
- return Py_None;
+ return 0;
}
-static PyObject *Texture_setNoiseDepth( BPy_Texture * self, PyObject * args )
+static int Texture_setNoiseDepth( BPy_Texture * self, PyObject * value )
{
- int depth;
- if( !PyArg_ParseTuple( args, "i", &depth ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected an int" );
-
- if( depth < 0 || depth > 6 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "value must be in range [0,6]" );
-
- self->texture->noisedepth = (short)depth;
-
- Py_INCREF( Py_None );
- return Py_None;
+ /* FIXME: depending on texture type, max clamp value differs
+ (see "Magic" texture)" */
+ return EXPP_setShortClamped ( value, &self->texture->noisedepth,
+ 0, 6);
}
-static PyObject *Texture_setNoiseSize( BPy_Texture * self, PyObject * args )
+static int Texture_setNoiseSize( BPy_Texture * self, PyObject * value )
{
- float size;
- if( !PyArg_ParseTuple( args, "f", &size ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a float" );
-
- if( size < 0 || size > 2 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "noise size must be in range [0,2]" );
-
- self->texture->noisesize = size;
-
- Py_INCREF( Py_None );
- return Py_None;
+ return EXPP_setFloatClamped ( value, &self->texture->noisesize,
+ 0.0001, 2.0);
}
-static PyObject *Texture_setNoiseType( BPy_Texture * self, PyObject * args )
+static int Texture_setNoiseType( BPy_Texture * self, PyObject * value )
{
- char *type;
+ char *param;
- if( !PyArg_ParseTuple( args, "s", &type ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
+ if( !PyString_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
"expected string argument" );
+ param = PyString_AS_STRING( value );
- if( STREQ( type, "soft" ) )
+ if( STREQ( param, "soft" ) )
self->texture->noisetype = TEX_NOISESOFT;
- else if( STREQ( type, "hard" ) )
+ else if( STREQ( param, "hard" ) )
self->texture->noisetype = TEX_NOISEPERL;
-
else
- return EXPP_ReturnPyObjError( PyExc_ValueError,
+ return EXPP_ReturnIntError( PyExc_ValueError,
"noise type must be 'soft' or 'hard'" );
- Py_INCREF( Py_None );
- return Py_None;
+ return 0;
}
-static PyObject *Texture_setNoiseBasis( BPy_Texture * self, PyObject * args )
+static int Texture_setNoiseBasis( BPy_Texture * self, PyObject * value )
{
- char *nbasis;
+ int param;
- if( !PyArg_ParseTuple( args, "s", &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" );
+ if( !PyInt_CheckExact ( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected int (see 'Noise' constant dictionary)" );
- Py_INCREF( Py_None );
- return Py_None;
+ param = PyInt_AS_LONG ( value );
+
+ if ( param < EXPP_TEX_STYPE_DN_BLENDER
+ || ( param > EXPP_TEX_STYPE_DN_VORONOICRACKLE
+ && param != EXPP_TEX_STYPE_DN_CELLNOISE ) )
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "invalid noise type" );
+
+ self->texture->noisebasis = param;
+ return 0;
}
-/* Distorted Noise */
-static PyObject *Texture_setDistNoise( BPy_Texture * self, PyObject * args )
+static int Texture_setNoiseBasis2( BPy_Texture * self, PyObject * value,
+ int type )
{
- char *nbasis;
-
- if( !PyArg_ParseTuple( args, "s", &nbasis ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
- if( self->texture->type == EXPP_TEX_TYPE_DISTNOISE &&
- !EXPP_map_getShortVal( tex_stype_map[EXPP_TEX_TYPE_DISTNOISE],
- nbasis, &self->texture->noisebasis ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "invalid noise basis" );
+ /*
+ * if type is EXPP_TEX_NOISEBASIS2, then this is the "noiseBasis2"
+ * attribute, so check the range and set the whole value
+ */
+
+ if( type == EXPP_TEX_NOISEBASIS2 ) {
+ int param;
+ if( !PyInt_CheckExact ( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected int (see 'Noise' constant dictionary)" );
+
+ param = PyInt_AS_LONG ( value );
+
+ if ( param < EXPP_TEX_STYPE_DN_BLENDER
+ || ( param > EXPP_TEX_STYPE_DN_VORONOICRACKLE
+ && param != EXPP_TEX_STYPE_DN_CELLNOISE ) )
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "invalid noise type" );
+
+ self->texture->noisebasis2 = param;
+
+ /*
+ * for other type values, the attribute is "sine", "saw" or "tri",
+ * so set the noise basis to the supplied type if value is 1
+ */
+
+ } else {
+ if( !PyInt_CheckExact ( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected int value of 1" );
+
+ if( PyInt_AS_LONG ( value ) != 1 )
+ return EXPP_ReturnIntError( PyExc_ValueError,
+ "expected intvalue of 1" );
- Py_INCREF( Py_None );
- return Py_None;
+ self->texture->noisebasis2 = type;
+ }
+ return 0;
}
-static PyObject *Texture_setRepeat( BPy_Texture * self, PyObject * args )
+static int Texture_setRepeat( BPy_Texture * self, PyObject * args )
{
int repeat[2];
- int i;
- if( !PyArg_ParseTuple( args, "(ii)", &repeat[0], &repeat[1] ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected tuple of 2 ints" );
- for( i = 0; i < 2; ++i )
- if( repeat[i] < 1 || repeat[i] > 512 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "values must be in range [1,512]" );
+ if( !PyArg_ParseTuple( args, "ii", &repeat[0], &repeat[1] ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected tuple of 2 ints" );
- self->texture->xrepeat = (short)repeat[0];
- self->texture->yrepeat = (short)repeat[1];
+ self->texture->xrepeat = EXPP_ClampInt( repeat[0], 1, 512 );
+ self->texture->yrepeat = EXPP_ClampInt( repeat[1], 1, 512 );
- Py_INCREF( Py_None );
- return Py_None;
+ return 0;
}
-static PyObject *Texture_setRGBCol( BPy_Texture * self, PyObject * args )
+static int Texture_setRGBCol( BPy_Texture * self, PyObject * args )
{
float rgb[3];
- int i;
- if( !PyArg_ParseTuple( args, "(fff)", &rgb[0], &rgb[1], &rgb[2] ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected tuple of 3 floats" );
-
- for( i = 0; i < 3; ++i )
- if( rgb[i] < 0 || rgb[i] > 2 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "values must be in range [0,2]" );
-
- self->texture->rfac = rgb[0];
- self->texture->gfac = rgb[1];
- self->texture->bfac = rgb[2];
-
- Py_INCREF( Py_None );
- return Py_None;
-}
+ if( !PyArg_ParseTuple( args, "fff", &rgb[0], &rgb[1], &rgb[2] ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected tuple of 3 floats" );
-static PyObject *Texture_setSType( BPy_Texture * self, PyObject * args )
-{
- char *stype = NULL;
- if( !PyArg_ParseTuple( args, "s", &stype ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
-
- /* can we really trust texture->type? */
- if( ( self->texture->type == EXPP_TEX_TYPE_VORONOI &&
- EXPP_map_getShortVal( tex_stype_map[self->texture->type],
- stype, &self->texture->vn_coltype ) ) );
- else if( ( self->texture->type == EXPP_TEX_TYPE_MUSGRAVE &&
- EXPP_map_getShortVal( tex_stype_map
- [EXPP_TEX_TYPE_DISTNOISE], stype,
- &self->texture->noisebasis ) ) );
- else if( ( self->texture->type == EXPP_TEX_TYPE_ENVMAP &&
- EXPP_map_getShortVal( tex_stype_map[self->texture->type],
- stype, &self->texture->env->stype ) ) );
- else if( !EXPP_map_getShortVal
- ( tex_stype_map[self->texture->type], stype,
- &self->texture->stype ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "invalid texture stype" );
+ self->texture->rfac = EXPP_ClampFloat( rgb[0], 0.0, 2.0 );
+ self->texture->gfac = EXPP_ClampFloat( rgb[1], 0.0, 2.0 );
+ self->texture->bfac = EXPP_ClampFloat( rgb[2], 0.0, 2.0 );
- Py_INCREF( Py_None );
- return Py_None;
+ return 0;
}
-static PyObject *Texture_setIntSType( BPy_Texture * self, PyObject * args )
+static int Texture_setSType( BPy_Texture * self, PyObject * value )
{
- int stype = 0;
+ short param;
const char *dummy = NULL;
- if( !PyArg_ParseTuple( args, "i", &stype ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
+
+ if( !PyInt_CheckExact ( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
"expected int argument" );
+ param = PyInt_AS_LONG ( value );
+
/* use the stype map to find out if this is a valid stype for this type *
* note that this will allow CLD_COLOR when type is ENVMAP. there's not *
* much that we can do about this though. */
if( !EXPP_map_getStrVal
- ( tex_stype_map[self->texture->type], stype, &dummy ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
+ ( tex_stype_map[self->texture->type], param, &dummy ) )
+ return EXPP_ReturnIntError( PyExc_ValueError,
"invalid stype (for this type)" );
- if( self->texture->type == EXPP_TEX_TYPE_ENVMAP )
- self->texture->env->stype = (short)stype;
- else
- self->texture->stype = (short)stype;
+ if( self->texture->type == EXPP_TEX_TYPE_VORONOI )
+ self->texture->vn_coltype = param;
+#if 0
+ else if( self->texture->type == EXPP_TEX_TYPE_MUSGRAVE )
+ self->texture->noisebasis = param;
+#endif
+ else if( self->texture->type == EXPP_TEX_TYPE_ENVMAP )
+ self->texture->env->stype = param;
+ else
+ self->texture->stype = param;
- Py_INCREF( Py_None );
- return Py_None;
+ return 0;
}
-static PyObject *Texture_setTurbulence( BPy_Texture * self, PyObject * args )
+static int Texture_setTurbulence( BPy_Texture * self, PyObject * value )
{
- float turb;
- if( !PyArg_ParseTuple( args, "f", &turb ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a float" );
+ return EXPP_setFloatClamped ( value, &self->texture->turbul,
+ 0.0, 200.0);
+}
- if( turb < 0 || turb > 200 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "turbulence must be in range [0,200]" );
+static int Texture_setHFracDim( BPy_Texture * self, PyObject * value )
+{
+ return EXPP_setFloatClamped ( value, &self->texture->mg_H,
+ 0.0001, 2.0);
+}
- self->texture->turbul = turb;
+static int Texture_setLacunarity( BPy_Texture * self, PyObject * value )
+{
+ return EXPP_setFloatClamped ( value, &self->texture->mg_lacunarity,
+ 0.0, 6.0);
+}
- Py_INCREF( Py_None );
- return Py_None;
+static int Texture_setOcts( BPy_Texture * self, PyObject * value )
+{
+ return EXPP_setFloatClamped ( value, &self->texture->mg_octaves,
+ 0.0, 8.0);
}
-static PyObject *Texture_setType( BPy_Texture * self, PyObject * args )
+static int Texture_setIScale( BPy_Texture * self, PyObject * value )
{
- char *type = NULL;
- if( !PyArg_ParseTuple( args, "s", &type ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
+ return EXPP_setFloatClamped ( value, &self->texture->ns_outscale,
+ 0.0, 10.0);
+}
- if( !EXPP_map_getShortVal( tex_type_map, type, &self->texture->type ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "invalid texture type" );
+static int Texture_setType( BPy_Texture * self, PyObject * value )
+{
+ int err = EXPP_setShortRange ( value, &self->texture->type,
+ EXPP_TEX_TYPE_MIN,
+ EXPP_TEX_TYPE_MAX );
- Py_INCREF( Py_None );
- return Py_None;
-}
+ /*
+ * if we set the texture OK, and it's a environment map, and
+ * there is no environment map yet, allocate one (code borrowed
+ * from texture_panel_envmap() in source/blender/src/buttons_shading.c)
+ */
+ if( !err && self->texture->type == EXPP_TEX_TYPE_ENVMAP
+ && !self->texture->env ) {
+ self->texture->env = RE_add_envmap();
+ self->texture->env->object= OBACT;
+ }
+ return err;
+}
-static PyObject *Texture_setHFrac( BPy_Texture * self, PyObject * args )
+static int Texture_setDistMetric( BPy_Texture * self, PyObject * value )
{
- float mg_H;
- if( !PyArg_ParseTuple( args, "f", &mg_H ) )
+#if 0
+ char *dist = NULL;
+
+ if( !PyArg_ParseTuple( value, "s", &dist ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a float" );
+ "expected string argument" );
- if( mg_H < 0 || mg_H > 2 )
+ /* can we really trust texture->type? */
+ if( self->texture->type == EXPP_TEX_TYPE_VORONOI &&
+ !EXPP_map_getShortVal( tex_stype_map[self->texture->type + 2],
+ dist, &self->texture->vn_distm ) )
return EXPP_ReturnPyObjError( PyExc_ValueError,
- "turbulence must be in range [0,2]" );
-
- self->texture->mg_H = mg_H;
+ "invalid dist metric type" );
Py_INCREF( Py_None );
return Py_None;
+#else
+ return EXPP_setShortRange ( value, &self->texture->vn_distm,
+ EXPP_TEX_STYPE_VN_TEX_DISTANCE,
+ EXPP_TEX_STYPE_VN_TEX_MINKOVSKY );
+#endif
}
-static PyObject *Texture_setLacunarity( BPy_Texture * self, PyObject * args )
+static int Texture_setExp( BPy_Texture * self, PyObject * value )
{
- float mg_lac;
- if( !PyArg_ParseTuple( args, "f", &mg_lac ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a float" );
+ return EXPP_setFloatClamped ( value, &self->texture->vn_mexp,
+ 0.010, 10.0);
+}
- if( mg_lac < 0 || mg_lac > 6 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "lacunarity must be in range [0,6]" );
+static int Texture_setWeight1( BPy_Texture * self, PyObject * value )
+{
+ return EXPP_setFloatClamped ( value, &self->texture->vn_w1,
+ -2.0, 2.0);
+}
- self->texture->mg_lacunarity = mg_lac;
+static int Texture_setWeight2( BPy_Texture * self, PyObject * value )
+{
+ return EXPP_setFloatClamped ( value, &self->texture->vn_w2,
+ -2.0, 2.0);
+}
- Py_INCREF( Py_None );
- return Py_None;
+static int Texture_setWeight3( BPy_Texture * self, PyObject * value )
+{
+ return EXPP_setFloatClamped ( value, &self->texture->vn_w3,
+ -2.0, 2.0);
}
-static PyObject *Texture_setOcts( BPy_Texture * self, PyObject * args )
+static int Texture_setWeight4( BPy_Texture * self, PyObject * value )
{
- float mg_oct;
- if( !PyArg_ParseTuple( args, "f", &mg_oct ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a float" );
+ return EXPP_setFloatClamped ( value, &self->texture->vn_w4,
+ -2.0, 2.0);
+}
- if( mg_oct < 0 || mg_oct > 8 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "turbulence must be in range [0,8]" );
+static int Texture_setDistAmnt( BPy_Texture * self, PyObject * value )
+{
+ return EXPP_setFloatClamped ( value, &self->texture->dist_amount,
+ 0.0, 10.0);
+}
- self->texture->mg_octaves = mg_oct;
+static PyObject *Texture_getIpo( BPy_Texture * self )
+{
+ struct Ipo *ipo = self->texture->ipo;
- Py_INCREF( Py_None );
- return Py_None;
+ if( !ipo ) {
+ Py_INCREF( Py_None );
+ return Py_None;
+ }
+
+ return Ipo_CreatePyObject( ipo );
}
-static PyObject *Texture_setiScale( BPy_Texture * self, PyObject * args )
+/*
+ * this should accept a Py_None argument and just delete the Ipo link
+ * (as Texture_clearIpo() does)
+ */
+
+static int Texture_setIpo( BPy_Texture * self, PyObject * value )
{
- float ns_osc;
- if( !PyArg_ParseTuple( args, "f", &ns_osc ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a float" );
+ Ipo *ipo = NULL;
+ Ipo *oldipo = self->texture->ipo;
+ ID *id;
- if( ns_osc < 0 || ns_osc > 10 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "turbulence must be in range [0,10]" );
+ /* if parameter is not None, check for valid Ipo */
- self->texture->ns_outscale = ns_osc;
+ if ( value != Py_None ) {
+ if ( !Ipo_CheckPyObject( value ) )
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "expected an Ipo object" );
- Py_INCREF( Py_None );
- return Py_None;
-}
+ ipo = Ipo_FromPyObject( value );
-static PyObject *Texture_setIntType( BPy_Texture * self, PyObject * args )
-{
- int type = 0;
- if( !PyArg_ParseTuple( args, "i", &type ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected int argument" );
+ if( !ipo )
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "null ipo!" );
- if( type < EXPP_TEX_TYPE_MIN || type > EXPP_TEX_TYPE_MAX )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "invalid type number" );
+ if( ipo->blocktype != ID_TE )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "Ipo is not a texture data Ipo" );
+ }
- self->texture->type = (short)type;
+ /* if already linked to Ipo, delete link */
- Py_INCREF( Py_None );
- return Py_None;
+ if ( oldipo ) {
+ id = &oldipo->id;
+ if( id->us > 0 )
+ id->us--;
+ }
+
+ /* assign new Ipo and increment user count, or set to NULL if deleting */
+
+ self->texture->ipo = ipo;
+ if ( ipo ) {
+ id = &ipo->id;
+ id->us++;
+ }
+
+ return 0;
}
-static PyObject *Texture_setDistMetric( BPy_Texture * self, PyObject * args )
+static PyObject *Texture_getAnimFrames( BPy_Texture *self )
{
- char *dist = NULL;
+ PyObject *attr = PyInt_FromLong( self->texture->frames );
- if( !PyArg_ParseTuple( args, "s", &dist ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected string argument" );
- /* can we really trust texture->type? */
- if( self->texture->type == EXPP_TEX_TYPE_VORONOI &&
- !EXPP_map_getShortVal( tex_stype_map[self->texture->type + 2],
- dist, &self->texture->vn_distm ) )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "invalid dist metric type" );
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
- Py_INCREF( Py_None );
- return Py_None;
+ return attr;
}
-static PyObject *Texture_setExp( BPy_Texture * self, PyObject * args )
+static PyObject *Texture_getAnimLength( BPy_Texture *self )
{
- float vn_mexp;
- if( !PyArg_ParseTuple( args, "f", &vn_mexp ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a float" );
-
- if( vn_mexp < 0 || vn_mexp > 10 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "Exp must be in range [0,10]" );
+ PyObject *attr = PyInt_FromLong( self->texture->len );
- self->texture->vn_mexp = vn_mexp;
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );return attr;
- Py_INCREF( Py_None );
- return Py_None;
+ return attr;
}
-static PyObject *Texture_setW1( BPy_Texture * self, PyObject * args )
+static PyObject *Texture_getAnimMontage( BPy_Texture *self )
{
- float vn_w1;
- if( !PyArg_ParseTuple( args, "f", &vn_w1 ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a float" );
-
- if( vn_w1 < -2 || vn_w1 > 2 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "Exp must be in range [0,10]" );
+ PyObject *attr;
+
+ attr = Py_BuildValue( "((i,i),(i,i),(i,i),(i,i))",
+ self->texture->fradur[0][0],
+ self->texture->fradur[0][1],
+ self->texture->fradur[1][0],
+ self->texture->fradur[1][1],
+ self->texture->fradur[2][0],
+ self->texture->fradur[2][1],
+ self->texture->fradur[3][0],
+ self->texture->fradur[3][1] );
- self->texture->vn_w1 = vn_w1;
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
- Py_INCREF( Py_None );
- return Py_None;
+ return attr;
}
-static PyObject *Texture_setW2( BPy_Texture * self, PyObject * args )
+static PyObject *Texture_getAnimOffset( BPy_Texture *self )
{
- float vn_w2;
- if( !PyArg_ParseTuple( args, "f", &vn_w2 ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a float" );
-
- if( vn_w2 < -2 || vn_w2 > 2 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "Exp must be in range [0,10]" );
+ PyObject *attr = PyInt_FromLong( self->texture->offset );
- self->texture->vn_w2 = vn_w2;
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
- Py_INCREF( Py_None );
- return Py_None;
+ return attr;
}
-static PyObject *Texture_setW3( BPy_Texture * self, PyObject * args )
+static PyObject *Texture_getAnimStart( BPy_Texture *self )
{
- float vn_w3;
- if( !PyArg_ParseTuple( args, "f", &vn_w3 ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a float" );
-
- if( vn_w3 < -2 || vn_w3 > 2 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "Exp must be in range [0,10]" );
+ PyObject *attr = PyInt_FromLong( self->texture->sfra );
- self->texture->vn_w3 = vn_w3;
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
- Py_INCREF( Py_None );
- return Py_None;
+ return attr;
}
-static PyObject *Texture_setW4( BPy_Texture * self, PyObject * args )
+static PyObject *Texture_getBrightness( BPy_Texture *self )
{
- float vn_w4;
- if( !PyArg_ParseTuple( args, "f", &vn_w4 ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a float" );
-
- if( vn_w4 < -2 || vn_w4 > 2 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "Exp must be in range [0,10]" );
+ PyObject *attr = PyFloat_FromDouble ( self->texture->bright );
- self->texture->vn_w4 = vn_w4;
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
- Py_INCREF( Py_None );
- return Py_None;
+ return attr;
}
-static PyObject *Texture_setDistAmnt( BPy_Texture * self, PyObject * args )
+static PyObject *Texture_getContrast( BPy_Texture *self )
{
- float dist_amount;
- if( !PyArg_ParseTuple( args, "f", &dist_amount ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a float" );
-
- if( dist_amount < 0 || dist_amount > 10 )
- return EXPP_ReturnPyObjError( PyExc_ValueError,
- "Exp must be in range [0,10]" );
+ PyObject *attr = PyFloat_FromDouble( self->texture->contrast );
- self->texture->dist_amount = dist_amount;
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
- Py_INCREF( Py_None );
- return Py_None;
+ return attr;
}
-static void Texture_dealloc( BPy_Texture * self )
+static PyObject *Texture_getCrop( BPy_Texture *self )
{
- PyObject_DEL( self );
+ PyObject *attr;
+
+ attr = Py_BuildValue( "(f,f,f,f)",
+ self->texture->cropxmin,
+ self->texture->cropymin,
+ self->texture->cropxmax,
+ self->texture->cropymax );
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
}
-static PyObject *Texture_getAttr( BPy_Texture * self, char *name )
+static PyObject *Texture_getDistAmnt( BPy_Texture *self )
{
- PyObject *attr = Py_None;
- Tex *tex = self->texture;
-
- if( STREQ( name, "animFrames" ) )
- attr = PyInt_FromLong( tex->frames );
- else if( STREQ( name, "animLength" ) )
- attr = PyInt_FromLong( tex->len );
- else if( STREQ( name, "animMontage" ) )
- attr = Py_BuildValue( "((i,i),(i,i),(i,i),(i,i))",
- tex->fradur[0][0], tex->fradur[0][1],
- tex->fradur[1][0], tex->fradur[1][1],
- tex->fradur[2][0], tex->fradur[2][1],
- tex->fradur[3][0], tex->fradur[3][1] );
- else if( STREQ( name, "animOffset" ) )
- attr = PyInt_FromLong( tex->offset );
- else if( STREQ( name, "animStart" ) )
- attr = PyInt_FromLong( tex->sfra );
- else if( STREQ( name, "brightness" ) )
- attr = PyFloat_FromDouble( tex->bright );
- else if( STREQ( name, "contrast" ) )
- attr = PyFloat_FromDouble( tex->contrast );
- else if( STREQ( name, "crop" ) )
- attr = Py_BuildValue( "(f,f,f,f)", tex->cropxmin,
- tex->cropymin, tex->cropxmax,
- tex->cropymax );
- else if( STREQ( name, "extend" ) )
- attr = PyInt_FromLong( tex->extend );
- else if( STREQ( name, "fieldsPerImage" ) )
- attr = PyInt_FromLong( tex->fie_ima );
- else if( STREQ( name, "filterSize" ) )
- attr = PyFloat_FromDouble( tex->filtersize );
- else if( STREQ( name, "flags" ) )
- attr = PyInt_FromLong( tex->flag );
- else if( STREQ( name, "image" ) )
- attr = Texture_getImage( self );
- else if( STREQ( name, "imageFlags" ) )
- attr = PyInt_FromLong( tex->imaflag );
- else if( STREQ( name, "name" ) )
- attr = PyString_FromString( tex->id.name + 2 );
- else if( STREQ( name, "noiseDepth" ) )
- attr = PyInt_FromLong( tex->noisedepth );
- else if( STREQ( name, "noiseSize" ) )
- attr = PyFloat_FromDouble( tex->noisesize );
- else if( STREQ( name, "noiseType" ) ) {
- if( tex->noisetype == TEX_NOISESOFT )
- attr = PyString_FromString( "soft" );
- else
- attr = PyString_FromString( "hard" );
- } else if( STREQ( name, "repeat" ) )
- attr = Py_BuildValue( "(i,i)", tex->xrepeat, tex->yrepeat );
- else if( STREQ( name, "rgbCol" ) )
- attr = Py_BuildValue( "(f,f,f)", tex->rfac, tex->gfac,
- tex->gfac );
- else if( STREQ( name, "stype" ) )
- if( self->texture->type == EXPP_TEX_TYPE_ENVMAP )
- attr = PyInt_FromLong( tex->env->stype );
- else
- attr = PyInt_FromLong( tex->stype );
- else if( STREQ( name, "turbulence" ) )
- attr = PyFloat_FromDouble( tex->turbul );
- else if( STREQ( name, "type" ) )
- attr = PyInt_FromLong( tex->type );
- else if( STREQ( name, "hFracDim" ) )
- attr = PyInt_FromLong( (long)tex->mg_H );
- else if( STREQ( name, "lacunarity" ) )
- attr = PyFloat_FromDouble( tex->mg_lacunarity );
- else if( STREQ( name, "octs" ) )
- attr = PyFloat_FromDouble( tex->mg_octaves );
- else if( STREQ( name, "iSacale" ) )
- attr = PyFloat_FromDouble( tex->ns_outscale );
- else if( STREQ( name, "exp" ) )
- attr = PyFloat_FromDouble( tex->vn_mexp );
- else if( STREQ( name, "weight1" ) )
- attr = PyFloat_FromDouble( tex->vn_w1 );
- else if( STREQ( name, "weight2" ) )
- attr = PyFloat_FromDouble( tex->vn_w2 );
- else if( STREQ( name, "weight3" ) )
- attr = PyFloat_FromDouble( tex->vn_w3 );
- else if( STREQ( name, "weight4" ) )
- attr = PyFloat_FromDouble( tex->vn_w4 );
- else if( STREQ( name, "distAmnt" ) )
- attr = PyFloat_FromDouble( tex->vn_w4 );
- else if( STREQ( name, "users" ) )
- 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]",
- "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" );
+ PyObject *attr = PyFloat_FromDouble( self->texture->dist_amount );
if( !attr )
- return EXPP_ReturnPyObjError( PyExc_MemoryError,
- "couldn't create PyObject" );
-
- if( attr != Py_None )
- return attr; /* member attribute found, return it */
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
- /* not an attribute, search the methods table */
- return Py_FindMethod( BPy_Texture_methods, ( PyObject * ) self, name );
+ return attr;
}
+static PyObject *Texture_getDistMetric( BPy_Texture *self )
+{
+ PyObject *attr = PyInt_FromLong( self->texture->vn_distm );
-static int Texture_setAttr( BPy_Texture * 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,
- "Texture_setAttr: couldn't create PyTuple" );
-
- if( STREQ( name, "animFrames" ) )
- error = Texture_setAnimFrames( self, valtuple );
- else if( STREQ( name, "animLength" ) )
- error = Texture_setAnimLength( self, valtuple );
- else if( STREQ( name, "animMontage" ) )
- error = Texture_setAnimMontage( self, valtuple );
- else if( STREQ( name, "animOffset" ) )
- error = Texture_setAnimOffset( self, valtuple );
- else if( STREQ( name, "animStart" ) )
- error = Texture_setAnimStart( self, valtuple );
- else if( STREQ( name, "brightness" ) )
- error = Texture_setBrightness( self, valtuple );
- else if( STREQ( name, "contrast" ) )
- error = Texture_setContrast( self, valtuple );
- else if( STREQ( name, "crop" ) )
- error = Texture_setCrop( self, valtuple );
- else if( STREQ( name, "extend" ) )
- error = Texture_setIntExtend( self, valtuple );
- else if( STREQ( name, "fieldsPerImage" ) )
- error = Texture_setFieldsPerImage( self, valtuple );
- else if( STREQ( name, "filterSize" ) )
- error = Texture_setFilterSize( self, valtuple );
- else if( STREQ( name, "flags" ) )
- error = Texture_setIntFlags( self, valtuple );
- else if( STREQ( name, "image" ) )
- error = Texture_setImage( self, valtuple );
- else if( STREQ( name, "imageFlags" ) )
- error = Texture_setIntImageFlags( self, valtuple );
- else if( STREQ( name, "name" ) )
- error = Texture_setName( self, valtuple );
- else if( STREQ( name, "noiseDepth" ) )
- error = Texture_setNoiseDepth( self, valtuple );
- else if( STREQ( name, "noiseSize" ) )
- error = Texture_setNoiseSize( self, valtuple );
- else if( STREQ( name, "noiseType" ) )
- error = Texture_setNoiseType( self, valtuple );
- else if( STREQ( name, "repeat" ) )
- error = Texture_setRepeat( self, valtuple );
- else if( STREQ( name, "rgbCol" ) )
- error = Texture_setRGBCol( self, valtuple );
- else if( STREQ( name, "stype" ) )
- error = Texture_setIntSType( self, valtuple );
- else if( STREQ( name, "turbulence" ) )
- error = Texture_setTurbulence( self, valtuple );
- else if( STREQ( name, "type" ) )
- error = Texture_setIntType( self, valtuple );
- else if( STREQ( name, "hFracDim" ) )
- error = Texture_setHFrac( self, valtuple );
- else if( STREQ( name, "lacunarity" ) )
- error = Texture_setLacunarity( self, valtuple );
- else if( STREQ( name, "octs" ) )
- error = Texture_setOcts( self, valtuple );
- else if( STREQ( name, "iScale" ) )
- error = Texture_setiScale( self, valtuple );
- else if( STREQ( name, "exp" ) )
- error = Texture_setExp( self, valtuple );
- else if( STREQ( name, "weight1" ) )
- error = Texture_setW1( self, valtuple );
- else if( STREQ( name, "weight2" ) )
- error = Texture_setW2( self, valtuple );
- else if( STREQ( name, "weight3" ) )
- error = Texture_setW3( self, valtuple );
- else if( STREQ( name, "weight4" ) )
- error = Texture_setW4( self, valtuple );
- else if( STREQ( name, "distAmnt" ) )
- error = Texture_setDistAmnt( self, valtuple );
-
-
- else {
- /* Error */
- Py_DECREF( valtuple );
- return EXPP_ReturnIntError( PyExc_KeyError,
- "attribute not found" );
- }
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
- Py_DECREF( valtuple );
+ return attr;
+}
- if( error != Py_None )
- return -1;
+static PyObject *Texture_getExp( BPy_Texture *self )
+{
+ PyObject *attr = PyFloat_FromDouble( self->texture->vn_mexp );
- /* Py_None was INCREF'd by the set*() function, so we need to DECREF it */
- Py_DECREF( Py_None );
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
- return 0;
+ return attr;
}
-static int Texture_compare( BPy_Texture * a, BPy_Texture * b )
+static PyObject *Texture_getIntExtend( BPy_Texture * self )
{
- return ( a->texture == b->texture ) ? 0 : -1;
+ PyObject *attr = PyInt_FromLong( self->texture->extend );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
}
-static PyObject *Texture_repr( BPy_Texture * self )
+static PyObject *Texture_getFieldsPerImage( BPy_Texture *self )
{
- return PyString_FromFormat( "[Texture \"%s\"]",
- self->texture->id.name + 2 );
+ PyObject *attr = PyInt_FromLong( self->texture->fie_ima );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
}
-static PyObject *Texture_getIpo( BPy_Texture * self )
+static PyObject *Texture_getFilterSize( BPy_Texture *self )
{
- struct Ipo *ipo = self->texture->ipo;
+ PyObject *attr = PyFloat_FromDouble( self->texture->filtersize );
- if( !ipo ) {
- Py_INCREF( Py_None );
- return Py_None;
- }
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
- return Ipo_CreatePyObject( ipo );
+ return attr;
}
-extern PyTypeObject Ipo_Type;
-
-static PyObject *Texture_setIpo( BPy_Texture * self, PyObject * args )
+static PyObject *Texture_getFlags( BPy_Texture *self )
{
- PyObject *pyipo = 0;
- Ipo *ipo = NULL;
- Ipo *oldipo;
+ PyObject *attr = PyInt_FromLong( self->texture->flag );
- if( !PyArg_ParseTuple( args, "O!", &Ipo_Type, &pyipo ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected Ipo as argument" );
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
+}
- ipo = Ipo_FromPyObject( pyipo );
+static PyObject *Texture_getHFracDim( BPy_Texture *self )
+{
+ PyObject *attr = PyInt_FromLong( self->texture->mg_H );
- if( !ipo )
+ if( !attr )
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
- "null ipo!" );
+ "couldn't get attribute" );
- if( ipo->blocktype != ID_TE )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "this ipo is not a texture data ipo" );
+ return attr;
+}
- oldipo = self->texture->ipo;
- if( oldipo ) {
- ID *id = &oldipo->id;
- if( id->us > 0 )
- id->us--;
- }
+static PyObject *Texture_getImageFlags( BPy_Texture *self, int type )
+{
+ PyObject *attr;
- ( ( ID * ) & ipo->id )->us++;
+ /*
+ * type == 0 means attribute "imageFlags"
+ * other types means attribute "mipmap", "calcAlpha", etc
+ */
- self->texture->ipo = ipo;
+ if( type )
+ attr = EXPP_getBitfield( &self->texture->imaflag, type, 'h' );
+ else
+ attr = PyInt_FromLong( self->texture->imaflag );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
+}
+
+static PyObject *Texture_getIScale( BPy_Texture *self )
+{
+ PyObject *attr = PyFloat_FromDouble( self->texture->ns_outscale );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
+}
+
+static PyObject *Texture_getLacunarity( BPy_Texture *self )
+{
+ PyObject *attr = PyFloat_FromDouble( self->texture->mg_lacunarity );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
+}
+
+static PyObject *Texture_getNoiseBasis( BPy_Texture *self )
+{
+ PyObject *attr = PyInt_FromLong( self->texture->noisebasis );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
+}
+
+static PyObject *Texture_getNoiseBasis2( BPy_Texture *self, int type )
+{
+ PyObject *attr;
+
+ /*
+ * type == EXPP_TEX_NOISEBASIS2 means attribute "noiseBasis2"
+ * other types means attribute "sine", "saw", or "tri" attribute
+ */
+
+ if( type == EXPP_TEX_NOISEBASIS2 )
+ attr = PyInt_FromLong( self->texture->noisebasis2 );
+ else
+ attr = PyInt_FromLong( ( self->texture->noisebasis2 == type ) ? 1 : 0 );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
+}
+
+static PyObject *Texture_getNoiseDepth( BPy_Texture *self )
+{
+ PyObject *attr = PyInt_FromLong( self->texture->noisedepth );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
+}
+
+static PyObject *Texture_getNoiseSize( BPy_Texture *self )
+{
+ PyObject *attr = PyFloat_FromDouble( self->texture->noisesize );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
+}
+
+static PyObject *Texture_getNoiseType( BPy_Texture *self )
+{
+ PyObject *attr;
+
+ if ( self->texture->noisetype == TEX_NOISESOFT )
+ attr = PyString_FromString( "soft" );
+ else
+ attr = PyString_FromString( "hard" );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
+}
+
+static PyObject *Texture_getOcts( BPy_Texture *self )
+{
+ PyObject *attr = PyFloat_FromDouble( self->texture->mg_octaves );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
+}
+
+static PyObject *Texture_getRepeat( BPy_Texture *self )
+{
+ PyObject *attr;
+
+ attr = Py_BuildValue( "(i,i)", self->texture->xrepeat,
+ self->texture->yrepeat );
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
+}
+
+static PyObject *Texture_getRGBCol( BPy_Texture *self )
+{
+ PyObject *attr;
+
+ attr = Py_BuildValue( "(f,f,f)", self->texture->rfac,
+ self->texture->gfac, self->texture->bfac );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
+}
+
+static PyObject *Texture_getSType( BPy_Texture *self )
+{
+ PyObject *attr;
+
+ if( self->texture->type == EXPP_TEX_TYPE_VORONOI )
+ attr = PyInt_FromLong( self->texture->vn_coltype );
+#if 0
+ else if( self->texture->type == EXPP_TEX_TYPE_MUSGRAVE )
+ attr = PyInt_FromLong( self->texture->noisebasis );
+#endif
+ else if( self->texture->type == EXPP_TEX_TYPE_ENVMAP )
+ attr = PyInt_FromLong( self->texture->env->stype );
+ else
+ attr = PyInt_FromLong( self->texture->stype );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
+}
+
+static PyObject *Texture_getTurbulence( BPy_Texture *self )
+{
+ PyObject *attr = PyFloat_FromDouble( self->texture->turbul );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
+}
+
+static PyObject *Texture_getType( BPy_Texture *self )
+{
+ PyObject *attr = PyInt_FromLong( self->texture->type );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
+}
+
+static PyObject *Texture_getUsers( BPy_Texture *self )
+{
+ PyObject *attr = PyInt_FromLong( self->texture->id.us );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
+}
+
+static PyObject *Texture_getWeight1( BPy_Texture *self )
+{
+ PyObject *attr = PyFloat_FromDouble( self->texture->vn_w1 );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
+}
+
+static PyObject *Texture_getWeight2( BPy_Texture *self )
+{
+ PyObject *attr = PyFloat_FromDouble( self->texture->vn_w2 );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
+}
+
+static PyObject *Texture_getWeight3( BPy_Texture *self )
+{
+ PyObject *attr = PyFloat_FromDouble( self->texture->vn_w3 );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
+}
+
+static PyObject *Texture_getWeight4( BPy_Texture *self )
+{
+ PyObject *attr = PyFloat_FromDouble( self->texture->vn_w4 );
+
+ if( !attr )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't get attribute" );
+
+ return attr;
+}
+
+/* #####DEPRECATED###### */
+
+static PyObject *Texture_oldsetImage( BPy_Texture * self, PyObject * args )
+{
+ return EXPP_setterWrapper( (void *)self, args,
+ (void *)Texture_setImage );
+}
+
+static PyObject *Texture_oldsetName( BPy_Texture * self, PyObject * args )
+{
+ return EXPP_setterWrapper( (void *)self, args,
+ (void *)Texture_setName );
+}
+
+static PyObject *Texture_oldsetIpo( BPy_Texture * self, PyObject * args )
+{
+ return EXPP_setterWrapper ( (void *)self, args, (void *)Texture_setIpo );
+}
+
+/*
+ * clearIpo() returns True/False depending on whether material has an Ipo
+ */
+
+static PyObject *Texture_clearIpo( BPy_Texture * self )
+{
+ /* if Ipo defined, delete it and return true */
+
+ if( self->texture->ipo ) {
+ PyObject *value = Py_BuildValue( "(O)", Py_None );
+ EXPP_setterWrapper( (void *)self, value, (void *)Texture_setIpo );
+ Py_DECREF( value );
+ return EXPP_incr_ret_True();
+ }
+ return EXPP_incr_ret_False(); /* no ipo found */
+}
+
+/*
+ * these older setter methods take strings as parameters; check the list of
+ * strings to figure out which bits to set, then call new attribute setters
+ * using the wrapper.
+ */
+
+static PyObject *Texture_oldsetFlags( BPy_Texture * self, PyObject * args )
+{
+ unsigned int i, flag = 0;
+ PyObject *value, *error;
+
+ /* check that we're passed a tuple */
+
+ if ( !PyTuple_Check( args ) )
+ return EXPP_ReturnPyObjError ( PyExc_AttributeError,
+ "expected a tuple of string arguments" );
+
+ /* check each argument for type, find its value */
+
+ for ( i = PyTuple_Size( args ); i-- ; ) {
+ short thisflag;
+ char * name = PyString_AsString( PySequence_Fast_GET_ITEM( args, i ) );
+ if( !name )
+ return EXPP_ReturnPyObjError ( PyExc_AttributeError,
+ "expected string argument" );
+
+ if( !EXPP_map_getShortVal( tex_flag_map, name, &thisflag ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "unknown Texture flag argument" ) );
+
+ flag |= thisflag;
+ }
+
+ /* build tuple, call wrapper */
+
+ value = Py_BuildValue( "(i)", flag );
+ error = EXPP_setterWrapper( (void *)self, value, (void *)Texture_setFlags );
+ Py_DECREF ( value );
+ return error;
+}
+
+/*
+ * Texture_oldsetType() and Texture_oldsetExtend()
+ *
+ * These older setter methods convert a string into an integer setting, so
+ * doesn't make sense to try wrapping them.
+ */
+
+static PyObject *Texture_oldsetType( BPy_Texture * self, PyObject * args )
+{
+ char *type = NULL;
+
+ if( !PyArg_ParseTuple( args, "s", &type ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
+
+ if( !EXPP_map_getShortVal( tex_type_map, type, &self->texture->type ) )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "invalid texture type" );
+
+ /*
+ * if we set the texture OK, and it's a environment map, and
+ * there is no environment map yet, allocate one (code borrowed
+ * from texture_panel_envmap() in source/blender/src/buttons_shading.c)
+ */
+
+ if( self->texture->type == EXPP_TEX_TYPE_ENVMAP
+ && !self->texture->env ) {
+ self->texture->env = RE_add_envmap();
+ self->texture->env->object= OBACT;
+ }
Py_INCREF( Py_None );
return Py_None;
}
-static PyObject *Texture_clearIpo( BPy_Texture * self )
+static PyObject *Texture_oldsetExtend( BPy_Texture * self, PyObject * args )
{
- Tex *tex = self->texture;
- Ipo *ipo = ( Ipo * ) tex->ipo;
+ char *extend = NULL;
+ if( !PyArg_ParseTuple( args, "s", &extend ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
- if( ipo ) {
- ID *id = &ipo->id;
- if( id->us > 0 )
- id->us--;
- tex->ipo = NULL;
+ if( !EXPP_map_getShortVal
+ ( tex_extend_map, extend, &self->texture->extend ) )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "invalid extend mode" );
- return EXPP_incr_ret_True();
+ Py_INCREF( Py_None );
+ return Py_None;
+}
+
+/*
+ * Texture_oldsetNoiseBasis(), Texture_oldsetDistNoise()
+ * Texture_oldsetSType(), Texture_oldsetDistMetric(),
+ * Texture_oldsetImageFlags()
+ *
+ * these old setter methods behave differently from the attribute
+ * setters, so they are left unchanged.
+ */
+
+static PyObject *Texture_oldsetNoiseBasis( BPy_Texture * self, PyObject * args )
+{
+/* NOTE: leave as-is: don't use setterWrapper */
+ char *nbasis;
+
+ if( !PyArg_ParseTuple( args, "s", &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" );
+
+ Py_INCREF( Py_None );
+ return Py_None;
+}
+
+static PyObject *Texture_oldsetDistNoise( BPy_Texture * self, PyObject * args )
+{
+/* NOTE: leave as-is: don't use setterWrapper */
+ char *nbasis;
+
+ if( !PyArg_ParseTuple( args, "s", &nbasis ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
+ if( self->texture->type == EXPP_TEX_TYPE_DISTNOISE &&
+ !EXPP_map_getShortVal( tex_stype_map[EXPP_TEX_TYPE_DISTNOISE],
+ nbasis, &self->texture->noisebasis ) )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "invalid noise basis" );
+
+ Py_INCREF( Py_None );
+ return Py_None;
+}
+
+static PyObject *Texture_oldsetSType( BPy_Texture * self, PyObject * args )
+{
+ char *stype = NULL;
+ if( !PyArg_ParseTuple( args, "s", &stype ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
+
+ /* can we really trust texture->type? */
+ if( ( self->texture->type == EXPP_TEX_TYPE_VORONOI &&
+ EXPP_map_getShortVal( tex_stype_map[self->texture->type],
+ stype, &self->texture->vn_coltype ) ) );
+#if 0
+ else if( ( self->texture->type == EXPP_TEX_TYPE_MUSGRAVE &&
+ EXPP_map_getShortVal( tex_stype_map
+ [EXPP_TEX_TYPE_DISTNOISE], stype,
+ &self->texture->noisebasis ) ) );
+#endif
+ else if( ( self->texture->type == EXPP_TEX_TYPE_ENVMAP &&
+ EXPP_map_getShortVal( tex_stype_map[self->texture->type],
+ stype, &self->texture->env->stype ) ) );
+ else if( !EXPP_map_getShortVal
+ ( tex_stype_map[self->texture->type], stype,
+ &self->texture->stype ) )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "invalid texture stype" );
+
+ Py_INCREF( Py_None );
+ return Py_None;
+}
+
+static PyObject *Texture_oldsetDistMetric( BPy_Texture * self, PyObject * args )
+{
+/* NOTE: leave as-is: don't use setterWrapper */
+ char *dist = NULL;
+
+ if( !PyArg_ParseTuple( args, "s", &dist ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string argument" );
+ /* can we really trust texture->type? */
+ if( self->texture->type == EXPP_TEX_TYPE_VORONOI &&
+ !EXPP_map_getShortVal( tex_stype_map[self->texture->type + 2],
+ dist, &self->texture->vn_distm ) )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "invalid dist metric type" );
+
+ Py_INCREF( Py_None );
+ return Py_None;
+}
+
+static PyObject *Texture_oldsetImageFlags( BPy_Texture * self, PyObject * args )
+{
+ unsigned int i, flag = 0;
+ PyObject *value, *error;
+
+ /* check that we're passed a tuple of no more than 3 args*/
+
+ if( !PyTuple_Check( args ) )
+ return EXPP_ReturnPyObjError ( PyExc_AttributeError,
+ "expected tuple of string arguments" );
+
+ /* check each argument for type, find its value */
+
+ for( i = PyTuple_Size( args ); i-- ; ) {
+ short thisflag;
+ char * name = PyString_AsString( PySequence_Fast_GET_ITEM( args, i ) );
+ if( !name )
+ return EXPP_ReturnPyObjError ( PyExc_AttributeError,
+ "expected string argument" );
+
+ if( !EXPP_map_getShortVal( tex_imageflag_map, name, &thisflag ) )
+ return EXPP_ReturnPyObjError( PyExc_ValueError,
+ "unknown Texture image flag name" );
+
+ flag |= thisflag;
}
- return EXPP_incr_ret_False(); /* no ipo found */
+ self->texture->imaflag = flag;
+
+ Py_INCREF( Py_None );
+ return Py_None;
}
+
Index: source/blender/python/api2_2x/gen_utils.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/gen_utils.c,v
retrieving revision 1.33
diff -u -r1.33 gen_utils.c
--- source/blender/python/api2_2x/gen_utils.c 17 Aug 2005 14:26:00 -0000 1.33
+++ source/blender/python/api2_2x/gen_utils.c 23 Aug 2005 05:03:23 -0000
@@ -39,6 +39,8 @@
#include "BKE_global.h"
#include "BKE_main.h"
+#include "constant.h"
+
//---------------------- EXPP_GetModuleConstant -------------------------
//Helper function for returning a module constant
PyObject *EXPP_GetModuleConstant(char *module, char *constant)
@@ -588,3 +590,317 @@
return EXPP_incr_ret (Py_None); /* normal exit */
}
+
+/*
+ * Utility routines to clamp and store various datatypes. The object type
+ * is checked and a exception is raised if it's not the correct type.
+ *
+ * Inputs:
+ * value: PyObject containing the new value
+ * param: pointer to destination variable
+ * max, min: range of values for clamping
+ *
+ * Return 0 on success, -1 on error.
+ */
+
+int EXPP_setCharClamped ( PyObject *value, char *param,
+ short min, short max )
+{
+ /* if value not of correct type, raise Type exception */
+
+ if( !PyInt_CheckExact( value ) ) {
+ char errstr[128];
+ sprintf ( errstr, "expected char argument in [%d,%d]", min, max );
+ return EXPP_ReturnIntError( PyExc_TypeError, errstr );
+ }
+
+ /* clamp and store value */
+
+ *param = EXPP_ClampInt( PyInt_AS_LONG ( value ), min, max );
+ return 0;
+}
+
+int EXPP_setShortClamped ( PyObject *value, short *param,
+ short min, short max )
+{
+ if( !PyInt_CheckExact ( value ) ) {
+ char errstr[128];
+ sprintf ( errstr, "expected int argument in [%d,%d]", min, max );
+ return EXPP_ReturnIntError( PyExc_TypeError, errstr );
+ }
+
+ *param = EXPP_ClampInt( PyInt_AS_LONG ( value ), min, max );
+
+ return 0;
+}
+
+int EXPP_setIntClamped ( PyObject *value, int *param,
+ int min, int max )
+{
+ if( !PyInt_CheckExact ( value ) ) {
+ char errstr[128];
+ sprintf ( errstr, "expected int argument in [%d,%d]", min, max );
+ return EXPP_ReturnIntError( PyExc_TypeError, errstr );
+ }
+
+ *param = EXPP_ClampInt( PyInt_AS_LONG ( value ), min, max );
+
+ return 0;
+}
+
+int EXPP_setFloatClamped ( PyObject *value, float *param,
+ float min, float max )
+{
+ if( !PyFloat_CheckExact ( value ) ) {
+ char errstr[128];
+ sprintf ( errstr, "expected float argument in [%f,%f]", min, max );
+ return EXPP_ReturnIntError( PyExc_TypeError, errstr );
+ }
+
+ *param = EXPP_ClampFloat( PyFloat_AS_DOUBLE( value ), min, max );
+
+ return 0;
+}
+
+/*
+ * Utility routines to range-check and store various datatypes. The object
+ * type is checked and a exception is raised if it's not the correct type.
+ * An exception is also raised if the value lies outside of the specified
+ * range.
+ *
+ * Inputs:
+ * value: PyObject containing the new value
+ * param: pointer to destination variable
+ * max, min: valid range for value
+ *
+ * Return 0 on success, -1 on error.
+ */
+
+int EXPP_setCharRange ( PyObject *value, char *param,
+ short min, short max )
+{
+ char errstr[128];
+ short number;
+
+ /* build exception error string */
+
+ sprintf ( errstr, "expected int argument in [%d,%d]", min, max );
+
+ /* if value not of correct type, raise Type exception */
+
+ if( !PyInt_CheckExact ( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError, errstr );
+
+ /* if value out of range, raise Value exception */
+
+ number = PyInt_AS_LONG ( value );
+ if ( number < min || number > max )
+ return EXPP_ReturnIntError( PyExc_ValueError, errstr );
+
+ /* store value */
+
+ *param = number;
+ return 0;
+}
+
+int EXPP_setShortRange ( PyObject *value, short *param,
+ short min, short max )
+{
+ char errstr[128];
+ short number;
+
+ sprintf ( errstr, "expected int argument in [%d,%d]", min, max );
+
+ if( !PyInt_CheckExact ( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError, errstr );
+
+ number = PyInt_AS_LONG ( value );
+ if ( number < min || number > max )
+ return EXPP_ReturnIntError( PyExc_ValueError, errstr );
+
+ *param = number;
+ return 0;
+}
+
+int EXPP_setIntRange ( PyObject *value, int *param,
+ int min, int max )
+{
+ char errstr[128];
+ int number;
+
+ sprintf ( errstr, "expected int argument in [%d,%d]", min, max );
+
+ if( !PyInt_CheckExact ( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError, errstr );
+
+ number = PyInt_AS_LONG ( value );
+ if ( number < min || number > max )
+ return EXPP_ReturnIntError( PyExc_ValueError, errstr );
+
+ *param = number;
+ return 0;
+}
+
+int EXPP_setFloatRange ( PyObject *value, float *param,
+ float min, float max )
+{
+ char errstr[128];
+ short number;
+
+ sprintf ( errstr, "expected int argument in [%f,%f]", min, max );
+
+ if( !PyFloat_CheckExact ( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError, errstr );
+
+ number = PyFloat_AS_DOUBLE( value );
+ if ( number < min || number > max )
+ return EXPP_ReturnIntError( PyExc_ValueError, errstr );
+
+ *param = number;
+ return 0;
+}
+
+/*
+ * Utility routines to handle all attribute setters which use module
+ * constants. Generic pointer to destination variable is used, and typecast
+ * to the appropriate type based on the "type" specifier.
+ *
+ * Inputs:
+ * constant: constant_Type value
+ * param: pointer to destination variable
+ * type: kind of pointer and data
+ *
+ * Return 0 on success, -1 on error.
+ */
+
+int EXPP_setModuleConstant ( BPy_constant *constant, void *param, char type )
+{
+ PyObject *item;
+
+ if( constant->ob_type != &constant_Type )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected module constant" );
+
+ item = PyDict_GetItemString( constant->dict, "value" );
+ if( !item )
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "module constant has no \"value\" key" );
+
+ switch ( type ) {
+ case 'h':
+ *(short *)param = PyInt_AS_LONG( item );
+ return 0;
+ case 'i':
+ *(int *)param = PyInt_AS_LONG( item );
+ return 0;
+ case 'f':
+ *(float *)param = PyFloat_AS_DOUBLE( item );
+ return 0;
+ default:
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "EXPP_setModuleConstant(): invalid type code" );
+ }
+}
+
+/*
+ * Utility routines to get/set bits in bitfields. Adapted from code in
+ * sceneRender.c (thanks, ascotan!).
+ *
+ * Inputs:
+ * param: pointer to source/destination variable
+ * setting: the bit to get/set
+ * type: pointer type ('h' == short, 'i' == integer)
+ */
+
+PyObject *EXPP_getBitfield( void *param, int setting, char type )
+{
+ switch ( type ) {
+ case 'h':
+ return (*(short *)param & setting)
+ ? EXPP_incr_ret_True() : EXPP_incr_ret_False();
+ case 'i':
+ return (*(int *)param & setting)
+ ? EXPP_incr_ret_True() : EXPP_incr_ret_False();
+ default:
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "EXPP_getBit(): invalid type code" );
+ }
+}
+
+int EXPP_setBitfield( PyObject * value, void *param, int setting, char type )
+{
+ int flag;
+ char errstr[] = "expected TRUE or FALSE (1 or 0)";
+
+ if( !PyInt_CheckExact ( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError, errstr );
+
+ flag = PyInt_AS_LONG ( value );
+ if( flag != 0 && flag != 1 )
+ return EXPP_ReturnIntError( PyExc_ValueError, errstr );
+
+ switch ( type ) {
+ case 'h':
+ if ( flag )
+ *(short *)param |= setting;
+ else
+ *(short *)param &= ~setting;
+ return 0;
+ case 'i':
+ if ( flag )
+ *(int *)param |= setting;
+ else
+ *(int *)param &= ~setting;
+ return 0;
+ default:
+ return EXPP_ReturnIntError( PyExc_RuntimeError,
+ "EXPP_setBit(): invalid type code" );
+ }
+}
+
+/*
+ * Procedure to handle older setStuff() methods. Assumes that argument
+ * is a tuple with one object, and so grabs the object and passes it to
+ * the specified tp_getset setter for the corresponding attribute.
+ */
+
+PyObject *EXPP_setterWrapper ( PyObject * self, PyObject * args,
+ int (*func)( PyObject * self, PyObject * args ))
+{
+ int error;
+
+ if ( !PyTuple_Check( args ) || PyTuple_Size( args ) != 1 )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "expected tuple of one item" );
+
+ error = func ( self, PySequence_Fast_GET_ITEM( args, 0 ) );
+ if ( !error ) {
+ Py_INCREF( Py_None );
+ return Py_None;
+ } else
+ return NULL;
+}
+
+/*
+ * Procedure to handle older setStuff() methods. Assumes that argument
+ * is a tuple, so just passes it to the specified tp_getset setter for
+ * the corresponding attribute.
+ */
+
+PyObject *EXPP_setterWrapperTuple ( PyObject * self, PyObject * args,
+ int (*func)( PyObject * self, PyObject * args ))
+{
+ int error;
+
+ if ( !PyTuple_Check( args ) )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "expected tuple" );
+
+ error = func ( self, args );
+ if ( !error ) {
+ Py_INCREF( Py_None );
+ return Py_None;
+ } else
+ return NULL;
+}
+
Index: source/blender/python/api2_2x/gen_utils.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/gen_utils.h,v
retrieving revision 1.27
diff -u -r1.27 gen_utils.h
--- source/blender/python/api2_2x/gen_utils.h 17 Aug 2005 14:26:00 -0000 1.27
+++ source/blender/python/api2_2x/gen_utils.h 23 Aug 2005 05:03:23 -0000
@@ -38,6 +38,8 @@
#include "DNA_scriptlink_types.h"
#include "DNA_listBase.h"
+#include "constant.h"
+
#define Py_PI 3.14159265358979323846
#define Py_WRAP 1024
#define Py_NEW 2048
@@ -97,6 +99,47 @@
int EXPP_map_getStrVal( const EXPP_map_pair * map,
int ival, const char **sval );
+/* clamping and range-checking utilities */
+
+int EXPP_setCharClamped ( PyObject *value, char *param,
+ short min, short max);
+int EXPP_setShortClamped ( PyObject *value, short *param,
+ short min, short max);
+int EXPP_setIntClamped ( PyObject *value, int *param,
+ int min, int max);
+int EXPP_setFloatClamped ( PyObject *value, float *param,
+ float min, float max);
+
+int EXPP_setCharRange ( PyObject *value, char *param,
+ short min, short max);
+int EXPP_setShortRange ( PyObject *value, short *param,
+ short min, short max);
+int EXPP_setIntRange ( PyObject *value, int *param,
+ int min, int max);
+int EXPP_setFloatRange ( PyObject *value, float *param,
+ float min, float max);
+
+/* utility routine for PyType attributes setters with module constant */
+
+int EXPP_setModuleConstant ( BPy_constant *constant, void *param,
+ char type );
+
+/* utilities to get/set bits in bitfields */
+
+PyObject *EXPP_getBitfield( void *param, int setting, char type );
+int EXPP_setBitfield( PyObject * value, void *param, int setting, char type );
+
+/*
+ * Procedures to handle older setStuff() methods, which now access
+ * a PyType's setter attributes using the tp_getset mechanism.
+ */
+
+PyObject *EXPP_setterWrapper ( PyObject * self, PyObject * args,
+ int (*func)( PyObject * self, PyObject * args ));
+
+PyObject *EXPP_setterWrapperTuple ( PyObject * self, PyObject * args,
+ int (*func)( PyObject * self, PyObject * args ));
+
/* scriplinks-related: */
PyObject *EXPP_getScriptLinks(ScriptLink *slink, PyObject *args, int is_scene);
PyObject *EXPP_addScriptLink(ScriptLink *slink, PyObject *args, int is_scene);
@@ -106,3 +149,4 @@
void EXPP_allqueue(unsigned short event, short val);
#endif /* EXPP_gen_utils_h */
+
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 -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 23 Aug 2005 05:03:23 -0000
@@ -4,7 +4,6 @@
# Written by Alex Mole
#
-
"""
The Blender.Texture submodule.
@@ -46,11 +45,16 @@
- IMAGE - Image texture
- PLUGIN - Plugin texture
- ENVMAP - EnvMap texture
+ - MUSGRAVE - Musgrave procedural texture
+ - VORONOI - Voronoi procedural texture
+ - DISTNOISE - Distorted noise texture
@type Flags: readonly dictionary
@var Flags: The available Texture flags:
- FLIPBLEND - Flips the blend texture's X and Y directions
- NEGALPHA - Reverse the alpha value
+ - CHECKER_ODD - Fill the "odd" checkerboard tiles
+ - CHECKER_EVEN - Fill the "even" checkerboard tiles
@type ImageFlags: readonly dictionary
@var ImageFlags: The available image flags for Texture.imageFlags:
@@ -67,11 +71,31 @@
- NORMALMAP - Use image RGB values for normal mapping
@type ExtendModes: readonly dictionary
-@var ExtendModes: Extend, clamp or repeat modes for images
+@var ExtendModes: Extend, clip, repeat or checker modes for image textures
- EXTEND - Extends the colour of the edge
- CLIP - Return alpha 0.0 outside image
- CLIPCUBE - Return alpha 0.0 around cube-shaped area around image
- REPEAT - Repeat image vertically and horizontally
+ - CHECKER - Repeat image in checkerboard pattern
+
+@type Noise: readonly dictionary
+@var Noise: Noise types and bases. SINE, SAW and TRI are only used for
+ marble and wood textures, while the remainder are used for all textures
+ which has a noise basis function (for these textures, the constant should
+ be used with the second noise basis setting).
+ - SINE - Produce bands using sine wave (marble, wood textures)
+ - SAW - Produce bands using saw wave (marble, wood textures)
+ - TRI - Produce bands using triangle wave (marble, wood textures)
+ - BLENDER - Original Blender algorithm
+ - PERLIN - Ken Perlin's original (1985) algorithm
+ - IMPROVEPERLIN - Ken Perlin's newer (2002) algorithm
+ - VORONOIF1 - none
+ - VORONOIF2 - none
+ - VORONOIF3 - none
+ - VORONOIF4 - none
+ - VORONOIF2F1 - none
+ - VORONOICRACKLE - none
+ - CELLNOISE - Steven Worley's cellular basis algorithm (1996)
@type STypes: readonly dictionary
@var STypes: Texture-type specific data. Depending on the value of
@@ -113,6 +137,28 @@
- ENV_STATIC - Calculate map only once
- ENV_ANIM - Calculate map each rendering
- ENV_LOAD - Load map from disk
+ 11. Musgrave type
+ - MUS_MFRACTAL - Hetero Multifractal
+ - MUS_RIDGEDMF - Ridged Multifractal
+ - MUS_HYBRIDMF - Hybrid Multifractal
+ - MUS_FBM - Fractal Brownian Motion
+ - MUS_HTERRAIN - Hetero Terrain
+ 12. Voronoi type
+ - VN_INT - Only calculate intensity
+ - VN_COL1 - Color cells by position
+ - VN_COL2 - Same as Col1 plus outline based on F2-F1
+ - VN_COL3 - Same as Col2 multiplied by intensity
+ 13. Distorted noise type
+ - DN_BLENDER - Original Blender algorithm
+ - DN_PERLIN - Ken Perlin's original (1985) algorithm
+ - DN_IMPROVEPERLIN - Ken Perlin's newer (2002) algorithm
+ - DN_VORONOIF1 - none
+ - DN_VORONOIF2 - none
+ - DN_VORONOIF3 - none
+ - DN_VORONOIF4 - none
+ - DN_VORONOIF2F1 - none
+ - DN_VORONOICRACKLE - none
+ - DN_CELLNOISE - Steven Worley's cellular basis algorithm (1996)
@var TexCo: Flags for MTex.texco.
- ORCO - Use the original coordinates of the mesh
@@ -166,41 +212,118 @@
==================
This object gives access to Texture-specific data in Blender.
- Note that many of the attributes of this object are only relevant if
- specific modes are enabled.
+ Note that many of the attributes of this object are only relevant for
+ specific texture types.
- @ivar name: The Texture name.
- @ivar type: The Texture type. See L{Types}
- @ivar flags: The texture flags (OR'd together). See L{Flags}
- @ivar imageFlags: The texture image flags (OR'd tegether).
- See L{ImageFlags}
- @ivar stype: Texture-type specific data. See L{STypes}
- @ivar image: The image associated with this texture, or None.
- @type image: Blender Image
- @ivar rgbCol: The texture's RGB color triplet.
- @ivar brightness: The brightness in range [0,2].
- @ivar contrast: The contrast in range [0,2].
- @ivar filterSize: The filter size for the image.
- @ivar extend: Texture extend/repeat mode. See L{ExtendModes}
- @ivar crop: Tuple of image crop values as floats,
- like C{(xmin, ymin, xmax, ymax)}
- @ivar repeat: Tuple of image repeat values as ints, like
- C{(xrepeat, yrepeat)}
- @ivar noiseSize: The noise size.
- @ivar noiseDepth: The noise depth.
- @ivar noiseType: The noise type: 'soft' or 'hard'.
- @ivar animLength: Length of the animation.
- @ivar animFrames: Frames of the animation.
- @ivar animOffset: The number of the first picture of the animation.
- @ivar animStart: Start frame of the animation.
- @ivar fieldsPerImage: The number of fields per rendered frame.
- @ivar animMontage: Montage mode data as a tuple of tuples, like
- C{( (fra1,dur1), (fra2,dur2), (fra3,dur3), (fra4,dur4) )}
+ @type animFrames: integer
+ @ivar animFrames: Number of frames of a movie to use
+ @type animLength: integer
+ @ivar animLength: Number of frames of a movie to use (0 for all)
+ @ivar animMontage: Montage mode, start frames and durations, like C{( (fra1,dur1), (fra2,dur2), (fra3,dur3), (fra4,dur4) )}.
+ @type animMontage: ((int,int), (int,int), (int,int), (int,int))
+ @type animOffset: integer
+ @ivar animOffset: Offsets the number of the first movie frame to use
+ @type animStart: integer
+ @ivar animStart: Starting frame of the movie to use
+ @ivar anti: Image anti-aliasing enabled. Also see L{ImageFlags}.
+ @type anti: integer
+ @ivar brightness: Changes the brightness of a texture's color
+ @type brightness: float
+ @ivar calcAlpha: Calculation of image's alpha channel enabled. Also see L{ImageFlags}.
+ @type calcAlpha: integer
+ @ivar contrast: Changes the contrast of a texture's color
+ @type contrast: float
+ @ivar crop: Sets the cropping extents (for image textures)
+ @type crop: (int, int, int, int)
+ @type cyclic: integer
+ @ivar cyclic: Looping of animated frames enabled. Also see L{ImageFlags}.
+ @ivar distAmnt: Amount of distortion (for distorted noise textures)
+ @type distAmnt: float
+ @type distMetric: integer
+ @ivar distMetric: The distance metric (for Voronoi textures)
+ @type exp: float
+ @ivar exp: Minkovsky exponent (for Minkovsky Voronoi textures)
+ @type extend: integer
+ @ivar extend: Texture's 'Extend' mode (for image textures). See L{ExtendModes}.
+ @type fields: integer
+ @type fieldsPerImage: integer
+ @ivar fieldsPerImage: Number of fields per rendered frame
+ @ivar fields: Use of image's fields enabled. Also see L{ImageFlags}.
+ @type filterSize: float
+ @ivar filterSize: The filter size (for image and envmap textures)
+ @type flags: integer
+ @ivar flags: Texture's 'Flag' bitfield. See L{Flags}.
+ @ivar hFracDim: Highest fractional dimension (for Musgrave textures)
+ @type hFracDim: integer
+ @type imageFlags: integer
+ @ivar imageFlags: Texture's 'ImageFlags' bits
+ @type image: Blender Image (or None)
+ @ivar image: Texture's image object
+ @type interpol: integer
+ @ivar interpol: Interpolate image's pixels to fit texture mapping enabled. Also see L{ImageFlags}.
+ @type ipo: Blender Ipo or None
+ @ivar ipo: Texture Ipo data
+ @type iScale: float
+ @ivar iScale: Intensity output scale (for Musgrave and Voronoi textures)
+ @type lacunarity: float
+ @ivar lacunarity: Gap between succesive frequencies (for Musgrave textures)
+ @type mipmap: integer
+ @ivar mipmap: Mipmaps enabled. Also see L{ImageFlags}.
+ @type movie: integer
+ @ivar movie: Movie frames as images enabled. Also see L{ImageFlags}.
+ @type name: string
+ @ivar name: Texture data name
+ @ivar noiseBasis2: Additional noise basis type (wood, marble, distorted noise)
+ @type noiseBasis2: integer
+ @type noiseBasis: integer
+ @ivar noiseBasis: Noise basis type (wood, stucci, marble, clouds, Musgrave, distorted)
+ @type noiseDepth: integer
+ @ivar noiseDepth: Noise depth (magic, marble, clouds)
+ @type noiseSize: float
+ @ivar noiseSize: Noise size (wood, stucci, marble, clouds, Musgrave, distorted noise)
+ @type noiseType: string ('soft' or 'hard')
+ @ivar noiseType: Noise type (for wood, stucci, marble, clouds textures)
+ @type normalMap: integer
+ @ivar normalMap: Use of image RGB values for normal mapping enabled. Also see L{ImageFlags}.
+ @type octs: float
+ @ivar octs: Number of frequencies (for Musgrave textures)
+ @ivar repeat: Repetition multiplier (for image textures)
+ @type repeat: (integer, integer)
+ @ivar rgbCol: RGB color tuple
+ @type rgbCol: (float,float,float)
+ @type rot90: integer
+ @ivar rot90: X/Y flip for rendering enabled. Also see L{ImageFlags}.
+ @type saw: integer
+ @ivar saw: Produce bands using saw wave (marble, wood textures). Also see L{Noise}.
+ @type sine: integer
+ @ivar sine: Produce bands using sine wave (marble, wood textures). Also see L{Noise}.
+ @type stField: integer
+ @ivar stField: Standard field deinterlacing enabled. Also see L{ImageFlags}.
+ @type stype: integer
+ @ivar stype: Texture's 'SType' mode. See L{STypes}.
+ @type tri: integer
+ @ivar tri: Produce bands using triangle wave (marble, wood textures). Also see L{Noise}.
+ @type turbulence: float
+ @ivar turbulence: Turbulence (for magic, wood, stucci, marble textures)
+ @type type: integer
+ @ivar type: Texture's 'Type' mode. See L{Types}.
+ @type useAlpha: integer
+ @ivar useAlpha: Use of image's alpha channel enabled. Also see L{ImageFlags}.
+ @type users: read-only integer
+ @ivar users: Number of texture users
+ @type weight1: float
+ @ivar weight1: Weight 1 (for Voronoi textures)
+ @type weight2: float
+ @ivar weight2: Weight 2 (for Voronoi textures)
+ @type weight3: float
+ @ivar weight3: Weight 3 (for Voronoi textures)
+ @type weight4: float
+ @ivar weight4: Weight 4 (for Voronoi textures)
"""
def getExtend():
"""
- Get the extend mode of the texture. See L{setExtend}
+ Get the extend mode of the texture. See L{setExtend}.
@rtype: string.
"""
@@ -218,9 +341,8 @@
def getType():
"""
- Get this Texture's type.
+ Get this Texture's type. See L{setType}.
@rtype: string
- @return: The Texture's type. See L{setType}
"""
def setExtend(extendmode):
@@ -231,12 +353,12 @@
@type extendmode: string
"""
- def setFlags(f=None, f2=None, f3=None):
+ def setFlags(f1=None, f2=None, f3=None, f4=None):
"""
Set this object's flags.
- @param f: Flags to be set (omitted flags are cleared). Can be any of
- 'ColorBand', 'FlipBlendXY', and 'NegAlpha'
- @type f: string
+ @param f1,f2,f3,f4: Flags to be set (omitted flags are cleared). Can be any of
+ 'FlipBlendXY', 'NegAlpha', 'CheckerOdd', and 'CheckerEven'
+ @type f1,f2,f3,f4: string
"""
def setImage(image):
@@ -247,14 +369,14 @@
@warning: This sets the texture's type to 'Image' if it is not already.
"""
- def setImageFlags(f=None, f2=None, f3=None, and_so_on=None):
+ def setImageFlags(f1=None, f2=None, f3=None, etc=None):
"""
Set the Image flags (only makes sense for IMAGE textures). Omitted
flags are cleared.
- @param f: Flag to set. See L{ImageFlags} for their meanings. Can be
+ @param f1, f2, f3, etc: Flag to set. See L{ImageFlags} for their meanings. Can be
any of: 'InterPol', 'UseAlpha', 'MipMap', 'Fields', 'Rot90',
- 'CalcAlpha', 'StField', 'Movie' and 'Cyclic'
- @type f: string
+ 'CalcAlpha', 'Cyclic', 'Movie', 'StField', 'Anti' and 'NormalMap'
+ @type f1, f2, f3, etc: string
"""
def setName(name):
@@ -267,24 +389,22 @@
def setSType(stype):
"""
Set the SType.
- @param stype: The new stype. This can be one of the following values
- or 'Default' which sets the stype to the default value. See
- L{STypes} for their meanings.
- 'CloudDefault', 'CloudColor', 'WoodBands', 'WoodRings',
- 'WoodBandNoise', 'WoodRingNoise', 'MarbleSoft', 'MarbleSharp',
- 'MarbleSharper', 'BlendLin', 'BlendQuad', 'BlendEase',
- 'BlendDiag', 'BlendSphere', 'BlendHalo', 'StucciPlastic',
- 'StucciWallIn', 'StucciWallOut', 'EnvmapStatic', 'EnvmapAnim',
- 'EnvmapLoad'
+ @param stype: The new stype. This can be any of the values listed in
+ L{STypes} or 'Default' which sets the stype to the default value.
@type stype: string
+
+ @note: the set of valid parameters is dependent on the current
+ texture type. Be sure to always set the texture type B{before}
+ setting the texture's stype; otherwise an exception might occur.
"""
-
+
def setType(type):
"""
Set this Texture's type.
@param type: The new type. Possible options are:
'None', 'Clouds', 'Wood', 'Marble', 'Magic', 'Blend', 'Stucci',
- 'Noise', 'Image', 'Plugin' and 'EnvMap'
+ 'Noise', 'Image', 'Plugin', 'EnvMap', 'Musgrave', 'Voronoi'
+ and 'DistNoise'
@type type: string
"""
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
10/a5/0cf438701d8c12bc025047452380
Event Timeline
Log In to Comment