Changing Sprites Orientation

August,2003

no changed
The sprites can map a texture image or image sequence on each particle. Here is a number of particles emitted from an Omni. Notice the arrows do not point at where it is flying to. So this is a doc about how to orient sprites to their on-screen velocity direction.
matrix product
First of all, we need a vector product utility created in the hypershade. It will transform the UP vector from "Camera" spase to "World" space. Rename it to "camera_to_world".










input1Y
Set "input1" to <<0,1,0>>,and choose "Vector Matrix Product" as the operation.
connect
Connect the "Xform Matrix" of the rendering camera to the "Matrix" of the vector  product.
add paricle attribute
Now add atribute "spriteTwistPP" to the particle.
vector $up=<<0,1,0>>;
vector $cameraup=<<camera_to_world.outputX,camera_to_world.outputY,camera_to_world.outputZ>>;
vector $ref = cross($up,$cameraup);
float $ang=acos(dot($up,unit(particleShape1.worldVelocity)))/3.14*180;

if(dot($ref,particleShape1.worldVelocity)>0)
    particleShape1.spriteTwistPP=$ang;
else
    particleShape1.spriteTwistPP=-$ang;

Then a Runtime expression like above.
aliagned
This approach only works when the camera is looking down, or you will have to edit the expression and use the negative velue of the twist angle.
a test
Download a test scene here.