How to retrieve a value from a child particle
#1
Question 
I am trying to retrieve the velocity megnitude value from child particles in the wobble.
For ex in the grass example scene, the first event containing the grass changes oriantation based on the position of the child particles. There is no force applied to the parent particle, but they are applied in the second event to the child particles which allows for the spring effect.
What I'm trying to do is to get that velocity magnitude value from those child particles and use that in the mapping operator of the parent particles (the grass).
  Reply
#2
(12-05-2019, 12:03 PM)oumoumad Wrote: I am trying to retrieve the velocity megnitude value from child particles in the wobble.
For ex in the grass example scene, the first event containing the grass changes oriantation based on the position of the child particles. There is no force applied to the parent particle, but they are applied in the second event to the child particles which allows for the spring effect.
What I'm trying to do is to get that velocity magnitude value from those child particles and use that in the mapping operator of the parent particles (the grass).


Answering myself to share a solution I just came up with.
Ended up achieving this through scripting, I noticed the IDs of the child particles come respectively after the parent particles, meaning the child for ID 1 is same as 101 if there are 100 particles in total.
So this is my working script :
Code:
for (int i = 0; i < eventParticleCount; i++)                
    {
        int sInx = tf.GetSimIndex(i); //simulation index for the event particles
        int childSInx = sInx + eventParticleCount ;  // simulation index for the child particles
        Point3 childVel = tf.GetVel(childSInx); // velocity of the child particles
        tf.SetCustomFloat(sInx, "childVel", childVel.magnitude)    ; // setting a custom float property with the velocity magnitude of the child particles
    }

Something tells me there is much simpler/intellegent ways to achieve this, so pelase let me know.
  Reply
#3
Pretty simple with no scripting required: you can set the target of your wobble particles to parent using a Set Target operator, and then use a Custom Properties operator to set values in the target...in your case, velocity.
  Reply
#4
I did try to do that initially, for some reason I couldn't figure out the proper way to make it work ^^', I'm sorry I'm really a beginner in tyflow.
What I did basically is this :
- Set target operator in the second event (wobble particles), Target > parent
- custom properties on parent particles (first event) with data source set to Value (target). At this point I tested many things, switching both value and channel to target, selecting the channel in custom float (since it's magnitude)... In the beginning it seemed all simple but at one point I started to get really confused ^^'. So I just done it through scripting.
  Reply


Forum Jump: