I am attempting to write an expression which puts motion vectors into rgbPP for regular Maya particles.
I got as far as this:
//multiplier float $mult=0.5; //velocity vector $vel=particleShape1.velocity; float $xvel=$vel.x; float $yvel=$vel.y; float $zvel=$vel.z; //rgbPP particleShape1.rgbPP=<<($mult*$xvel),($mult*$yvel),0>>;
which does indeed do the job, just as long as the camera is pointing exactly down the z-axis. Fine, but of limited use. Now I need a bit of help with some vector transformation maths.
Ideally I want to get the motion vectors to work from my camera, whatever direction it is pointing.
I think I can get the unit vector to the camera:
//camera vector $camPos=`getAttr camera1.translate`; float $xCamPos = $camPos.x; float $yCamPos = $camPos.y; float $zCamPos = $camPos.z; vector $camUnitAngle = `unit<<$xCamPos,$yCamPos,$zCamPos>>`; float $xCamUnitAngle=$camUnitAngle.x; float $yCamUnitAngle=$camUnitAngle.y; float $zCamUnitAngle=$camUnitAngle.z;
(is that right???)
I think I need to multiply the inverse of this unit vector by the particle’s velocity but I am not sure how to do that. (I should have paid more attention to my maths teacher in that hot summer of 1976…) Any help would be gratefully received !
I should also let you know that I have no Python at all (yet)