I have red some gamedev articles. Some people say that it would be better to use Transformation Matrices than Vectors3f for moving, rotating, scaling objects. I just want to ask professionals - what will be better to use in a small project? Vectors or Matrices.
As I understand that Matrices are more complex, but more advanced. I should make Rotation, Move, Scale matrices to apply each matrix to an object.
As far as im concerned the movement with Vectors is automaticly computed to a transformation matrix… So its quite unecessary to do all this computation yourself, isnt it?
So, we can make NPCs movements with Vectors and everything will be fine?
There are many reasons to keep them separate.
A movement vector can be used to move the object directly. A transformation matrix will include rotation and so isn’t really good at just moving an object forward. You’ll go through a lot of trouble when a simple pos.addLocal( moveVector ) would have done.
For rotation, Quaternion is superior. It’s only 4 floats and is easier to make sure it’s valid. A 3x3 or 4x4 matrix occasionally will have to be fixed for accumulated floating point errors to make sure it is still a proper rotation matrix (ie: all columns are orthogonal vectors, etc).
If you always want to incorporate scaling, rotation, and translation into one object and accumulate scaling, rotations, and translation together then a 4x4 transformation matrix is the only way to go.
If you only want to keep translation and orientation and you will frequently be operating on these separately (ie: moving translation without rotating or rotating without moving translation) then I think a Vector3f and a Quaternion are the best. And you’ll save a bit of math and a little memory in the process.
And I’d note: jme3 has a Transform class that in many ways acts like a 4x4 matrix but keeps separate position, scale, and rotation internally. You just can’t accumulate them quite like a 4x4… but really you almost never need that.
WOW! Thanks for answering!
Can you tell what TRANSFORM classes and what methods are most important for rotation, location, scale in last case you described?
I found in javadoc:
com.jme.math.TransformMatrix - where methods - get/set rotation/translation with matrix3f. I should apply a Matrix3f to rotation Matrix?
com.jme.math.TransformQuaternion - where methods - setRotationQuaternion, setScale, setTranslation. I should apply vectors and quaternions to a Spatial?
I’m not sure where you see those. Is this jme3?
I was talking about:
Internally it keeps a Vector3f for position, a Vector3f for scale, and a Quaternion for rotation. It acts similarly to a Matrix4f in the sense that transform() will apply scale, rotation, and translation in a similar order. However, you can also get direct access to the individual parts.
From my reading, this is what is used internally to Node/Spatial for parent/child transformation.
Oh, sorry! it was jme2.
THANK YOU FOR YOUR EXPLANATION!!!