[artoolkit-commits] artoolkit/examples/twoView twoView.c, 1.17, 1.18
Optical marker tracking and overlay for augmented reality.
Brought to you by:
philip_lamb
From: Philip L. <phi...@us...> - 2007-01-18 22:51:49
|
Update of /cvsroot/artoolkit/artoolkit/examples/twoView In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv10251 Modified Files: twoView.c Log Message: Test and clean up twoView. Index: twoView.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/twoView/twoView.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** twoView.c 17 Nov 2006 03:35:37 -0000 1.17 --- twoView.c 18 Jan 2007 22:51:48 -0000 1.18 *************** *** 233,238 **** 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); --- 233,238 ---- 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); *************** *** 278,300 **** } #ifdef APPLE_TEXTURE_FAST_TRANSFER - # ifdef GL_APPLE_client_storage fprintf(stderr, "arglAppleClientStorage is %d.\n", arglAppleClientStorage); - # endif // GL_APPLE_client_storage - # ifdef GL_APPLE_texture_range fprintf(stderr, "arglAppleTextureRange is %d.\n", arglAppleTextureRange); - fprintf(stderr, "arglAppleTextureRangeStorageHint is "); - switch (arglAppleTextureRangeStorageHint) { - case GL_STORAGE_SHARED_APPLE: - fprintf(stderr, "GL_STORAGE_SHARED_APPLE.\n"); - break; - case GL_STORAGE_CACHED_APPLE: - fprintf(stderr, "GL_STORAGE_CACHED_APPLE.\n"); - break; - default: - case GL_STORAGE_PRIVATE_APPLE: - fprintf(stderr, "GL_STORAGE_PRIVATE_APPLE.\n"); - break; - } - # endif // GL_APPLE_texture_range #endif // APPLE_TEXTURE_FAST_TRANSFER } --- 278,283 ---- *************** *** 406,410 **** if ((image = ar2VideoGetImage(gContextsActive[i].ARTVideo)) != NULL) { gContextsActive[i].ARTImage = image; // Save the fetched image. - gContextsActive[i].patt_found = FALSE; // Invalidate any previous detected markers. gContextsActive[i].callCountMarkerDetect++; // Increment ARToolKit FPS counter. --- 389,392 ---- *************** *** 422,426 **** if (marker_info[j].id == gPatt_id) { if (k == -1) k = j; // First marker detected. ! else if(marker_info[j].cf > marker_info[k].cf) k = j; // Higher confidence marker detected. } } --- 404,408 ---- if (marker_info[j].id == gPatt_id) { if (k == -1) k = j; // First marker detected. ! else if (marker_info[j].cf > marker_info[k].cf) k = j; // Higher confidence marker detected. } } *************** *** 430,433 **** --- 412,417 ---- arGetTransMat(&(marker_info[k]), gPatt_centre, gPatt_width, gContextsActive[i].patt_trans); gContextsActive[i].patt_found = TRUE; + } else { + gContextsActive[i].patt_found = FALSE; } *************** *** 487,510 **** gContextsActive[drawContextIndex].ARTImage = NULL; // Image data is no longer valid after calling ar2VideoCapNext(). if (gContextsActive[drawContextIndex].patt_found) { ! // Projection transformation. ! arglCameraFrustumRH(&(gContextsActive[drawContextIndex].ARTCparam), 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(gContextsActive[drawContextIndex].patt_trans, m, VIEW_SCALEFACTOR); glLoadMatrixd(m); ! // All other lighting and geometry goes here. DrawCube(drawContextIndex); } // patt_found --- 471,496 ---- gContextsActive[drawContextIndex].ARTImage = NULL; // Image data is no longer valid after calling ar2VideoCapNext(). + // Projection transformation. + arglCameraFrustumRH(&(gContextsActive[drawContextIndex].ARTCparam), 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 (gContextsActive[drawContextIndex].patt_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(gContextsActive[drawContextIndex].patt_trans, m, VIEW_SCALEFACTOR); glLoadMatrixd(m); ! // All lighting and geometry to be drawn relative to the marker goes here. DrawCube(drawContextIndex); + } // patt_found *************** *** 589,597 **** } gContextsActiveCount = CONTEXTSACTIVECOUNT; ! for (i = 0; i < gContextsActiveCount; i++) if (!setupMarker(patt_name, &gPatt_id)) { ! fprintf(stderr, "main(): Unable to set up AR marker.\n"); ! exit(-1); ! } ! // ---------------------------------------------------------------------------- // Library setup. --- 575,579 ---- } gContextsActiveCount = CONTEXTSACTIVECOUNT; ! // ---------------------------------------------------------------------------- // Library setup. *************** *** 625,628 **** --- 607,615 ---- } arUtilTimerReset(); + + if (!setupMarker(patt_name, &gPatt_id)) { + fprintf(stderr, "main(): Unable to set up AR marker in context %d.\n", i); + exit(-1); + } // Register GLUT event-handling callbacks. |