tyFlow Forum
How to move partices along local axis using script? - Printable Version

+- tyFlow Forum (https://forum.tyflow.com)
+-- Forum: tyFlow Discussion (https://forum.tyflow.com/forum-1.html)
+--- Forum: General Discussion (https://forum.tyflow.com/forum-2.html)
+--- Thread: How to move partices along local axis using script? (/thread-1288.html)



How to move partices along local axis using script? - ThirdDimension - 11-20-2019

Hi,

Does anyone know how to move particles along local axis using script operator? For example: add 10 units to local Z axis.
Using SetPos() I can only move particles in world-space but not local.


RE: How to move partices along local axis using script? - tyFlow - 11-20-2019

Get the particle TM...then use the appropriate row as your axis of movement.

So if you want to move the particle along its z-axis by 10 units, you'd add (particleTM.row3 * 10) to its position.


RE: How to move partices along local axis using script? - ThirdDimension - 11-20-2019

You made my first script working Smile Thank you!
Also I noticed small mistype in script manual: [Marix3] GetTM(int sInx)


RE: How to move partices along local axis using script? - tyFlow - 11-21-2019

Ah, thanks! Will fix Smile


RE: How to move partices along local axis using script? - ThirdDimension - 11-29-2019

I have similar question to last one only about local rotation. After few days of research I found that max script has rotateZmatrix function to apply rotation to existing matrices. In tyFlow there is no such function. So basically to do this in tyFlow I need to manually write equation for TM rotation?


RE: How to move partices along local axis using script? - tyFlow - 11-29-2019

Yes at the moment there are no Matrix3 rotation functions in tyFlow....so you're on your own for that Smile

Here's a page with some applicable math:

https://github.com/andykorth/opentk/blob/master/Source/OpenTK/Math/Matrix3.cs

To rotate any given matrix, create a rotated identity matrix and then multiply that on the left side of your target matrix.


RE: How to move partices along local axis using script? - ThirdDimension - 11-30-2019

I don't know how, but with some dark magic I got this rotation working. That generalization you wrote helped me a lot. Thank you!


RE: How to move partices along local axis using script? - FirePro - 02-07-2020

(11-20-2019, 07:43 PM)tyFlow Wrote: Get the particle TM...then use the appropriate row as your axis of movement.

So if you want to move the particle along its z-axis by 10 units, you'd add (particleTM.row3 * 10) to its position.

Hi, I have same task - need move particles along their local Y-axis (500mm). Can you help me? Thank you.

Code:
public void simulationStep()
{    
    for (int i = 0; i < eventParticleCount; i++)
    {
        int sInx = tf.GetSimIndex(i);

        float eventAge = tf.GetEventAge(sInx);

        if (eventAge == 0)
        {
            Matrix3 particleTM = tf.GetTM(sInx);
            //What I need place here for move particles along their local Y-axis (500mm)
            tf.SetTM(sInx, particleTM);
        }        
    }    
}



RE: How to move partices along local axis using script? - ThirdDimension - 02-07-2020

Script:
https://pastebin.com/ZY8T5jwR

You only need to change "move" value


RE: How to move partices along local axis using script? - FirePro - 02-07-2020

(02-07-2020, 10:26 AM)ThirdDimension Wrote: Script:
https://pastebin.com/ZY8T5jwR

You only need to change "move" value

Thank you very much! It work


RE: How to move partices along local axis using script? - FirePro - 11-29-2021

(11-29-2019, 06:47 PM)ThirdDimension Wrote: I have similar question to last one only about local rotation. After few days of research I found that max script has rotateZmatrix function to apply rotation to existing matrices. In tyFlow there is no such function. So basically to do this in tyFlow I need to manually write equation for TM rotation?

Hi!
Did you solve this task?
I have the same problem, can you help?
I need to rotate the particles on the local z-axis randomly
Thank you!


RE: How to move partices along local axis using script? - tyFlow - 12-01-2021

The Spin operator has local axis options.

Also if you need to fine-tune rotations, the Script operator now has matrix rotation functions.