Esempio n. 1
0
static errcode GetObject(FILE * dfile, SceneHandle scene) {
  char objtype[80];
 
  fscanf(dfile, "%s", objtype);
  if (!stringcmp(objtype, "END_SCENE")) {
    return PARSEEOF; /* end parsing */
  }
  if (!stringcmp(objtype, "TEXDEF")) {
    return GetTexDef(dfile);
  }	
  if (!stringcmp(objtype, "TEXALIAS")) {
    return GetTexAlias(dfile);
  }
  if (!stringcmp(objtype, "BACKGROUND")) {
    return GetBackGnd(dfile);
  }
  if (!stringcmp(objtype, "CYLINDER")) {
    return GetCylinder(dfile);
  }
  if (!stringcmp(objtype, "FCYLINDER")) {
    return GetFCylinder(dfile);
  }
  if (!stringcmp(objtype, "POLYCYLINDER")) {
    return GetPolyCylinder(dfile);
  }
  if (!stringcmp(objtype, "SPHERE")) {
    return GetSphere(dfile);
  }
  if (!stringcmp(objtype, "PLANE")) {
    return GetPlane(dfile);
  }
  if (!stringcmp(objtype, "RING")) {
    return GetRing(dfile);
  }
  if (!stringcmp(objtype, "BOX")) {
    return GetBox(dfile);
  }
  if (!stringcmp(objtype, "SCALARVOL")) {
    return GetVol(dfile);
  }
  if (!stringcmp(objtype, "TRI")) {
    return GetTri(dfile);
  }
  if (!stringcmp(objtype, "STRI")) {
    return GetSTri(dfile);
  }
  if (!stringcmp(objtype, "LIGHT")) {
    return GetLight(dfile);
  }
  if (!stringcmp(objtype, "SCAPE")) {
    return GetLandScape(dfile);
  }
  if (!stringcmp(objtype, "TPOLYFILE")) {
    return GetTPolyFile(dfile);
  }

  fprintf(stderr, "Found bad token: %s expected an object type\n", objtype);
  return PARSEBADSYNTAX;
}
static errcode GetObject(parsehandle * ph, SceneHandle scene) {
  char objtype[256];
 
  if (fscanf(ph->ifp, "%s", objtype) == EOF) {
    return PARSEEOF;
  }
  if (!stringcmp(objtype, "TRI")) {
    return GetTri(ph, scene);
  }
  if (!stringcmp(objtype, "STRI")) {
    return GetSTri(ph, scene);
  }
  if (!stringcmp(objtype, "VCSTRI")) {
    return GetVCSTri(ph, scene);
  }
  if (!stringcmp(objtype, "SPHERE")) {
    return GetSphere(ph, scene);
  }
  if (!stringcmp(objtype, "FCYLINDER")) {
    return GetFCylinder(ph, scene);
  }
  if (!stringcmp(objtype, "RING")) {
    return GetRing(ph, scene);
  }
  if (!stringcmp(objtype, "POLYCYLINDER")) {
    return GetPolyCylinder(ph, scene);
  }
  if (!stringcmp(objtype, "CYLINDER")) {
    return GetCylinder(ph, scene);
  }
  if (!stringcmp(objtype, "PLANE")) {
    return GetPlane(ph, scene);
  }
  if (!stringcmp(objtype, "BOX")) {
    return GetBox(ph, scene);
  }
  if (!stringcmp(objtype, "SCALARVOL")) {
    return GetVol(ph, scene);
  }
  if (!stringcmp(objtype, "TEXDEF")) {
    return GetTexDef(ph, scene);
  }	
  if (!stringcmp(objtype, "TEXALIAS")) {
    return GetTexAlias(ph);
  }
  if (!stringcmp(objtype, "LIGHT")) {
    return GetLight(ph, scene);
  }
  if (!stringcmp(objtype, "DIRECTIONAL_LIGHT")) {
    return GetDirLight(ph, scene);
  }
  if (!stringcmp(objtype, "SPOTLIGHT")) {
    return GetSpotLight(ph, scene);
  }
  if (!stringcmp(objtype, "SCAPE")) {
    return GetLandScape(ph, scene);
  }
  if (!stringcmp(objtype, "CAMERA")) {
    return GetCamera(ph, scene);
  }
  if (!stringcmp(objtype, "TPOLYFILE")) {
    return GetTPolyFile(ph, scene);
  }
  if (!stringcmp(objtype, "MGFFILE")) {
#ifdef USELIBMGF
    return GetMGFFile(ph, scene);
#else
    printf("MGF File Parsing is not available in this build.\n");
    return PARSEBADSYNTAX;
#endif
  }
  if (!stringcmp(objtype, "#")) {
    int c;
    while (1) {
      c=fgetc(ph->ifp);
      if (c == EOF || c == '\n')    /* eat comment text */
        return PARSENOERR;
    } 
  }
  if (!stringcmp(objtype, "BACKGROUND")) {
    return GetBackGnd(ph, scene);
  }
  if (!stringcmp(objtype, "FOG")) {
    return GetFog(ph, scene);
  }
  if (!stringcmp(objtype, "INCLUDE")) {
    char includefile[FILENAME_MAX];
    fscanf(ph->ifp, "%s", includefile);
    return ReadIncludeFile(ph, includefile, scene);
  }
  if (!stringcmp(objtype, "START_CLIPGROUP")) {
    return GetClipGroup(ph, scene);
  }
  if (!stringcmp(objtype, "END_CLIPGROUP")) {
    return GetClipGroupEnd(ph, scene);
  }
  if (!stringcmp(objtype, "END_SCENE")) {
    return PARSEEOF; /* end parsing */
  }

  PrintSyntaxError(ph, "an object or other declaration", objtype);

  return PARSEBADSYNTAX;
}