//-------------------------------------------------------------------------------------------- MAD_REF load_one_model_profile_vfs( const char* tmploadname, const MAD_REF imad ) { mad_t * pmad; STRING newloadname; if ( !VALID_MAD_RANGE( imad ) ) return ( MAD_REF )MAX_MAD; pmad = MadStack.lst + imad; // clear out the mad mad_reconstruct( pmad ); // mark it as used pmad->loaded = btrue; // Make up a name for the model... IMPORT\TEMP0000.OBJ strncpy( pmad->name, tmploadname, SDL_arraysize( pmad->name ) ); pmad->name[ SDL_arraysize( pmad->name ) - 1 ] = CSTR_END; // Load the imad model make_newloadname( tmploadname, "/tris.md2", newloadname ); // do this for now. maybe make it dynamic later... //pmad->md2_ref = imad; // load the model from the file pmad->md2_ptr = md2_load( vfs_resolveReadFilename( newloadname ), NULL ); // set the model's file name szModelName[0] = CSTR_END; if ( NULL != pmad->md2_ptr ) { strncpy( szModelName, vfs_resolveReadFilename( newloadname ), SDL_arraysize( szModelName ) ); /// @details BB@> Egoboo md2 models were designed with 1 tile = 32x32 units, but internally Egoboo uses /// 1 tile = 128x128 units. Previously, this was handled by sprinkling a bunch of /// commands that multiplied various quantities by 4 or by 4.125 throughout the code. /// It was very counterintuitive, and caused me no end of headaches... Of course the /// solution is to scale the model! md2_scale_model( pmad->md2_ptr, -3.5f, 3.5f, 3.5f ); } // Create the actions table for this imad mad_rip_actions( pmad ); mad_heal_actions( pmad, tmploadname ); mad_finalize( pmad ); return imad; }
void main (int argc, char **argv) { int menuopen = 0; int x, y, x1; CEvent cwevent; XEvent xevent; Window choicewin, editorwin, win3d; init_desktop (&desktop); stereo_init (argv[0]); choicewin = Cdrawwindow ("choicewin", CMain, 0, 0, 10, 10, ""); Cgethintpos (&x, &y); x1 = x; Cdrawbutton ("load", choicewin, x, y, AUTO_SIZE, " Load Image "); Cgethintpos (&x, 0); Cdrawbutton ("loadcal", choicewin, x, y, AUTO_SIZE, " Load Calibration File "); Cgethintpos (&x, 0); Cdrawbutton ("showcal", choicewin, x, y, AUTO_SIZE, " Display Calibration Points "); Cgethintpos (0, &y); x = x1; Cdrawbutton ("loadd", choicewin, x, y, AUTO_SIZE, " Load Previous Desktop "); Cgethintpos (&x, 0); Cdrawbutton ("saved", choicewin, x, y, AUTO_SIZE, " Save Previous Desktop "); Cgethintpos (&x, 0); Cdrawbutton ("finish", choicewin, x, y, AUTO_SIZE, " Quit "); Cgethintpos (0, &y); x = x1; Cdrawbutton ("getpnt", choicewin, x, y, AUTO_SIZE, " Triangulate Point "); Cgethintpos (&x, 0); Cdrawbutton ("getsurf", choicewin, x, y, AUTO_SIZE, " Triangulate Multiple Points (Surface) "); Cgethintpos (0, &y); x = x1; Cdrawbutton ("getline", choicewin, x, y, AUTO_SIZE, " Fit Line from Points "); Cgethintpos (&x, 0); Cdrawbutton ("getlineedge", choicewin, x, y, AUTO_SIZE, " Fit Line from two Line Projections "); Cgethintpos (0, &y); x = x1; Cdrawbutton ("getcyl", choicewin, x, y, AUTO_SIZE, " Fit Cylinder from Points "); Cgethintpos (&x, 0); Cdrawbutton ("getcyle", choicewin, x, y, AUTO_SIZE, " Fit Cylinder from four Line Projections "); Cgethintpos (0, &y); x = x1; Cdrawbutton ("getcirc", choicewin, x, y, AUTO_SIZE, " Fit Circle from Points "); Cgethintpos (&x, 0); Cdrawbutton ("getcircedge", choicewin, x, y, AUTO_SIZE, " Fit Circle from Ellipses Projections "); Cgethintpos (0, &y); x = x1; Cdrawbutton ("getellipse", choicewin, x, y, AUTO_SIZE, " Fit Ellipse from Points "); Cgethintpos (&x, 0); Csetsizehintpos ("choicewin"); editorwin = Cdrawwindow ("editorwin", CMain, 200, 100, 640 + 18, \ 450 + 40 + 18 + TEXT_PIX_PER_LINE + 11, ""); Cdraweditor ("editor", editorwin, 6, 6 + 40, 640, 450, "", 0, "/home/terry/stereo-0.2b/tmp/"); CDrawEditMenuButtons ("em", editorwin, Cwidget ("editor")->winid, 10, 10); Caddcallback ("editor", cb_editor); Cdraw3dobject ("3dview", win3d = Cdrawwindow ("3dplanewin", CMain, 150, 150, WIDTH3D + 100, 16 + HEIGHT3D, ""), 6, 6, WIDTH3D, HEIGHT3D, 1, 256); Cdrawbutton ("plshr", win3d, WIDTH3D + 20, 10, 70, 20, "Shrink"); Cdrawbutton ("plenl", win3d, WIDTH3D + 20, 40, 70, 20, "Enlarge"); Cdrawbutton ("newrender", win3d, WIDTH3D + 20, 70, 70, 20, "New render"); Cdrawbutton ("density", win3d, WIDTH3D + 20, 100, 70, 20, "Density"); Cdrawbutton ("flattri", win3d, WIDTH3D + 20, 130, 70, 20, "Flat Triangle"); Cdrawbutton ("savewin", win3d, WIDTH3D + 20, 160, 70, 20, "Save Window"); Caddcallback ("getpnt", cb_getpoint); Caddcallback ("getellipse", cb_getellipse); Caddcallback ("getcircedge", cb_getcircleedge); Caddcallback ("load", cb_newimage); Caddcallback ("3dview", cb_3dplane); Caddcallback ("newrender", cb_newrender); Caddcallback ("getsurf", cb_getsurface); Caddcallback ("getline", cb_getline); Caddcallback ("getcirc", cb_getcircle); Caddcallback ("getcyle", cb_getcylinderedge); Caddcallback ("getcyl", cb_getcylinder); Caddcallback ("getlineedge", cb_getlineedge); Caddcallback ("loadcal", cb_loadcal); Caddcallback ("showcal", cb_showcal); Caddcallback ("saved", cb_save_desktop); Caddcallback ("loadd", cb_load_desktop); Caddcallback ("savewin", cb_save_window); if (argc > 1) if (*argv[1] != '-') do_load_desktop (&desktop, argv[1]); do { CNextEvent (&xevent, &cwevent); if (!strcmp (cwevent.ident, "plshr")) { Cwidget ("3dview")->solid->distance += 2400; Cwidget ("3dview")->solid->y_cam += 2400; Credraw3dobject ("3dview", 0); } if (!strcmp (cwevent.ident, "plenl")) { Cwidget ("3dview")->solid->distance -= 2400; Cwidget ("3dview")->solid->y_cam -= 2400; Credraw3dobject ("3dview", 0); } if (!strcmp (cwevent.ident, "flattri")) { CWidget *w = Cwidget ("3dview"); if (w->solid->option_flags & TDOPTION_FLAT_TRIANGLE) { w->solid->option_flags &= 0xFFFFFFFF - TDOPTION_FLAT_TRIANGLE; } else { w->solid->option_flags |= TDOPTION_FLAT_TRIANGLE; } Credraw3dobject ("3dview", 0); } if (!strcmp (cwevent.ident, "kill")) { menuopen = 0; Cundrawwidget ("win1"); } } while (strcmp (cwevent.ident, "finish")); Cundrawall (); mad_finalize (__FILE__, __LINE__); }