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.
added on the 2009-01-20 19:52:53 by mrdoob mrdoob
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 ]; }


added on the 2009-01-20 19:55:10 by xyz xyz
also read this
added on the 2009-01-20 19:57:50 by xyz xyz
That's just where I come from!!

Hehe, well I guess angles are good for rotating objects, but not as a base for projecting the vertices.
added on the 2009-01-20 20:01:01 by mrdoob mrdoob
well, the field of view (FOV) is also an angle :)

even if you do not use OpenGL, take a look here to see how a perspective projection matrix is built.
added on the 2009-01-20 20:04:04 by xyz xyz
single vectors for rotation are also sucky, use 3 axes (with quaternions) so you can do spherical (or quadratic) interpolation nicely :-)
added on the 2009-01-20 20:28:28 by Jcl Jcl

login