ISceneNodes appearing at origin on creation

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
luvcraft
Posts: 23
Joined: Sun Apr 25, 2004 1:00 am
Location: Albuquerque, NM

ISceneNodes appearing at origin on creation

Post by luvcraft »

I have an annoying problem where every time I create a new ISceneNode it appears at the origin for one frame before it moves to its correct location. I'm creating the nodes and setting their positions outside of the main loop (i.e. after driver->endScene() and before driver->beginScene()), but it does the same thing even if I do those functions in the middle of the main loop. I'd post a code snippet, but at this point my code is huge and I have no idea where the problem could be occurring. Does anyone have any general suggestions on this?
dhenton9000
Posts: 395
Joined: Fri Apr 08, 2005 8:46 pm

Post by dhenton9000 »

there have been a few posts about a positioning being one step behind requested changes. The recommendation was issuing updateabsoluteposition() manually immediately after positioning.

I think searching the forum for "updateabsoluteposition" will get you most of the posts.

HTH

PS. Nice nickname. :wink:
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The child scene node should have a correct position immediately after construction because the constructor calls ISceneNode::updateAbsolutePosition(). If you call ISceneNode::setParent(), ISceneNode::addChild(), or ISeceneNode::setPosition() after construction then you will have to call ISceneNode::updateAbsolutePosition() or wait for an ISceneNode::OnPostRender() to get the actual position.

I modified the mesh viewer example...

Code: Select all

   Model = Device->getSceneManager()->addAnimatedMeshSceneNode(Mesh, 0, -1, core::vector3df(10.f, 10.f, 10.f));

   core::vector3df pos = Model->getPosition();
   fprintf(stderr, "x=%f y=%f z=%f\n", pos.X, pos.Y, pos.Z);
And it printed x=10.000000 y=10.000000 z=10.000000 as expected.

Travis
luvcraft
Posts: 23
Joined: Sun Apr 25, 2004 1:00 am
Location: Albuquerque, NM

Post by luvcraft »

Aha! That did it! Thanks!
Post Reply