# pouët.net

## Camera rotation based on Camera.view > target vector

category: general [glöplog]
Ok, after 8 hours messing with all this I think I got the move to matrices done \o/

So I had to figure out how to create matrix transformations for each object. What I'm doing now is at the end of setting up the new position/rotation/scale of an object, I have a function that generated the matrix that will transform all the vertices on it.

It looks like this:

Code:```public function updateTransform() : void { transform = Matrix3D.translationMatrix(x, y, z); transform.multiply( transform, Matrix3D.rotationXMatrix( rotationX ) ); transform.multiply( transform, Matrix3D.rotationYMatrix( rotationY ) ); transform.multiply( transform, Matrix3D.rotationZMatrix( rotationZ ) ); transform.multiply( transform, Matrix3D.scaleMatrix( scale, scale, scale ) ); }```

It seems to be working quite well! ^^ But I'm just posting it here in case I'm doing something in the wrong order. I've realised that the scale matrix is the last thing to do, I guess the others doesn't matter much...

Is there a way to generate a Matrix with all the rotation components at once?

PS: This has been pretty handy.
Code:``` initEuler(Matrix4f m, float ry, rx, rz) { float cx,cy,cz; float sx,sy,sz; cx = cos(rx); cy = cos(ry); cz = cos(rz); sx = sin(rx); sy = sin(ry); sz = sin(rz); m = [cx*cz - sx*sy*sz , -cy*sz, sx*cz + cx*sy*sz, 0, cx*sz + sx*sy*cz , cy*cz , sx*sz - cx*sy*cz, 0, -sx*cy , sy , cx*cy , 0, 0 , 0 , 0 , 1 ]; } ```