I am trying to load several big models in code and show the scenes. Generally, it is taking long time for loading and showing scene on screen as it need to extract lot of resources from a pod model. So, i thought of populate the first scene in main thread and remaining others in a separate thread. But, it is crashing when i move my part code into separate thread. Here is my sample code:
-(void) loadFirstScene
{
CC3PODResourceNode* podRezNode = [CC3PODResourceNode nodeWithName: @"FirstModel"];
podRezNode.resource = [IntroducingPODResource resourceFromFile: @"FirstModel.pod"];
podRezNode.shouldCullBackFaces = NO;
podRezNode.location = cc3v(0.0, -10.0, 0.2);
podRezNode.isTouchEnabled = YES;
[self addChild: podRezNode];
[NSThread detachNewThreadSelector:@selector(loadScenesInThread) toTarget:self
withObject:nil];
}
// Crashing if i add the below function in separate thread or background thread
-(void) loadScenesInThread
{
CC3PODResourceNode* podRezNode = [CC3PODResourceNode nodeWithName: @"SecondModel"];
podRezNode.resource = [IntroducingPODResource resourceFromFile: @"SecondModel.pod"];
podRezNode.shouldCullBackFaces = NO;
podRezNode.location = cc3v(0.0, -10.0, -5.0);
podRezNode.isTouchEnabled = YES;
[self addChild: podRezNode];
podRezNode = [CC3PODResourceNode nodeWithName: @"ThirdModel"];
podRezNode.resource = [IntroducingPODResource resourceFromFile: @"ThirdModel.pod"];
podRezNode.shouldCullBackFaces = NO;
podRezNode.location = cc3v(0.0, -10.0, -5.0);
podRezNode.isTouchEnabled = YES;
[self addChild: podRezNode];
// .. do more
}
Could someone guide me how would i handle such situation?