2
$\begingroup$

Blender Animation Nodes (BAN)

How does the Blender user obtain the Particle Rotation Data in a later version of BAN, visible in a previous version of BAN?

Short and sufficient answer please.

A comment below has led me to include the screen capture below

enter image description here

What might the term "pattern-matching" mean in the image above?

All responses within 48 hours have the same priority. No need to rush. I may not be able to see responses for that amount of time.


enter image description here


BAN Earlier Version

On the left side of a previous image is a Particle Info Node with Rotation output enabled


BAN Later Version

On the right side of the previous image is a Particle Data Node with Velocities output enabled.

The user does not see the Rotation output available.

$\endgroup$
  • 1
    $\begingroup$ While there are other outputs available, see node properties for other values to display, the rotation is not there. This has already been reported as an issue on github. $\endgroup$ – sambler Apr 21 '18 at 11:18
1
$\begingroup$

Rotation data is stored as unit quaternions in Particle data as stated in the API. And since it is a bpy_prop_collection, it allows fast access through the foreach_get function. So, we initialize a quaternion list with length equal to the number of particles using this expression:

QuaternionList(length = len(system.particles))

Then foreach_get is used to copy the quaternion data from the particles to the initialized list using this expression:

(system.particles.foreach_get("rotation", quaternions.asMemoryView()), quaternions)[1]

The creation of the tuple and sampling of the second element is just to make sure quaternions are actually returned from the expression node. So the node tree is as follows:

Node Tree

You can now convert this to Eulers using the Convert Rotation Type Node and use it as you wish. The output list, however, is not masked based on the alive status of the particles, meaning all particles are output even if they are dead or aren't born yet. To mask it, we can first get the alive_state of each particle, to do this we can use a list comprehension (since foreach_get doesn't support string data, and alive_state is either "DEAD", "UNBORN", "ALIVE" or "DYING"):

[particle.alive_state for particle in system.particles]

But we actually want a boolean that tells us whether or not this particle should be kept, and we can do this by some if and logic statements. For instance, to get the particles that are alive or unborn, we can write:

[particle.alive_state == "ALIVE" or particle.alive_state == "UNBORN" for particle in system.particles]

We can then use the Mask List Node to mask the quaternion list based on this boolean list:

Mask Node Tree

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.