Particle Submodule , modified : New function, and added :GetParticlesLoc function #3328

Closed
opened 2005-11-02 13:56:53 +01:00 by jean-michel soler · 2 comments

%%%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

  • 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- ,e- ,e- ,1.0])
  • VEC=OBJMAT*VEC
 emp=Object.New('Empty')
 SC.link(emp)

#emp.setLocation(VEC- [x],VEC- [x],VEC[2])

 emp.setLocation(e)

Blender.Window.RedrawAll()

%%%

%%%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- [x],e- [x],e- [x],1.0]) - VEC=OBJMAT*VEC ``` emp=Object.New('Empty') SC.link(emp) ``` #emp.setLocation(VEC- [x],VEC- [x],VEC[2]) ``` emp.setLocation(e) ``` Blender.Window.RedrawAll() %%%

Changed status to: 'Open'

Changed status to: 'Open'
Member

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#3328
No description provided.