[artoolkit-commits] artoolkit/examples/simpleLite simpleLite.c, 1.20, 1.21
Optical marker tracking and overlay for augmented reality.
Brought to you by:
philip_lamb
From: Philip L. <phi...@us...> - 2007-01-16 21:08:12
|
Update of /cvsroot/artoolkit/artoolkit/examples/simpleLite In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv32074 Modified Files: simpleLite.c Log Message: Small cleanup of example code, plus temp. fix for problem with bud_B vrml. Index: simpleLite.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/simpleLite/simpleLite.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** simpleLite.c 17 Nov 2006 03:34:25 -0000 1.20 --- simpleLite.c 16 Jan 2007 21:08:07 -0000 1.21 *************** *** 186,195 **** static int setupMarker(const char *patt_name, int *patt_id) { ! ! if((*patt_id = arLoadPatt(patt_name)) < 0) { ! fprintf(stderr, "setupMarker(): pattern load error !!\n"); ! return (FALSE); ! } ! return (TRUE); } --- 186,195 ---- static int setupMarker(const char *patt_name, int *patt_id) { ! // Loading only 1 pattern in this example. ! if((*patt_id = arLoadPatt(patt_name)) < 0) { ! fprintf(stderr, "setupMarker(): pattern load error !!\n"); ! return (FALSE); ! } ! return (TRUE); } *************** *** 197,203 **** // Report state of ARToolKit global variables arFittingMode, // arImageProcMode, arglDrawMode, arTemplateMatchingMode, arMatchingPCAMode. ! static void debugReportMode(void) { ! if(arFittingMode == AR_FITTING_TO_INPUT ) { fprintf(stderr, "FittingMode (Z): INPUT IMAGE\n"); } else { --- 197,203 ---- // Report state of ARToolKit global variables arFittingMode, // arImageProcMode, arglDrawMode, arTemplateMatchingMode, arMatchingPCAMode. ! static void debugReportMode(const ARGL_CONTEXT_SETTINGS_REF arglContextSettings) { ! if (arFittingMode == AR_FITTING_TO_INPUT) { fprintf(stderr, "FittingMode (Z): INPUT IMAGE\n"); } else { *************** *** 205,209 **** } ! if( arImageProcMode == AR_IMAGE_PROC_IN_FULL ) { fprintf(stderr, "ProcMode (X) : FULL IMAGE\n"); } else { --- 205,209 ---- } ! if (arImageProcMode == AR_IMAGE_PROC_IN_FULL) { fprintf(stderr, "ProcMode (X) : FULL IMAGE\n"); } else { *************** *** 211,217 **** } ! if (arglDrawModeGet(gArglSettings) == AR_DRAW_BY_GL_DRAW_PIXELS) { fprintf(stderr, "DrawMode (C) : GL_DRAW_PIXELS\n"); ! } else if (arglTexmapModeGet(gArglSettings) == AR_DRAW_TEXTURE_FULL_IMAGE) { fprintf(stderr, "DrawMode (C) : TEXTURE MAPPING (FULL RESOLUTION)\n"); } else { --- 211,217 ---- } ! if (arglDrawModeGet(arglContextSettings) == AR_DRAW_BY_GL_DRAW_PIXELS) { fprintf(stderr, "DrawMode (C) : GL_DRAW_PIXELS\n"); ! } else if (arglTexmapModeGet(arglContextSettings) == AR_DRAW_TEXTURE_FULL_IMAGE) { fprintf(stderr, "DrawMode (C) : TEXTURE MAPPING (FULL RESOLUTION)\n"); } else { *************** *** 219,223 **** } ! if( arTemplateMatchingMode == AR_TEMPLATE_MATCHING_COLOR ) { fprintf(stderr, "TemplateMatchingMode (M) : Color Template\n"); } else { --- 219,223 ---- } ! if (arTemplateMatchingMode == AR_TEMPLATE_MATCHING_COLOR) { fprintf(stderr, "TemplateMatchingMode (M) : Color Template\n"); } else { *************** *** 225,229 **** } ! if( arMatchingPCAMode == AR_MATCHING_WITHOUT_PCA ) { fprintf(stderr, "MatchingPCAMode (P) : Without PCA\n"); } else { --- 225,229 ---- } ! if (arMatchingPCAMode == AR_MATCHING_WITHOUT_PCA) { fprintf(stderr, "MatchingPCAMode (P) : Without PCA\n"); } else { *************** *** 266,270 **** gCallCountMarkerDetect = 0; arUtilTimerReset(); ! debugReportMode(); break; case 'D': --- 266,270 ---- gCallCountMarkerDetect = 0; arUtilTimerReset(); ! debugReportMode(gArglSettings); break; case 'D': *************** *** 310,314 **** if ((image = arVideoGetImage()) != NULL) { gARTImage = image; // Save the fetched image. - gPatt_found = FALSE; // Invalidate any previous detected markers. gCallCountMarkerDetect++; // Increment ARToolKit FPS counter. --- 310,313 ---- *************** *** 333,336 **** --- 332,337 ---- arGetTransMat(&(marker_info[k]), gPatt_centre, gPatt_width, gPatt_trans); gPatt_found = TRUE; + } else { + gPatt_found = FALSE; } *************** *** 386,408 **** gARTImage = NULL; // Image data is no longer valid after calling arVideoCapNext(). ! if (gPatt_found) { ! // Projection transformation. ! arglCameraFrustumRH(&gARTCparam, VIEW_DISTANCE_MIN, VIEW_DISTANCE_MAX, p); ! glMatrixMode(GL_PROJECTION); ! glLoadMatrixd(p); ! glMatrixMode(GL_MODELVIEW); ! ! // Viewing transformation. ! glLoadIdentity(); ! // Lighting and geometry that moves with the camera should go here. ! // (I.e. must be specified before viewing transformations.) ! //none ! // ARToolKit supplied distance in millimetres, but I want OpenGL to work in my units. arglCameraViewRH(gPatt_trans, m, VIEW_SCALEFACTOR); glLoadMatrixd(m); ! // All other lighting and geometry goes here. DrawCube(); } // gPatt_found --- 387,412 ---- gARTImage = NULL; // Image data is no longer valid after calling arVideoCapNext(). ! // Projection transformation. ! arglCameraFrustumRH(&gARTCparam, VIEW_DISTANCE_MIN, VIEW_DISTANCE_MAX, p); ! glMatrixMode(GL_PROJECTION); ! glLoadMatrixd(p); ! glMatrixMode(GL_MODELVIEW); ! // Viewing transformation. ! glLoadIdentity(); ! // Lighting and geometry that moves with the camera should go here. ! // (I.e. must be specified before viewing transformations.) ! //none ! ! if (gPatt_found) { ! ! // Calculate the camera position relative to the marker. ! // Replace VIEW_SCALEFACTOR with 1.0 to make one drawing unit equal to 1.0 ARToolKit units (usually millimeters). arglCameraViewRH(gPatt_trans, m, VIEW_SCALEFACTOR); glLoadMatrixd(m); ! // All lighting and geometry to be drawn relative to the marker goes here. DrawCube(); + } // gPatt_found *************** *** 441,449 **** exit(-1); } ! if (!setupMarker(patt_name, &gPatt_id)) { ! fprintf(stderr, "main(): Unable to set up AR marker.\n"); ! exit(-1); ! } ! // ---------------------------------------------------------------------------- // Library setup. --- 445,449 ---- exit(-1); } ! // ---------------------------------------------------------------------------- // Library setup. *************** *** 467,474 **** exit(-1); } ! debugReportMode(); glEnable(GL_DEPTH_TEST); arUtilTimerReset(); // Register GLUT event-handling callbacks. // NB: Idle() is registered by Visibility. --- 467,479 ---- exit(-1); } ! debugReportMode(gArglSettings); glEnable(GL_DEPTH_TEST); arUtilTimerReset(); + if (!setupMarker(patt_name, &gPatt_id)) { + fprintf(stderr, "main(): Unable to set up AR marker.\n"); + Quit(); + } + // Register GLUT event-handling callbacks. // NB: Idle() is registered by Visibility. |