Relative-, AbsoluteTransformation: being off-by-1-frame

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
specialtactics
Posts: 17
Joined: Tue Dec 09, 2003 9:03 am
Location: Germany

Relative-, AbsoluteTransformation: being off-by-1-frame

Post by specialtactics »

Hi,

I again have an issue with irrlicht not updating the AbsoluteTransformation of scenenodes for the rendering of the current frame. The core problem is basically the same I had with the updating of my camera, see: http://irrlicht.sourceforge.net/phpBB2/ ... highlight=. I just realized that updating the position of any scenenode can be tricky.

The problem is that when you have a ISceneNode (let's call it node) and do node->setPosition(...) the node will be rendered at the new position in the next frame, in this frame it will be rendered at the old position. Here is why:
setPosition(...) updates the node's RelativeTransformationMatrix, but not it's AbsoluteTransformationMatrix (which is used for the rendering). The AbsoluteTransformation will be updated OnPostRender. To solve this problem you can call node->updateAbsoluteTransformation() which syncs the Absolute- to the RelativeTransformation. Now, I wouldn't bother about 1 additional line of code, but here is another problem:

Now assume node has a parent ISceneNode* (let's call it mom). Further assume the following code:

Code: Select all

mom = smgr->addDummyTransformationSceneNode();
node = smgr->addTestSceneNode(mom);
mom->setPosition(...);
mom->updateAbsoluteTransformation();
Ok, so we moved node's mom and updated mom's AbsoluteTransformation. But that's not enough, cause node's AbsoluteTransformationMatrix is still where it was before, so node will render itself this frame not caring that its mom has moved. On PostRender, node syncs its AbsoluteTransformation to mom's.

So when you change a node's transformation, you must call updateAbsoluteTransformation() on all children, too, in order to see the effect in the current frame. This is awkward. I think the engine should be patched so that the user never has to call updateAbsoluteTransformation() himself.
ThommyE
Posts: 48
Joined: Sun Sep 18, 2005 3:02 pm
Location: germany/badnerlaendle

Post by ThommyE »

well I wouldn't care about 2 lines of additional code i i had know this 2 weeks ago.. i was lost not knowing how to solve the problems of childs being behind their parents.

thx you a million time...but.. haven't you read my earlyer thread?.. would've saved me lot of trouble^^

i never imagined a solution beeing that simple.. guess this will become a short night again rewriting some code^^

-i tried to change the irrlicht sources to make them update the absolut positions befor rendering the frame, but since i dcan't really prog c++ i was not fery sucsessfull^^

good luck to you.. and thx again=) i finally can start the actual work

EDIT:well. guess i was a little bit too fast... even thoug your idea is not bad, and my error seems to be smaler.. it's still there.
See the gap between legs and upper body. if its not moving its perfectly fine.. but. you see
Image

i really wont highjack this thread.. but isn't this absoluteupdate thing supposed to update childs posotion when linked via matrices- ( getMatrixOfJoint() )?
athlon2400xp+,geforce4200ti, 0.2Tb hd+64mb extern, 512mb ram, linux FC5 2.6.16-1.2096, 100%gates-free system
Post Reply