Screen freezes
Posted: Sun Sep 16, 2007 12:21 am
This is a piece of code in one of my event receiver. The screen freezes when it should actually be rendering the nodes to the color red according to the time elapsed. When the screen unfreezes again, it gives me all the nodes red at one go instead of having it in order of the 'Start time'. Here is the code
Any help would be appreciated. Thanks.
Code: Select all
int timeelapsed=0;
int presenttime=0;
ITimer *timenow1=mydevice->getTimer();
for(int j=0;j<=projectfinish;j++)
{
presenttime=timenow1->getRealTime();
do
{for(int i=0;i<50;i++)
{if((activities[i]->existsAttribute("Start time")==true)&&(j==activities[i]->getAttributeAsInt("Start time")))
{if(activities[i]->getAttributeAsInt("Group 1")!=0&&groups[activities[i]->getAttributeAsInt("Group 1")]!=0)
{ listofchildren=groups[activities[i]->getAttributeAsInt("Group 1")]->getChildren();
if(listofchildren.empty()!=true)
{core::list<ISceneNode*>::Iterator it = listofchildren.begin();
do
{
(*it)->getMaterial(0).EmissiveColor.setRed(255);
it++;}
while(it!=listofchildren.end() );
}
}
if(activities[i]->getAttributeAsInt("Group 2")!=0&&groups[activities[i]->getAttributeAsInt("Group 2")]!=0)
{ listofchildren=groups[activities[i]->getAttributeAsInt("Group 2")]->getChildren();
if(listofchildren.empty()!=true)
{core::list<ISceneNode*>::Iterator it = listofchildren.begin();
do
{
(*it)->setMaterialFlag(video::EMF_LIGHTING, false);
it++;}
while(it!=listofchildren.end() );
}
}
if(activities[i]->getAttributeAsInt("Group 3")!=0&&groups[activities[i]->getAttributeAsInt("Group 3")]!=0)
{ listofchildren=groups[activities[i]->getAttributeAsInt("Group 3")]->getChildren();
if(listofchildren.empty()!=true)
{core::list<ISceneNode*>::Iterator it = listofchildren.begin();
do
{
(*it)->setMaterialFlag(video::EMF_LIGHTING, false);
it++;}
while(it!=listofchildren.end() );
}
}
if(activities[i]->getAttributeAsInt("Group 4")!=0&&groups[activities[i]->getAttributeAsInt("Group 4")]!=0)
{ listofchildren=groups[activities[i]->getAttributeAsInt("Group 4")]->getChildren();
if(listofchildren.empty()!=true)
{core::list<ISceneNode*>::Iterator it = listofchildren.begin();
do
{
(*it)->setMaterialFlag(video::EMF_LIGHTING, false);
it++;}
while(it!=listofchildren.end() );
}
}}}
myscene->drawAll();
timeelapsed=timenow1->getRealTime()-presenttime;
timeelapsed+=1;
}while(timeelapsed<=1000);
}