Particle Submodule , modified : New function, and added :GetParticlesLoc function
Closed, ArchivedPublic

Description

Little modif to connect the Particle Effect to a mesh object :

/*****************************************************************************/
/* 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 */
/*****************************************************************************/

A new procedure from scratch to get the particles locations as a python list
of 3D coordinates :

/*****************************************************************************/
/* 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 */
/*****************************************************************************/

They seem to work correctly on a blender compilation made with cygwin .
A script to test :
#------------------------------------------------
# PATCH to the Particle submodule of the python API
# To get particles location .
#
# Effect.Particle.New(objectName)
# return a particle effect linked to effect list of the mesh object
# pointed by the namObject
#
# Effect.Particle.GetParticlesLoc(objectName,effectNumber,frame)
# return a list of all particles positions :
# [[x0,y0,z0],[x1,y1,z1],...[xn,yn,zn]]
#
# example of use :
#------------------------------------------------
import Blender
from Blender import Effect, Object,Scene, Mathutils

OBJMAT=Mathutils.Matrix(Object.Get('Cube').getMatrix())

PART=Effect.Particle.New('Cube')
PART.setNormfac(0.5)
#PART.setRandfac(0.01)
PART.setTotpart(100)
PART.setFlag(9)
Blender.Window.RedrawAll()

PARTLOC=Effect.Particle.GetParticlesLoc('Cube',0,50)

SC=Scene.getCurrent()
for e in PARTLOC :
#VEC=Mathutils.Vector([e[0],e[1],e[2],1.0])
#VEC=OBJMAT*VEC
emp=Object.New('Empty')
SC.link(emp)
#emp.setLocation(VEC[0],VEC[1],VEC[2])
emp.setLocation(e)
Blender.Window.RedrawAll()

Details

Type
Patch