Page Menu
Home
Search
Configure Global Search
Log In
Files
F1609
source.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
jean-michel soler (jms)
Nov 13 2013, 12:58 PM
Size
9 KB
Subscribers
None
source.patch
View Options
? source/blender/python/Raccourci vers api2_2x.lnk
Index: source/blender/python/api2_2x/Particle.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Particle.c,v
retrieving revision 1.10
diff -u -r1.10 Particle.c
--- source/blender/python/api2_2x/Particle.c 18 Jul 2005 03:50:37 -0000 1.10
+++ source/blender/python/api2_2x/Particle.c 2 Nov 2005 12:34:02 -0000
@@ -36,8 +36,10 @@
#include "BKE_effect.h"
#include "BKE_global.h"
#include "BKE_main.h"
+#include "BKE_object.h"
#include "gen_utils.h"
+
/*****************************************************************************/
/* Python BPy_Particle methods table: */
/*****************************************************************************/
@@ -126,6 +128,8 @@
METH_NOARGS, "()-Return particle life time"},
{"setDefvec", ( PyCFunction ) Particle_setDefvec, METH_VARARGS,
"()- Sets particle life time "},
+
+
{NULL, NULL, 0, NULL}
};
@@ -168,47 +172,72 @@
char M_Particle_doc[] = "The Blender Particle module\n\n\
This module provides access to **Object Data** in Blender.\n\
Functions :\n\
- New(opt name) : creates a new part object with the given name (optional)\n\
+ New(object mesh's name) : creates a new part object and adds it to the given mesh object \n\
Get(name) : retreives a particle with the given name (mandatory)\n\
- get(name) : same as Get. Kept for compatibility reasons";
-char M_Particle_New_doc[] = "";
+ get(name) : same as Get. Kept for compatibility reasons\n\
+ GetParticlesLoc(object mesh's name, effect num, curframe) : return current particles location\n";
+char M_Particle_New_doc[] = "New(object mesh's name) : creates a new part object and adds it to the given mesh object \n";
char M_Particle_Get_doc[] = "xxx";
+char M_Particle_GetParticlesLoc_doc[] = "GetParticlesLoc(name,effect num, curframe) : current particles locations\n";
+
+
/*****************************************************************************/
/* Python method structure definition for Blender.Particle module: */
/*****************************************************************************/
struct PyMethodDef M_Particle_methods[] = {
- {"New", ( PyCFunction ) M_Particle_New, METH_VARARGS,
- M_Particle_New_doc},
+ {"New", ( PyCFunction ) M_Particle_New, METH_VARARGS, M_Particle_New_doc},
+ {"GetParticlesLoc", M_Particle_GetParticlesLoc, METH_VARARGS, M_Particle_GetParticlesLoc_doc},
{"Get", M_Particle_Get, METH_VARARGS, M_Particle_Get_doc},
{"get", M_Particle_Get, METH_VARARGS, M_Particle_Get_doc},
{NULL, NULL, 0, NULL}
};
+
/*****************************************************************************/
/* Function: M_Particle_New */
/* Python equivalent: Blender.Effect.Particle.New */
+/* Description : Create a particle effect and add a link */
+/* to the given Object mesh */
+/* Data : String mesh object name */
+/* Return : pyobject particle */
/*****************************************************************************/
PyObject *M_Particle_New( PyObject * self, PyObject * args )
{
int type = EFF_PARTICLE;
BPy_Effect *pyeffect;
Effect *bleffect = 0;
+ Object *ob;
+ char *name = NULL;
+ void BLI_addtail(struct ListBase *listbase, void *vlink);
bleffect = add_effect( type );
+
+ if( !PyArg_ParseTuple( args, "s", &name ) )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected string : mesh object name )" ) );
if( bleffect == NULL )
return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't create Effect Data in Blender" ) );
pyeffect = ( BPy_Effect * ) PyObject_NEW( BPy_Effect, &Effect_Type );
-
if( pyeffect == NULL )
return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
"couldn't create Effect Data object" ) );
-
+
pyeffect->effect = bleffect;
-
+ ob = G.main->object.first;
+
+ while( ob ) {
+ if( !strcmp( name, ob->id.name + 2 ) ) {
+ if( ob->type != OB_MESH )
+ return ( EXPP_ReturnPyObjError( PyExc_TypeError,
+ "couldn't create a particule effect on object of this kind . Use an object mesh's name " ) );
+ BLI_addtail(&ob->effect, bleffect);
+ }
+ ob = ob->id.next;
+ }
return ( PyObject * ) pyeffect;
}
@@ -225,6 +254,7 @@
Effect *eff;
BPy_Particle *wanted_eff;
int num, i;
+
if( !PyArg_ParseTuple( args, "si", &name, &num ) )
return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
"expected string int argument" ) );
@@ -250,7 +280,7 @@
if( !eff )
return ( EXPP_ReturnPyObjError
( PyExc_AttributeError,
- "bject" ) );
+ "Object" ) );
}
wanted_eff =
( BPy_Particle * ) PyObject_NEW( BPy_Particle,
@@ -264,6 +294,94 @@
return Py_None;
}
+
+/*****************************************************************************/
+/* Function: GetParticlesLoc */
+/* Python equivalent: Blender.Effect.Particle.GetParticlesLoc */
+/* Description: Get the current location of each particle */
+/* and return a list of 3D coords */
+/* Data: String object name, int particle effect number, */
+/* float currentframe */
+/* Return: One python list of python lists of 3D coords */
+/*****************************************************************************/
+PyObject *M_Particle_GetParticlesLoc( PyObject * self, PyObject * args )
+{
+ char *name = 0;
+ Object *object_iter;
+ Effect *eff;
+ PartEff *paf;
+ Particle *pa=0;
+ int num, i, a;
+ PyObject *list;
+ float p_time, c_time, vec[3],cfra;
+
+ float bsystem_time(struct Object *ob, struct Object *par, float cfra, float ofs);
+
+ if( !PyArg_ParseTuple( args, "sif", &name, &num , &cfra) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected string int float argument" ) );
+
+ object_iter = G.main->object.first;
+ if( !object_iter )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "Scene contains no object" ) );
+
+ while( object_iter ) {
+ if( strcmp( name, object_iter->id.name + 2 ) ) {
+ object_iter = object_iter->id.next;
+ continue;
+ }
+
+ if( object_iter->effect.first != NULL ) {
+ eff = object_iter->effect.first;
+ for( i = 0; i < num; i++ ) {
+ if( eff->type != EFF_PARTICLE )
+ continue;
+ eff = eff->next;
+ if( !eff )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ "Object" ) );
+ }
+ break ; //return ( PyObject * ) wanted_eff;
+ }
+ object_iter = object_iter->id.next;
+ }
+
+ /*if( mat==NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "no Object Matrix available ." ) );*/
+
+ paf= (PartEff *)eff;
+ pa= paf->keys;
+ if(pa==NULL) {return ( EXPP_ReturnPyObjError
+ ( PyExc_AttributeError,
+ " Particles Location : no Keys" ) );}
+
+ if(object_iter->ipoflag & OB_OFFS_PARTICLE) p_time= object_iter->sf;
+ else p_time= 0.0;
+
+ c_time= bsystem_time(object_iter, 0, cfra, p_time);
+ list = PyList_New(0);
+
+ for(a=0; a<paf->totpart; a++, pa+=paf->totkey) {
+ if(c_time > pa->time) {
+ if(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 )
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "Couldn't add item to list" );
+ }
+ }
+ }
+
+ return list;
+}
+
+
/*****************************************************************************/
/* Function: Particle_Init */
/*****************************************************************************/
@@ -272,8 +390,7 @@
PyObject *submodule;
Particle_Type.ob_type = &PyType_Type;
submodule =
- Py_InitModule3( "Blender.Particle", M_Particle_methods,
- M_Particle_doc );
+ Py_InitModule3( "Blender.Particle", M_Particle_methods, M_Particle_doc );
return ( submodule );
}
@@ -745,7 +862,6 @@
Py_INCREF( Py_None );
return Py_None;
}
-
/*****************************************************************************/
Index: source/blender/python/api2_2x/Particle.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Particle.h,v
retrieving revision 1.6
diff -u -r1.6 Particle.h
--- source/blender/python/api2_2x/Particle.h 18 Jul 2005 03:50:37 -0000 1.6
+++ source/blender/python/api2_2x/Particle.h 2 Nov 2005 12:30:32 -0000
@@ -54,7 +54,7 @@
/*****************************************************************************/
PyObject *M_Particle_New( PyObject * self, PyObject * args );
PyObject *M_Particle_Get( PyObject * self, PyObject * args );
-
+PyObject *M_Particle_GetParticlesLoc( PyObject * self, PyObject * args );
#include"Effect.h"
@@ -103,7 +103,6 @@
PyObject *Particle_setChild( BPy_Particle * self, PyObject * a );
PyObject *Particle_getDefvec( BPy_Particle * self );
PyObject *Particle_setDefvec( BPy_Particle * self, PyObject * a );
-
/*****************************************************************************/
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
b3/0a/9ffa9bc8a317637f323f93f03d26
Event Timeline
Log In to Comment