unsigned int readmodel(char * modelfile, SceneHandle scene) {
  FILE * dfile;
  errcode rc;
 
  reset_tex_table(); 
  dfile=NULL;

  dfile=fopen(modelfile,"r");
  if (dfile==NULL) {
    return PARSEBADFILE;
  }

  rc = GetScenedefs(dfile, scene); 
  if (rc != PARSENOERR)
    return rc;

  scenebackcol.r = 0.0; /* default background is black */
  scenebackcol.g = 0.0;
  scenebackcol.b = 0.0;

  numobjectsparsed=0;
  while ((rc = GetObject(dfile, scene)) == PARSENOERR) {
    numobjectsparsed++;
  } 
  fclose(dfile);

  if (rc == PARSEEOF)
    rc = PARSENOERR;

  rt_background(scene, scenebackcol);

  return rc;
}
unsigned int readmodel(const char * modelfile, SceneHandle scene) {
  parsehandle ph;
  errcode rc;

  memset(&ph, 0, sizeof(ph));
  ph.filename = modelfile;
  ph.ifp=fopen(modelfile, "r");
  if (ph.ifp == NULL) {
    return PARSEBADFILE;
  }

  reset_tex_table(&ph, scene); 

  rc = GetScenedefs(&ph, scene); 
  if (rc == PARSENOERR) {
    ph.numobjectsparsed=0;
    while ((rc = GetObject(&ph, scene)) == PARSENOERR) {
      ph.numobjectsparsed++;
    } 
    fclose(ph.ifp);
  
    if (rc == PARSEEOF)
      rc = PARSENOERR;
  }

  free_tex_table(&ph, scene);

  return rc;
}
unsigned int ParseAC3D(char * modelfile, SceneHandle scene) {
  FILE * dfile;
  char filehdr[255];
  errcode rc;
 
  reset_tex_table(); 
  dfile=NULL;

  dfile=fopen(modelfile,"r");
  if (dfile==NULL) {
    return PARSEBADFILE;
  }

  fscanf(dfile, "%s", filehdr);
  if (strcmp(filehdr, "AC3Db")) {
    printf("Unknown version of AC3D Model File Format\n");
    fclose(dfile);
    return PARSEBADFILE;
  }

  rc = GetScenedefs(dfile, scene); 
  if (rc != PARSENOERR)
    return rc;

  scenebackcol.r = 0.0; /* default background is black */
  scenebackcol.g = 0.0;
  scenebackcol.b = 0.0;

  numobjectsparsed=0;
  while ((rc = GetScene(dfile, scene)) == PARSENOERR) {
    numobjectsparsed++;
  } 
  fclose(dfile);

  if (rc == PARSEEOF)
    rc = PARSENOERR;

  rt_background(scene, scenebackcol);

  return rc;
}