Page 1 of 1

updating an entity

Posted: Wed Jan 11, 2006 8:02 pm
by Moulded
I have implemented iterators , i know this quesion is a stupid one but though i m in a little bit of confussion .

Ques: Where in the main loop i must call the update function where all the iterators are started.

while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, 0 );
smgr->drawAll();
env->drawAll();
driver->endScene();
}

Should i call it
1.after driver->endscene();
2.between beginscene and endscene
3.Before begin scene
4.Or drop the idea calling the update function in main loop

Plz tell me the better option to go for for better efficiancy
thanx

Posted: Thu Jan 12, 2006 6:39 am
by GueZt
Most likely, computation and objects update
should be done after the rendering.

The best place for update is BEFORE or AFTER
the the rendering routine.

"Even irrlicht engine do the internal updates and
other computation before and after DrawAll routine
by calling OnPreRender() first before rendering
and OnPostRender() right after everything has been drawn."


I will never attempt to do some object updates while
in rendering mode.

I know theres a much better way, but here's how i've done mine.

while(device->run())
{
//
UpdateCustomMenu();
UpdateAllObjects();
//
RenderAll(); // << this is were i call beginScene and endScene
//
UpdateInput();
UpdateNet();
//
UpdateMisc();
//
}

Posted: Thu Jan 12, 2006 6:45 am
by kushagra
u can even try out overriding the OnPreRender() and OnPostRender() methods according to ur needs. Try making ur objcet class as a child of ISceneNode and define the methods . OnPostRender has one special feature that it has its argument as the time and u can get the time tick for ur better calculations. It hardly matters if u call upon updates before or after the render , it all depends on u and ur critical sections. If there is any critical calculation on an object which must be there before its rendering then call before else do afterwards.

Posted: Thu Jan 12, 2006 10:21 am
by area51
Picking up on what kushagra said, I would keep the game and render objects seperate, which is the opposite, ie don't subclass ISceneNode.

Game objects/structures shouldn't need to know anything about how it's rendered, but hold a pointer to it's on screen representation instead.
________
Dc medical marijuana dispensary

Posted: Thu Jan 12, 2006 12:07 pm
by GueZt
I agree with area51, lols.