[Closed] Billboard lookat with pFlow
Hello, i have been desperately trying to create a billboard behaviour for particles (used for a forest of 2d trees were only one axis should rotate.)
I found a script in this forum wich creates a transform matrix that matches a vector looking at the target (thanks to the original creator! hope you don’t mind me using it)
Being the beginner scripter i am i need some hints and tips.
The script is inside the standard “update each particle each step” script in pFlow.
-- References to the used nodes
source = pf_node_current
target = $camera01
-- We need the source node to look at the target node, so...
-- Calculates the vector from the source to the target (the view or look vector)
look = normalize (target.pos - source.pos)
-- Take the target's up vector as the temporal source's up vector
tempUp = target.transform.row2
-- Calculates the right vector
right = cross look tempUp
-- Calculates the source's real up vector
up = cross look right
-- Finally calculates the source's matrix transformation
newTM = matrix3 right up look source.transform.translation
This code works well for single mesh objects wich uses quat rotations.
But particles uses XYZ orientation and i’m not sure how to convert the quats in the resulting matrix so they work with the particles.
Also the rotation should only affect one axis (Z) and i’m not sure how to do that with code either. There is a workaround for that issue though, by simply creating a target object that uses the cameras X and Y positions but not the Z. But i rather use code for this if i only knew how.
I know this forum holds many maxscript masterminds who could help me and i would greatly appreciate it. Or if anyone know a better solution than to use raw code i’m happy with that too as long as it don’t involve buying plugins or extra tools.
Thanks!
Why not use PFlow, Shape Facing, you can do exactly this without a need for scripting? You can restrict it to one axis.