Hi everyone,
My current object requires me to transform one object with a given transformation matrix (4 by 4). Looks like there is no API for this function. Be more specific, what I want is given a transformation matrix A, I somehow get the current modelview matrix B, and set B = A*B to change its location, rotation and scale. If you know OpenGL, what I ask is very similar to the function glMultMatrix to change the location of the model.
Any suggestions about how should I do this? Thanks very much.
How to move an object based on a transformation matrix
Re: How to move an object based on a transformation matrix
It's not the fastest solution as it adds additional transformations for the nodes, but you can use a addDummyTransformationSceneNode as parent of your node. And then set getRelativeTransformationMatrix () (which returns a reference) to your matrix.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: How to move an object based on a transformation matrix
thanks, I think this would work for me.CuteAlien wrote:It's not the fastest solution as it adds additional transformations for the nodes, but you can use a addDummyTransformationSceneNode as parent of your node. And then set getRelativeTransformationMatrix () (which returns a reference) to your matrix.
Re: How to move an object based on a transformation matrix
Irrlicht splits matrices into world view and proj, so modelview is actually a concatenation of two matrices in the engine. All you really need to do is get the relative transformation matrix and multiply it by the matrix A, then get the position, scale and rotation and set it on the object again.
If you know plain GL and matrices, and need instancing with LoD.. you should check out my fork.
I changed ISceneNode (it actually inherits from IDummyTransformationSceneNode) to support setting rotation, position and scale directly from a 4x3 matrix (works like a 4x4 with assumed 0 0 0 1 on the bottom row)
You can get the relative transformation matrix (there's a call for that) concatenate it with the matrix A, then use setRelativeTransform to set it immediately.
I removed the operator* on matrices, but provided `concatenate` functions which allow more control over the associativity of the operation, precision and ordering.
If you know plain GL and matrices, and need instancing with LoD.. you should check out my fork.
I changed ISceneNode (it actually inherits from IDummyTransformationSceneNode) to support setting rotation, position and scale directly from a 4x3 matrix (works like a 4x4 with assumed 0 0 0 1 on the bottom row)
You can get the relative transformation matrix (there's a call for that) concatenate it with the matrix A, then use setRelativeTransform to set it immediately.
I removed the operator* on matrices, but provided `concatenate` functions which allow more control over the associativity of the operation, precision and ordering.