Part of Bpy Cleanup: change attribute access to use tp_getset.
for these modules. Adds some new convenience funcs to gen_utils. This is internal change only and presents little change to the BPy API except for cleanup of some inconsistencies. A big contribution from Ken Hughes. Thanks!
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -393,11 +394,11 @@ static PyGetSetDef BPy_Lamp_getseters[] = {
|
||||
NULL},
|
||||
{"quad1",
|
||||
(getter)Lamp_getQuad1, (setter)Lamp_setQuad1,
|
||||
"Quad lamp linear distance attenuatation",
|
||||
"Quad lamp linear distance attenuation",
|
||||
NULL},
|
||||
{"quad2",
|
||||
(getter)Lamp_getQuad2, (setter)Lamp_setQuad2,
|
||||
"Quad lamp quadratic distance attenuatation",
|
||||
"Quad lamp quadratic distance attenuation",
|
||||
NULL},
|
||||
{"samples",
|
||||
(getter)Lamp_getSamples, (setter)Lamp_setSamples,
|
||||
@@ -1055,8 +1056,8 @@ static int Lamp_setName( BPy_Lamp * self, PyObject * value )
|
||||
|
||||
static int Lamp_setType( BPy_Lamp * self, PyObject * value )
|
||||
{
|
||||
return EXPP_setShortRange ( value, &self->lamp->type,
|
||||
0, EXPP_LAMP_TYPE_MAX );
|
||||
return EXPP_setIValueRange ( value, &self->lamp->type,
|
||||
0, EXPP_LAMP_TYPE_MAX, 'h' );
|
||||
}
|
||||
|
||||
static int Lamp_setMode( BPy_Lamp * self, PyObject * value )
|
||||
@@ -1091,23 +1092,23 @@ static int Lamp_setMode( BPy_Lamp * self, PyObject * value )
|
||||
|
||||
static int Lamp_setSamples( BPy_Lamp * self, PyObject * value )
|
||||
{
|
||||
return EXPP_setShortClamped ( value, &self->lamp->samp,
|
||||
return EXPP_setIValueClamped ( value, &self->lamp->samp,
|
||||
EXPP_LAMP_SAMPLES_MIN,
|
||||
EXPP_LAMP_SAMPLES_MAX );
|
||||
EXPP_LAMP_SAMPLES_MAX, 'h' );
|
||||
}
|
||||
|
||||
static int Lamp_setBufferSize( BPy_Lamp * self, PyObject * value )
|
||||
{
|
||||
return EXPP_setShortClamped ( value, &self->lamp->bufsize,
|
||||
return EXPP_setIValueClamped ( value, &self->lamp->bufsize,
|
||||
EXPP_LAMP_BUFFERSIZE_MIN,
|
||||
EXPP_LAMP_BUFFERSIZE_MAX );
|
||||
EXPP_LAMP_BUFFERSIZE_MAX, 'h' );
|
||||
}
|
||||
|
||||
static int Lamp_setHaloStep( BPy_Lamp * self, PyObject * value )
|
||||
{
|
||||
return EXPP_setShortClamped ( value, &self->lamp->shadhalostep,
|
||||
return EXPP_setIValueClamped ( value, &self->lamp->shadhalostep,
|
||||
EXPP_LAMP_HALOSTEP_MIN,
|
||||
EXPP_LAMP_HALOSTEP_MAX );
|
||||
EXPP_LAMP_HALOSTEP_MAX, 'h' );
|
||||
}
|
||||
|
||||
static int Lamp_setEnergy( BPy_Lamp * self, PyObject * value )
|
||||
@@ -1217,11 +1218,11 @@ static int Lamp_setComponent( BPy_Lamp * self, PyObject * value,
|
||||
{
|
||||
float color;
|
||||
|
||||
if( !PyFloat_CheckExact ( value ) )
|
||||
if( !PyNumber_Check ( value ) )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected float argument in [0.0,1.0]" );
|
||||
|
||||
color = PyFloat_AS_DOUBLE( value );
|
||||
color = PyFloat_AsDouble( value );
|
||||
color = EXPP_ClampFloat( color, EXPP_LAMP_COL_MIN, EXPP_LAMP_COL_MAX );
|
||||
|
||||
switch ( (int)closure ) {
|
||||
@@ -1241,14 +1242,7 @@ static int Lamp_setComponent( BPy_Lamp * self, PyObject * value,
|
||||
|
||||
static int Lamp_setCol( BPy_Lamp * self, PyObject * args )
|
||||
{
|
||||
PyObject *error;
|
||||
|
||||
error = rgbTuple_setCol( self->color, args );
|
||||
if ( error ) {
|
||||
Py_DECREF ( error );
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
return rgbTuple_setCol( self->color, args );
|
||||
}
|
||||
|
||||
/* lamp.addScriptLink */
|
||||
@@ -1476,108 +1470,89 @@ static PyObject *Lamp_getUsers( BPy_Lamp * self )
|
||||
|
||||
/* #####DEPRECATED###### */
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
static PyObject *Lamp_setterWrapper ( BPy_Lamp * self, PyObject * args,
|
||||
int (*func)( BPy_Lamp * 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;
|
||||
}
|
||||
|
||||
static PyObject *Lamp_oldsetName( BPy_Lamp * self, PyObject * args )
|
||||
{
|
||||
return Lamp_setterWrapper ( self, args, Lamp_setName );
|
||||
return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setName );
|
||||
}
|
||||
|
||||
|
||||
static PyObject *Lamp_oldsetSamples( BPy_Lamp * self, PyObject * args )
|
||||
{
|
||||
return Lamp_setterWrapper ( self, args, Lamp_setSamples );
|
||||
return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setSamples );
|
||||
}
|
||||
|
||||
static PyObject *Lamp_oldsetBufferSize( BPy_Lamp * self, PyObject * args )
|
||||
{
|
||||
return Lamp_setterWrapper ( self, args, Lamp_setBufferSize );
|
||||
return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setBufferSize );
|
||||
}
|
||||
|
||||
static PyObject *Lamp_oldsetHaloStep( BPy_Lamp * self, PyObject * args )
|
||||
{
|
||||
return Lamp_setterWrapper ( self, args, Lamp_setHaloStep );
|
||||
return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setHaloStep );
|
||||
}
|
||||
|
||||
static PyObject *Lamp_oldsetEnergy( BPy_Lamp * self, PyObject * args )
|
||||
{
|
||||
return Lamp_setterWrapper ( self, args, Lamp_setEnergy );
|
||||
return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setEnergy );
|
||||
}
|
||||
|
||||
static PyObject *Lamp_oldsetDist( BPy_Lamp * self, PyObject * args )
|
||||
{
|
||||
return Lamp_setterWrapper ( self, args, Lamp_setDist );
|
||||
return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setDist );
|
||||
}
|
||||
|
||||
static PyObject *Lamp_oldsetSpotSize( BPy_Lamp * self, PyObject * args )
|
||||
{
|
||||
return Lamp_setterWrapper ( self, args, Lamp_setSpotSize );
|
||||
return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setSpotSize );
|
||||
}
|
||||
|
||||
static PyObject *Lamp_oldsetSpotBlend( BPy_Lamp * self, PyObject * args )
|
||||
{
|
||||
return Lamp_setterWrapper ( self, args, Lamp_setSpotBlend );
|
||||
return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setSpotBlend );
|
||||
}
|
||||
|
||||
static PyObject *Lamp_oldsetClipStart( BPy_Lamp * self, PyObject * args )
|
||||
{
|
||||
return Lamp_setterWrapper ( self, args, Lamp_setClipStart );
|
||||
return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setClipStart );
|
||||
}
|
||||
|
||||
static PyObject *Lamp_oldsetClipEnd( BPy_Lamp * self, PyObject * args )
|
||||
{
|
||||
return Lamp_setterWrapper ( self, args, Lamp_setClipEnd );
|
||||
return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setClipEnd );
|
||||
}
|
||||
|
||||
static PyObject *Lamp_oldsetBias( BPy_Lamp * self, PyObject * args )
|
||||
{
|
||||
return Lamp_setterWrapper ( self, args, Lamp_setBias );
|
||||
return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setBias );
|
||||
}
|
||||
|
||||
static PyObject *Lamp_oldsetSoftness( BPy_Lamp * self, PyObject * args )
|
||||
{
|
||||
return Lamp_setterWrapper ( self, args, Lamp_setSoftness );
|
||||
return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setSoftness );
|
||||
}
|
||||
|
||||
static PyObject *Lamp_oldsetHaloInt( BPy_Lamp * self, PyObject * args )
|
||||
{
|
||||
return Lamp_setterWrapper ( self, args, Lamp_setHaloInt );
|
||||
return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setHaloInt );
|
||||
}
|
||||
|
||||
static PyObject *Lamp_oldsetQuad1( BPy_Lamp * self, PyObject * args )
|
||||
{
|
||||
return Lamp_setterWrapper ( self, args, Lamp_setQuad1 );
|
||||
return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setQuad1 );
|
||||
}
|
||||
|
||||
static PyObject *Lamp_oldsetQuad2( BPy_Lamp * self, PyObject * args )
|
||||
{
|
||||
return Lamp_setterWrapper ( self, args, Lamp_setQuad2 );
|
||||
return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setQuad2 );
|
||||
}
|
||||
|
||||
static PyObject *Lamp_oldsetIpo( BPy_Lamp * self, PyObject * args )
|
||||
{
|
||||
return Lamp_setterWrapper ( self, args, Lamp_setIpo );
|
||||
return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setIpo );
|
||||
}
|
||||
|
||||
static PyObject *Lamp_oldsetCol( BPy_Lamp * self, PyObject * args )
|
||||
{
|
||||
return EXPP_setterWrapper ( (void *)self, args, (setter)Lamp_setCol );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1595,7 +1570,7 @@ static PyObject *Lamp_clearIpo( BPy_Lamp * self )
|
||||
|
||||
if( self->lamp->ipo ) {
|
||||
PyObject *value = Py_BuildValue( "(O)", Py_None );
|
||||
Lamp_setterWrapper ( self, value, Lamp_setIpo );
|
||||
EXPP_setterWrapper ( (void *)self, value, (setter)Lamp_setIpo );
|
||||
Py_DECREF ( value );
|
||||
return EXPP_incr_ret_True();
|
||||
}
|
||||
@@ -1638,7 +1613,7 @@ static PyObject *Lamp_oldsetType( BPy_Lamp * self, PyObject * args )
|
||||
/* build tuple, call wrapper */
|
||||
|
||||
value = Py_BuildValue( "(i)", type );
|
||||
error = Lamp_setterWrapper ( self, value, Lamp_setType );
|
||||
error = EXPP_setterWrapper ( (void *)self, value, (setter)Lamp_setType );
|
||||
Py_DECREF ( value );
|
||||
return error;
|
||||
}
|
||||
@@ -1695,19 +1670,8 @@ static PyObject *Lamp_oldsetMode( BPy_Lamp * self, PyObject * args )
|
||||
/* build tuple, call wrapper */
|
||||
|
||||
value = Py_BuildValue( "(i)", flag );
|
||||
error = Lamp_setterWrapper ( self, value, Lamp_setMode );
|
||||
error = EXPP_setterWrapper ( (void *)self, value, (setter)Lamp_setMode );
|
||||
Py_DECREF ( value );
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* This one isn't changed at all since rgbTuple_setCol() hasn't changed
|
||||
* either, and the new attribute setter expects a tuple with a single
|
||||
* argument. It's valid to do "lamp.setCol(r,g,b)", which passes three-
|
||||
* argument tuple.
|
||||
*/
|
||||
|
||||
static PyObject *Lamp_oldsetCol( BPy_Lamp * self, PyObject * args )
|
||||
{
|
||||
return rgbTuple_setCol( self->color, args );
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,25 @@ Example::
|
||||
l.setMode('square', 'shadow') # set these two lamp mode flags
|
||||
ob = Object.New('Lamp') # create new lamp object
|
||||
ob.link(l) # link lamp obj with lamp data
|
||||
|
||||
@type Types: read-only dictionary
|
||||
@var Types: The lamp types.
|
||||
- 'Lamp': 0
|
||||
- 'Sun' : 1
|
||||
- 'Spot': 2
|
||||
- 'Hemi': 3
|
||||
- 'Area': 4
|
||||
- 'Photon': 5
|
||||
@type Modes: read-only dictionary
|
||||
@var Modes: The lamp modes. Modes may be ORed together.
|
||||
- 'Shadows'
|
||||
- 'Halo'
|
||||
- 'Layer'
|
||||
- 'Quad'
|
||||
- 'Negative'
|
||||
- 'OnlyShadow'
|
||||
- 'Sphere'
|
||||
- 'Square'
|
||||
"""
|
||||
|
||||
def New (type = 'Lamp', name = 'LampData'):
|
||||
@@ -46,44 +65,73 @@ class Lamp:
|
||||
The Lamp Data object
|
||||
====================
|
||||
This object gives access to Lamp-specific data in Blender.
|
||||
@ivar name: The Lamp Data name.
|
||||
@ivar type: The Lamp type (see the Types dict).
|
||||
@cvar Types: The Types dictionary.
|
||||
- 'Lamp': 0
|
||||
- 'Sun' : 1
|
||||
- 'Spot': 2
|
||||
- 'Hemi': 3
|
||||
- 'Area': 4
|
||||
- 'Photon': 5
|
||||
@ivar mode: The mode flags: B{or'ed value} of the flags in the Modes dict.
|
||||
@cvar Modes: The Modes dictionary.
|
||||
- 'Shadows'
|
||||
- 'Halo'
|
||||
- 'Layer'
|
||||
- 'Quad'
|
||||
- 'Negative'
|
||||
- 'OnlyShadow'
|
||||
- 'Sphere'
|
||||
- 'Square'
|
||||
@ivar samples: The number of shadow map samples in [1, 16].
|
||||
@ivar bufferSize: The size of the shadow buffer in [512, 5120].
|
||||
@ivar haloStep: Volumetric halo sampling frequency in [0, 12].
|
||||
@ivar energy: The intensity of the light in [0.0, 10.0].
|
||||
@ivar dist: The distance value in [0.1, 5000.0].
|
||||
@ivar spotSize: The angle of the spot beam in degrees in [1.0, 180.0].
|
||||
@ivar spotBlend: The softness of the spot edge in [0.0, 1.0].
|
||||
@ivar clipStart: The shadow map clip start in [0.1, 1000.0].
|
||||
@ivar clipEnd: The shadow map clip end in [1.0, 5000.0].
|
||||
@ivar bias: The shadow map sampling bias in [0.01, 5.00].
|
||||
@ivar softness: The size of the shadow sample area in [1.0, 100.0].
|
||||
@ivar haloInt: The intensity of the spot halo in [0.0, 5.0].
|
||||
@ivar quad1: Light intensity value 1 for a Quad lamp in [0.0, 1.0].
|
||||
@ivar quad2: Light intensity value 2 for a Quad lamp in [0.0, 1.0].
|
||||
@ivar col: The color of the light, with each rgb component in [0.0, 1.0].
|
||||
This is an rgb tuple whose values can be accessed in many ways:
|
||||
- as a tuple: lamp.col, lamp.col[0], same for 1 and 2.
|
||||
- as a dictionary: lamp.col['R'], same for 'G' and 'B'.
|
||||
- as an object: lamp.col.R, same for G and B.
|
||||
|
||||
@ivar B: Lamp color blue component.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type B: float
|
||||
@ivar G: Lamp color green component.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type G: float
|
||||
@ivar R: Lamp color red component.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type R: float
|
||||
@ivar bias: Lamp shadow map sampling bias.
|
||||
Value is clamped to the range [0.01,5.0].
|
||||
@type bias: float
|
||||
@ivar bufferSize: Lamp shadow buffer size.
|
||||
Value is clamped to the range [512,5120].
|
||||
@type bufferSize: int
|
||||
@ivar clipEnd: Lamp shadow map clip end.
|
||||
Value is clamped to the range [1.0,5000.0].
|
||||
@type clipEnd: float
|
||||
@ivar clipStart: Lamp shadow map clip start.
|
||||
Value is clamped to the range [0.1,1000.0].
|
||||
@type clipStart: float
|
||||
@ivar col: Lamp RGB color triplet.
|
||||
Components are clamped to the range [0.0,1.0].
|
||||
@type col: RGB tuple
|
||||
@ivar dist: Lamp clipping distance.
|
||||
Value is clamped to the range [0.1,5000.0].
|
||||
@type dist: float
|
||||
@ivar energy: Lamp light intensity.
|
||||
Value is clamped to the range [0.0,10.0].
|
||||
@type energy: float
|
||||
@ivar haloInt: Lamp spotlight halo intensity.
|
||||
Value is clamped to the range [0.0,5.0].
|
||||
@type haloInt: float
|
||||
@ivar haloStep: Lamp volumetric halo sampling frequency.
|
||||
Value is clamped to the range [0,12].
|
||||
@type haloStep: int
|
||||
@ivar ipo: Lamp Ipo.
|
||||
Contains the Ipo if one is assigned to the object, B{None} otherwise. Setting to B{None} clears the current Ipo..
|
||||
@type ipo: Blender Ipo
|
||||
@ivar mode: Lamp mode bitfield. See L{Modes} for values.
|
||||
@type mode: int
|
||||
@ivar name: Lamp data name.
|
||||
@type name: str
|
||||
@ivar quad1: Quad lamp linear distance attenuation.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type quad1: float
|
||||
@ivar quad2: Quad lamp quadratic distance attenuation.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type quad2: float
|
||||
@ivar samples: Lamp shadow map samples.
|
||||
Value is clamped to the range [1,16].
|
||||
@type samples: int
|
||||
@ivar softness: Lamp shadow sample area size.
|
||||
Value is clamped to the range [1.0,100.0].
|
||||
@type softness: float
|
||||
@ivar spotBlend: Lamp spotlight edge softness.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type spotBlend: float
|
||||
@ivar spotSize: Lamp spotlight beam angle (in degrees).
|
||||
Value is clamped to the range [1.0,180.0].
|
||||
@type spotSize: float
|
||||
@ivar type: Lamp type. See L{Types} for values.
|
||||
@type type: int
|
||||
@ivar users: Number of lamp users.
|
||||
@type users: int
|
||||
|
||||
@warning: Most member variables assume values in some [Min, Max] interval.
|
||||
When trying to set them, the given parameter will be clamped to lie in
|
||||
that range: if val < Min, then val = Min, if val > Max, then val = Max.
|
||||
|
||||
@@ -57,7 +57,6 @@ Example::
|
||||
uses an already taken value is preceded by "-" and appear below the normal
|
||||
mode which also uses that value.
|
||||
|
||||
|
||||
@type Shaders: readonly dictionary
|
||||
@var Shaders: The available Material Shaders.
|
||||
- DIFFUSE_LAMBERT - Make Material use the lambert diffuse shader.
|
||||
@@ -96,59 +95,173 @@ class Material:
|
||||
The Material object
|
||||
===================
|
||||
This object gives access to Materials in Blender.
|
||||
@ivar name: Material's name.
|
||||
@type mode: int
|
||||
@ivar mode: Mode flags as an or'ed int value. See the Modes dictionary keys
|
||||
and descriptions in L{Modes}.
|
||||
@ivar rgbCol: Material's RGB color triplet sequence.
|
||||
@ivar specCol: Specular color rgb triplet sequence.
|
||||
@ivar mirCol: Mirror color rgb triplet sequence.
|
||||
@ivar R: Red component of L{rgbCol} - [0.0, 1.0].
|
||||
@ivar G: Green component of L{rgbCol} - [0.0, 1.0].
|
||||
@ivar B: Blue component of L{rgbCol} - [0.0, 1.0].
|
||||
@ivar alpha: Alpha (translucency) component of the Material - [0.0, 1.0].
|
||||
@ivar amb: Ambient factor - [0.0, 1.0].
|
||||
@ivar emit: Emitting light intensity - [0.0, 1.0].
|
||||
@ivar ref: Reflectivity - [0.0, 1.0].
|
||||
@ivar spec: Specularity - [0.0, 2.0].
|
||||
@ivar specTransp: Specular transparency - [0.0, 1.0].
|
||||
@ivar add: Glow factor - [0.0, 1.0].
|
||||
@ivar zOffset: Artificial Z offset for faces - [0.0, 10.0].
|
||||
@ivar haloSize: Dimension of the halo - [0.0, 100.0].
|
||||
@ivar flareSize: Factor the flare is larger than the halo - [0.1, 25.0].
|
||||
@ivar flareBoost: Flare's extra strength - [0.1, 10.0].
|
||||
@ivar haloSeed: To use random values for ring dimension and line location -
|
||||
[0, 255].
|
||||
@ivar flareSeed: Offset in the seed table - [0, 255].
|
||||
@ivar subSize: Dimension of subflares, dots and circles - [0.1, 25.0].
|
||||
@ivar hard: Hardness of the specularity - [1, 255].
|
||||
@ivar nFlares: Number of halo subflares - [1, 32].
|
||||
@ivar nStars: Number of points on the halo stars - [3, 50].
|
||||
@ivar nLines: Number of star shaped lines on each halo - [0, 250].
|
||||
@ivar nRings: Number of halo rings - [0, 24].
|
||||
@type ipo: Blender Ipo
|
||||
@ivar ipo: This Material's ipo.
|
||||
@ivar rayMirr: Amount mirror reflection for raytrace.
|
||||
@ivar rayMirrDepth: Amount of inter-reflections calculated maximal.
|
||||
@ivar fresnelDepth: Power of Fresnel for mirror reflection.
|
||||
@ivar fresnelDepthFac: Blending factor for Fresnel.
|
||||
@ivar IOR: Sets the angular index of refraction for raytrace.
|
||||
@ivar transDepth: Amount of refractions calculated maximal.
|
||||
@ivar fresnelTrans: Power of Fresnel for transparency.
|
||||
@ivar fresnelTransFac: Blending factor for Fresnel.
|
||||
@ivar specTrans: Makes specular areas opaque on transparent materials.
|
||||
@cvar specShader: Specular shader from one of the shaders in Material.Shaders dict - [0, 4].
|
||||
@cvar diffuseShader: Diffuse shader from one of the shaders in Material.Shaders dict - [0, 3].
|
||||
@cvar roughness: Material's Roughness (applies to the \"Oren Nayar\" Diffuse Shader only) - [0.0, 3.14].
|
||||
@cvar specSize: Material's size of speculara area (applies to the \"Toon\" Specular Shader only) - [0.0, 1.53].
|
||||
@cvar diffuseSize: Material's size of diffuse area (applies to the \"Toon\" Diffuse Shader only) - [0.0, 3.14].
|
||||
@cvar specSmooth: Material's smoothing of specular area (applies to the \"Toon\" Specular Shader only) - [0.0, 1.0].
|
||||
@cvar diffuseSmooth: Material's smoothing of diffuse area (applies to the \"Toon\" Diffuse Shader only) - [0.0, 1.0].
|
||||
@cvar diffuseDarkness: Material's diffuse darkness (applies to the \"Minnaert\" Diffuse Shader only) - [0.0, 2.0].
|
||||
@cvar refracIndex: Material's Index of Refraction (applies to the \"Blinn\" Specular Shader only) - [1.0, 10.0].
|
||||
@cvar rms: Material's standard deviation of surface slope (applies to the \"WardIso\" Specular Shader only) - [0.0, 0.4].
|
||||
@cvar filter: Amount of filtering when transparent raytrace is enabled - [0.0, 1.0].
|
||||
@cvar translucency: Amount of diffuse shading of the back side - [0.0, 1.0].
|
||||
@ivar B: Diffuse color (L{rgbCol}) blue component.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type B: float
|
||||
@ivar G: Diffuse color (L{rgbCol}) green component.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type G: float
|
||||
@ivar IOR: Angular index of refraction for raytrace.
|
||||
Value is clamped to the range [1.0,3.0].
|
||||
@type IOR: float
|
||||
@ivar R: Diffuse color (L{rgbCol}) red component.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type R: float
|
||||
@ivar add: Strength of the add effect.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type add: float
|
||||
@ivar alpha: Alpha (translucency) component of the material.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type alpha: float
|
||||
@ivar amb: Amount of global ambient color material receives.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type amb: float
|
||||
@ivar diffuseDarkness: Material's diffuse darkness ("Minnaert" diffuse shader only).
|
||||
Value is clamped to the range [0.0,2.0].
|
||||
@type diffuseDarkness: float
|
||||
@ivar diffuseShader: Diffuse shader type (see L{Shaders}).
|
||||
Value must be in the range [0,3].
|
||||
@type diffuseShader: int
|
||||
@ivar diffuseSize: Material's diffuse area size ("Toon" diffuse shader only).
|
||||
Value is clamped to the range [0.0,3.14].
|
||||
@type diffuseSize: float
|
||||
@ivar diffuseSmooth: Material's diffuse area smoothing ("Toon" diffuse shader only).
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type diffuseSmooth: float
|
||||
@ivar emit: Amount of light the material emits.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type emit: float
|
||||
@ivar filter: Amount of filtering when transparent raytrace is enabled.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type filter: float
|
||||
@ivar flareBoost: Flare's extra strength.
|
||||
Value is clamped to the range [0.1,1.0].
|
||||
@type flareBoost: float
|
||||
@ivar flareSeed: Offset in the flare seed table.
|
||||
Value is clamped to the range [1,255].
|
||||
@type flareSeed: int
|
||||
@ivar flareSize: Ratio of flare size to halo size.
|
||||
Value is clamped to the range [0.1,25.0].
|
||||
@type flareSize: float
|
||||
@ivar fresnelDepth: Power of Fresnel for mirror reflection.
|
||||
Value is clamped to the range [0.0,5.0].
|
||||
@type fresnelDepth: float
|
||||
@ivar fresnelDepthFac: Blending factor for Fresnel mirror.
|
||||
Value is clamped to the range [1.0,5.0].
|
||||
@type fresnelDepthFac: float
|
||||
@ivar fresnelTrans: Power of Fresnel for transparency.
|
||||
Value is clamped to the range [0.0,5.0].
|
||||
@type fresnelTrans: float
|
||||
@ivar fresnelTransFac: Blending factor for Fresnel transparency.
|
||||
Value is clamped to the range [1.0,5.0].
|
||||
@type fresnelTransFac: float
|
||||
@ivar haloSeed: Randomizes halo ring dimension and line location.
|
||||
Value is clamped to the range [1,255].
|
||||
@type haloSeed: int
|
||||
@ivar haloSize: Dimension of the halo.
|
||||
Value is clamped to the range [0.0,100.0].
|
||||
@type haloSize: float
|
||||
@ivar hard: Hardness of the specularity.
|
||||
Value is clamped to the range [1,255].
|
||||
@type hard: int
|
||||
@ivar ipo: Material Ipo data.
|
||||
Contains the Ipo if one is assigned to the object, None otherwise. Setting to None clears the current Ipo.
|
||||
@type ipo: Blender Ipo
|
||||
@ivar mirB: Mirror color (L{mirCol}) blue component.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type mirB: float
|
||||
@ivar mirCol: Mirror RGB color triplet.
|
||||
Components are clamped to the range [0.0,1.0].
|
||||
@type mirCol: list of 3 floats
|
||||
@ivar mirG: Mirror color (L{mirCol}) green component.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type mirG: float
|
||||
@ivar mirR: Mirror color (L{mirCol}) red component.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type mirR: float
|
||||
@ivar mode: Mode mode bitfield. See L{the Modes dictionary<Modes>} keys and descriptions.
|
||||
@type mode: int
|
||||
@ivar nFlares: Number of subflares with halo.
|
||||
Value is clamped to the range [1,32].
|
||||
@type nFlares: int
|
||||
@ivar nLines: Number of star-shaped lines with halo.
|
||||
Value is clamped to the range [0,250].
|
||||
@type nLines: int
|
||||
@ivar nRings: Number of rings with halo.
|
||||
Value is clamped to the range [0,24].
|
||||
@type nRings: int
|
||||
@ivar nStars: Number of star points with halo.
|
||||
Value is clamped to the range [3,50].
|
||||
@type nStars: int
|
||||
@ivar name: Material data name.
|
||||
@type name: str
|
||||
@ivar oopsLoc: Material OOPs location. Returns None if materal not found in list.
|
||||
@type oopsLoc: list of 2 floats
|
||||
@ivar oopsSel: Material OOPs selection flag.
|
||||
Value must be in the range [0,1].
|
||||
@type oopsSel: int
|
||||
@ivar rayMirr: Mirror reflection amount for raytrace.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type rayMirr: float
|
||||
@ivar rayMirrDepth: Amount of raytrace inter-reflections.
|
||||
Value is clamped to the range [0,10].
|
||||
@type rayMirrDepth: int
|
||||
@ivar ref: Amount of reflections (for shader).
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type ref: float
|
||||
@ivar refracIndex: Material's Index of Refraction (applies to the "Blinn" Specular Shader only.
|
||||
Value is clamped to the range [1.0,10.0].
|
||||
@type refracIndex: float
|
||||
@ivar rgbCol: Diffuse RGB color triplet.
|
||||
Components are clamped to the range [0.0,1.0].
|
||||
@type rgbCol: list of 3 floats
|
||||
@ivar rms: Material's surface slope standard deviation ("WardIso" specular shader only).
|
||||
Value is clamped to the range [0.0,0.4].
|
||||
@type rms: float
|
||||
@ivar roughness: Material's roughness ("Oren Nayar" diffuse shader only).
|
||||
Value is clamped to the range [0.0,3.14].
|
||||
@type roughness: float
|
||||
@ivar spec: Degree of specularity.
|
||||
Value is clamped to the range [0.0,2.0].
|
||||
@type spec: float
|
||||
@ivar specB: Specular color (L{specCol}) blue component.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type specB: float
|
||||
@ivar specCol: Specular RGB color triplet.
|
||||
Components are clamped to the range [0.0,1.0].
|
||||
@type specCol: list of 3 floats
|
||||
@ivar specG: Specular color (L{specCol}) green component.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type specG: float
|
||||
@ivar specR: Specular color (L{specCol}) red component.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type specR: float
|
||||
@ivar specShader: Specular shader type. See L{Shaders}.
|
||||
Value must be in the range [0,4].
|
||||
@type specShader: int
|
||||
@ivar specSize: Material's specular area size ("Toon" specular shader only).
|
||||
Value is clamped to the range [0.0,1.53].
|
||||
@type specSize: float
|
||||
@ivar specSmooth: Sets the smoothness of specular toon area.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type specSmooth: float
|
||||
@ivar specTransp: Makes specular areas opaque on transparent materials.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type specTransp: float
|
||||
@ivar subSize: Dimension of subflares, dots and circles.
|
||||
Value is clamped to the range [0.1,25.0].
|
||||
@type subSize: float
|
||||
@ivar transDepth: calculated maximal. Amount of refractions for raytrace.
|
||||
Value is clamped to the range [0,10].
|
||||
@type transDepth: int
|
||||
@ivar translucency: Amount of diffuse shading of the back side.
|
||||
Value is clamped to the range [0.0,1.0].
|
||||
@type translucency: float
|
||||
@ivar users: Number of material users.
|
||||
@type users: int
|
||||
@ivar zOffset: Artificial offset in the Z buffer (for Ztransp option).
|
||||
Value is clamped to the range [0.0,10.0].
|
||||
@type zOffset: float
|
||||
@warning: Most member variables assume values in some [Min, Max] interval.
|
||||
When trying to set them, the given parameter will be clamped to lie in
|
||||
that range: if val < Min, then val = Min, if val > Max, then val = Max.
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
# Written by Alex Mole
|
||||
#
|
||||
|
||||
|
||||
"""
|
||||
The Blender.Texture submodule.
|
||||
|
||||
@@ -46,11 +45,16 @@ Example::
|
||||
- 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 @@ Example::
|
||||
- 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 @@ Example::
|
||||
- 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,146 @@ class Texture:
|
||||
==================
|
||||
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) )}
|
||||
@ivar animFrames: Number of frames of a movie to use.
|
||||
Value is clamped to the range [0,30000].
|
||||
@type animFrames: int
|
||||
@ivar animLength: Number of frames of a movie to use (0 for all).
|
||||
Value is clamped to the range [0,9000].
|
||||
@type animLength: int
|
||||
@ivar animMontage: Montage mode, start frames and durations. Example: C{( (fra1,dur1), (fra2,dur2), (fra3,dur3), (fra4,dur4) )}.
|
||||
@type animMontage: tuple of 4 (int,int)
|
||||
@ivar animOffset: Offsets the number of the first movie frame to use.
|
||||
Value is clamped to the range [-9000,9000].
|
||||
@type animOffset: int
|
||||
@ivar animStart: Starting frame of the movie to use.
|
||||
Value is clamped to the range [1,9000].
|
||||
@type animStart: int
|
||||
@ivar anti: Image anti-aliasing enabled. Also see L{ImageFlags}.
|
||||
@type anti: int
|
||||
@ivar brightness: Changes the brightness of a texture's color.
|
||||
Value is clamped to the range [0.0,2.0].
|
||||
@type brightness: float
|
||||
@ivar calcAlpha: Calculation of image's alpha channel enabled. Also see L{ImageFlags}.
|
||||
@type calcAlpha: int
|
||||
@ivar contrast: Changes the contrast of a texture's color.
|
||||
Value is clamped to the range [0.01,5.0].
|
||||
@type contrast: float
|
||||
@ivar crop: Sets the cropping extents (for image textures).
|
||||
@type crop: tuple of 4 ints
|
||||
@ivar cyclic: Looping of animated frames enabled. Also see L{ImageFlags}.
|
||||
@type cyclic: int
|
||||
@ivar distAmnt: Amount of distortion (for distorted noise textures).
|
||||
Value is clamped to the range [0.0,10.0].
|
||||
@type distAmnt: float
|
||||
@ivar distMetric: The distance metric (for Voronoi textures).
|
||||
@type distMetric: int
|
||||
@ivar exp: Minkovsky exponent (for Minkovsky Voronoi textures).
|
||||
Value is clamped to the range [0.01,10.0].
|
||||
@type exp: float
|
||||
@ivar extend: Texture's 'Extend' mode (for image textures). See L{ExtendModes}.
|
||||
@type extend: int
|
||||
@ivar fields: Use of image's fields enabled. Also see L{ImageFlags}.
|
||||
@type fields: int
|
||||
@ivar fieldsPerImage: Number of fields per rendered frame.
|
||||
Value is clamped to the range [1,200].
|
||||
@type fieldsPerImage: int
|
||||
@ivar filterSize: The filter size (for image and envmap textures).
|
||||
Value is clamped to the range [0.1,25.0].
|
||||
@type filterSize: float
|
||||
@ivar flags: Texture's 'Flag' bitfield. See L{Flags}.
|
||||
bitmask.
|
||||
@type flags: int
|
||||
@ivar hFracDim: Highest fractional dimension (for Musgrave textures).
|
||||
Value is clamped to the range [0.0001,2.0].
|
||||
@type hFracDim: float
|
||||
@ivar iScale: Intensity output scale (for Musgrave and Voronoi textures).
|
||||
Value is clamped to the range [0.0,10.0].
|
||||
@type iScale: float
|
||||
@ivar image: Texture's image object.
|
||||
@type image: Blender Image (or None)
|
||||
@ivar imageFlags: Texture's 'ImageFlags' bits.
|
||||
@type imageFlags: int
|
||||
@ivar interpol: Interpolate image's pixels to fit texture mapping enabled. Also see L{ImageFlags}.
|
||||
@type interpol: int
|
||||
@ivar ipo: Texture Ipo data.
|
||||
Contains the Ipo if one is assigned to the object, B{None} otherwise. Setting to B{None} clears the current Ipo..
|
||||
@type ipo: Blender Ipo
|
||||
@ivar lacunarity: Gap between succesive frequencies (for Musgrave textures).
|
||||
Value is clamped to the range [0.0,6.0].
|
||||
@type lacunarity: float
|
||||
@ivar mipmap: Mipmaps enabled. Also see L{ImageFlags}.
|
||||
@type mipmap: int
|
||||
@ivar movie: Movie frames as images enabled. Also see L{ImageFlags}.
|
||||
@type movie: int
|
||||
@ivar name: Texture data name.
|
||||
@type name: string
|
||||
@ivar noiseBasis: Noise basis type (wood, stucci, marble, clouds,
|
||||
Musgrave, distorted). See L{Noise} dictionary.
|
||||
@type noiseBasis: int
|
||||
@ivar noiseBasis2: Additional noise basis type (wood, marble, distorted
|
||||
noise). See L{Noise} dictionary.
|
||||
@type noiseBasis2: int
|
||||
@ivar noiseDepth: Noise depth (magic, marble, clouds).
|
||||
Value is clamped to the range [0,6].
|
||||
@type noiseDepth: int
|
||||
@ivar noiseSize: Noise size (wood, stucci, marble, clouds, Musgrave,
|
||||
distorted noise).
|
||||
Value is clamped to the range [0.0001,2.0].
|
||||
@type noiseSize: float
|
||||
@ivar noiseType: Noise type (for wood, stucci, marble, clouds textures). Valid values are 'hard' or 'soft'.
|
||||
@type noiseType: string
|
||||
@ivar normalMap: Use of image RGB values for normal mapping enabled.
|
||||
Also see L{ImageFlags}.
|
||||
@type normalMap: int
|
||||
@ivar octs: Number of frequencies (for Musgrave textures).
|
||||
Value is clamped to the range [0.0,8.0].
|
||||
@type octs: float
|
||||
@ivar repeat: Repetition multiplier (for image textures).
|
||||
@type repeat: tuple of 2 ints
|
||||
@ivar rgbCol: RGB color tuple.
|
||||
@type rgbCol: tuple of 3 floats
|
||||
@ivar rot90: X/Y flip for rendering enabled. Also see L{ImageFlags}.
|
||||
@type rot90: int
|
||||
@ivar saw: Produce bands using saw wave (marble, wood textures). Also see L{Noise}.
|
||||
@type saw: int
|
||||
@ivar sine: Produce bands using sine wave (marble, wood textures). Also see L{Noise}.
|
||||
@type sine: int
|
||||
@ivar stField: Standard field deinterlacing enabled. Also see L{ImageFlags}.
|
||||
@type stField: int
|
||||
@ivar stype: Texture's 'SType' mode. See L{STypes}.
|
||||
@type stype: int
|
||||
@ivar tri: Produce bands using triangle wave (marble, wood textures). Also see L{Noise}.
|
||||
@type tri: int
|
||||
@ivar turbulence: Turbulence (for magic, wood, stucci, marble textures).
|
||||
Value is clamped to the range [0.0,200.0].
|
||||
@type turbulence: float
|
||||
@ivar type: Texture's 'Type' mode. See L{Types}.
|
||||
Value must be in the range [0,13].
|
||||
@type type: int
|
||||
@ivar useAlpha: Use of image's alpha channel enabled. Also see L{ImageFlags}.
|
||||
@type useAlpha: int
|
||||
@ivar users: Number of texture users. Read-only.
|
||||
@type users: int
|
||||
@ivar weight1: Weight 1 (for Voronoi textures).
|
||||
Value is clamped to the range [-2.0,2.0].
|
||||
@type weight1: float
|
||||
@ivar weight2: Weight 2 (for Voronoi textures).
|
||||
Value is clamped to the range [-2.0,2.0].
|
||||
@type weight2: float
|
||||
@ivar weight3: Weight 3 (for Voronoi textures).
|
||||
Value is clamped to the range [-2.0,2.0].
|
||||
@type weight3: float
|
||||
@ivar weight4: Weight 4 (for Voronoi textures).
|
||||
Value is clamped to the range [-2.0,2.0].
|
||||
@type weight4: float
|
||||
"""
|
||||
|
||||
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 +369,8 @@ class Texture:
|
||||
|
||||
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 +381,12 @@ class Texture:
|
||||
@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 +397,14 @@ class Texture:
|
||||
@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,16 +417,13 @@ class Texture:
|
||||
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):
|
||||
@@ -284,7 +431,8 @@ class Texture:
|
||||
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
|
||||
"""
|
||||
|
||||
|
||||
@@ -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)
|
||||
@@ -597,69 +599,59 @@ PyObject *EXPP_addScriptLink(ScriptLink *slink, PyObject *args, int is_scene)
|
||||
* value: PyObject containing the new value
|
||||
* param: pointer to destination variable
|
||||
* max, min: range of values for clamping
|
||||
* type: kind of pointer and data (uses the same characters as
|
||||
* PyArgs_ParseTuple() and Py_BuildValue()
|
||||
*
|
||||
* 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,
|
||||
int EXPP_setFloatClamped( PyObject *value, float *param,
|
||||
float min, float max )
|
||||
{
|
||||
if( !PyFloat_CheckExact ( value ) ) {
|
||||
if( !PyNumber_Check ( 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 );
|
||||
*param = EXPP_ClampFloat( PyFloat_AsDouble( value ), min, max );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int EXPP_setIValueClamped( PyObject *value, void *param,
|
||||
int min, int max, char type )
|
||||
{
|
||||
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 );
|
||||
|
||||
switch ( type ) {
|
||||
case 'b':
|
||||
*(char *)param = EXPP_ClampInt( number, min, max );
|
||||
return 0;
|
||||
case 'h':
|
||||
*(short *)param = EXPP_ClampInt( number, min, max );
|
||||
return 0;
|
||||
case 'H':
|
||||
*(unsigned short *)param = EXPP_ClampInt( number, min, max );
|
||||
return 0;
|
||||
case 'i':
|
||||
*(int *)param = EXPP_ClampInt( number, min, max );
|
||||
return 0;
|
||||
default:
|
||||
return EXPP_ReturnIntError( PyExc_RuntimeError,
|
||||
"EXPP_setIValueClamped(): invalid type code" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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.
|
||||
@@ -670,49 +662,24 @@ int EXPP_setFloatClamped ( PyObject *value, float *param,
|
||||
* value: PyObject containing the new value
|
||||
* param: pointer to destination variable
|
||||
* max, min: valid range for value
|
||||
* type: kind of pointer and data (uses the same characters as
|
||||
* PyArgs_ParseTuple() and Py_BuildValue()
|
||||
*
|
||||
* Return 0 on success, -1 on error.
|
||||
*/
|
||||
|
||||
int EXPP_setCharRange ( PyObject *value, char *param,
|
||||
short min, short max )
|
||||
int EXPP_setFloatRange( PyObject *value, float *param,
|
||||
float min, float max )
|
||||
{
|
||||
char errstr[128];
|
||||
short number;
|
||||
|
||||
/* build exception error string */
|
||||
sprintf ( errstr, "expected int argument in [%f,%f]", min, max );
|
||||
|
||||
sprintf ( errstr, "expected int argument in [%d,%d]", min, max );
|
||||
|
||||
/* if value not of correct type, raise Type exception */
|
||||
|
||||
if( !PyInt_CheckExact ( value ) )
|
||||
if( !PyNumber_Check ( 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 );
|
||||
number = PyFloat_AsDouble( value );
|
||||
if ( number < min || number > max )
|
||||
return EXPP_ReturnIntError( PyExc_ValueError, errstr );
|
||||
|
||||
@@ -720,8 +687,8 @@ int EXPP_setShortRange ( PyObject *value, short *param,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int EXPP_setIntRange ( PyObject *value, int *param,
|
||||
int min, int max )
|
||||
int EXPP_setIValueRange( PyObject *value, void *param,
|
||||
int min, int max, char type )
|
||||
{
|
||||
char errstr[128];
|
||||
int number;
|
||||
@@ -731,29 +698,179 @@ int EXPP_setIntRange ( PyObject *value, int *param,
|
||||
if( !PyInt_CheckExact ( value ) )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError, errstr );
|
||||
|
||||
number = PyInt_AS_LONG ( value );
|
||||
if ( number < min || number > max )
|
||||
number = PyInt_AS_LONG( value );
|
||||
if( number < min || number > max )
|
||||
return EXPP_ReturnIntError( PyExc_ValueError, errstr );
|
||||
|
||||
*param = number;
|
||||
return 0;
|
||||
switch ( type ) {
|
||||
case 'b':
|
||||
*(char *)param = number;
|
||||
return 0;
|
||||
case 'h':
|
||||
*(short *)param = number;
|
||||
return 0;
|
||||
case 'H':
|
||||
*(unsigned short *)param = number;
|
||||
return 0;
|
||||
case 'i':
|
||||
*(int *)param = number;
|
||||
return 0;
|
||||
default:
|
||||
return EXPP_ReturnIntError( PyExc_RuntimeError,
|
||||
"EXPP_setIValueRange(): invalid type code" );
|
||||
}
|
||||
}
|
||||
|
||||
int EXPP_setFloatRange ( PyObject *value, float *param,
|
||||
float min, float max )
|
||||
/*
|
||||
* 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 )
|
||||
{
|
||||
char errstr[128];
|
||||
short number;
|
||||
PyObject *item;
|
||||
|
||||
sprintf ( errstr, "expected int argument in [%f,%f]", min, max );
|
||||
if( constant->ob_type != &constant_Type )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected module constant" );
|
||||
|
||||
if( !PyFloat_CheckExact ( value ) )
|
||||
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 'b':
|
||||
return (*(char *)param & setting)
|
||||
? EXPP_incr_ret_True() : EXPP_incr_ret_False();
|
||||
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 );
|
||||
|
||||
number = PyFloat_AS_DOUBLE( value );
|
||||
if ( number < min || number > max )
|
||||
flag = PyInt_AS_LONG ( value );
|
||||
if( flag != 0 && flag != 1 )
|
||||
return EXPP_ReturnIntError( PyExc_ValueError, errstr );
|
||||
|
||||
*param = number;
|
||||
return 0;
|
||||
switch ( type ) {
|
||||
case 'b':
|
||||
if ( flag )
|
||||
*(char *)param |= setting;
|
||||
else
|
||||
*(char *)param &= ~setting;
|
||||
return 0;
|
||||
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,
|
||||
setter func)
|
||||
{
|
||||
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 ), NULL );
|
||||
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,
|
||||
setter func)
|
||||
{
|
||||
int error;
|
||||
|
||||
if ( !PyTuple_Check( args ) )
|
||||
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
|
||||
"expected tuple" );
|
||||
|
||||
error = func ( self, args, NULL );
|
||||
if ( !error ) {
|
||||
Py_INCREF( Py_None );
|
||||
return Py_None;
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -99,24 +101,36 @@ int EXPP_map_getStrVal( const EXPP_map_pair * map,
|
||||
|
||||
/* 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_setIValueClamped( PyObject *value, void *param,
|
||||
int min, int max, char type );
|
||||
int EXPP_setFloatClamped ( PyObject *value, float *param,
|
||||
float min, float max);
|
||||
|
||||
int EXPP_setChrRange ( 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_setIValueRange( PyObject *value, void *param,
|
||||
int min, int max, char type );
|
||||
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,
|
||||
setter func);
|
||||
|
||||
PyObject *EXPP_setterWrapperTuple ( PyObject * self, PyObject * args,
|
||||
setter func);
|
||||
|
||||
/* scriplinks-related: */
|
||||
PyObject *EXPP_getScriptLinks(ScriptLink *slink, PyObject *args, int is_scene);
|
||||
PyObject *EXPP_addScriptLink(ScriptLink *slink, PyObject *args, int is_scene);
|
||||
|
||||
@@ -45,7 +45,7 @@ static PyObject *rgbTuple_getAttr( BPy_rgbTuple * self, char *name );
|
||||
static int rgbTuple_setAttr( BPy_rgbTuple * self, char *name, PyObject * v );
|
||||
static PyObject *rgbTuple_repr( BPy_rgbTuple * self );
|
||||
|
||||
static int rgbTupleLength( BPy_rgbTuple * self );
|
||||
static int rgbTupleLength( void );
|
||||
|
||||
static PyObject *rgbTupleSubscript( BPy_rgbTuple * self, PyObject * key );
|
||||
static int rgbTupleAssSubscript( BPy_rgbTuple * self, PyObject * who,
|
||||
@@ -138,39 +138,47 @@ PyObject *rgbTuple_New( float *rgb[3] )
|
||||
/*****************************************************************************/
|
||||
PyObject *rgbTuple_getCol( BPy_rgbTuple * self )
|
||||
{
|
||||
PyObject *list = PyList_New( 3 );
|
||||
|
||||
if( !list )
|
||||
PyObject *attr = Py_BuildValue( "[fff]", *(self->rgb[0]),
|
||||
*(self->rgb[1]), *(self->rgb[2]));
|
||||
if( !attr )
|
||||
return EXPP_ReturnPyObjError( PyExc_MemoryError,
|
||||
"couldn't create PyList" );
|
||||
|
||||
PyList_SET_ITEM( list, 0, Py_BuildValue( "f", *( self->rgb[0] ) ) );
|
||||
PyList_SET_ITEM( list, 1, Py_BuildValue( "f", *( self->rgb[1] ) ) );
|
||||
PyList_SET_ITEM( list, 2, Py_BuildValue( "f", *( self->rgb[2] ) ) );
|
||||
|
||||
return list;
|
||||
"Py_BuildValue() failed" );
|
||||
return attr;
|
||||
}
|
||||
|
||||
PyObject *rgbTuple_setCol( BPy_rgbTuple * self, PyObject * args )
|
||||
int rgbTuple_setCol( BPy_rgbTuple * self, PyObject * args )
|
||||
{
|
||||
int ok;
|
||||
int ok = 0;
|
||||
float r = 0, g = 0, b = 0;
|
||||
|
||||
if( PyObject_Length( args ) == 3 )
|
||||
ok = PyArg_ParseTuple( args, "fff", &r, &g, &b );
|
||||
/*
|
||||
* since rgbTuple_getCol() returns a list, be sure we accept a list
|
||||
* as valid input
|
||||
*/
|
||||
|
||||
else
|
||||
if( PyObject_Length( args ) == 3 ) {
|
||||
if ( PyList_Check ( args ) &&
|
||||
PyNumber_Check( PySequence_Fast_GET_ITEM( args, 0 ) ) &&
|
||||
PyNumber_Check( PySequence_Fast_GET_ITEM( args, 1 ) ) &&
|
||||
PyNumber_Check( PySequence_Fast_GET_ITEM( args, 2 ) ) ) {
|
||||
r = PyFloat_AsDouble( PySequence_Fast_GET_ITEM( args, 0 ) );
|
||||
g = PyFloat_AsDouble( PySequence_Fast_GET_ITEM( args, 1 ) );
|
||||
b = PyFloat_AsDouble( PySequence_Fast_GET_ITEM( args, 2 ) );
|
||||
ok = 1;
|
||||
} else
|
||||
ok = PyArg_ParseTuple( args, "fff", &r, &g, &b );
|
||||
} else
|
||||
ok = PyArg_ParseTuple( args, "|(fff)", &r, &g, &b );
|
||||
|
||||
if( !ok )
|
||||
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||
"expected [f,f,f] or f,f,f as arguments (or nothing)" );
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected [f,f,f], (f,f,f) or f,f,f as arguments (or nothing)" );
|
||||
|
||||
*( self->rgb[0] ) = EXPP_ClampFloat( r, 0.0, 1.0 );
|
||||
*( self->rgb[1] ) = EXPP_ClampFloat( g, 0.0, 1.0 );
|
||||
*( self->rgb[2] ) = EXPP_ClampFloat( b, 0.0, 1.0 );
|
||||
|
||||
return EXPP_incr_ret( Py_None );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -245,7 +253,7 @@ static int rgbTuple_setAttr( BPy_rgbTuple * self, char *name, PyObject * v )
|
||||
/* These functions provide code to access rgbTuple objects as */
|
||||
/* mappings. */
|
||||
/*****************************************************************************/
|
||||
static int rgbTupleLength( BPy_rgbTuple * self )
|
||||
static int rgbTupleLength( void )
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,6 @@ typedef struct {
|
||||
/*****************************************************************************/
|
||||
PyObject *rgbTuple_New( float *rgb[3] );
|
||||
PyObject *rgbTuple_getCol( BPy_rgbTuple * self );
|
||||
PyObject *rgbTuple_setCol( BPy_rgbTuple * self, PyObject * args );
|
||||
int rgbTuple_setCol( BPy_rgbTuple * self, PyObject * args );
|
||||
|
||||
#endif /* EXPP_rgbTuple_H */
|
||||
|
||||
Reference in New Issue
Block a user