How to get scale vector of objects
#1
Hi all, first poster here.

I really love TyFlow, its such a gamechanger, I just wish I would be smarter in using it...
I work on a small case study here, where a couple of cubes are changing scale more or less randomly.



Those cubes shall produce different particles according to whether they are scaling up or scaling down.
Like sparks when they grow and debris when shrinking. I managed to get particles depending on their movement with the filter option in the spawn operator, but cant find any way to seperate them by up or down scalement.

Does anybody has an idea?

Thx in advance, hope You understand my gibberish
  Reply
#2
There's not a built-in way to measure scale delta, but you could easily do it in a Script operator.

Basically, just grab the magnitude of the scale vector of a particle and check if it's bigger or smaller than the previous magnitude of the particle's scale vector (if it's larger, it means the particle is growing, etc). After you're done the check, save the magnitude value to a custom properties channel so that the current value becomes the previous value in the next time step. Default custom property float values are 0, so you can check for a previous value of 0 to ensure you don't try a comparison before any previous value was saved (ie, on the first frame of your sim).

The code inside your Script for loop would be something like:

Code:
float mag = tf.GetScale(sInx).magnitude;
float prevMag = tf.GetCustomFloat(sInx, "scaleMag");
if (prevMag > mag && prevMag != 0)
{
     //particle is shrinking so spawn some sparks or whatever here
}
tf.SetCustomFloat(sInx, "scaleMag", mag);
  Reply
#3
Thx a ton...

I think I know some of those words.. ;-)
As soon as I am back in the office, I will give it a try, thx again for now!

Cheers
  Reply
#4
I am so sorry for coming back at this, but I was trying make it work for the last 4 hours.
After a couple of tutorials and reading the list of commands in the editor, I got stuck.

I managed to insert the code You posted here in the editor without getting errors, but I am just not able to
spawn particles from there.
Especially this line if where I fail:

//particle is shrinking so spawn some sparks or whatever here

Could You guide me just a little bit further, so I can generate these different particle types?
Thx in advance (again!)
  Reply
#5
You just have to call "tf.NewParticle()", wherever you want to spawn a new particle. The return value of that function is the simulation index of the new particle, which you can then manipulate however you want.
  Reply
#6
(12-09-2019, 11:34 PM)tyFlow Wrote: You just have to call "tf.NewParticle()", wherever you want to spawn a new particle. The return value of that function is the simulation index of the new particle, which you can then manipulate however you want.

Thx for the answer and Your time.
I will give that a try.

Best wishes,
-André
  Reply


Forum Jump: