Thread: [artoolkit-commits] artoolkit/examples/simpleVRML simpleVRML.c, 1.16, 1.17
Optical marker tracking and overlay for augmented reality.
Brought to you by:
philip_lamb
From: Philip L. <phi...@us...> - 2007-01-16 21:08:27
|
Update of /cvsroot/artoolkit/artoolkit/examples/simpleVRML In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv32187 Modified Files: simpleVRML.c Log Message: Small cleanup of example code, plus temp. fix for problem with bud_B vrml. Index: simpleVRML.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/simpleVRML/simpleVRML.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** simpleVRML.c 4 Oct 2006 03:44:31 -0000 1.16 --- simpleVRML.c 16 Jan 2007 21:08:23 -0000 1.17 *************** *** 67,75 **** // ============================================================================ ! #define VIEW_SCALEFACTOR 0.025 // 1.0 ARToolKit unit becomes 0.025 of my OpenGL units. ! #define VIEW_SCALEFACTOR_1 1.0 // 1.0 ARToolKit unit becomes 1.0 of my OpenGL units. ! #define VIEW_SCALEFACTOR_4 4.0 // 1.0 ARToolKit unit becomes 4.0 of my OpenGL units. ! #define VIEW_DISTANCE_MIN 4.0 // Objects closer to the camera than this will not be displayed. ! #define VIEW_DISTANCE_MAX 4000.0 // Objects further away from the camera than this will not be displayed. --- 67,73 ---- // ============================================================================ ! #define VIEW_SCALEFACTOR 1.0 // 1.0 ARToolKit unit becomes 1.0 of my OpenGL units. ! #define VIEW_DISTANCE_MIN 10.0 // Objects closer to the camera than this will not be displayed. ! #define VIEW_DISTANCE_MAX 10000.0 // Objects further away from the camera than this will not be displayed. *************** *** 92,98 **** static long gCallCountMarkerDetect = 0; - // Transformation matrix retrieval. - static int gPatt_found = FALSE; // At least one marker. - // Drawing. static ARParam gARTCparam; --- 90,93 ---- *************** *** 141,154 **** } ! static int setupMarkersObjects(char *objectDataFilename) { // Load in the object data - trained markers and associated bitmap files. ! if ((gObjectData = read_VRMLdata(objectDataFilename, &gObjectDataCount)) == NULL) { fprintf(stderr, "setupMarkersObjects(): read_VRMLdata returned error !!\n"); return (FALSE); } - printf("Object count = %d\n", gObjectDataCount); - return (TRUE); } --- 136,148 ---- } ! static int setupMarkersObjects(char *objectDataFilename, ObjectData_T **objectDataRef, int *objectDataCountRef) { // Load in the object data - trained markers and associated bitmap files. ! if ((*objectDataRef = read_VRMLdata(objectDataFilename, objectDataCountRef)) == NULL) { fprintf(stderr, "setupMarkersObjects(): read_VRMLdata returned error !!\n"); return (FALSE); } + printf("Object count = %d\n", *objectDataCountRef); return (TRUE); } *************** *** 156,162 **** // 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 { --- 150,156 ---- // 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 { *************** *** 164,168 **** } ! if( arImageProcMode == AR_IMAGE_PROC_IN_FULL ) { fprintf(stderr, "ProcMode (X) : FULL IMAGE\n"); } else { --- 158,162 ---- } ! if (arImageProcMode == AR_IMAGE_PROC_IN_FULL) { fprintf(stderr, "ProcMode (X) : FULL IMAGE\n"); } else { *************** *** 170,176 **** } ! 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 { --- 164,170 ---- } ! 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 { *************** *** 178,182 **** } ! if( arTemplateMatchingMode == AR_TEMPLATE_MATCHING_COLOR ) { fprintf(stderr, "TemplateMatchingMode (M) : Color Template\n"); } else { --- 172,176 ---- } ! if (arTemplateMatchingMode == AR_TEMPLATE_MATCHING_COLOR) { fprintf(stderr, "TemplateMatchingMode (M) : Color Template\n"); } else { *************** *** 184,188 **** } ! if( arMatchingPCAMode == AR_MATCHING_WITHOUT_PCA ) { fprintf(stderr, "MatchingPCAMode (P) : Without PCA\n"); } else { --- 178,182 ---- } ! if (arMatchingPCAMode == AR_MATCHING_WITHOUT_PCA) { fprintf(stderr, "MatchingPCAMode (P) : Without PCA\n"); } else { *************** *** 204,208 **** static void Keyboard(unsigned char key, int x, int y) { ! int mode; switch (key) { case 0x1B: // Quit. --- 198,203 ---- static void Keyboard(unsigned char key, int x, int y) { ! int mode, threshChange = 0; ! switch (key) { case 0x1B: // Quit. *************** *** 225,229 **** gCallCountMarkerDetect = 0; arUtilTimerReset(); ! debugReportMode(); break; case '?': --- 220,235 ---- gCallCountMarkerDetect = 0; arUtilTimerReset(); ! debugReportMode(gArglSettings); ! break; ! case '-': ! threshChange = -5; ! break; ! case '+': ! case '=': ! threshChange = +5; ! break; ! case 'D': ! case 'd': ! arDebug = !arDebug; break; case '?': *************** *** 232,235 **** --- 238,243 ---- printf(" q or [esc] Quit demo.\n"); printf(" c Change arglDrawMode and arglTexmapMode.\n"); + printf(" - and + Adjust threshhold.\n"); + printf(" d Activate / deactivate debug mode.\n"); printf(" ? or / Show this help.\n"); printf("\nAdditionally, the ARVideo library supplied the following help text:\n"); *************** *** 239,242 **** --- 247,256 ---- break; } + if (threshChange) { + gARTThreshhold += threshChange; + if (gARTThreshhold < 0) gARTThreshhold = 0; + if (gARTThreshhold > 255) gARTThreshhold = 255; + printf("Threshhold changed to %d.\n", gARTThreshhold); + } } *************** *** 264,268 **** if ((image = arVideoGetImage()) != NULL) { gARTImage = image; // Save the fetched image. - gPatt_found = FALSE; // Invalidate any previous detected markers. gCallCountMarkerDetect++; // Increment ARToolKit FPS counter. --- 278,281 ---- *************** *** 300,304 **** } gObjectData[i].visible = 1; - gPatt_found = TRUE; } else { gObjectData[i].visible = 0; --- 313,316 ---- *************** *** 306,310 **** } ! // Tell GLUT to update the display. glutPostRedisplay(); } --- 318,322 ---- } ! // Tell GLUT the display has changed. glutPostRedisplay(); } *************** *** 358,386 **** 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 ! // All other lighting and geometry goes here. ! // Calculate the camera position for each object and draw it. ! for (i = 0; i < gObjectDataCount; i++) { ! if ((gObjectData[i].visible != 0) && (gObjectData[i].vrml_id >= 0)) { ! //fprintf(stderr, "About to draw object %i\n", i); ! arglCameraViewRH(gObjectData[i].trans, m, VIEW_SCALEFACTOR_4); ! glLoadMatrixd(m); ! arVrmlDraw(gObjectData[i].vrml_id); ! } ! } ! } // gPatt_found // Any 2D overlays go here. --- 370,399 ---- 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 ! ! for (i = 0; i < gObjectDataCount; i++) { ! ! if ((gObjectData[i].visible != 0) && (gObjectData[i].vrml_id >= 0)) { ! ! // Calculate the camera position for the object and draw it. ! // Replace VIEW_SCALEFACTOR with 1.0 to make one drawing unit equal to 1.0 ARToolKit units (usually millimeters). ! arglCameraViewRH(gObjectData[i].trans, m, VIEW_SCALEFACTOR); ! glLoadMatrixd(m); ! // All lighting and geometry to be drawn relative to the marker goes here. ! //fprintf(stderr, "About to draw object %i\n", i); ! arVrmlDraw(gObjectData[i].vrml_id); ! } ! } // Any 2D overlays go here. *************** *** 394,399 **** int i; char glutGamemode[32]; ! const char *cparam_name = ! "Data/camera_para.dat"; #ifdef _WIN32 char *vconf = "Data\\WDM_camera_flipV.xml"; --- 407,414 ---- int i; char glutGamemode[32]; ! const char *cparam_name = "Data/camera_para.dat"; ! // ! // Camera configuration. ! // #ifdef _WIN32 char *vconf = "Data\\WDM_camera_flipV.xml"; *************** *** 434,438 **** glutEnterGameMode(); } else { ! glutInitWindowSize(gARTCparam.xsize, gARTCparam.ysize); glutCreateWindow(argv[0]); } --- 449,453 ---- glutEnterGameMode(); } else { ! glutInitWindowSize(prefWidth, prefHeight); glutCreateWindow(argv[0]); } *************** *** 443,450 **** exit(-1); } ! debugReportMode(); arUtilTimerReset(); ! if (!setupMarkersObjects(objectDataFilename)) { fprintf(stderr, "main(): Unable to set up AR objects and markers.\n"); Quit(); --- 458,466 ---- exit(-1); } ! debugReportMode(gArglSettings); ! glEnable(GL_DEPTH_TEST); arUtilTimerReset(); ! if (!setupMarkersObjects(objectDataFilename, &gObjectData, &gObjectDataCount)) { fprintf(stderr, "main(): Unable to set up AR objects and markers.\n"); Quit(); |