How to move partices along local axis using script?
#1
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.
  Reply
#2
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.
  Reply
#3
You made my first script working Smile Thank you!
Also I noticed small mistype in script manual: [Marix3] GetTM(int sInx)
  Reply
#4
Ah, thanks! Will fix Smile
  Reply
#5
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?
  Reply
#6
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...Matrix3.cs

To rotate any given matrix, create a rotated identity matrix and then multiply that on the left side of your target matrix.
  Reply
#7
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!
  Reply
#8
(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);
        }        
    }    
}
  Reply
#9
Script:
https://pastebin.com/ZY8T5jwR

You only need to change "move" value
  Reply
#10
(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
  Reply


Forum Jump: