/** * Load an OBJ model from file, in two passes. */ int ReadOBJModel (const char *filename, struct obj_model_t *mdl) { FILE *fp; fp = fopen (filename, "r"); if (!fp) { fprintf (stderr, "Error: couldn't open \"%s\"!\n", filename); return 0; } /* reset model data */ memset (mdl, 0, sizeof (struct obj_model_t)); /* first pass: read model info */ if (!FirstPass (fp, mdl)) { fclose (fp); return 0; } rewind (fp); /* memory allocation */ if (!MallocModel (mdl)) { fclose (fp); FreeModel (mdl); return 0; } /* second pass: read model data */ if (!SecondPass (fp, mdl)) { fclose (fp); FreeModel (mdl); return 0; } fclose (fp); return 1; }
/** * Load an OBJ model from file, in two passes. */ int LoadOBJ::ReadOBJModel (const char *filename) { FILE *fp; fp = fopen (filename, "r"); if (!fp) { fprintf (stderr, "Error: couldn't open \"%s\"!\n", filename); return 0; } //std::cout << "premem" << std::endl; /* reset model data */ memset (&mdl, 0, sizeof (struct obj_model_t)); //std::cout << "memorioainitializado" << std::endl; /* first pass: read model info */ if (!FirstPass (fp)) { fclose (fp); return 0; } rewind (fp); /* memory allocation */ if (!MallocModel ()) { fclose (fp); FreeModel (); return 0; } /* second pass: read model data */ if (!SecondPass (fp)) { fclose (fp); FreeModel (); return 0; } fclose (fp); return 1; }