? source/creator/winbuildinfo.h ? tools/Blender.pyc ? tools/__init__.pyc ? tools/bcolors.pyc ? tools/btools.pyc Index: source/blender/python/api2_2x/Effect.c =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Effect.c,v retrieving revision 1.23 diff -u -r1.23 Effect.c --- source/blender/python/api2_2x/Effect.c 30 Nov 2005 20:18:54 -0000 1.23 +++ source/blender/python/api2_2x/Effect.c 8 Aug 2006 15:39:08 -0000 @@ -32,15 +32,19 @@ #include "Effect.h" /*This must come first */ #include "DNA_object_types.h" +#include "DNA_scene_types.h" /* for G.scene->r.cfra */ #include "BKE_global.h" #include "BKE_main.h" #include "BKE_effect.h" #include "BKE_object.h" #include "BKE_deform.h" +#include "BKE_scene.h" /* for G.scene->r.cfra */ +#include "BKE_ipo.h" /* frame_to_float() */ #include "BLI_blenlib.h" #include "gen_utils.h" #include "blendef.h" - +#include "Vector.h" + #define EXPP_EFFECT_STA_MIN -250.0f #define EXPP_EFFECT_END_MIN 1.0f #define EXPP_EFFECT_LIFETIME_MIN 1.0f @@ -104,6 +108,8 @@ /*****************************************************************************/ static PyObject *Effect_getType( BPy_Effect * self ); static int Effect_setType( void ); +static PyObject *Effect_getStype( BPy_Effect * self ); +static int Effect_setStype( BPy_Effect * self, PyObject * args ); static PyObject *Effect_getFlag( BPy_Effect * self ); static int Effect_setFlag( BPy_Effect * self, PyObject * args ); static PyObject *Effect_getSta( BPy_Effect * self ); @@ -160,9 +166,10 @@ static int Effect_setVertGroup( BPy_Effect * self, PyObject * a ); static PyObject *Effect_getSpeedVertGroup( BPy_Effect * self ); static int Effect_setSpeedVertGroup( BPy_Effect * self, PyObject * a ); -static PyObject *Effect_getParticlesLoc( BPy_Effect * self, PyObject * a ); +static PyObject *Effect_getParticlesLoc( BPy_Effect * self ); static PyObject *Effect_oldsetType( void ); +static PyObject *Effect_oldsetStype( BPy_Effect * self, PyObject * args ); static PyObject *Effect_oldsetFlag( BPy_Effect * self, PyObject * args ); static PyObject *Effect_oldsetSta( BPy_Effect * self, PyObject * a ); static PyObject *Effect_oldsetEnd( BPy_Effect * self, PyObject * a ); @@ -222,6 +229,10 @@ METH_NOARGS, "() - Return Effect type"}, {"setType", ( PyCFunction ) Effect_oldsetType, METH_VARARGS, "() - Set Effect type"}, + {"getStype", ( PyCFunction ) Effect_getStype, + METH_NOARGS, "() - Return Effect stype"}, + {"setStype", ( PyCFunction ) Effect_oldsetStype, + METH_VARARGS, "() - Set Effect stype"}, {"getFlag", ( PyCFunction ) Effect_getFlag, METH_NOARGS, "() - Return Effect flag"}, {"setFlag", ( PyCFunction ) Effect_oldsetFlag, @@ -302,7 +313,7 @@ METH_NOARGS, "()-Return particle life time"}, {"setDefvec", ( PyCFunction ) Effect_oldsetDefvec, METH_VARARGS, "()- Sets particle life time "}, - {"getParticlesLoc", ( PyCFunction ) Effect_getParticlesLoc, METH_VARARGS, + {"getParticlesLoc", ( PyCFunction ) Effect_getParticlesLoc, METH_NOARGS, "()- Sets particle life time "}, {NULL, NULL, 0, NULL} }; @@ -315,6 +326,10 @@ (getter)Effect_getFlag, (setter)Effect_setFlag, "The particle flag bitfield", NULL}, + {"stype", + (getter)Effect_getStype, (setter)Effect_setStype, + "The particle stype bitfield", + NULL}, {"type", (getter)Effect_getType, (setter)Effect_setType, "The effect's type (deprecated)", @@ -758,6 +773,27 @@ return 0; } +static int Effect_setStype( BPy_Effect * self, PyObject * args ) +{ + short param; + if( !PyArg_Parse( args, "h", ¶m ) ) + return EXPP_ReturnIntError( PyExc_TypeError, + "expected an int as argument" ); + self->effect->stype |= 1-param; + return 0; +} + +static PyObject *Effect_getStype( BPy_Effect * self ) +{ + PyObject *attr; + long stype = (long)( self->effect->stype ); + + attr = PyInt_FromLong( stype ); + if( attr ) return attr; + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "couldn't get Effect.stype attribute" ); +} + static PyObject *Effect_getFlag( BPy_Effect * self ) { PyObject *attr; @@ -1383,53 +1419,134 @@ /* Method: getParticlesLoc */ /* Python equivalent: effect.getParticlesLoc */ /* Description: Get the current location of each particle */ -/* and return a list of 3D coords */ -/* Data: float currentframe */ -/* Return: One python list of python lists of 3D coords */ +/* and return a list of 3D vectors */ +/* or a list of ists of two 3D vectors */ +/* if effect.vect has any sense */ +/* Data: notihng get the current time from G.scene */ +/* Return: One python list of 3D vector */ /*****************************************************************************/ -static PyObject *Effect_getParticlesLoc( BPy_Effect * self, PyObject * args ) +static PyObject *Effect_getParticlesLoc( BPy_Effect * self ) { - Object *ob; + Object *object_iter; + Effect *eff, *eff1; PartEff *paf; - Particle *pa; + Particle *pa=0; + PyObject *list; + float p_time, c_time, vec[3], vec1[3],cfra, m_time, s_time; int a; - PyObject *list; - float p_time, c_time, vec[3], cfra; + short disp=100 ; - if( !PyArg_ParseTuple( args, "f", &cfra) ) - return EXPP_ReturnPyObjError( PyExc_TypeError, - "expected float argument" ); +cfra=frame_to_float( G.scene->r.cfra ); + + object_iter = G.main->object.first; + if( !object_iter ) + return ( EXPP_ReturnPyObjError( PyExc_AttributeError, + "Scene contains no object" ) ); - ob = self->object; - paf = (PartEff *)self->effect; +/* as we need to update the particles system we try to retrieve + the object to which the effect is connected */ + eff1 =(Effect *) self->effect; - pa = paf->keys; - if( !pa ) - return EXPP_ReturnPyObjError( PyExc_AttributeError, - "Particles location: no keys" ); - - if( ob->ipoflag & OB_OFFS_PARTICLE ) - p_time= ob->sf; +while( object_iter ) { + if( object_iter->effect.first != NULL ) { + eff = object_iter->effect.first; + if (eff == eff1) { break;} + /* not really needed as there no more than one effect by object */ + eff = eff->next; + } + object_iter = object_iter->id.next; + } + +/*get the particles data */ +paf= (PartEff *)eff; + +/* particles->disp reduce the display number of particles */ +/* as we want the complete list ... */ +if (paf->disp<100) {disp= paf->disp; paf->disp=100;} + +build_particle_system(object_iter); +pa= paf->keys; + + +if(pa==NULL) { +return ( EXPP_ReturnPyObjError + ( PyExc_AttributeError, + " Particles Location : no Keys" ) );} + +/* if object is in motion */ + if( object_iter->ipoflag & OB_OFFS_PARTICLE ) + p_time= object_iter->sf; else p_time= 0.0; - - c_time= bsystem_time( ob, 0, cfra, p_time ); + list = PyList_New( 0 ); if( !list ) return EXPP_ReturnPyObjError( PyExc_MemoryError, "PyList() failed" ); - - for( a=0; atotpart; a++, pa += paf->totkey ) { - if( c_time > pa->time && c_time < pa->time+pa->lifetime ) { - where_is_particle(paf, pa, c_time, vec); - if( PyList_Append( list, Py_BuildValue("[fff]", - vec[0], vec[1], vec[2]) ) < 0 ) { - Py_DECREF( list ); - return EXPP_ReturnPyObjError( PyExc_RuntimeError, - "Couldn't append item to PyList" ); - } - } - } + c_time= bsystem_time( object_iter, 0, cfra, p_time ); + + for( a=0; atotpart; a++, pa += paf->totkey ) { + if(paf->flag & PAF_STATIC ) + { + m_time= pa->time+pa->lifetime+paf->staticstep-1; + for(c_time= pa->time; c_timestaticstep) { + where_is_particle(paf, pa, c_time, vec); + MTC_Mat4MulVecfl(object_iter->obmat, vec); + if( PyList_Append( list, + Py_BuildValue("O",newVectorObject(vec, 3, Py_NEW)) + )< 0 ) { + Py_DECREF( list ); + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "Couldn't append item to PyList" ); + } + } + } + else { + if(c_time > pa->time && c_time < pa->time+pa->lifetime ) + { + + if(paf->stype==PAF_VECT ) { + s_time= c_time; + p_time= c_time+1.0f; + if(c_time < pa->time) { + if(paf->flag & PAF_UNBORN) + p_time= pa->time+1.0f; + else + continue; + } + if(c_time > pa->time+pa->lifetime) { + if(paf->flag & PAF_DIED) + s_time= pa->time+pa->lifetime-1.0f; + else + continue; + } + where_is_particle(paf, pa, s_time, vec); + where_is_particle(paf, pa, p_time, vec1); + if( PyList_Append( list, + Py_BuildValue("[OO]",newVectorObject(vec, 3, Py_NEW), + newVectorObject(vec1, 3, Py_NEW))) < 0 ) { + Py_DECREF( list ); + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "Couldn't append item to PyList" ); + } + } else + { + where_is_particle(paf, pa, c_time, vec); + if( PyList_Append( list, + Py_BuildValue("O",newVectorObject(vec, 3, Py_NEW)) + ) < 0 ) { + Py_DECREF( list ); + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "Couldn't append item to PyList" ); + } + } + } + } + } +if (disp<100){ + paf->disp=disp; + build_particle_system(object_iter); +} return list; } @@ -1582,6 +1699,11 @@ static PyObject *Effect_oldsetFlag( BPy_Effect * self, PyObject * args ) { return EXPP_setterWrapper( (void *)self, args, (setter)Effect_setFlag ); +} + +static PyObject *Effect_oldsetStype( BPy_Effect * self, PyObject * args ) +{ + return EXPP_setterWrapper( (void *)self, args, (setter)Effect_setStype ); } static PyObject *Effect_oldsetType( void ) Index: source/blender/python/api2_2x/doc/Effect.py =================================================================== RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/doc/Effect.py,v retrieving revision 1.10 diff -u -r1.10 Effect.py --- source/blender/python/api2_2x/doc/Effect.py 12 Jul 2006 01:36:07 -0000 1.10 +++ source/blender/python/api2_2x/doc/Effect.py 8 Aug 2006 16:33:21 -0000 @@ -304,6 +304,22 @@ @rtype: None @return: None """ + + def getStype(): + """ + Retrieves the vect state of an effect object. + @rtype: int + @return: the Stype (Vect) of an effect object : 0 , Vect is not enabled, 1, Vect is enabled + (particle effect) + """ + + def setStype(int): + """ + @type int : int + @param int : state of the Stype : 0 not enabled, 1 enabled. + @rtype: None + @return: None + """ def getTexfac(): """ @@ -519,11 +535,35 @@ @return: None """ - def getParticlesLoc ( time ): + def getParticlesLoc(): """ - Get the location of each particle at a given time. - @type time: int - @param time: The desired time during the particle effect. - @rtype: List of x,y,z coordinates - @return: The coordinates of each particle at the requested time. + Gets the location of each particle at the current time . + @type None : None + @param None : None + @rtype: A list of vector or a list of pair of vectors + @return: The coordinates of each particle at the current time or the cordinates + of the boundary of each segment when the particles Vect option is set . + + Example:: + + import Blender + OB=Blender.Scene.getCurrent().getActiveObject() + EF=OB.effects[0] + PA=EF.getParticlesLoc() + + if (EF.getFlag() & Blender.Effect.Flags.STATIC) + or (not EF.getStype()): + for P in PA: + EM=Blender.Object.New('Empty') + EM.setLocation(P) + Blender.Scene.getCurrent().link(EM) + else : + for P in PA: + EM=Blender.Object.New('Empty') + EM.setLocation(P[0]) + Blender.Scene.getCurrent().link(EM) + EM=Blender.Object.New('Empty') + EM.setLocation(P[1]) + Blender.Scene.getCurrent().link(EM) + """