Hi!
 
I wanted to know the progress of file loading and display that satatus
For it, I designed the program as followings:
 
-----------------------------------------------------------------------------------
static NodePtr pzModel = NullFC;
static bool bThread = FALSE;
static int nLoadProgress = 0;
static char sPathNameModel[BUF_SIZE];
 
static Thread *pzFileLoader = NULL;
static Barrier *pzSyncBarrier = NULL;
 
//===
void FileLoader_Thread(void *pArg);
void FileLoader_CB(void)
{
 pzSyncBarrier->enter( 2 );  // Position A
 pzSyncBarrier->enter( 2 );  // Position B
 
 if (bThread == FALSE)
 {
  if (pzModel != NullFC)
  {
   pzModel->setActive(TRUE);
   pzFileLoader->getChangeList()->applyAndClear();
   AddSceneToTop(pzModel);
  }
  Thread::join(pzFileLoader);
 }
} // FileLoader_CB
void Progress_CB(UInt32 nProgress)
{
 pzSyncBarrier->enter( 2 );  // Position C
 {
  nLoadProgress = nProgress;
 }
 pzSyncBarrier->enter( 2 );  // Position D
 
} // Progress_CB
 
void FileLoader_Thread(void *pArg)
{
 SceneFileHandler::the().setReadProgressCB(Progress_CB);
 
 pzModel = SceneFileHandler::the().read(sPathNameModel);
 
 SceneFileHandler::the().setReadProgressCB(NULL);
 
 Sleep(1);
 // Before Postion E, Position A must be waited.
 // But, in the high speed computer, Position C can be preceded.
 // Therefore, a delay for proper termination of Progress thread
 // in SceneFileHandler is required!
 
 pzSyncBarrier->enter( 2 );  // Position E
 {
  bThread = FALSE;
 }
 pzSyncBarrier->enter( 2 );  // Position F
 
} // FileLoader_Thread
void LoadModel(const char*sPathModel)
{
 //=== create the barrier
 pzSyncBarrier = Barrier::get("FileLoader");
 
 //=== create the producer thread
 pzFileLoader =  OSG::Thread::get("FileLoader");
 
 if (pzFileLoader == NULL)
 {
  //    Error
  return;
 }
 
 // Populate the producer's aspect
// Thread::getCurrent()->getChangeList()->applyTo(1);
// Thread::getCurrent()->getChangeList()->clearAll();
 
 //===
 AddNJob(FileLoader_CB);
 
 strcpy(sPathNameModel, sPathModel);
 
 bThread = TRUE;
 
 //=== run it, using a separate aspect
 pzFileLoader->runFunction(FileLoader_Thread, 1, (void *)NULL);
 
} // LoadModel
-----------------------------------------------------------------------------------
With this code, I could load a model successfully!
after solving some trouble with positioning
 "pzFileLoader->getChangeList()->applyAndClear();" in the code.
 
Rendered image of the model loaded seem to be shown with no fault.
But, when calcVertexTangents() is applied to this model,
the rendered model was cracked.that is, polygons of the model was dispersed.
 
I just guess there were some missings in change list applying
 
please your help!

Reply via email to