[artoolkit-commits] artoolkit/examples/simpleVRML simpleVRML.c,1.5,1.6
Optical marker tracking and overlay for augmented reality.
Brought to you by:
philip_lamb
From: Philip L. <phi...@us...> - 2005-07-29 23:23:13
|
Update of /cvsroot/artoolkit/artoolkit/examples/simpleVRML In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23886 Modified Files: simpleVRML.c Log Message: Cleanup drawing code. Index: simpleVRML.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/simpleVRML/simpleVRML.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** simpleVRML.c 28 Jul 2005 21:57:44 -0000 1.5 --- simpleVRML.c 29 Jul 2005 23:23:03 -0000 1.6 *************** *** 8,12 **** * Copyright (c) 2002 Mark Billinghurst (MB) gr...@hi... * Copyright (c) 2004 Raphael Grasset (RG) rap...@hi.... ! * Copyright (c) 2004 Philip Lamb (PRL) ph...@ed.... * * Rev Date Who Changes --- 8,12 ---- * Copyright (c) 2002 Mark Billinghurst (MB) gr...@hi... * Copyright (c) 2004 Raphael Grasset (RG) rap...@hi.... ! * Copyright (c) 2004-2005 Philip Lamb (PRL) ph...@ed.... * * Rev Date Who Changes *************** *** 86,98 **** // ARToolKit globals. - static long gCallCountMarkerDetect = 0; - static int gARTThreshhold = 100; static ARParam gARTCparam; static ARUint8 *gARTImage = NULL; ! static int gPatt_found; static ARGL_CONTEXT_SETTINGS_REF gArglSettings = NULL; // Object Data. - static char *gObjectDataFilename = "Data/object_data_vrml"; static ObjectData_T *gObjectData; static int gObjectDataCount; --- 86,97 ---- // ARToolKit globals. static ARParam gARTCparam; static ARUint8 *gARTImage = NULL; ! static int gARTThreshhold = 100; ! static long gCallCountMarkerDetect = 0; ! static int gPatt_found = FALSE; static ARGL_CONTEXT_SETTINGS_REF gArglSettings = NULL; // Object Data. static ObjectData_T *gObjectData; static int gObjectDataCount; *************** *** 116,120 **** // Find the size of the window. if (arVideoInqSize(&xsize, &ysize) < 0) return (FALSE); ! fprintf(stderr, "demoARSetupCamera(): Camera image size (x,y) = (%d,%d)\n", xsize, ysize); // Load the camera parameters, resize for the window and init. --- 115,119 ---- // Find the size of the window. if (arVideoInqSize(&xsize, &ysize) < 0) return (FALSE); ! fprintf(stdout, "Camera image size (x,y) = (%d,%d)\n", xsize, ysize); // Load the camera parameters, resize for the window and init. *************** *** 125,129 **** arParamChangeSize(&wparam, xsize, ysize, &gARTCparam); arInitCparam(&gARTCparam); ! fprintf(stderr, "*** Camera Parameter ***\n"); arParamDisp(&gARTCparam); --- 124,128 ---- arParamChangeSize(&wparam, xsize, ysize, &gARTCparam); arInitCparam(&gARTCparam); ! fprintf(stdout, "*** Camera Parameter ***\n"); arParamDisp(&gARTCparam); *************** *** 136,143 **** } ! static int demoARSetupMarkersObjects(void) { // Load in the object data - trained markers and associated bitmap files. ! if ((gObjectData = read_VRMLdata(gObjectDataFilename, &gObjectDataCount)) == NULL) exit(0); printf("Object count = %d\n", gObjectDataCount); --- 135,146 ---- } ! static int demoARSetupMarkersObjects(char *objectDataFilename) { // Load in the object data - trained markers and associated bitmap files. ! if ((gObjectData = read_VRMLdata(objectDataFilename, &gObjectDataCount)) == NULL) { ! fprintf(stderr, "demoARSetupMarkersObjects(): read_VRMLdata returned error !!\n"); ! return (FALSE); ! } ! printf("Object count = %d\n", gObjectDataCount); *************** *** 217,221 **** demoARDebugReportMode(); break; - break; #ifdef AR_OPENGL_TEXTURE_RECTANGLE case 'R': --- 220,223 ---- *************** *** 248,252 **** float s_elapsed; ARUint8 *image; ! ARMarkerInfo *marker_info; // Pointer to array holding the details of detected markers. int marker_num; // Count of number of markers detected. --- 250,254 ---- float s_elapsed; ARUint8 *image; ! ARMarkerInfo *marker_info; // Pointer to array holding the details of detected markers. int marker_num; // Count of number of markers detected. *************** *** 264,268 **** // Grab a video frame. if ((image = arVideoGetImage()) != NULL) { ! gARTImage = image; gCallCountMarkerDetect++; // Increment ARToolKit FPS counter. --- 266,271 ---- // Grab a video frame. if ((image = arVideoGetImage()) != NULL) { ! gARTImage = image; // Save the fetched image. ! gPatt_found = FALSE; // Invalidate any previous detected markers. gCallCountMarkerDetect++; // Increment ARToolKit FPS counter. *************** *** 274,278 **** // Check for object visibility. - gPatt_found = FALSE; // At this stage, no patterns found. for (i = 0; i < gObjectDataCount; i++) { --- 277,280 ---- *************** *** 305,313 **** gPatt_found = TRUE; } ! } } - - // Tell GLUT to update the display. - glutPostRedisplay(); } --- 307,315 ---- gPatt_found = TRUE; } ! } ! ! // Tell GLUT to update the display. ! glutPostRedisplay(); } } *************** *** 338,342 **** glMatrixMode(GL_MODELVIEW); glLoadIdentity(); ! // Call through to anyone else who needs to know about window sizing here. } --- 340,344 ---- glMatrixMode(GL_MODELVIEW); glLoadIdentity(); ! // Call through to anyone else who needs to know about window sizing here. } *************** *** 348,372 **** { int i; ! static GLdouble *p = NULL; GLdouble m[16]; ! // Context setup. glDrawBuffer(GL_BACK); arglDispImage(gARTImage, &gARTCparam, 1.0, gArglSettings); // zoom = 1.0. - arVideoCapNext(); ! if (gPatt_found) { glClear(GL_DEPTH_BUFFER_BIT); // Clear the buffers for new frame. // Projection transformation. ! if (p == NULL) { ! p = (GLdouble *)malloc(16 * (sizeof(GLdouble))); ! arglCameraFrustum(&gARTCparam, VIEW_DISTANCE_MIN, VIEW_DISTANCE_MAX, p); ! } glMatrixMode(GL_PROJECTION); glLoadMatrixd(p); glMatrixMode(GL_MODELVIEW); ! // Viewing transformation. glLoadIdentity(); --- 350,371 ---- { int i; ! GLdouble p[16]; GLdouble m[16]; ! // Select correct buffer for this context. glDrawBuffer(GL_BACK); + arglDispImage(gARTImage, &gARTCparam, 1.0, gArglSettings); // zoom = 1.0. arVideoCapNext(); ! if (gPatt_found) { glClear(GL_DEPTH_BUFFER_BIT); // Clear the buffers for new frame. // Projection transformation. ! arglCameraFrustum(&gARTCparam, VIEW_DISTANCE_MIN, VIEW_DISTANCE_MAX, p); glMatrixMode(GL_PROJECTION); glLoadMatrixd(p); glMatrixMode(GL_MODELVIEW); ! // Viewing transformation. glLoadIdentity(); *************** *** 386,393 **** } } - - gPatt_found = FALSE; } // gPatt_found ! // Any 2D overlays go here. //none --- 385,390 ---- } } } // gPatt_found ! // Any 2D overlays go here. //none *************** *** 409,412 **** --- 406,410 ---- "-dev=/dev/video0 -channel=0 -palette=YUV420P -width=320 -height=240"; #endif + static char objectDataFilename[] = "Data/object_data_vrml"; // ---------------------------------------------------------------------------- *************** *** 415,419 **** glutInit(&argc, argv); ! // ---------------------------------------------------------------------------- // Hardware setup. --- 413,417 ---- glutInit(&argc, argv); ! // ---------------------------------------------------------------------------- // Hardware setup. *************** *** 453,458 **** arUtilTimerReset(); ! if (!demoARSetupMarkersObjects()) { fprintf(stderr, "main(): Unable to set up AR objects and markers.\n"); } --- 451,457 ---- arUtilTimerReset(); ! if (!demoARSetupMarkersObjects(objectDataFilename)) { fprintf(stderr, "main(): Unable to set up AR objects and markers.\n"); + Quit(); } *************** *** 465,469 **** glutMainLoop(); ! return (0); ! } \ No newline at end of file --- 464,468 ---- glutMainLoop(); ! return (0); ! } |