I have a billboard deep inside a 3D scene node hierarchy. The billboard inherits all 3D transformations applied to parent nodes.
I want the billboard to always “face the camera” (= have a zero derived rotation vector). The problem is that its derived matrix is read-only so I can’t manipulate it directly to nullify rotation (as proposed in another case).
What I can do is manipulate its local matrix so that the final derived matrix meets my requirements.
Is there a formula to achieve this?
As long as you don’t use the homogeneous portion of the matrix, you can always do this.
A*B + B*A = C, where B = {0,0,0,0;0,0,0,0;0,0,0,0;0,0,0,1}
This should give you C = {0,0,0,s; 0,0,0,s; 0,0,0,s; x,y,z,2*w} where s is a scaling value and this is column oriented, meaning {1,2,3,4; 1,2,3,4} would be 4×2 matrix (4 rows two columns).
Hope this helps.