Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Susano Pinto <andresusanopinto@gmail.com>2008-08-22 02:57:25 +0400
committerAndre Susano Pinto <andresusanopinto@gmail.com>2008-08-22 02:57:25 +0400
commitf4ae23f3794605f5b7c0a5b90d982d6dfd20d492 (patch)
tree0f1c725f89be062437f0114d5ef1a2fe501fd600 /source/blender/python
parenta06321d55c2f25440120ac2fdead20639863a608 (diff)
svn merge -r 16174:16215 https://svn.blender.org/svnroot/bf-blender/trunk/blender
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/api2_2x/Material.c92
-rw-r--r--source/blender/python/api2_2x/Mesh.c4
-rw-r--r--source/blender/python/api2_2x/Object.c37
-rw-r--r--source/blender/python/api2_2x/doc/Material.py19
-rw-r--r--source/blender/python/api2_2x/doc/Object.py8
5 files changed, 150 insertions, 10 deletions
diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c
index ccd24a437b5..20747a167e6 100644
--- a/source/blender/python/api2_2x/Material.c
+++ b/source/blender/python/api2_2x/Material.c
@@ -554,6 +554,7 @@ static int Material_setSssTexScatter( BPy_Material * self, PyObject * value );
static int Material_setSssFront( BPy_Material * self, PyObject * value );
static int Material_setSssBack( BPy_Material * self, PyObject * value );
static int Material_setSssBack( BPy_Material * self, PyObject * value );
+static int Material_setTexChannel( BPy_Material * self, PyObject * value );
static PyObject *Material_getColorComponent( BPy_Material * self,
void * closure );
@@ -633,6 +634,7 @@ static PyObject *Material_getSssBack( BPy_Material * self );
static PyObject *Material_getFilter( BPy_Material * self );
static PyObject *Material_getTranslucency( BPy_Material * self );
static PyObject *Material_getTextures( BPy_Material * self );
+static PyObject *Material_getTexChannel( BPy_Material * self );
static PyObject *Material_clearIpo( BPy_Material * self );
static PyObject *Material_setTexture( BPy_Material * self, PyObject * args );
@@ -1140,7 +1142,11 @@ static PyGetSetDef BPy_Material_getseters[] = {
NULL},
{"lightGroup",
(getter)Material_getLightGroup, (setter)Material_setLightGroup,
- "Set the light group for this material",
+ "The light group for this material",
+ NULL},
+ {"enabledTextures",
+ (getter)Material_getTexChannel, (setter)Material_setTexChannel,
+ "Enabled texture channels for this material",
NULL},
{"R",
(getter)Material_getColorComponent, (setter)Material_setColorComponent,
@@ -1517,6 +1523,36 @@ static PyObject *Material_getLightGroup( BPy_Material * self )
return Group_CreatePyObject( self->material->group );
}
+static PyObject *Material_getTexChannel( BPy_Material * self )
+{
+ int i;
+ short mask = 1;
+ PyObject *list = PyList_New(0);
+ if( !list )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "PyList_New() failed" );
+
+ for( i = 0, mask = 1; i < MAX_MTEX ; ++i, mask <<= 1 ) {
+ if( self->material->mtex[i] && (mask & self->material->septex) == 0 ) {
+ PyObject * val = PyInt_FromLong(i);
+ if( !val ) {
+ Py_DECREF( list );
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "PyInt_FromLong() failed" );
+ }
+ if( PyList_Append( list, val ) < 0 ) {
+ Py_DECREF( val );
+ Py_DECREF( list );
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "PyList_Append() failed" );
+ }
+ Py_DECREF( val );
+ }
+ }
+
+ return list;
+}
+
static PyObject *Material_getHaloSize( BPy_Material * self )
{
return PyFloat_FromDouble( ( double ) self->material->hasize );
@@ -1982,6 +2018,57 @@ static int Material_setLightGroup( BPy_Material * self, PyObject * value )
return GenericLib_assignData(value, (void **) &self->material->group, NULL, 1, ID_GR, 0);
}
+static int Material_setTexChannel( BPy_Material * self, PyObject * value )
+{
+ int i, mask;
+ short septex = 0;
+ int result = 1;
+
+ /* fail if input is not a standard sequence */
+ if( !PyList_Check( value ) && !PyTuple_Check( value ) )
+ return EXPP_ReturnIntError( PyExc_TypeError,
+ "expected tuple or list of integers" );
+
+ /* get a fast sequence; in Python 2.5, this just return the original
+ * list or tuple and INCREFs it, so we must DECREF */
+ value = PySequence_Fast( value, "" );
+
+ /* set the disable bit for each existing texture */
+ for( i= 0, mask= 1; i < MAX_MTEX; ++i, mask <<= 1 )
+ if( self->material->mtex[i] != NULL )
+ septex |= mask;
+
+ /* check the list, and build new septex value */
+ for( i= PySequence_Size(value)-1; i >= 0; --i ) {
+ long ival;
+ PyObject *item = PySequence_Fast_GET_ITEM( value, i );
+ if( !PyInt_Check( item ) ) {
+ PyErr_SetString ( PyExc_TypeError,
+ "expected tuple or list of integers" );
+ goto exit;
+ }
+ ival= PyInt_AsLong( item );
+ if(ival < 0 || ival > MAX_MTEX) {
+ PyErr_SetString( PyExc_ValueError,
+ "channel value out of range" );
+ goto exit;
+ }
+ ival&= (1<<MAX_MTEX)-1;
+ if( self->material->mtex[(int)ival] == NULL ) {
+ PyErr_SetString( PyExc_ValueError,
+ "channels must have a texture assigned" );
+ goto exit;
+ }
+ septex&= ~(1<<ival);
+ }
+ self->material->septex= septex;
+ result = 0;
+
+exit:
+ Py_DECREF(value);
+ return result;
+}
+
static int Material_setAdd( BPy_Material * self, PyObject * value )
{
return EXPP_setFloatClamped ( value, &self->material->add,
@@ -2313,9 +2400,6 @@ static int Material_setSssBack( BPy_Material * self, PyObject * value )
EXPP_MAT_SSS_BACK_MAX);
}
-
-
-
static PyObject *Material_setTexture( BPy_Material * self, PyObject * args )
{
int texnum;
diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c
index 9f68287d658..b3e8fefdb7b 100644
--- a/source/blender/python/api2_2x/Mesh.c
+++ b/source/blender/python/api2_2x/Mesh.c
@@ -5381,11 +5381,11 @@ static PyObject *MFaceSeq_delete( BPy_MFaceSeq * self, PyObject *args )
if( PySequence_Size( args ) != 2 ||
!PyArg_ParseTuple( args, "iO", &edge_also, &args ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected and int and a sequence of ints or MFaces" );
+ "expected an int and a sequence of ints or MFaces" );
if( !PyList_Check( args ) && !PyTuple_Check( args ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected and int and a sequence of ints or MFaces" );
+ "expected an int and a sequence of ints or MFaces" );
/* see how many args we need to parse */
len = PySequence_Size( args );
diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c
index 45cce46d389..dc70921492c 100644
--- a/source/blender/python/api2_2x/Object.c
+++ b/source/blender/python/api2_2x/Object.c
@@ -204,6 +204,7 @@ enum obj_consts {
EXPP_OBJ_ATTR_SB_INSPRING,
EXPP_OBJ_ATTR_SB_INFRICT,
+ EXPP_OBJ_ATTR_EMPTY_DRAWTYPE
};
#define EXPP_OBJECT_DRAWSIZEMIN 0.01f
@@ -2431,6 +2432,12 @@ static int Object_setDrawType( BPy_Object * self, PyObject * value )
OB_BOUNDBOX, OB_TEXTURE, 'b' );
}
+static int Object_setEmptyShape( BPy_Object * self, PyObject * value )
+{
+ return EXPP_setIValueRange( value, &self->object->empty_drawtype,
+ OB_ARROWS, OB_EMPTY_CONE, 'b' );
+}
+
static int Object_setEuler( BPy_Object * self, PyObject * args )
{
float rot1, rot2, rot3;
@@ -3758,6 +3765,9 @@ static PyObject *getIntAttr( BPy_Object *self, void *type )
case EXPP_OBJ_ATTR_DRAWTYPE:
param = object->dt;
break;
+ case EXPP_OBJ_ATTR_EMPTY_DRAWTYPE:
+ param = object->empty_drawtype;
+ break;
case EXPP_OBJ_ATTR_PARENT_TYPE:
param = object->partype;
break;
@@ -4938,6 +4948,10 @@ static PyGetSetDef BPy_Object_getseters[] = {
(getter)getIntAttr, (setter)Object_setDrawType,
"The object's drawing type",
(void *)EXPP_OBJ_ATTR_DRAWTYPE},
+ {"emptyShape",
+ (getter)getIntAttr, (setter)Object_setEmptyShape,
+ "The empty's drawing shape",
+ (void *)EXPP_OBJ_ATTR_EMPTY_DRAWTYPE},
{"parentType",
(getter)getIntAttr, (setter)NULL,
"The object's parent type",
@@ -5538,6 +5552,24 @@ static PyObject *M_Object_IpoKeyTypesDict( void )
return M;
}
+static PyObject *M_Object_EmptyShapesDict( void )
+{
+ PyObject *M = PyConstant_New( );
+
+ if( M ) {
+ BPy_constant *d = ( BPy_constant * ) M;
+ PyConstant_Insert( d, "ARROWS", PyInt_FromLong( OB_ARROWS ) );
+ PyConstant_Insert( d, "AXES", PyInt_FromLong( OB_PLAINAXES ) );
+ PyConstant_Insert( d, "CIRCLE", PyInt_FromLong( OB_CIRCLE ) );
+ PyConstant_Insert( d, "ARROW", PyInt_FromLong( OB_SINGLE_ARROW ) );
+ PyConstant_Insert( d, "CUBE", PyInt_FromLong( OB_CUBE ) );
+ PyConstant_Insert( d, "SPHERE", PyInt_FromLong( OB_EMPTY_SPHERE ) );
+ PyConstant_Insert( d, "CONE", PyInt_FromLong( OB_EMPTY_CONE ) );
+ }
+ return M;
+}
+
+
/*****************************************************************************/
/* Function: initObject */
/*****************************************************************************/
@@ -5552,6 +5584,7 @@ PyObject *Object_Init( void )
PyObject *RBFlagsDict = M_Object_RBFlagsDict( );
PyObject *RBShapesDict = M_Object_RBShapeBoundDict( );
PyObject *IpoKeyTypesDict = M_Object_IpoKeyTypesDict( );
+ PyObject *EmptyShapesDict = M_Object_EmptyShapesDict( );
PyType_Ready( &Object_Type ) ;
@@ -5596,7 +5629,9 @@ PyObject *Object_Init( void )
if( RBShapesDict )
PyModule_AddObject( module, "RBShapes", RBShapesDict );
if( IpoKeyTypesDict )
- PyModule_AddObject( module, "IpoKeyTypes", IpoKeyTypesDict );
+ PyModule_AddObject( module, "IpoKeyTypes", IpoKeyTypesDict );
+ if( EmptyShapesDict )
+ PyModule_AddObject( module, "EmptyShapes", EmptyShapesDict );
/*Add SUBMODULES to the module*/
dict = PyModule_GetDict( module ); /*borrowed*/
diff --git a/source/blender/python/api2_2x/doc/Material.py b/source/blender/python/api2_2x/doc/Material.py
index a3496164cd1..02f7edd77f5 100644
--- a/source/blender/python/api2_2x/doc/Material.py
+++ b/source/blender/python/api2_2x/doc/Material.py
@@ -323,6 +323,21 @@ class Material:
each color a list of 5 floats [0 - 1], [r,g,b,a,pos].
The colorband can have between 1 and 31 colors.
@type colorbandSpecular: list
+ @type enabledTextures: list of integers
+ @ivar enabledTextures: The texture channels enabled in this material.
+ The attribute returns is list of integers in the range [0, 9], each
+ number representing the respective enabled MTex entry (see
+ L{getTextures()<getTextures>}). Enabling is done by assigning
+ a list of ints or an empty list. Attempting to enable a channel
+ which does not have a texture assigned to it will result in a
+ ValueError exception.
+ Example::
+ mat.enabledTextures = [] # no texture channels are enabled
+ mat.enabledTextures = [0, 6] # texture channels 0 and 6 are enabled
+ ch = mat.enabledTextures
+ ch.append(4)
+ mat.enabledTextures = ch
+ print mat.enabledTextures # will print: [0, 4, 6]
@ivar enableSSS: If True, subsurface scattering will be rendered on this material.
@type enableSSS: bool
@@ -1010,7 +1025,7 @@ class Material:
def setTexture(index, texture, texco, mapto):
"""
- Assign a Blender Texture object to slot number 'number'.
+ Assign a Blender Texture object to channel number 'number'.
@type index: int
@param index: material's texture index in [0, 9].
@type texture: Blender Texture
@@ -1033,7 +1048,7 @@ class Material:
Get this Material's Texture list.
@rtype: list of MTex
@return: a list of Blender MTex objects. None is returned for each empty
- texture slot.
+ texture channel.
"""
def getScriptLinks (event):
diff --git a/source/blender/python/api2_2x/doc/Object.py b/source/blender/python/api2_2x/doc/Object.py
index 2e4850aeb14..07942d58093 100644
--- a/source/blender/python/api2_2x/doc/Object.py
+++ b/source/blender/python/api2_2x/doc/Object.py
@@ -117,6 +117,10 @@ Example::
attribute. Only one type can be selected at a time. Values are
BOX, SPHERE, CYLINDER, CONE, and POLYHEDERON
+@type EmptyShapes: readonly dictionary
+@var EmptyShapes: Constant dict used for with L{Object.emptyShape} attribute.
+ Only one type can be selected at a time. Values are
+ ARROW, ARROWS, AXES, CIRCLE, CONE, CUBE AND SPHERE
"""
def New (type, name='type'):
@@ -347,7 +351,7 @@ class Object:
ob.layers = [] # object won't be visible
ob.layers = [1, 4] # object visible only in layers 1 and 4
ls = o.layers
- ls.append([10])
+ ls.append(10)
o.layers = ls
print ob.layers # will print: [1, 4, 10]
B{Note}: changes will only be visible after the screen (at least
@@ -525,6 +529,8 @@ class Object:
@ivar drawType: The object's drawing type.
See L{DrawTypes} constant dict for values.
@type drawType: int
+ @ivar emptyShape: The empty drawing shape.
+ See L{EmptyShapes} constant dict for values.
@ivar parentType: The object's parent type. Read-only.
See L{ParentTypes} constant dict for values.
@type parentType: int