artoolkit-commits Mailing List for ARToolKit (Page 25)
Optical marker tracking and overlay for augmented reality.
Brought to you by:
philip_lamb
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(65) |
Dec
(32) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
|
Feb
(5) |
Mar
(15) |
Apr
(22) |
May
|
Jun
(9) |
Jul
(108) |
Aug
(42) |
Sep
(62) |
Oct
(5) |
Nov
|
Dec
(4) |
2006 |
Jan
|
Feb
|
Mar
|
Apr
(38) |
May
(27) |
Jun
(58) |
Jul
(8) |
Aug
(11) |
Sep
(51) |
Oct
(15) |
Nov
(12) |
Dec
(3) |
2007 |
Jan
(25) |
Feb
(6) |
Mar
(8) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(13) |
Sep
(1) |
Oct
(1) |
Nov
(2) |
Dec
|
2008 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(20) |
Sep
(5) |
Oct
|
Nov
|
Dec
(2) |
2009 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
From: Philip L. <phi...@us...> - 2004-12-02 00:48:18
|
Update of /cvsroot/artoolkit/artoolkit/examples/loadMultiple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21251 Modified Files: object.c loadMultiple.c Log Message: Fix some build warnings. Index: object.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/loadMultiple/object.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** object.c 22 Nov 2004 03:38:05 -0000 1.1 --- object.c 2 Dec 2004 00:48:07 -0000 1.2 *************** *** 1,101 **** ! ! /* ! ** ARToolKit object parsing function ! ** - reads in object data from object file in Data/object_data ! ** ! ** Format: ! ** <obj_num> ! ** ! ** <obj_name> ! ** <obj_pattern filename> ! ** <marker_width> ! ** <centerX centerY> ! ** ! ** ... ! ** ! ** eg ! ** ! ** #pattern 1 ! ** Hiro ! ** Data/hiroPatt ! ** 80.0 ! ** 0.0 0.0 ! ** ! */ ! ! #include <stdio.h> ! #include <malloc.h> ! #include <stdlib.h> ! #include <string.h> ! #include <AR/ar.h> ! #include "object.h" ! ! static char *get_buff( char *buf, int n, FILE *fp ); ! ! ObjectData_T *read_ObjData( char *name, int *objectnum ) ! { ! FILE *fp; ! ObjectData_T *object; ! char buf[256], buf1[256]; ! int i; ! ! printf("Opening Data File %s\n",name); ! ! if( (fp=fopen(name, "r")) == NULL ) { ! printf("Can't find the file - quitting \n"); ! return(0); ! } ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%d", objectnum) != 1 ) {fclose(fp); return(0);} ! ! printf("About to load %d Models\n",*objectnum); ! ! object = (ObjectData_T *)malloc( sizeof(ObjectData_T) * *objectnum ); ! if( object == NULL ) return(0); ! ! for( i = 0; i < *objectnum; i++ ) { ! object[i].visible = 0; ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%s", buf1, object[i].name) != 1 ) { ! fclose(fp); free(object); return(0); ! } ! ! printf("Read in No.%d \n", i+1); ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%s", buf1) != 1 ) { ! fclose(fp); free(object); return(0);} ! ! if( (object[i].id = arLoadPatt(buf1)) < 0 ) ! {fclose(fp); free(object); return(0);} ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%lf", &object[i].marker_width) != 1 ) { ! fclose(fp); free(object); return(0); ! } ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%lf %lf", &object[i].marker_center[0], ! &object[i].marker_center[1]) != 2 ) { ! fclose(fp); free(object); return(0); ! } ! ! } ! ! fclose(fp); ! ! return( object ); ! } ! ! static char *get_buff( char *buf, int n, FILE *fp ) ! { ! char *ret; ! ! for(;;) { ! ret = fgets( buf, n, fp ); ! if( ret == NULL ) return(NULL); ! if( buf[0] != '\n' && buf[0] != '#' ) return(ret); ! } ! } --- 1,100 ---- ! ! /* ! ** ARToolKit object parsing function ! ** - reads in object data from object file in Data/object_data ! ** ! ** Format: ! ** <obj_num> ! ** ! ** <obj_name> ! ** <obj_pattern filename> ! ** <marker_width> ! ** <centerX centerY> ! ** ! ** ... ! ** ! ** eg ! ** ! ** #pattern 1 ! ** Hiro ! ** Data/hiroPatt ! ** 80.0 ! ** 0.0 0.0 ! ** ! */ ! ! #include <stdio.h> ! #include <stdlib.h> ! #include <string.h> ! #include <AR/ar.h> ! #include "object.h" ! ! static char *get_buff( char *buf, int n, FILE *fp ); ! ! ObjectData_T *read_ObjData( char *name, int *objectnum ) ! { ! FILE *fp; ! ObjectData_T *object; ! char buf[256], buf1[256]; ! int i; ! ! printf("Opening Data File %s\n",name); ! ! if( (fp=fopen(name, "r")) == NULL ) { ! printf("Can't find the file - quitting \n"); ! return(0); ! } ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%d", objectnum) != 1 ) {fclose(fp); return(0);} ! ! printf("About to load %d Models\n",*objectnum); ! ! object = (ObjectData_T *)malloc( sizeof(ObjectData_T) * *objectnum ); ! if( object == NULL ) return(0); ! ! for( i = 0; i < *objectnum; i++ ) { ! object[i].visible = 0; ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%s", object[i].name) != 1 ) { ! fclose(fp); free(object); return(0); ! } ! ! printf("Read in No.%d \n", i+1); ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%s", buf1) != 1 ) { ! fclose(fp); free(object); return(0);} ! ! if( (object[i].id = arLoadPatt(buf1)) < 0 ) ! {fclose(fp); free(object); return(0);} ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%lf", &object[i].marker_width) != 1 ) { ! fclose(fp); free(object); return(0); ! } ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%lf %lf", &object[i].marker_center[0], ! &object[i].marker_center[1]) != 2 ) { ! fclose(fp); free(object); return(0); ! } ! ! } ! ! fclose(fp); ! ! return( object ); ! } ! ! static char *get_buff( char *buf, int n, FILE *fp ) ! { ! char *ret; ! ! for(;;) { ! ret = fgets( buf, n, fp ); ! if( ret == NULL ) return(NULL); ! if( buf[0] != '\n' && buf[0] != '#' ) return(ret); ! } ! } Index: loadMultiple.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/loadMultiple/loadMultiple.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** loadMultiple.c 22 Nov 2004 03:38:05 -0000 1.1 --- loadMultiple.c 2 Dec 2004 00:48:07 -0000 1.2 *************** *** 1,256 **** ! #ifdef _WIN32 ! #include <windows.h> ! #endif ! #include <stdio.h> ! #include <stdlib.h> ! #include <string.h> ! #include <math.h> ! ! #include <GL/gl.h> ! #include <GL/glut.h> ! #include <AR/gsub.h> ! #include <AR/param.h> ! #include <AR/ar.h> ! #include <AR/video.h> ! ! #include "object.h" ! ! #define COLLIDE_DIST 30000.0 ! ! /* Object Data */ ! char *model_name = "Data/object_data2"; ! ObjectData_T *object; ! int objectnum; ! ! int xsize, ysize; ! int thresh = 100; ! int count = 0; ! ! /* set video capture configuration */ ! /*****************************************************************************/ ! // modified by Thomas Pintaric, Vienna University of Technology ! ! #ifdef _WIN32 ! char *vconf = "flipV,showDlg"; // see video.h for a list of supported parameters ! #else ! char *vconf = ""; ! #endif ! /*****************************************************************************/ ! ! char *cparam_name = "Data/camera_para.dat"; ! ARParam cparam; ! ! static void init(void); ! static void cleanup(void); ! static void keyEvent( unsigned char key, int x, int y); ! static void mainLoop(void); ! static int draw( ObjectData_T *object, int objectnum ); ! static int draw_object( int obj_id, double gl_para[16] ); ! ! int main() ! { ! //initialize applications ! init(); ! ! arVideoCapStart(); ! ! //start the main event loop ! argMainLoop( NULL, keyEvent, mainLoop ); ! ! return 0; ! } ! ! static void keyEvent( unsigned char key, int x, int y) ! { ! /* quit if the ESC key is pressed */ ! if( key == 0x1b ) { ! printf("*** %f (frame/sec)\n", (double)count/arUtilTimer()); ! cleanup(); ! exit(0); ! } ! } ! ! /* main loop */ ! static void mainLoop(void) ! { ! ARUint8 *dataPtr; ! ARMarkerInfo *marker_info; ! int marker_num; ! int i,j,k; ! ! /* grab a video frame */ ! if( (dataPtr = (ARUint8 *)arVideoGetImage()) == NULL ) { ! arUtilSleep(2); ! return; ! } ! ! if( count == 0 ) arUtilTimerReset(); ! count++; ! ! /*draw the video*/ ! argDrawMode2D(); ! argDispImage( dataPtr, 0,0 ); ! ! glColor3f( 1.0, 0.0, 0.0 ); ! glLineWidth(6.0); ! ! /* detect the markers in the video frame */ ! if(arDetectMarker(dataPtr, thresh, ! &marker_info, &marker_num) < 0 ) { ! cleanup(); ! exit(0); ! } ! for( i = 0; i < marker_num; i++ ) { ! argDrawSquare(marker_info[i].vertex,0,0); ! } ! ! /* check for known patterns */ ! for( i = 0; i < objectnum; i++ ) { ! k = -1; ! for( j = 0; j < marker_num; j++ ) { ! if( object[i].id == marker_info[j].id) { ! ! /* you've found a pattern */ ! //printf("Found pattern: %d ",patt_id); ! glColor3f( 0.0, 1.0, 0.0 ); ! argDrawSquare(marker_info[j].vertex,0,0); ! ! if( k == -1 ) k = j; ! else /* make sure you have the best pattern (highest confidence factor) */ ! if( marker_info[k].cf < marker_info[j].cf ) k = j; ! } ! } ! if( k == -1 ) { ! object[i].visible = 0; ! continue; ! } ! ! /* calculate the transform for each marker */ ! if( object[i].visible == 0 ) { ! arGetTransMat(&marker_info[k], ! object[i].marker_center, object[i].marker_width, ! object[i].trans); ! } ! else { ! arGetTransMatCont(&marker_info[k], object[i].trans, ! object[i].marker_center, object[i].marker_width, ! object[i].trans); ! } ! object[i].visible = 1; ! } ! ! arVideoCapNext(); ! ! /* draw the AR graphics */ ! draw( object, objectnum ); ! ! /*swap the graphics buffers*/ ! argSwapBuffers(); ! } ! ! static void init( void ) ! { ! ARParam wparam; ! ! /* open the video path */ ! if( arVideoOpen( vconf ) < 0 ) exit(0); ! /* find the size of the window */ ! if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0); ! printf("Image size (x,y) = (%d,%d)\n", xsize, ysize); ! ! /* set the initial camera parameters */ ! if( arParamLoad(cparam_name, 1, &wparam) < 0 ) { ! printf("Camera parameter load error !!\n"); ! exit(0); ! } ! arParamChangeSize( &wparam, xsize, ysize, &cparam ); ! arInitCparam( &cparam ); ! printf("*** Camera Parameter ***\n"); ! arParamDisp( &cparam ); ! ! /* load in the object data - trained markers and associated bitmap files */ ! if( (object=read_ObjData(model_name, &objectnum)) == NULL ) exit(0); ! printf("Objectfile num = %d\n", objectnum); ! ! /* open the graphics window */ ! argInit( &cparam, 2.0, 0, 0, 0, 0 ); ! } ! ! /* cleanup function called when program exits */ ! static void cleanup(void) ! { ! arVideoCapStop(); ! arVideoClose(); ! argCleanup(); ! } ! ! /* draw the the AR objects */ ! static int draw( ObjectData_T *object, int objectnum ) ! { ! int i; ! double gl_para[16]; ! ! glClearDepth( 1.0 ); ! glClear(GL_DEPTH_BUFFER_BIT); ! glEnable(GL_DEPTH_TEST); ! glDepthFunc(GL_LEQUAL); ! glEnable(GL_LIGHTING); ! ! /* calculate the viewing parameters - gl_para */ ! for( i = 0; i < objectnum; i++ ) { ! if( object[i].visible == 0 ) continue; ! argConvGlpara(object[i].trans, gl_para); ! draw_object( object[i].id, gl_para); ! } ! ! glDisable( GL_LIGHTING ); ! glDisable( GL_DEPTH_TEST ); ! ! return(0); ! } ! ! /* draw the user object */ ! static int draw_object( int obj_id, double gl_para[16]) ! { ! GLfloat mat_ambient[] = {0.0, 0.0, 1.0, 1.0}; ! GLfloat mat_ambient_collide[] = {1.0, 0.0, 0.0, 1.0}; ! GLfloat mat_flash[] = {0.0, 0.0, 1.0, 1.0}; ! GLfloat mat_flash_collide[] = {1.0, 0.0, 0.0, 1.0}; ! GLfloat mat_flash_shiny[] = {50.0}; ! GLfloat light_position[] = {100.0,-200.0,200.0,0.0}; ! GLfloat ambi[] = {0.1, 0.1, 0.1, 0.1}; ! GLfloat lightZeroColor[] = {0.9, 0.9, 0.9, 0.1}; ! ! argDrawMode3D(); ! argDraw3dCamera( 0, 0 ); ! glMatrixMode(GL_MODELVIEW); ! glLoadMatrixd( gl_para ); ! ! /* set the material */ ! glEnable(GL_LIGHTING); ! glEnable(GL_LIGHT0); ! glLightfv(GL_LIGHT0, GL_POSITION, light_position); ! glLightfv(GL_LIGHT0, GL_AMBIENT, ambi); ! glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor); ! ! glMaterialfv(GL_FRONT, GL_SHININESS, mat_flash_shiny); ! ! if(obj_id == 0){ ! glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash_collide); ! glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_collide); ! /* draw a cube */ ! glTranslatef( 0.0, 0.0, 30.0 ); ! glutSolidSphere(30,12,6); ! } ! else { ! glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash); ! glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); ! /* draw a cube */ ! glTranslatef( 0.0, 0.0, 30.0 ); ! glutSolidCube(60); ! } ! ! argDrawMode2D(); ! ! return 0; ! } --- 1,259 ---- ! #ifdef _WIN32 ! # include <windows.h> ! #endif ! #include <stdio.h> ! #include <stdlib.h> ! #include <string.h> ! #include <math.h> ! ! #ifndef __APPLE__ ! # include <GL/glut.h> ! #else ! # include <GLUT/glut.h> ! #endif ! #include <AR/gsub.h> ! #include <AR/param.h> ! #include <AR/ar.h> ! #include <AR/video.h> ! ! #include "object.h" ! ! #define COLLIDE_DIST 30000.0 ! ! /* Object Data */ ! char *model_name = "Data/object_data2"; ! ObjectData_T *object; ! int objectnum; ! ! int xsize, ysize; ! int thresh = 100; ! int count = 0; ! ! /* set video capture configuration */ ! /*****************************************************************************/ ! // modified by Thomas Pintaric, Vienna University of Technology ! ! #ifdef _WIN32 ! char *vconf = "flipV,showDlg"; // see video.h for a list of supported parameters ! #else ! char *vconf = ""; ! #endif ! /*****************************************************************************/ ! ! char *cparam_name = "Data/camera_para.dat"; ! ARParam cparam; ! ! static void init(void); ! static void cleanup(void); ! static void keyEvent( unsigned char key, int x, int y); ! static void mainLoop(void); ! static int draw( ObjectData_T *object, int objectnum ); ! static int draw_object( int obj_id, double gl_para[16] ); ! ! int main() ! { ! //initialize applications ! init(); ! ! arVideoCapStart(); ! ! //start the main event loop ! argMainLoop( NULL, keyEvent, mainLoop ); ! ! return 0; ! } ! ! static void keyEvent( unsigned char key, int x, int y) ! { ! /* quit if the ESC key is pressed */ ! if( key == 0x1b ) { ! printf("*** %f (frame/sec)\n", (double)count/arUtilTimer()); ! cleanup(); ! exit(0); ! } ! } ! ! /* main loop */ ! static void mainLoop(void) ! { ! ARUint8 *dataPtr; ! ARMarkerInfo *marker_info; ! int marker_num; ! int i,j,k; ! ! /* grab a video frame */ ! if( (dataPtr = (ARUint8 *)arVideoGetImage()) == NULL ) { ! arUtilSleep(2); ! return; ! } ! ! if( count == 0 ) arUtilTimerReset(); ! count++; ! ! /*draw the video*/ ! argDrawMode2D(); ! argDispImage( dataPtr, 0,0 ); ! ! glColor3f( 1.0, 0.0, 0.0 ); ! glLineWidth(6.0); ! ! /* detect the markers in the video frame */ ! if(arDetectMarker(dataPtr, thresh, ! &marker_info, &marker_num) < 0 ) { ! cleanup(); ! exit(0); ! } ! for( i = 0; i < marker_num; i++ ) { ! argDrawSquare(marker_info[i].vertex,0,0); ! } ! ! /* check for known patterns */ ! for( i = 0; i < objectnum; i++ ) { ! k = -1; ! for( j = 0; j < marker_num; j++ ) { ! if( object[i].id == marker_info[j].id) { ! ! /* you've found a pattern */ ! //printf("Found pattern: %d ",patt_id); ! glColor3f( 0.0, 1.0, 0.0 ); ! argDrawSquare(marker_info[j].vertex,0,0); ! ! if( k == -1 ) k = j; ! else /* make sure you have the best pattern (highest confidence factor) */ ! if( marker_info[k].cf < marker_info[j].cf ) k = j; ! } ! } ! if( k == -1 ) { ! object[i].visible = 0; ! continue; ! } ! ! /* calculate the transform for each marker */ ! if( object[i].visible == 0 ) { ! arGetTransMat(&marker_info[k], ! object[i].marker_center, object[i].marker_width, ! object[i].trans); ! } ! else { ! arGetTransMatCont(&marker_info[k], object[i].trans, ! object[i].marker_center, object[i].marker_width, ! object[i].trans); ! } ! object[i].visible = 1; ! } ! ! arVideoCapNext(); ! ! /* draw the AR graphics */ ! draw( object, objectnum ); ! ! /*swap the graphics buffers*/ ! argSwapBuffers(); ! } ! ! static void init( void ) ! { ! ARParam wparam; ! ! /* open the video path */ ! if( arVideoOpen( vconf ) < 0 ) exit(0); ! /* find the size of the window */ ! if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0); ! printf("Image size (x,y) = (%d,%d)\n", xsize, ysize); ! ! /* set the initial camera parameters */ ! if( arParamLoad(cparam_name, 1, &wparam) < 0 ) { ! printf("Camera parameter load error !!\n"); ! exit(0); ! } ! arParamChangeSize( &wparam, xsize, ysize, &cparam ); ! arInitCparam( &cparam ); ! printf("*** Camera Parameter ***\n"); ! arParamDisp( &cparam ); ! ! /* load in the object data - trained markers and associated bitmap files */ ! if( (object=read_ObjData(model_name, &objectnum)) == NULL ) exit(0); ! printf("Objectfile num = %d\n", objectnum); ! ! /* open the graphics window */ ! argInit( &cparam, 2.0, 0, 0, 0, 0 ); ! } ! ! /* cleanup function called when program exits */ ! static void cleanup(void) ! { ! arVideoCapStop(); ! arVideoClose(); ! argCleanup(); ! } ! ! /* draw the the AR objects */ ! static int draw( ObjectData_T *object, int objectnum ) ! { ! int i; ! double gl_para[16]; ! ! glClearDepth( 1.0 ); ! glClear(GL_DEPTH_BUFFER_BIT); ! glEnable(GL_DEPTH_TEST); ! glDepthFunc(GL_LEQUAL); ! glEnable(GL_LIGHTING); ! ! /* calculate the viewing parameters - gl_para */ ! for( i = 0; i < objectnum; i++ ) { ! if( object[i].visible == 0 ) continue; ! argConvGlpara(object[i].trans, gl_para); ! draw_object( object[i].id, gl_para); ! } ! ! glDisable( GL_LIGHTING ); ! glDisable( GL_DEPTH_TEST ); ! ! return(0); ! } ! ! /* draw the user object */ ! static int draw_object( int obj_id, double gl_para[16]) ! { ! GLfloat mat_ambient[] = {0.0, 0.0, 1.0, 1.0}; ! GLfloat mat_ambient_collide[] = {1.0, 0.0, 0.0, 1.0}; ! GLfloat mat_flash[] = {0.0, 0.0, 1.0, 1.0}; ! GLfloat mat_flash_collide[] = {1.0, 0.0, 0.0, 1.0}; ! GLfloat mat_flash_shiny[] = {50.0}; ! GLfloat light_position[] = {100.0,-200.0,200.0,0.0}; ! GLfloat ambi[] = {0.1, 0.1, 0.1, 0.1}; ! GLfloat lightZeroColor[] = {0.9, 0.9, 0.9, 0.1}; ! ! argDrawMode3D(); ! argDraw3dCamera( 0, 0 ); ! glMatrixMode(GL_MODELVIEW); ! glLoadMatrixd( gl_para ); ! ! /* set the material */ ! glEnable(GL_LIGHTING); ! glEnable(GL_LIGHT0); ! glLightfv(GL_LIGHT0, GL_POSITION, light_position); ! glLightfv(GL_LIGHT0, GL_AMBIENT, ambi); ! glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor); ! ! glMaterialfv(GL_FRONT, GL_SHININESS, mat_flash_shiny); ! ! if(obj_id == 0){ ! glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash_collide); ! glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_collide); ! /* draw a cube */ ! glTranslatef( 0.0, 0.0, 30.0 ); ! glutSolidSphere(30,12,6); ! } ! else { ! glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash); ! glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); ! /* draw a cube */ ! glTranslatef( 0.0, 0.0, 30.0 ); ! glutSolidCube(60); ! } ! ! argDrawMode2D(); ! ! return 0; ! } |
From: Philip L. <phi...@us...> - 2004-12-02 00:47:53
|
Update of /cvsroot/artoolkit/artoolkit/examples/paddleDemo In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21131 Modified Files: command_sub.h command_sub.c paddle.c paddleDemo.c Log Message: Fix some build warnings. Index: command_sub.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/paddleDemo/command_sub.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** command_sub.c 22 Nov 2004 03:37:35 -0000 1.1 --- command_sub.c 2 Dec 2004 00:47:43 -0000 1.2 *************** *** 1,276 **** ! #ifdef _WIN32 ! #include <windows.h> ! #endif ! #include <stdio.h> ! #include <stdlib.h> ! #include <string.h> ! #include <math.h> ! #include <AR/param.h> ! #include <AR/matrix.h> ! #include <AR/ar.h> ! #include "paddle.h" ! #include "command_sub.h" ! #include "util.h" ! ! ! #define SHAKE_BUF_SIZE 10 ! #define PUNCH_BUF_SIZE 5 ! #define PUSH_BUF_SIZE 2 ! ! typedef struct { ! double mat[3][4]; ! int f; ! } SHAKE_BUF_T; ! ! typedef struct { ! double x, y, z; ! int f; ! } PUNCH_BUF_T; ! ! typedef struct { ! double x, y, z; ! int f; ! } PUSH_BUF_T; ! ! static SHAKE_BUF_T shake_buf[SHAKE_BUF_SIZE]; ! static int shake_buf_num = 0; ! static PUNCH_BUF_T punch_buf[PUNCH_BUF_SIZE]; ! static int punch_buf_num = 0; ! static PUSH_BUF_T push_buf[PUNCH_BUF_SIZE]; ! static int push_buf_num = 0; ! ! ! int check_shake( double card_trans[3][4], int f ) ! { ! ARMat *mat_a, *mat_b, *mat_c; ! double lxy, lz; ! int i, j, k; ! ! if( shake_buf_num < SHAKE_BUF_SIZE ) { ! if( f ) { ! for( j = 0; j < 3; j++ ) { ! for( i = 0; i < 4; i++ ) { ! shake_buf[shake_buf_num].mat[j][i] = card_trans[j][i]; ! } ! } ! shake_buf[shake_buf_num].f = 1; ! } ! else { ! shake_buf[shake_buf_num].f = 0; ! } ! shake_buf_num++; ! ! return 0; ! } ! for( i = 1; i < shake_buf_num; i++ ) { ! shake_buf[i-1] = shake_buf[i]; ! } ! if( f ) { ! for( j = 0; j < 3; j++ ) { ! for( i = 0; i < 4; i++ ) { ! shake_buf[shake_buf_num-1].mat[j][i] = card_trans[j][i]; ! } ! } ! shake_buf[shake_buf_num-1].f = 1; ! } ! else { ! shake_buf[shake_buf_num-1].f = 0; ! ! return 0; ! } ! ! if( shake_buf[SHAKE_BUF_SIZE-3].f == 0 ! || shake_buf[0].f == 0 ) return 0; ! ! ! mat_a = arMatrixAlloc( 4, 4 ); ! mat_b = arMatrixAlloc( 4, 4 ); ! mat_c = arMatrixAlloc( 4, 4 ); ! for( j = 0; j < 3; j++ ) { ! for( i = 0; i < 4; i++ ) { ! mat_a->m[j*4+i] = card_trans[j][i]; ! } ! } ! mat_a->m[3*4+0] = 0.0; ! mat_a->m[3*4+1] = 0.0; ! mat_a->m[3*4+2] = 0.0; ! mat_a->m[3*4+3] = 1.0; ! arMatrixSelfInv( mat_a ); ! ! for( k = 0 ; k < SHAKE_BUF_SIZE-3; k++ ) { ! if( shake_buf[k].f == 0 ) continue; ! ! for( j = 0; j < 3; j++ ) { ! for( i = 0; i < 4; i++ ) { ! mat_b->m[j*4+i] = shake_buf[k].mat[j][i]; ! } ! } ! mat_b->m[3*4+0] = 0.0; ! mat_b->m[3*4+1] = 0.0; ! mat_b->m[3*4+2] = 0.0; ! mat_b->m[3*4+3] = 1.0; ! arMatrixMul( mat_c, mat_a, mat_b ); ! ! lxy = sqrt( (mat_c->m[0*4+3])*(mat_c->m[0*4+3]) ! +(mat_c->m[1*4+3])*(mat_c->m[1*4+3])); ! lz = mat_c->m[2*4+3]; ! ! if( lxy < 20.0 && lz < 20.0 ) break; ! } ! if( k == SHAKE_BUF_SIZE-3 ) { ! arMatrixFree( mat_a ); ! arMatrixFree( mat_b ); ! arMatrixFree( mat_c ); ! return 0; ! } ! ! for( ; k < SHAKE_BUF_SIZE-1; k++ ) { ! if( shake_buf[k].f == 0 ) continue; ! ! for( j = 0; j < 3; j++ ) { ! for( i = 0; i < 4; i++ ) { ! mat_b->m[j*4+i] = shake_buf[k].mat[j][i]; ! } ! } ! mat_b->m[3*4+0] = 0.0; ! mat_b->m[3*4+1] = 0.0; ! mat_b->m[3*4+2] = 0.0; ! mat_b->m[3*4+3] = 1.0; ! arMatrixMul( mat_c, mat_a, mat_b ); ! ! lxy = sqrt( (mat_c->m[0*4+3])*(mat_c->m[0*4+3]) ! +(mat_c->m[1*4+3])*(mat_c->m[1*4+3])); ! lz = mat_c->m[2*4+3]; ! ! if( lxy > 60.0 && lz < 20.0 ) break; ! } ! arMatrixFree( mat_a ); ! arMatrixFree( mat_b ); ! arMatrixFree( mat_c ); ! ! if( k < SHAKE_BUF_SIZE-1 ) { ! shake_buf_num = 0; ! return 1; ! } ! ! return 0; ! } ! ! ! int check_incline( double card_trans[3][4], double base_trans[3][4], double *angle ) ! { ! ARMat *mat_a, *mat_b, *mat_c; ! double a, b, c; ! int i, j; ! ! mat_a = arMatrixAlloc( 4, 4 ); ! mat_b = arMatrixAlloc( 4, 4 ); ! mat_c = arMatrixAlloc( 4, 4 ); ! for( j = 0; j < 3; j++ ) { ! for( i = 0; i < 4; i++ ) { ! mat_b->m[j*4+i] = base_trans[j][i]; ! } ! } ! mat_b->m[3*4+0] = 0.0; ! mat_b->m[3*4+1] = 0.0; ! mat_b->m[3*4+2] = 0.0; ! mat_b->m[3*4+3] = 1.0; ! ! for( j = 0; j < 3; j++ ) { ! for( i = 0; i < 4; i++ ) { ! mat_a->m[j*4+i] = card_trans[j][i]; ! } ! } ! mat_a->m[3*4+0] = 0.0; ! mat_a->m[3*4+1] = 0.0; ! mat_a->m[3*4+2] = 0.0; ! mat_a->m[3*4+3] = 1.0; ! arMatrixSelfInv( mat_a ); ! arMatrixMul( mat_c, mat_a, mat_b ); ! ! get_angle( (double (*)[4])(mat_c->m), &a, &b, &c ); ! ! arMatrixFree( mat_a ); ! arMatrixFree( mat_b ); ! arMatrixFree( mat_c ); ! ! if( b > 0.4 ) { ! *angle = a + 3.141592; ! return 1; ! } ! ! return 0; ! } ! ! int check_pickup(double card_trans[3][4], double base_trans[3][4], ItemList* itlist,float* angle) ! { ! ARMat *t1, *t2, *t3; ! double x, y, z; ! double lx, ly; ! double a, b, c; ! int ret; ! int i, j; ! ! // printf("checking pickup New \n"); ! ! t1 = arMatrixAlloc( 4, 4 ); ! for( j = 0; j < 3; j++ ) { ! for( i = 0; i < 4; i++ ) { ! t1->m[j*4+i] = base_trans[j][i]; ! } ! } ! t1->m[12] = t1->m[13] = t1->m[14] = 0.0; ! t1->m[15] = 1.0; ! ! t2 = arMatrixAlloc( 4, 4 ); ! for( j = 0; j < 3; j++ ) { ! for( i = 0; i < 4; i++ ) { ! t2->m[j*4+i] = card_trans[j][i]; ! } ! } ! t2->m[12] = t2->m[13] = t2->m[14] = 0.0; ! t2->m[15] = 1.0; ! ! if( arMatrixSelfInv(t1) != 0 ) { ! arMatrixFree( t1 ); ! arMatrixFree( t2 ); ! return -1; ! } ! // printf("past arMatrixSelfInv\n"); ! ! t3 = arMatrixAllocMul(t1, t2); ! if( t3 == NULL ) { ! arMatrixFree( t1 ); ! arMatrixFree( t2 ); ! return -1; ! } ! ! // printf("past arMatrixAllocMul\n"); ! ! x = t3->m[0*4+3]; ! y = t3->m[1*4+3]; ! z = t3->m[2*4+3]; ! ! // printf("x: %f y: %f z: %f\n",x,y,z); ! ! ret = -1; ! for( i = 0; i < itlist->itemnum; i ++ ){ ! lx = x - itlist->item[i].pos[0]; ! ly = y - itlist->item[i].pos[1]; ! //MB increased by a factor of 10 ! if( lx*lx + ly*ly < 1000.0 && z < 20.0 ) { ! ret = i; ! } ! } ! ! if( ret >= 0 ) { ! get_angle( (double (*)[4])(t3->m), &a, &b, &c ); ! *angle = -c; ! } ! ! arMatrixFree( t1 ); ! arMatrixFree( t2 ); ! arMatrixFree( t3 ); ! ! return ret; ! } --- 1,276 ---- ! #ifdef _WIN32 ! #include <windows.h> ! #endif ! #include <stdio.h> ! #include <stdlib.h> ! #include <string.h> ! #include <math.h> ! #include <AR/param.h> ! #include <AR/matrix.h> ! #include <AR/ar.h> ! #include "paddle.h" ! #include "command_sub.h" ! #include "util.h" ! ! ! #define SHAKE_BUF_SIZE 10 ! #define PUNCH_BUF_SIZE 5 ! #define PUSH_BUF_SIZE 2 ! ! typedef struct { ! double mat[3][4]; ! int f; ! } SHAKE_BUF_T; ! ! typedef struct { ! double x, y, z; ! int f; ! } PUNCH_BUF_T; ! ! typedef struct { ! double x, y, z; ! int f; ! } PUSH_BUF_T; ! ! static SHAKE_BUF_T shake_buf[SHAKE_BUF_SIZE]; ! static int shake_buf_num = 0; ! //static PUNCH_BUF_T punch_buf[PUNCH_BUF_SIZE]; ! //static int punch_buf_num = 0; ! //static PUSH_BUF_T push_buf[PUNCH_BUF_SIZE]; ! //static int push_buf_num = 0; ! ! ! int check_shake( double card_trans[3][4], int f ) ! { ! ARMat *mat_a, *mat_b, *mat_c; ! double lxy, lz; ! int i, j, k; ! ! if( shake_buf_num < SHAKE_BUF_SIZE ) { ! if( f ) { ! for( j = 0; j < 3; j++ ) { ! for( i = 0; i < 4; i++ ) { ! shake_buf[shake_buf_num].mat[j][i] = card_trans[j][i]; ! } ! } ! shake_buf[shake_buf_num].f = 1; ! } ! else { ! shake_buf[shake_buf_num].f = 0; ! } ! shake_buf_num++; ! ! return 0; ! } ! for( i = 1; i < shake_buf_num; i++ ) { ! shake_buf[i-1] = shake_buf[i]; ! } ! if( f ) { ! for( j = 0; j < 3; j++ ) { ! for( i = 0; i < 4; i++ ) { ! shake_buf[shake_buf_num-1].mat[j][i] = card_trans[j][i]; ! } ! } ! shake_buf[shake_buf_num-1].f = 1; ! } ! else { ! shake_buf[shake_buf_num-1].f = 0; ! ! return 0; ! } ! ! if( shake_buf[SHAKE_BUF_SIZE-3].f == 0 ! || shake_buf[0].f == 0 ) return 0; ! ! ! mat_a = arMatrixAlloc( 4, 4 ); ! mat_b = arMatrixAlloc( 4, 4 ); ! mat_c = arMatrixAlloc( 4, 4 ); ! for( j = 0; j < 3; j++ ) { ! for( i = 0; i < 4; i++ ) { ! mat_a->m[j*4+i] = card_trans[j][i]; ! } ! } ! mat_a->m[3*4+0] = 0.0; ! mat_a->m[3*4+1] = 0.0; ! mat_a->m[3*4+2] = 0.0; ! mat_a->m[3*4+3] = 1.0; ! arMatrixSelfInv( mat_a ); ! ! for( k = 0 ; k < SHAKE_BUF_SIZE-3; k++ ) { ! if( shake_buf[k].f == 0 ) continue; ! ! for( j = 0; j < 3; j++ ) { ! for( i = 0; i < 4; i++ ) { ! mat_b->m[j*4+i] = shake_buf[k].mat[j][i]; ! } ! } ! mat_b->m[3*4+0] = 0.0; ! mat_b->m[3*4+1] = 0.0; ! mat_b->m[3*4+2] = 0.0; ! mat_b->m[3*4+3] = 1.0; ! arMatrixMul( mat_c, mat_a, mat_b ); ! ! lxy = sqrt( (mat_c->m[0*4+3])*(mat_c->m[0*4+3]) ! +(mat_c->m[1*4+3])*(mat_c->m[1*4+3])); ! lz = mat_c->m[2*4+3]; ! ! if( lxy < 20.0 && lz < 20.0 ) break; ! } ! if( k == SHAKE_BUF_SIZE-3 ) { ! arMatrixFree( mat_a ); ! arMatrixFree( mat_b ); ! arMatrixFree( mat_c ); ! return 0; ! } ! ! for( ; k < SHAKE_BUF_SIZE-1; k++ ) { ! if( shake_buf[k].f == 0 ) continue; ! ! for( j = 0; j < 3; j++ ) { ! for( i = 0; i < 4; i++ ) { ! mat_b->m[j*4+i] = shake_buf[k].mat[j][i]; ! } ! } ! mat_b->m[3*4+0] = 0.0; ! mat_b->m[3*4+1] = 0.0; ! mat_b->m[3*4+2] = 0.0; ! mat_b->m[3*4+3] = 1.0; ! arMatrixMul( mat_c, mat_a, mat_b ); ! ! lxy = sqrt( (mat_c->m[0*4+3])*(mat_c->m[0*4+3]) ! +(mat_c->m[1*4+3])*(mat_c->m[1*4+3])); ! lz = mat_c->m[2*4+3]; ! ! if( lxy > 60.0 && lz < 20.0 ) break; ! } ! arMatrixFree( mat_a ); ! arMatrixFree( mat_b ); ! arMatrixFree( mat_c ); ! ! if( k < SHAKE_BUF_SIZE-1 ) { ! shake_buf_num = 0; ! return 1; ! } ! ! return 0; ! } ! ! ! int check_incline( double card_trans[3][4], double base_trans[3][4], double *angle ) ! { ! ARMat *mat_a, *mat_b, *mat_c; ! double a, b, c; ! int i, j; ! ! mat_a = arMatrixAlloc( 4, 4 ); ! mat_b = arMatrixAlloc( 4, 4 ); ! mat_c = arMatrixAlloc( 4, 4 ); ! for( j = 0; j < 3; j++ ) { ! for( i = 0; i < 4; i++ ) { ! mat_b->m[j*4+i] = base_trans[j][i]; ! } ! } ! mat_b->m[3*4+0] = 0.0; ! mat_b->m[3*4+1] = 0.0; ! mat_b->m[3*4+2] = 0.0; ! mat_b->m[3*4+3] = 1.0; ! ! for( j = 0; j < 3; j++ ) { ! for( i = 0; i < 4; i++ ) { ! mat_a->m[j*4+i] = card_trans[j][i]; ! } ! } ! mat_a->m[3*4+0] = 0.0; ! mat_a->m[3*4+1] = 0.0; ! mat_a->m[3*4+2] = 0.0; ! mat_a->m[3*4+3] = 1.0; ! arMatrixSelfInv( mat_a ); ! arMatrixMul( mat_c, mat_a, mat_b ); ! ! get_angle( (double (*)[4])(mat_c->m), &a, &b, &c ); ! ! arMatrixFree( mat_a ); ! arMatrixFree( mat_b ); ! arMatrixFree( mat_c ); ! ! if( b > 0.4 ) { ! *angle = a + 3.141592; ! return 1; ! } ! ! return 0; ! } ! ! int check_pickup(double card_trans[3][4], double base_trans[3][4], ItemList* itlist, double* angle) ! { ! ARMat *t1, *t2, *t3; ! double x, y, z; ! double lx, ly; ! double a, b, c; ! int ret; ! int i, j; ! ! // printf("checking pickup New \n"); ! ! t1 = arMatrixAlloc( 4, 4 ); ! for( j = 0; j < 3; j++ ) { ! for( i = 0; i < 4; i++ ) { ! t1->m[j*4+i] = base_trans[j][i]; ! } ! } ! t1->m[12] = t1->m[13] = t1->m[14] = 0.0; ! t1->m[15] = 1.0; ! ! t2 = arMatrixAlloc( 4, 4 ); ! for( j = 0; j < 3; j++ ) { ! for( i = 0; i < 4; i++ ) { ! t2->m[j*4+i] = card_trans[j][i]; ! } ! } ! t2->m[12] = t2->m[13] = t2->m[14] = 0.0; ! t2->m[15] = 1.0; ! ! if( arMatrixSelfInv(t1) != 0 ) { ! arMatrixFree( t1 ); ! arMatrixFree( t2 ); ! return -1; ! } ! // printf("past arMatrixSelfInv\n"); ! ! t3 = arMatrixAllocMul(t1, t2); ! if( t3 == NULL ) { ! arMatrixFree( t1 ); ! arMatrixFree( t2 ); ! return -1; ! } ! ! // printf("past arMatrixAllocMul\n"); ! ! x = t3->m[0*4+3]; ! y = t3->m[1*4+3]; ! z = t3->m[2*4+3]; ! ! // printf("x: %f y: %f z: %f\n",x,y,z); ! ! ret = -1; ! for( i = 0; i < itlist->itemnum; i ++ ){ ! lx = x - itlist->item[i].pos[0]; ! ly = y - itlist->item[i].pos[1]; ! //MB increased by a factor of 10 ! if( lx*lx + ly*ly < 1000.0 && z < 20.0 ) { ! ret = i; ! } ! } ! ! if( ret >= 0 ) { ! get_angle( (double (*)[4])(t3->m), &a, &b, &c ); ! *angle = -c; ! } ! ! arMatrixFree( t1 ); ! arMatrixFree( t2 ); ! arMatrixFree( t3 ); ! ! return ret; ! } Index: paddle.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/paddleDemo/paddle.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** paddle.c 22 Nov 2004 03:37:35 -0000 1.1 --- paddle.c 2 Dec 2004 00:47:43 -0000 1.2 *************** *** 1,155 **** ! #include <stdio.h> ! #include <malloc.h> ! #include <stdlib.h> ! #include <AR/ar.h> ! #include "paddle.h" ! ! static ARMarkerInfo prevInfoL; ! static ARMarkerInfo prevInfoR; ! static int pcountL = 0; ! static int pcountR = 0; ! ! static char *get_buff( char *buf, int n, FILE *fp ); ! ! static int get_marker( ARMarkerInfo *markerInfo, int *markerFlag, ! int marker_num, int id, ! ARMarkerInfo *prevInfo, int *pcount ); ! ! ! ARPaddleInfo *paddleInit( char *name ) ! { ! FILE *fp; ! ARPaddleInfo *paddleInfo; ! char buf[256], buf1[256]; ! ! if( (fp=fopen(name, "r")) == NULL ) return(0); ! ! arMalloc( paddleInfo, ARPaddleInfo, 1 ); ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%s", paddleInfo->name) != 1 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%s", buf1) != 1 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! if( (paddleInfo->marker_id = arLoadPatt(buf1)) < 0 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%lf", &paddleInfo->width) != 1 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! ! paddleInfo->center[0] = 0.0; ! paddleInfo->center[1] = 0.0; ! paddleInfo->active = 0; ! paddleInfo->pcount = 0; ! paddleInfo->pcountL = 0; ! paddleInfo->pcountR = 0; ! ! fclose(fp); ! ! return paddleInfo; ! } ! ! static char *get_buff( char *buf, int n, FILE *fp ) ! { ! char *ret; ! ! for(;;) { ! ret = fgets( buf, n, fp ); ! if( ret == NULL ) return(NULL); ! if( buf[0] != '\n' && buf[0] != '#' ) return(ret); ! } ! } ! ! int paddleGetTrans( ARPaddleInfo *paddleInfo, ARMarkerInfo *markerInfo, int *markerFlag, int marker_num, ARParam *cparam ) ! { ! int id; ! ! id = get_marker( markerInfo, markerFlag, marker_num, paddleInfo->marker_id, ! &(paddleInfo->prevInfo), &(paddleInfo->pcount) ); ! ! if( id == -1 ) { paddleInfo->active = 0; return 0; } ! ! arGetTransMat(&markerInfo[id], ! paddleInfo->center, paddleInfo->width, paddleInfo->trans); ! markerFlag[id] = 1; ! ! paddleInfo->active = 1; ! ! return 0; ! } ! ! static int get_marker( ARMarkerInfo *markerInfo, int *markerFlag, int marker_num, int id, ! ARMarkerInfo *prevInfo, int *pcount ) ! { ! double rlen, rlenmin, rarea, diff, diffmin; ! int cid, cdir; ! int i, j; ! ! cid = -1; ! for( i = 0; i < marker_num; i++ ) { ! if( markerInfo[i].id == id && markerFlag[i] == 0 ) { ! if( cid == -1 ) cid = i; ! else { ! if( markerInfo[cid].cf < markerInfo[i].cf ) cid = i; ! } ! } ! } ! if( cid == -1 ) { ! if( *pcount == 0 ) return -1; ! ! rlenmin = 10.0; ! for( i = 0; i < marker_num; i++ ) { ! if( markerFlag[i] ) continue; ! rarea = (double)prevInfo->area / (double)markerInfo[i].area; ! if( rarea < 0.7 || rarea > 1.43 ) continue; ! rlen = ( (markerInfo[i].pos[0] - prevInfo->pos[0]) ! * (markerInfo[i].pos[0] - prevInfo->pos[0]) ! + (markerInfo[i].pos[1] - prevInfo->pos[1]) ! * (markerInfo[i].pos[1] - prevInfo->pos[1]) ) / markerInfo[i].area; ! if( rlen < 0.5 && rlen < rlenmin ) { ! rlenmin = rlen; ! cid = i; ! } ! } ! if( cid >= 0 && markerInfo[cid].cf < prevInfo->cf ) { ! markerInfo[cid].cf = prevInfo->cf; ! markerInfo[cid].id = prevInfo->id; ! diffmin = 10000.0 * 10000.0; ! cdir = -1; ! for( i = 0; i < 4; i++ ) { ! diff = 0.0; ! for( j = 0; j < 4; j++ ) { ! diff += (prevInfo->vertex[j][0] - markerInfo[cid].vertex[(i+j)%4][0]) ! * (prevInfo->vertex[j][0] - markerInfo[cid].vertex[(i+j)%4][0]) ! + (prevInfo->vertex[j][1] - markerInfo[cid].vertex[(i+j)%4][1]) ! * (prevInfo->vertex[j][1] - markerInfo[cid].vertex[(i+j)%4][1]); ! } ! if( diff < diffmin ) { ! diffmin = diff; ! cdir = (prevInfo->dir - i + 4) % 4; ! } ! } ! markerInfo[cid].dir = cdir; ! ! *prevInfo = markerInfo[cid]; ! *pcount = 1; ! } ! else { ! *pcount = 0; ! return -1; ! } ! } ! else { ! *prevInfo = markerInfo[cid]; ! *pcount = 1; ! } ! ! return cid; ! } --- 1,149 ---- ! #include <stdio.h> ! #include <stdlib.h> ! #include <AR/ar.h> ! #include "paddle.h" ! ! static char *get_buff( char *buf, int n, FILE *fp ); ! ! static int get_marker( ARMarkerInfo *markerInfo, int *markerFlag, ! int marker_num, int id, ! ARMarkerInfo *prevInfo, int *pcount ); ! ! ! ARPaddleInfo *paddleInit( char *name ) ! { ! FILE *fp; ! ARPaddleInfo *paddleInfo; ! char buf[256], buf1[256]; ! ! if( (fp=fopen(name, "r")) == NULL ) return(0); ! ! arMalloc( paddleInfo, ARPaddleInfo, 1 ); ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%s", paddleInfo->name) != 1 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%s", buf1) != 1 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! if( (paddleInfo->marker_id = arLoadPatt(buf1)) < 0 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%lf", &paddleInfo->width) != 1 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! ! paddleInfo->center[0] = 0.0; ! paddleInfo->center[1] = 0.0; ! paddleInfo->active = 0; ! paddleInfo->pcount = 0; ! paddleInfo->pcountL = 0; ! paddleInfo->pcountR = 0; ! ! fclose(fp); ! ! return paddleInfo; ! } ! ! static char *get_buff( char *buf, int n, FILE *fp ) ! { ! char *ret; ! ! for(;;) { ! ret = fgets( buf, n, fp ); ! if( ret == NULL ) return(NULL); ! if( buf[0] != '\n' && buf[0] != '#' ) return(ret); ! } ! } ! ! int paddleGetTrans( ARPaddleInfo *paddleInfo, ARMarkerInfo *markerInfo, int *markerFlag, int marker_num, ARParam *cparam ) ! { ! int id; ! ! id = get_marker( markerInfo, markerFlag, marker_num, paddleInfo->marker_id, ! &(paddleInfo->prevInfo), &(paddleInfo->pcount) ); ! ! if( id == -1 ) { paddleInfo->active = 0; return 0; } ! ! arGetTransMat(&markerInfo[id], ! paddleInfo->center, paddleInfo->width, paddleInfo->trans); ! markerFlag[id] = 1; ! ! paddleInfo->active = 1; ! ! return 0; ! } ! ! static int get_marker( ARMarkerInfo *markerInfo, int *markerFlag, int marker_num, int id, ! ARMarkerInfo *prevInfo, int *pcount ) ! { ! double rlen, rlenmin, rarea, diff, diffmin; ! int cid, cdir; ! int i, j; ! ! cid = -1; ! for( i = 0; i < marker_num; i++ ) { ! if( markerInfo[i].id == id && markerFlag[i] == 0 ) { ! if( cid == -1 ) cid = i; ! else { ! if( markerInfo[cid].cf < markerInfo[i].cf ) cid = i; ! } ! } ! } ! if( cid == -1 ) { ! if( *pcount == 0 ) return -1; ! ! rlenmin = 10.0; ! for( i = 0; i < marker_num; i++ ) { ! if( markerFlag[i] ) continue; ! rarea = (double)prevInfo->area / (double)markerInfo[i].area; ! if( rarea < 0.7 || rarea > 1.43 ) continue; ! rlen = ( (markerInfo[i].pos[0] - prevInfo->pos[0]) ! * (markerInfo[i].pos[0] - prevInfo->pos[0]) ! + (markerInfo[i].pos[1] - prevInfo->pos[1]) ! * (markerInfo[i].pos[1] - prevInfo->pos[1]) ) / markerInfo[i].area; ! if( rlen < 0.5 && rlen < rlenmin ) { ! rlenmin = rlen; ! cid = i; ! } ! } ! if( cid >= 0 && markerInfo[cid].cf < prevInfo->cf ) { ! markerInfo[cid].cf = prevInfo->cf; ! markerInfo[cid].id = prevInfo->id; ! diffmin = 10000.0 * 10000.0; ! cdir = -1; ! for( i = 0; i < 4; i++ ) { ! diff = 0.0; ! for( j = 0; j < 4; j++ ) { ! diff += (prevInfo->vertex[j][0] - markerInfo[cid].vertex[(i+j)%4][0]) ! * (prevInfo->vertex[j][0] - markerInfo[cid].vertex[(i+j)%4][0]) ! + (prevInfo->vertex[j][1] - markerInfo[cid].vertex[(i+j)%4][1]) ! * (prevInfo->vertex[j][1] - markerInfo[cid].vertex[(i+j)%4][1]); ! } ! if( diff < diffmin ) { ! diffmin = diff; ! cdir = (prevInfo->dir - i + 4) % 4; ! } ! } ! markerInfo[cid].dir = cdir; ! ! *prevInfo = markerInfo[cid]; ! *pcount = 1; ! } ! else { ! *pcount = 0; ! return -1; ! } ! } ! else { ! *prevInfo = markerInfo[cid]; ! *pcount = 1; ! } ! ! return cid; ! } Index: paddleDemo.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/paddleDemo/paddleDemo.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** paddleDemo.c 22 Nov 2004 03:37:35 -0000 1.1 --- paddleDemo.c 2 Dec 2004 00:47:43 -0000 1.2 *************** *** 1,546 **** ! #ifdef _WIN32 ! #include <windows.h> ! #endif ! #include <stdio.h> ! #include <stdlib.h> ! #include <string.h> ! #include <math.h> ! ! #include <GL/gl.h> ! #include <GL/glut.h> [...1061 lines suppressed...] ! y0 = y0 + deltaY; ! glBegin(GL_LINES); ! glVertex3f(x0,y0,height); ! glVertex3f(x1,y0,height); ! glEnd(); ! } ! ! glLineWidth(1.0); ! ! glEnable(GL_LIGHTING); ! glEnable(GL_LIGHT0); ! glLightfv(GL_LIGHT0, GL_POSITION, light_position); ! glLightfv(GL_LIGHT0, GL_AMBIENT, ambi); ! glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor); ! ! glDisable( GL_LIGHTING ); ! glDisable( GL_DEPTH_TEST ); ! argDrawMode2D(); ! return 0; ! } Index: command_sub.h =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/paddleDemo/command_sub.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** command_sub.h 22 Nov 2004 03:37:35 -0000 1.1 --- command_sub.h 2 Dec 2004 00:47:43 -0000 1.2 *************** *** 1,34 **** ! #ifndef COMMAND_SUB_H ! #define COMMAND_SUB_H ! ! #include "paddle.h" ! ! /* on item structure */ ! typedef struct { ! double pos[2]; ! int onpaddle; ! } Item; ! ! /* list of items */ ! typedef struct { ! int itemnum; ! Item item[256]; ! } ItemList; ! ! /* item which is on the paddle */ ! typedef struct { ! int item; ! double angle; ! double x, y; ! } PaddleItemInfo; ! ! /* shaking gesture to remove a pattern */ ! int check_shake ( double paddleTrans[3][4], int f ); ! ! /* inclining gesture to put an object on the ground*/ ! int check_incline ( double paddleTrans[3][4], double baseTrans[3][4], double *angle ); ! ! /* picking gesture to take an object from the ground*/ ! int check_pickup(double card_trans[3][4], double base_trans[3][4], ItemList* itlist,float* angle); ! ! #endif --- 1,34 ---- ! #ifndef COMMAND_SUB_H ! #define COMMAND_SUB_H ! ! #include "paddle.h" ! ! /* on item structure */ ! typedef struct { ! double pos[2]; ! int onpaddle; ! } Item; ! ! /* list of items */ ! typedef struct { ! int itemnum; ! Item item[256]; ! } ItemList; ! ! /* item which is on the paddle */ ! typedef struct { ! int item; ! double angle; ! double x, y; ! } PaddleItemInfo; ! ! /* shaking gesture to remove a pattern */ ! int check_shake ( double paddleTrans[3][4], int f ); ! ! /* inclining gesture to put an object on the ground*/ ! int check_incline ( double paddleTrans[3][4], double baseTrans[3][4], double *angle ); ! ! /* picking gesture to take an object from the ground*/ ! int check_pickup(double card_trans[3][4], double base_trans[3][4], ItemList* itlist, double* angle); ! ! #endif |
From: Philip L. <phi...@us...> - 2004-12-02 00:47:46
|
Update of /cvsroot/artoolkit/artoolkit/examples/paddle In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21077 Modified Files: paddle.c paddleTest.c Log Message: Fix some build warnings. Index: paddleTest.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/paddle/paddleTest.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** paddleTest.c 22 Nov 2004 03:38:33 -0000 1.1 --- paddleTest.c 2 Dec 2004 00:47:36 -0000 1.2 *************** *** 1,340 **** ! #ifdef _WIN32 ! #include <windows.h> ! #endif ! #include <stdio.h> ! #include <stdlib.h> ! #include <string.h> ! #include <math.h> ! ! #include <GL/gl.h> ! #include <GL/glut.h> ! #include <AR/gsub.h> ! #include <AR/param.h> ! #include <AR/ar.h> ! #include <AR/video.h> ! #include <AR/arMulti.h> ! ! #include "paddle.h" ! int draw_paddle( ARPaddleInfo *paddleInfo ); ! ! int xsize, ysize; ! int thresh = 100; ! int count = 0; ! ! char *cparam_name = "Data/camera_para.dat"; ! ARParam cparam; ! ! /* set video capture configuration */ ! /*****************************************************************************/ ! // modified by Thomas Pintaric, Vienna University of Technology ! ! #ifdef _WIN32 ! char *vconf = "flipV,showDlg"; // see video.h for a list of supported parameters ! #else ! char *vconf = ""; ! #endif ! /*****************************************************************************/ ! ! char *config_name = "Data/multi/marker.dat"; ! ARMultiMarkerInfoT *config; ! ! //MB - paddle information ! int marker_flag[AR_SQUARE_MAX]; ! ARPaddleInfo *paddleInfo; ! char *paddle_name = "Data/paddle_data"; ! ! static void init(void); ! static void cleanup(void); ! static void keyEvent( unsigned char key, int x, int y); ! static void mainLoop(void); ! static void draw( double trans1[3][4], double trans2[3][4], int mode ); ! ! int main() ! { ! //initialize application ! init(); ! ! arVideoCapStart(); ! ! //start the main event loop ! argMainLoop( NULL, keyEvent, mainLoop ); ! ! return 0; ! } ! ! static void keyEvent( unsigned char key, int x, int y) ! { ! /* quit if the ESC key is pressed */ ! if( key == 0x1b ) { ! printf("*** %f (frame/sec)\n", (double)count/arUtilTimer()); ! cleanup(); ! exit(0); ! } ! ! /* turn on and off the debug mode with d key */ ! if( key == 'd' ) { ! printf("*** %f (frame/sec)\n", (double)count/arUtilTimer()); ! arDebug = 1 - arDebug; ! if( arDebug == 0 ) { ! glClearColor( 0.0, 0.0, 0.0, 0.0 ); ! glClear(GL_COLOR_BUFFER_BIT); ! argSwapBuffers(); ! glClear(GL_COLOR_BUFFER_BIT); ! argSwapBuffers(); ! } ! count = 0; ! } ! } ! ! /* main loop */ ! static void mainLoop(void) ! { ! ARUint8 *dataPtr; ! ARMarkerInfo *marker_info; ! int marker_num; ! int i; ! double err; ! ! /* grab a video frame */ ! if( (dataPtr = (ARUint8 *)arVideoGetImage()) == NULL ) { ! arUtilSleep(2); ! return; ! } ! ! if( count == 0 ) arUtilTimerReset(); ! count++; ! ! /* detect the markers in the video frame */ ! if( arDetectMarkerLite(dataPtr, thresh, &marker_info, &marker_num) < 0 ) { ! cleanup(); ! exit(0); ! } ! ! argDrawMode2D(); ! if( !arDebug ) { ! argDispImage( dataPtr, 0,0 ); ! } ! else { ! argDispImage( dataPtr, 1, 1 ); ! if( arImageProcMode == AR_IMAGE_PROC_IN_HALF ) ! argDispHalfImage( arImage, 0, 0 ); ! else ! argDispImage( arImage, 0, 0); ! ! glColor3f( 1.0, 0.0, 0.0 ); ! glLineWidth( 1.0 ); ! for( i = 0; i < marker_num; i++ ) { ! argDrawSquare( marker_info[i].vertex, 0, 0 ); ! } ! glLineWidth( 1.0 ); ! } ! ! arVideoCapNext(); ! ! //MB - multiple marker tracking ! for( i = 0; i < marker_num; i++ ) marker_flag[i] = 0; ! ! /* get the paddle position */ ! paddleGetTrans(paddleInfo, marker_info, marker_flag, ! marker_num, &cparam); ! ! /* draw the 3D models */ ! glClearDepth( 1.0 ); ! glClear(GL_DEPTH_BUFFER_BIT); ! ! /* draw the paddle */ ! if( paddleInfo->active ){ ! draw_paddle( paddleInfo); ! } ! ! /* get the translation from the multimarker pattern */ ! if( (err=arMultiGetTransMat(marker_info, marker_num, config)) < 0 ) { ! argSwapBuffers(); ! return; ! } ! ! //printf("err = %f\n", err); ! if(err > 100.0 ) { ! argSwapBuffers(); ! return; ! } ! ! /* draw the multimarker pattern */ ! for( i = 0; i < config->marker_num; i++ ) { ! if( config->marker[i].visible >= 0 ) ! draw( config->trans, config->marker[i].trans, 0 ); ! else ! draw( config->trans, config->marker[i].trans, 1 ); ! } ! ! argSwapBuffers(); ! } ! ! static void init( void ) ! { ! ARParam wparam; ! ! /* open the video path */ ! if( arVideoOpen( vconf ) < 0 ) exit(0); ! /* find the size of the window */ ! if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0); ! printf("Image size (x,y) = (%d,%d)\n", xsize, ysize); ! ! /* set the initial camera parameters */ ! if( arParamLoad(cparam_name, 1, &wparam) < 0 ) { ! printf("Camera parameter load error !!\n"); ! exit(0); ! } ! arParamChangeSize( &wparam, xsize, ysize, &cparam ); ! arInitCparam( &cparam ); ! printf("*** Camera Parameter ***\n"); ! arParamDisp( &cparam ); ! ! /* load the paddle marker file */ ! if( (paddleInfo = paddleInit(paddle_name)) == NULL ) { ! printf("paddleInit error!!\n"); ! exit(0); ! } ! printf("Loaded Paddle File\n"); ! ! if( (config = arMultiReadConfigFile(config_name)) == NULL ) { ! printf("config data load error !!\n"); ! exit(0); ! } ! printf("Loaded Multi Marker File\n"); ! ! /* open the graphics window */ ! // argInit( &cparam, 2.0, 0, 2, 1, 0 ); ! argInit( &cparam, 1.0, 0, 0, 0, 0 ); ! ! } ! ! /* cleanup function called when program exits */ ! static void cleanup(void) ! { ! arVideoCapStop(); ! arVideoClose(); ! argCleanup(); ! } ! ! static void draw( double trans1[3][4], double trans2[3][4], int mode ) ! { ! double gl_para[16]; ! GLfloat mat_ambient[] = {0.0, 0.0, 1.0, 1.0}; ! GLfloat mat_ambient1[] = {1.0, 0.0, 0.0, 1.0}; ! GLfloat mat_flash[] = {0.0, 0.0, 1.0, 1.0}; ! GLfloat mat_flash1[] = {1.0, 0.0, 0.0, 1.0}; ! GLfloat mat_flash_shiny[] = {50.0}; ! GLfloat mat_flash_shiny1[]= {50.0}; ! GLfloat light_position[] = {100.0,-200.0,200.0,0.0}; ! GLfloat ambi[] = {0.1, 0.1, 0.1, 0.1}; ! GLfloat lightZeroColor[] = {0.9, 0.9, 0.9, 0.1}; ! ! argDrawMode3D(); ! argDraw3dCamera( 0, 0 ); ! glEnable(GL_DEPTH_TEST); ! glDepthFunc(GL_LEQUAL); ! ! /* load the camera transformation matrix */ ! glMatrixMode(GL_MODELVIEW); ! argConvGlpara(trans1, gl_para); ! glLoadMatrixd( gl_para ); ! argConvGlpara(trans2, gl_para); ! glMultMatrixd( gl_para ); ! ! if( mode == 0 ) { ! glEnable(GL_LIGHTING); ! glEnable(GL_LIGHT0); ! glLightfv(GL_LIGHT0, GL_POSITION, light_position); ! glLightfv(GL_LIGHT0, GL_AMBIENT, ambi); ! glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor); ! glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash); ! glMaterialfv(GL_FRONT, GL_SHININESS, mat_flash_shiny); ! glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); ! } ! else { ! glEnable(GL_LIGHTING); ! glEnable(GL_LIGHT0); ! glLightfv(GL_LIGHT0, GL_POSITION, light_position); ! glLightfv(GL_LIGHT0, GL_AMBIENT, ambi); ! glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor); ! glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash1); ! glMaterialfv(GL_FRONT, GL_SHININESS, mat_flash_shiny1); ! glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient1); ! } ! glMatrixMode(GL_MODELVIEW); ! glTranslatef( 0.0, 0.0, 25.0 ); ! if( !arDebug ) glutSolidCube(50.0); ! else glutWireCube(50.0); ! glDisable( GL_LIGHTING ); ! glDisable( GL_DEPTH_TEST ); ! argDrawMode2D(); ! } ! ! /* draw the paddle - using a stencil buffer */ ! int draw_paddle( ARPaddleInfo *paddleInfo ) ! { ! double gl_para[16]; ! int i; ! ! argDrawMode3D(); ! glEnable(GL_DEPTH_TEST); ! glDepthFunc(GL_LEQUAL); ! ! argDraw3dCamera( 0, 0 ); ! argConvGlpara(paddleInfo->trans, gl_para); ! ! glMatrixMode(GL_MODELVIEW); ! glLoadMatrixd( gl_para ); ! ! /* draw the paddle graphics */ ! glColor3f( 1.0, 0.0, 0.0 ); ! glLineWidth(4.0); ! glBegin(GL_LINE_LOOP); ! glVertex2f( -25.0, -25.0 ); ! glVertex2f( 25.0, -25.0 ); ! glVertex2f( 25.0, 25.0 ); ! glVertex2f( -25.0, 25.0 ); ! glEnd(); ! ! glColor3f( 0.0, 0.0, 1.0); ! glBegin(GL_LINE_LOOP); ! for( i = 0; i < 16; i++ ) { ! double x, y; ! x = PADDLE_RADIUS * cos(i*3.141592*2/16); ! y = PADDLE_RADIUS * sin(i*3.141592*2/16); ! glVertex2d( x, y ); ! } ! glEnd(); ! glBegin(GL_LINE_LOOP); ! glVertex2f( -7.5, 0.0 ); ! glVertex2f( 7.5, 0.0 ); ! glVertex2f( 7.5, -105.0 ); ! glVertex2f( -7.5, -105.0 ); ! glEnd(); ! ! /* start drawing the stencil */ ! glEnable(GL_BLEND); ! glBlendFunc(GL_ZERO,GL_ONE); ! ! glColor4f(1,1,1,0); ! glBegin(GL_POLYGON); ! for( i = 0; i < 16; i++ ) { ! double x, y; ! x = 40.0 * cos(i*3.141592*2/16); ! y = 40.0 * sin(i*3.141592*2/16); ! glVertex2d( x, y ); ! } ! glEnd(); ! glBegin(GL_POLYGON); ! glVertex2f( -7.5, 0.0 ); ! glVertex2f( 7.5, 0.0 ); ! glVertex2f( 7.5, -105.0 ); ! glVertex2f( -7.5, -105.0 ); ! glEnd(); ! glDisable(GL_BLEND); ! ! glDisable(GL_DEPTH_TEST); ! argDrawMode2D(); ! return 0; ! } --- 1,343 ---- ! #ifdef _WIN32 ! # include <windows.h> ! #endif ! #include <stdio.h> ! #include <stdlib.h> ! #include <string.h> ! #include <math.h> ! ! #ifndef __APPLE__ ! # include <GL/glut.h> ! #else ! # include <GLUT/glut.h> ! #endif ! #include <AR/gsub.h> ! #include <AR/param.h> ! #include <AR/ar.h> ! #include <AR/video.h> ! #include <AR/arMulti.h> ! ! #include "paddle.h" ! int draw_paddle( ARPaddleInfo *paddleInfo ); ! ! int xsize, ysize; ! int thresh = 100; ! int count = 0; ! ! char *cparam_name = "Data/camera_para.dat"; ! ARParam cparam; ! ! /* set video capture configuration */ ! /*****************************************************************************/ ! // modified by Thomas Pintaric, Vienna University of Technology ! ! #ifdef _WIN32 ! char *vconf = "flipV,showDlg"; // see video.h for a list of supported parameters ! #else ! char *vconf = ""; ! #endif ! /*****************************************************************************/ ! ! char *config_name = "Data/multi/marker.dat"; ! ARMultiMarkerInfoT *config; ! ! //MB - paddle information ! int marker_flag[AR_SQUARE_MAX]; ! ARPaddleInfo *paddleInfo; ! char *paddle_name = "Data/paddle_data"; ! ! static void init(void); ! static void cleanup(void); ! static void keyEvent( unsigned char key, int x, int y); ! static void mainLoop(void); ! static void draw( double trans1[3][4], double trans2[3][4], int mode ); ! ! int main() ! { ! //initialize application ! init(); ! ! arVideoCapStart(); ! ! //start the main event loop ! argMainLoop( NULL, keyEvent, mainLoop ); ! ! return 0; ! } ! ! static void keyEvent( unsigned char key, int x, int y) ! { ! /* quit if the ESC key is pressed */ ! if( key == 0x1b ) { ! printf("*** %f (frame/sec)\n", (double)count/arUtilTimer()); ! cleanup(); ! exit(0); ! } ! ! /* turn on and off the debug mode with d key */ ! if( key == 'd' ) { ! printf("*** %f (frame/sec)\n", (double)count/arUtilTimer()); ! arDebug = 1 - arDebug; ! if( arDebug == 0 ) { ! glClearColor( 0.0, 0.0, 0.0, 0.0 ); ! glClear(GL_COLOR_BUFFER_BIT); ! argSwapBuffers(); ! glClear(GL_COLOR_BUFFER_BIT); ! argSwapBuffers(); ! } ! count = 0; ! } ! } ! ! /* main loop */ ! static void mainLoop(void) ! { ! ARUint8 *dataPtr; ! ARMarkerInfo *marker_info; ! int marker_num; ! int i; ! double err; ! ! /* grab a video frame */ ! if( (dataPtr = (ARUint8 *)arVideoGetImage()) == NULL ) { ! arUtilSleep(2); ! return; ! } ! ! if( count == 0 ) arUtilTimerReset(); ! count++; ! ! /* detect the markers in the video frame */ ! if( arDetectMarkerLite(dataPtr, thresh, &marker_info, &marker_num) < 0 ) { ! cleanup(); ! exit(0); ! } ! ! argDrawMode2D(); ! if( !arDebug ) { ! argDispImage( dataPtr, 0,0 ); ! } ! else { ! argDispImage( dataPtr, 1, 1 ); ! if( arImageProcMode == AR_IMAGE_PROC_IN_HALF ) ! argDispHalfImage( arImage, 0, 0 ); ! else ! argDispImage( arImage, 0, 0); ! ! glColor3f( 1.0, 0.0, 0.0 ); ! glLineWidth( 1.0 ); ! for( i = 0; i < marker_num; i++ ) { ! argDrawSquare( marker_info[i].vertex, 0, 0 ); ! } ! glLineWidth( 1.0 ); ! } ! ! arVideoCapNext(); ! ! //MB - multiple marker tracking ! for( i = 0; i < marker_num; i++ ) marker_flag[i] = 0; ! ! /* get the paddle position */ ! paddleGetTrans(paddleInfo, marker_info, marker_flag, ! marker_num, &cparam); ! ! /* draw the 3D models */ ! glClearDepth( 1.0 ); ! glClear(GL_DEPTH_BUFFER_BIT); ! ! /* draw the paddle */ ! if( paddleInfo->active ){ ! draw_paddle( paddleInfo); ! } ! ! /* get the translation from the multimarker pattern */ ! if( (err=arMultiGetTransMat(marker_info, marker_num, config)) < 0 ) { ! argSwapBuffers(); ! return; ! } ! ! //printf("err = %f\n", err); ! if(err > 100.0 ) { ! argSwapBuffers(); ! return; ! } ! ! /* draw the multimarker pattern */ ! for( i = 0; i < config->marker_num; i++ ) { ! if( config->marker[i].visible >= 0 ) ! draw( config->trans, config->marker[i].trans, 0 ); ! else ! draw( config->trans, config->marker[i].trans, 1 ); ! } ! ! argSwapBuffers(); ! } ! ! static void init( void ) ! { ! ARParam wparam; ! ! /* open the video path */ ! if( arVideoOpen( vconf ) < 0 ) exit(0); ! /* find the size of the window */ ! if( arVideoInqSize(&xsize, &ysize) < 0 ) exit(0); ! printf("Image size (x,y) = (%d,%d)\n", xsize, ysize); ! ! /* set the initial camera parameters */ ! if( arParamLoad(cparam_name, 1, &wparam) < 0 ) { ! printf("Camera parameter load error !!\n"); ! exit(0); ! } ! arParamChangeSize( &wparam, xsize, ysize, &cparam ); ! arInitCparam( &cparam ); ! printf("*** Camera Parameter ***\n"); ! arParamDisp( &cparam ); ! ! /* load the paddle marker file */ ! if( (paddleInfo = paddleInit(paddle_name)) == NULL ) { ! printf("paddleInit error!!\n"); ! exit(0); ! } ! printf("Loaded Paddle File\n"); ! ! if( (config = arMultiReadConfigFile(config_name)) == NULL ) { ! printf("config data load error !!\n"); ! exit(0); ! } ! printf("Loaded Multi Marker File\n"); ! ! /* open the graphics window */ ! // argInit( &cparam, 2.0, 0, 2, 1, 0 ); ! argInit( &cparam, 1.0, 0, 0, 0, 0 ); ! ! } ! ! /* cleanup function called when program exits */ ! static void cleanup(void) ! { ! arVideoCapStop(); ! arVideoClose(); ! argCleanup(); ! } ! ! static void draw( double trans1[3][4], double trans2[3][4], int mode ) ! { ! double gl_para[16]; ! GLfloat mat_ambient[] = {0.0, 0.0, 1.0, 1.0}; ! GLfloat mat_ambient1[] = {1.0, 0.0, 0.0, 1.0}; ! GLfloat mat_flash[] = {0.0, 0.0, 1.0, 1.0}; ! GLfloat mat_flash1[] = {1.0, 0.0, 0.0, 1.0}; ! GLfloat mat_flash_shiny[] = {50.0}; ! GLfloat mat_flash_shiny1[]= {50.0}; ! GLfloat light_position[] = {100.0,-200.0,200.0,0.0}; ! GLfloat ambi[] = {0.1, 0.1, 0.1, 0.1}; ! GLfloat lightZeroColor[] = {0.9, 0.9, 0.9, 0.1}; ! ! argDrawMode3D(); ! argDraw3dCamera( 0, 0 ); ! glEnable(GL_DEPTH_TEST); ! glDepthFunc(GL_LEQUAL); ! ! /* load the camera transformation matrix */ ! glMatrixMode(GL_MODELVIEW); ! argConvGlpara(trans1, gl_para); ! glLoadMatrixd( gl_para ); ! argConvGlpara(trans2, gl_para); ! glMultMatrixd( gl_para ); ! ! if( mode == 0 ) { ! glEnable(GL_LIGHTING); ! glEnable(GL_LIGHT0); ! glLightfv(GL_LIGHT0, GL_POSITION, light_position); ! glLightfv(GL_LIGHT0, GL_AMBIENT, ambi); ! glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor); ! glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash); ! glMaterialfv(GL_FRONT, GL_SHININESS, mat_flash_shiny); ! glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient); ! } ! else { ! glEnable(GL_LIGHTING); ! glEnable(GL_LIGHT0); ! glLightfv(GL_LIGHT0, GL_POSITION, light_position); ! glLightfv(GL_LIGHT0, GL_AMBIENT, ambi); ! glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor); ! glMaterialfv(GL_FRONT, GL_SPECULAR, mat_flash1); ! glMaterialfv(GL_FRONT, GL_SHININESS, mat_flash_shiny1); ! glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient1); ! } ! glMatrixMode(GL_MODELVIEW); ! glTranslatef( 0.0, 0.0, 25.0 ); ! if( !arDebug ) glutSolidCube(50.0); ! else glutWireCube(50.0); ! glDisable( GL_LIGHTING ); ! glDisable( GL_DEPTH_TEST ); ! argDrawMode2D(); ! } ! ! /* draw the paddle - using a stencil buffer */ ! int draw_paddle( ARPaddleInfo *paddleInfo ) ! { ! double gl_para[16]; ! int i; ! ! argDrawMode3D(); ! glEnable(GL_DEPTH_TEST); ! glDepthFunc(GL_LEQUAL); ! ! argDraw3dCamera( 0, 0 ); ! argConvGlpara(paddleInfo->trans, gl_para); ! ! glMatrixMode(GL_MODELVIEW); ! glLoadMatrixd( gl_para ); ! ! /* draw the paddle graphics */ ! glColor3f( 1.0, 0.0, 0.0 ); ! glLineWidth(4.0); ! glBegin(GL_LINE_LOOP); ! glVertex2f( -25.0, -25.0 ); ! glVertex2f( 25.0, -25.0 ); ! glVertex2f( 25.0, 25.0 ); ! glVertex2f( -25.0, 25.0 ); ! glEnd(); ! ! glColor3f( 0.0, 0.0, 1.0); ! glBegin(GL_LINE_LOOP); ! for( i = 0; i < 16; i++ ) { ! double x, y; ! x = PADDLE_RADIUS * cos(i*3.141592*2/16); ! y = PADDLE_RADIUS * sin(i*3.141592*2/16); ! glVertex2d( x, y ); ! } ! glEnd(); ! glBegin(GL_LINE_LOOP); ! glVertex2f( -7.5, 0.0 ); ! glVertex2f( 7.5, 0.0 ); ! glVertex2f( 7.5, -105.0 ); ! glVertex2f( -7.5, -105.0 ); ! glEnd(); ! ! /* start drawing the stencil */ ! glEnable(GL_BLEND); ! glBlendFunc(GL_ZERO,GL_ONE); ! ! glColor4f(1,1,1,0); ! glBegin(GL_POLYGON); ! for( i = 0; i < 16; i++ ) { ! double x, y; ! x = 40.0 * cos(i*3.141592*2/16); ! y = 40.0 * sin(i*3.141592*2/16); ! glVertex2d( x, y ); ! } ! glEnd(); ! glBegin(GL_POLYGON); ! glVertex2f( -7.5, 0.0 ); ! glVertex2f( 7.5, 0.0 ); ! glVertex2f( 7.5, -105.0 ); ! glVertex2f( -7.5, -105.0 ); ! glEnd(); ! glDisable(GL_BLEND); ! ! glDisable(GL_DEPTH_TEST); ! argDrawMode2D(); ! return 0; ! } Index: paddle.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/paddle/paddle.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** paddle.c 22 Nov 2004 03:38:33 -0000 1.1 --- paddle.c 2 Dec 2004 00:47:36 -0000 1.2 *************** *** 1,155 **** ! #include <stdio.h> ! #include <malloc.h> ! #include <stdlib.h> ! #include <AR/ar.h> ! #include "paddle.h" ! ! static ARMarkerInfo prevInfoL; ! static ARMarkerInfo prevInfoR; ! static int pcountL = 0; ! static int pcountR = 0; ! ! static char *get_buff( char *buf, int n, FILE *fp ); ! ! static int get_marker( ARMarkerInfo *markerInfo, int *markerFlag, ! int marker_num, int id, ! ARMarkerInfo *prevInfo, int *pcount ); ! ! ! ARPaddleInfo *paddleInit( char *name ) ! { ! FILE *fp; ! ARPaddleInfo *paddleInfo; ! char buf[256], buf1[256]; ! ! if( (fp=fopen(name, "r")) == NULL ) return(0); ! ! arMalloc( paddleInfo, ARPaddleInfo, 1 ); ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%s", paddleInfo->name) != 1 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%s", buf1) != 1 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! if( (paddleInfo->marker_id = arLoadPatt(buf1)) < 0 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%lf", &paddleInfo->width) != 1 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! ! paddleInfo->center[0] = 0.0; ! paddleInfo->center[1] = 0.0; ! paddleInfo->active = 0; ! paddleInfo->pcount = 0; ! paddleInfo->pcountL = 0; ! paddleInfo->pcountR = 0; ! ! fclose(fp); ! ! return paddleInfo; ! } ! ! static char *get_buff( char *buf, int n, FILE *fp ) ! { ! char *ret; ! ! for(;;) { ! ret = fgets( buf, n, fp ); ! if( ret == NULL ) return(NULL); ! if( buf[0] != '\n' && buf[0] != '#' ) return(ret); ! } ! } ! ! int paddleGetTrans( ARPaddleInfo *paddleInfo, ARMarkerInfo *markerInfo, int *markerFlag, int marker_num, ARParam *cparam ) ! { ! int id; ! ! id = get_marker( markerInfo, markerFlag, marker_num, paddleInfo->marker_id, ! &(paddleInfo->prevInfo), &(paddleInfo->pcount) ); ! ! if( id == -1 ) { paddleInfo->active = 0; return 0; } ! ! arGetTransMat(&markerInfo[id], ! paddleInfo->center, paddleInfo->width, paddleInfo->trans); ! markerFlag[id] = 1; ! ! paddleInfo->active = 1; ! ! return 0; ! } ! ! static int get_marker( ARMarkerInfo *markerInfo, int *markerFlag, int marker_num, int id, ! ARMarkerInfo *prevInfo, int *pcount ) ! { ! double rlen, rlenmin, rarea, diff, diffmin; ! int cid, cdir; ! int i, j; ! ! cid = -1; ! for( i = 0; i < marker_num; i++ ) { ! if( markerInfo[i].id == id && markerFlag[i] == 0 ) { ! if( cid == -1 ) cid = i; ! else { ! if( markerInfo[cid].cf < markerInfo[i].cf ) cid = i; ! } ! } ! } ! if( cid == -1 ) { ! if( *pcount == 0 ) return -1; ! ! rlenmin = 10.0; ! for( i = 0; i < marker_num; i++ ) { ! if( markerFlag[i] ) continue; ! rarea = (double)prevInfo->area / (double)markerInfo[i].area; ! if( rarea < 0.7 || rarea > 1.43 ) continue; ! rlen = ( (markerInfo[i].pos[0] - prevInfo->pos[0]) ! * (markerInfo[i].pos[0] - prevInfo->pos[0]) ! + (markerInfo[i].pos[1] - prevInfo->pos[1]) ! * (markerInfo[i].pos[1] - prevInfo->pos[1]) ) / markerInfo[i].area; ! if( rlen < 0.5 && rlen < rlenmin ) { ! rlenmin = rlen; ! cid = i; ! } ! } ! if( cid >= 0 && markerInfo[cid].cf < prevInfo->cf ) { ! markerInfo[cid].cf = prevInfo->cf; ! markerInfo[cid].id = prevInfo->id; ! diffmin = 10000.0 * 10000.0; ! cdir = -1; ! for( i = 0; i < 4; i++ ) { ! diff = 0.0; ! for( j = 0; j < 4; j++ ) { ! diff += (prevInfo->vertex[j][0] - markerInfo[cid].vertex[(i+j)%4][0]) ! * (prevInfo->vertex[j][0] - markerInfo[cid].vertex[(i+j)%4][0]) ! + (prevInfo->vertex[j][1] - markerInfo[cid].vertex[(i+j)%4][1]) ! * (prevInfo->vertex[j][1] - markerInfo[cid].vertex[(i+j)%4][1]); ! } ! if( diff < diffmin ) { ! diffmin = diff; ! cdir = (prevInfo->dir - i + 4) % 4; ! } ! } ! markerInfo[cid].dir = cdir; ! ! *prevInfo = markerInfo[cid]; ! *pcount = 1; ! } ! else { ! *pcount = 0; ! return -1; ! } ! } ! else { ! *prevInfo = markerInfo[cid]; ! *pcount = 1; ! } ! ! return cid; ! } --- 1,149 ---- ! #include <stdio.h> ! #include <stdlib.h> ! #include <AR/ar.h> ! #include "paddle.h" ! ! static char *get_buff( char *buf, int n, FILE *fp ); ! ! static int get_marker( ARMarkerInfo *markerInfo, int *markerFlag, ! int marker_num, int id, ! ARMarkerInfo *prevInfo, int *pcount ); ! ! ! ARPaddleInfo *paddleInit( char *name ) ! { ! FILE *fp; ! ARPaddleInfo *paddleInfo; ! char buf[256], buf1[256]; ! ! if( (fp=fopen(name, "r")) == NULL ) return(0); ! ! arMalloc( paddleInfo, ARPaddleInfo, 1 ); ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%s", paddleInfo->name) != 1 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%s", buf1) != 1 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! if( (paddleInfo->marker_id = arLoadPatt(buf1)) < 0 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%lf", &paddleInfo->width) != 1 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! ! paddleInfo->center[0] = 0.0; ! paddleInfo->center[1] = 0.0; ! paddleInfo->active = 0; ! paddleInfo->pcount = 0; ! paddleInfo->pcountL = 0; ! paddleInfo->pcountR = 0; ! ! fclose(fp); ! ! return paddleInfo; ! } ! ! static char *get_buff( char *buf, int n, FILE *fp ) ! { ! char *ret; ! ! for(;;) { ! ret = fgets( buf, n, fp ); ! if( ret == NULL ) return(NULL); ! if( buf[0] != '\n' && buf[0] != '#' ) return(ret); ! } ! } ! ! int paddleGetTrans( ARPaddleInfo *paddleInfo, ARMarkerInfo *markerInfo, int *markerFlag, int marker_num, ARParam *cparam ) ! { ! int id; ! ! id = get_marker( markerInfo, markerFlag, marker_num, paddleInfo->marker_id, ! &(paddleInfo->prevInfo), &(paddleInfo->pcount) ); ! ! if( id == -1 ) { paddleInfo->active = 0; return 0; } ! ! arGetTransMat(&markerInfo[id], ! paddleInfo->center, paddleInfo->width, paddleInfo->trans); ! markerFlag[id] = 1; ! ! paddleInfo->active = 1; ! ! return 0; ! } ! ! static int get_marker( ARMarkerInfo *markerInfo, int *markerFlag, int marker_num, int id, ! ARMarkerInfo *prevInfo, int *pcount ) ! { ! double rlen, rlenmin, rarea, diff, diffmin; ! int cid, cdir; ! int i, j; ! ! cid = -1; ! for( i = 0; i < marker_num; i++ ) { ! if( markerInfo[i].id == id && markerFlag[i] == 0 ) { ! if( cid == -1 ) cid = i; ! else { ! if( markerInfo[cid].cf < markerInfo[i].cf ) cid = i; ! } ! } ! } ! if( cid == -1 ) { ! if( *pcount == 0 ) return -1; ! ! rlenmin = 10.0; ! for( i = 0; i < marker_num; i++ ) { ! if( markerFlag[i] ) continue; ! rarea = (double)prevInfo->area / (double)markerInfo[i].area; ! if( rarea < 0.7 || rarea > 1.43 ) continue; ! rlen = ( (markerInfo[i].pos[0] - prevInfo->pos[0]) ! * (markerInfo[i].pos[0] - prevInfo->pos[0]) ! + (markerInfo[i].pos[1] - prevInfo->pos[1]) ! * (markerInfo[i].pos[1] - prevInfo->pos[1]) ) / markerInfo[i].area; ! if( rlen < 0.5 && rlen < rlenmin ) { ! rlenmin = rlen; ! cid = i; ! } ! } ! if( cid >= 0 && markerInfo[cid].cf < prevInfo->cf ) { ! markerInfo[cid].cf = prevInfo->cf; ! markerInfo[cid].id = prevInfo->id; ! diffmin = 10000.0 * 10000.0; ! cdir = -1; ! for( i = 0; i < 4; i++ ) { ! diff = 0.0; ! for( j = 0; j < 4; j++ ) { ! diff += (prevInfo->vertex[j][0] - markerInfo[cid].vertex[(i+j)%4][0]) ! * (prevInfo->vertex[j][0] - markerInfo[cid].vertex[(i+j)%4][0]) ! + (prevInfo->vertex[j][1] - markerInfo[cid].vertex[(i+j)%4][1]) ! * (prevInfo->vertex[j][1] - markerInfo[cid].vertex[(i+j)%4][1]); ! } ! if( diff < diffmin ) { ! diffmin = diff; ! cdir = (prevInfo->dir - i + 4) % 4; ! } ! } ! markerInfo[cid].dir = cdir; ! ! *prevInfo = markerInfo[cid]; ! *pcount = 1; ! } ! else { ! *pcount = 0; ! return -1; ! } ! } ! else { ! *prevInfo = markerInfo[cid]; ! *pcount = 1; ! } ! ! return cid; ! } |
From: Philip L. <phi...@us...> - 2004-12-02 00:47:39
|
Update of /cvsroot/artoolkit/artoolkit/examples/paddleInteraction In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21050 Modified Files: paddle.c paddleInteractionTest.c Log Message: Fix some build warnings. Index: paddle.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/paddleInteraction/paddle.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** paddle.c 22 Nov 2004 03:37:43 -0000 1.1 --- paddle.c 2 Dec 2004 00:47:30 -0000 1.2 *************** *** 1,155 **** ! #include <stdio.h> ! #include <malloc.h> ! #include <stdlib.h> ! #include <AR/ar.h> ! #include "paddle.h" ! ! static ARMarkerInfo prevInfoL; ! static ARMarkerInfo prevInfoR; ! static int pcountL = 0; ! static int pcountR = 0; ! ! static char *get_buff( char *buf, int n, FILE *fp ); ! ! static int get_marker( ARMarkerInfo *markerInfo, int *markerFlag, ! int marker_num, int id, ! ARMarkerInfo *prevInfo, int *pcount ); ! ! ! ARPaddleInfo *paddleInit( char *name ) ! { ! FILE *fp; ! ARPaddleInfo *paddleInfo; ! char buf[256], buf1[256]; ! ! if( (fp=fopen(name, "r")) == NULL ) return(0); ! ! arMalloc( paddleInfo, ARPaddleInfo, 1 ); ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%s", paddleInfo->name) != 1 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%s", buf1) != 1 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! if( (paddleInfo->marker_id = arLoadPatt(buf1)) < 0 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%lf", &paddleInfo->width) != 1 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! ! paddleInfo->center[0] = 0.0; ! paddleInfo->center[1] = 0.0; ! paddleInfo->active = 0; ! paddleInfo->pcount = 0; ! paddleInfo->pcountL = 0; ! paddleInfo->pcountR = 0; ! ! fclose(fp); ! ! return paddleInfo; ! } ! ! static char *get_buff( char *buf, int n, FILE *fp ) ! { ! char *ret; ! ! for(;;) { ! ret = fgets( buf, n, fp ); ! if( ret == NULL ) return(NULL); ! if( buf[0] != '\n' && buf[0] != '#' ) return(ret); ! } ! } ! ! int paddleGetTrans( ARPaddleInfo *paddleInfo, ARMarkerInfo *markerInfo, int *markerFlag, int marker_num, ARParam *cparam ) ! { ! int id; ! ! id = get_marker( markerInfo, markerFlag, marker_num, paddleInfo->marker_id, ! &(paddleInfo->prevInfo), &(paddleInfo->pcount) ); ! ! if( id == -1 ) { paddleInfo->active = 0; return 0; } ! ! arGetTransMat(&markerInfo[id], ! paddleInfo->center, paddleInfo->width, paddleInfo->trans); ! markerFlag[id] = 1; ! ! paddleInfo->active = 1; ! ! return 0; ! } ! ! static int get_marker( ARMarkerInfo *markerInfo, int *markerFlag, int marker_num, int id, ! ARMarkerInfo *prevInfo, int *pcount ) ! { ! double rlen, rlenmin, rarea, diff, diffmin; ! int cid, cdir; ! int i, j; ! ! cid = -1; ! for( i = 0; i < marker_num; i++ ) { ! if( markerInfo[i].id == id && markerFlag[i] == 0 ) { ! if( cid == -1 ) cid = i; ! else { ! if( markerInfo[cid].cf < markerInfo[i].cf ) cid = i; ! } ! } ! } ! if( cid == -1 ) { ! if( *pcount == 0 ) return -1; ! ! rlenmin = 10.0; ! for( i = 0; i < marker_num; i++ ) { ! if( markerFlag[i] ) continue; ! rarea = (double)prevInfo->area / (double)markerInfo[i].area; ! if( rarea < 0.7 || rarea > 1.43 ) continue; ! rlen = ( (markerInfo[i].pos[0] - prevInfo->pos[0]) ! * (markerInfo[i].pos[0] - prevInfo->pos[0]) ! + (markerInfo[i].pos[1] - prevInfo->pos[1]) ! * (markerInfo[i].pos[1] - prevInfo->pos[1]) ) / markerInfo[i].area; ! if( rlen < 0.5 && rlen < rlenmin ) { ! rlenmin = rlen; ! cid = i; ! } ! } ! if( cid >= 0 && markerInfo[cid].cf < prevInfo->cf ) { ! markerInfo[cid].cf = prevInfo->cf; ! markerInfo[cid].id = prevInfo->id; ! diffmin = 10000.0 * 10000.0; ! cdir = -1; ! for( i = 0; i < 4; i++ ) { ! diff = 0.0; ! for( j = 0; j < 4; j++ ) { ! diff += (prevInfo->vertex[j][0] - markerInfo[cid].vertex[(i+j)%4][0]) ! * (prevInfo->vertex[j][0] - markerInfo[cid].vertex[(i+j)%4][0]) ! + (prevInfo->vertex[j][1] - markerInfo[cid].vertex[(i+j)%4][1]) ! * (prevInfo->vertex[j][1] - markerInfo[cid].vertex[(i+j)%4][1]); ! } ! if( diff < diffmin ) { ! diffmin = diff; ! cdir = (prevInfo->dir - i + 4) % 4; ! } ! } ! markerInfo[cid].dir = cdir; ! ! *prevInfo = markerInfo[cid]; ! *pcount = 1; ! } ! else { ! *pcount = 0; ! return -1; ! } ! } ! else { ! *prevInfo = markerInfo[cid]; ! *pcount = 1; ! } ! ! return cid; ! } --- 1,149 ---- ! #include <stdio.h> ! #include <stdlib.h> ! #include <AR/ar.h> ! #include "paddle.h" ! ! static char *get_buff( char *buf, int n, FILE *fp ); ! ! static int get_marker( ARMarkerInfo *markerInfo, int *markerFlag, ! int marker_num, int id, ! ARMarkerInfo *prevInfo, int *pcount ); ! ! ! ARPaddleInfo *paddleInit( char *name ) ! { ! FILE *fp; ! ARPaddleInfo *paddleInfo; ! char buf[256], buf1[256]; ! ! if( (fp=fopen(name, "r")) == NULL ) return(0); ! ! arMalloc( paddleInfo, ARPaddleInfo, 1 ); ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%s", paddleInfo->name) != 1 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%s", buf1) != 1 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! if( (paddleInfo->marker_id = arLoadPatt(buf1)) < 0 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! ! get_buff(buf, 256, fp); ! if( sscanf(buf, "%lf", &paddleInfo->width) != 1 ) { ! fclose(fp); free(paddleInfo); return 0; ! } ! ! paddleInfo->center[0] = 0.0; ! paddleInfo->center[1] = 0.0; ! paddleInfo->active = 0; ! paddleInfo->pcount = 0; ! paddleInfo->pcountL = 0; ! paddleInfo->pcountR = 0; ! ! fclose(fp); ! ! return paddleInfo; ! } ! ! static char *get_buff( char *buf, int n, FILE *fp ) ! { ! char *ret; ! ! for(;;) { ! ret = fgets( buf, n, fp ); ! if( ret == NULL ) return(NULL); ! if( buf[0] != '\n' && buf[0] != '#' ) return(ret); ! } ! } ! ! int paddleGetTrans( ARPaddleInfo *paddleInfo, ARMarkerInfo *markerInfo, int *markerFlag, int marker_num, ARParam *cparam ) ! { ! int id; ! ! id = get_marker( markerInfo, markerFlag, marker_num, paddleInfo->marker_id, ! &(paddleInfo->prevInfo), &(paddleInfo->pcount) ); ! ! if( id == -1 ) { paddleInfo->active = 0; return 0; } ! ! arGetTransMat(&markerInfo[id], ! paddleInfo->center, paddleInfo->width, paddleInfo->trans); ! markerFlag[id] = 1; ! ! paddleInfo->active = 1; ! ! return 0; ! } ! ! static int get_marker( ARMarkerInfo *markerInfo, int *markerFlag, int marker_num, int id, ! ARMarkerInfo *prevInfo, int *pcount ) ! { ! double rlen, rlenmin, rarea, diff, diffmin; ! int cid, cdir; ! int i, j; ! ! cid = -1; ! for( i = 0; i < marker_num; i++ ) { ! if( markerInfo[i].id == id && markerFlag[i] == 0 ) { ! if( cid == -1 ) cid = i; ! else { ! if( markerInfo[cid].cf < markerInfo[i].cf ) cid = i; ! } ! } ! } ! if( cid == -1 ) { ! if( *pcount == 0 ) return -1; ! ! rlenmin = 10.0; ! for( i = 0; i < marker_num; i++ ) { ! if( markerFlag[i] ) continue; ! rarea = (double)prevInfo->area / (double)markerInfo[i].area; ! if( rarea < 0.7 || rarea > 1.43 ) continue; ! rlen = ( (markerInfo[i].pos[0] - prevInfo->pos[0]) ! * (markerInfo[i].pos[0] - prevInfo->pos[0]) ! + (markerInfo[i].pos[1] - prevInfo->pos[1]) ! * (markerInfo[i].pos[1] - prevInfo->pos[1]) ) / markerInfo[i].area; ! if( rlen < 0.5 && rlen < rlenmin ) { ! rlenmin = rlen; ! cid = i; ! } ! } ! if( cid >= 0 && markerInfo[cid].cf < prevInfo->cf ) { ! markerInfo[cid].cf = prevInfo->cf; ! markerInfo[cid].id = prevInfo->id; ! diffmin = 10000.0 * 10000.0; ! cdir = -1; ! for( i = 0; i < 4; i++ ) { ! diff = 0.0; ! for( j = 0; j < 4; j++ ) { ! diff += (prevInfo->vertex[j][0] - markerInfo[cid].vertex[(i+j)%4][0]) ! * (prevInfo->vertex[j][0] - markerInfo[cid].vertex[(i+j)%4][0]) ! + (prevInfo->vertex[j][1] - markerInfo[cid].vertex[(i+j)%4][1]) ! * (prevInfo->vertex[j][1] - markerInfo[cid].vertex[(i+j)%4][1]); ! } ! if( diff < diffmin ) { ! diffmin = diff; ! cdir = (prevInfo->dir - i + 4) % 4; ! } ! } ! markerInfo[cid].dir = cdir; ! ! *prevInfo = markerInfo[cid]; ! *pcount = 1; ! } ! else { ! *pcount = 0; ! return -1; ! } ! } ! else { ! *prevInfo = markerInfo[cid]; ! *pcount = 1; ! } ! ! return cid; ! } Index: paddleInteractionTest.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/paddleInteraction/paddleInteractionTest.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** paddleInteractionTest.c 22 Nov 2004 03:37:43 -0000 1.1 --- paddleInteractionTest.c 2 Dec 2004 00:47:30 -0000 1.2 *************** *** 1,526 **** ! #ifdef _WIN32 ! #include <windows.h> ! #endif ! #include <stdio.h> ! #include <stdlib.h> ! #include <string.h> ! #include <math.h> ! ! #include <GL/gl.h> ! #include <GL/glut.h> [...1022 lines suppressed...] ! y0 = y0 + deltaY; ! glBegin(GL_LINES); ! glVertex3f(x0,y0,height); ! glVertex3f(x1,y0,height); ! glEnd(); ! } ! ! glLineWidth(1.0); ! ! glEnable(GL_LIGHTING); ! glEnable(GL_LIGHT0); ! glLightfv(GL_LIGHT0, GL_POSITION, light_position); ! glLightfv(GL_LIGHT0, GL_AMBIENT, ambi); ! glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor); ! ! glDisable( GL_LIGHTING ); ! glDisable( GL_DEPTH_TEST ); ! argDrawMode2D(); ! return 0; ! } |
From: Philip L. <phi...@us...> - 2004-12-02 00:46:48
|
Update of /cvsroot/artoolkit/artoolkit/util/calib_cparam In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20770 Modified Files: calib_cparam_sub.c Log Message: Include stdlib.h Index: calib_cparam_sub.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/util/calib_cparam/calib_cparam_sub.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** calib_cparam_sub.c 4 Nov 2004 08:52:10 -0000 1.1.1.1 --- calib_cparam_sub.c 2 Dec 2004 00:46:28 -0000 1.2 *************** *** 1,7 **** #ifdef _WIN32 ! #include <windows.h> #endif #include <math.h> #include <stdio.h> #include "calib_cparam.h" --- 1,8 ---- #ifdef _WIN32 ! # include <windows.h> #endif #include <math.h> #include <stdio.h> + #include <stdlib.h> #include "calib_cparam.h" |
From: Philip L. <phi...@us...> - 2004-12-02 00:45:55
|
Update of /cvsroot/artoolkit/artoolkit/util/calib_distortion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20612 Modified Files: check_dist.c Log Message: Include stdlib.h Index: check_dist.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/util/calib_distortion/check_dist.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** check_dist.c 4 Nov 2004 08:52:13 -0000 1.1.1.1 --- check_dist.c 2 Dec 2004 00:45:47 -0000 1.2 *************** *** 1,7 **** #ifdef _WIN32 ! #include <windows.h> #endif #include <math.h> #include <stdio.h> #include <AR/param.h> #include <AR/matrix.h> --- 1,8 ---- #ifdef _WIN32 ! # include <windows.h> #endif #include <math.h> #include <stdio.h> + #include <stdlib.h> #include <AR/param.h> #include <AR/matrix.h> |
From: Philip L. <phi...@us...> - 2004-12-02 00:44:28
|
Update of /cvsroot/artoolkit/artoolkit/examples/relation In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20237 Modified Files: relationTest.c Log Message: Fix GLUT include on Mac OS X. Index: relationTest.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/relation/relationTest.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** relationTest.c 4 Nov 2004 08:51:05 -0000 1.1.1.1 --- relationTest.c 2 Dec 2004 00:44:20 -0000 1.2 *************** *** 1,13 **** #ifdef _WIN32 ! #include <windows.h> #endif #include <stdio.h> #include <stdlib.h> #ifndef __APPLE__ ! #include <GL/gl.h> ! #include <GL/glut.h> #else ! #include <OpenGL/gl.h> ! #include <GLUT/glut.h> #endif #include <AR/gsub.h> --- 1,11 ---- #ifdef _WIN32 ! # include <windows.h> #endif #include <stdio.h> #include <stdlib.h> #ifndef __APPLE__ ! # include <GL/glut.h> #else ! # include <GLUT/glut.h> #endif #include <AR/gsub.h> |
From: Philip L. <phi...@us...> - 2004-12-01 22:48:20
|
Update of /cvsroot/artoolkit/artoolkit/include/AR In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22494 Modified Files: arvrml.h Log Message: Add const qualifier to filename in arVrmlLoadFile. Index: arvrml.h =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/include/AR/arvrml.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** arvrml.h 19 Nov 2004 03:26:35 -0000 1.1 --- arvrml.h 1 Dec 2004 22:48:11 -0000 1.2 *************** *** 26,30 **** #endif ! int arVrmlLoadFile( char *file ); int arVrmlFree( int id ); int arVrmlDraw( int id ); --- 26,30 ---- #endif ! int arVrmlLoadFile(const char *file); int arVrmlFree( int id ); int arVrmlDraw( int id ); |
From: Philip L. <phi...@us...> - 2004-12-01 22:48:13
|
Update of /cvsroot/artoolkit/artoolkit/lib/SRC/ARvrml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22437 Modified Files: arViewerCapi.cpp Log Message: Add const qualifier to filename in arVrmlLoadFile. Index: arViewerCapi.cpp =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/lib/SRC/ARvrml/arViewerCapi.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** arViewerCapi.cpp 19 Nov 2004 03:26:52 -0000 1.1 --- arViewerCapi.cpp 1 Dec 2004 22:48:03 -0000 1.2 *************** *** 46,50 **** ! int arVrmlLoadFile( char *file ) { --- 46,50 ---- ! int arVrmlLoadFile(const char *file) { |
From: Philip L. <phi...@us...> - 2004-12-01 20:58:24
|
Update of /cvsroot/artoolkit/artoolkit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28604 Modified Files: README.txt Log Message: Added simpleVRML example. Index: README.txt =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/README.txt,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** README.txt 22 Nov 2004 18:48:10 -0000 1.5 --- README.txt 1 Dec 2004 20:58:15 -0000 1.6 *************** *** 85,89 **** Latest changes. --------------- ! - Added libARvrml. Build instructions and examples are in the works. - Turn off texturing in gsub/gsub_lite when argDrawMode/arglDrawmode is AR_DRAW_BY_GL_DRAW_PIXELS. - Added new examples collide, loadMultiple, paddle, paddleDemo, paddleInteraction, range and twoView. --- 85,89 ---- Latest changes. --------------- ! - Added libARvrml and simpleVRML example. Build instructions are in the works. - Turn off texturing in gsub/gsub_lite when argDrawMode/arglDrawmode is AR_DRAW_BY_GL_DRAW_PIXELS. - Added new examples collide, loadMultiple, paddle, paddleDemo, paddleInteraction, range and twoView. |
From: Philip L. <phi...@us...> - 2004-12-01 20:51:11
|
Update of /cvsroot/artoolkit/artoolkit/examples/simpleLite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26925 Modified Files: simpleLite.c Log Message: Changes to fullscreen (gamemode) glut setup. Index: simpleLite.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/simpleLite/simpleLite.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** simpleLite.c 30 Nov 2004 04:06:11 -0000 1.2 --- simpleLite.c 1 Dec 2004 20:51:03 -0000 1.3 *************** *** 69,74 **** static int prefWidth = 640; // Fullscreen mode width. static int prefHeight = 480; // Fullscreen mode height. ! //static int prefDepth = 32; // Fullscreen mode bit depth. ! //static int prefRefresh = 60; // Fullscreen mode refresh rate. // ARToolKit globals. --- 69,74 ---- static int prefWidth = 640; // Fullscreen mode width. static int prefHeight = 480; // Fullscreen mode height. ! static int prefDepth = 32; // Fullscreen mode bit depth. ! static int prefRefresh = 0; // Fullscreen mode refresh rate. Set to 0 to use default rate. // ARToolKit globals. *************** *** 454,463 **** // Set up GL context(s) for OpenGL to draw into. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); ! if (!prefWindowed) { // GLUT mono fullscreen. ! //sprintf(glutGamemode, "%ix%i:%i@%i", prefWidth, prefHeight, prefDepth, prefRefresh); ! sprintf(glutGamemode, "%ix%i", prefWidth, prefHeight); glutGameModeString(glutGamemode); glutEnterGameMode(); ! } else { // GLUT mono windowed. glutInitWindowSize(gARTCparam.xsize, gARTCparam.ysize); glutCreateWindow(argv[0]); --- 454,463 ---- // Set up GL context(s) for OpenGL to draw into. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); ! if (!prefWindowed) { ! if (prefRefresh) sprintf(glutGamemode, "%ix%i:%i@%i", prefWidth, prefHeight, prefDepth, prefRefresh); ! else sprintf(glutGamemode, "%ix%i:%i", prefWidth, prefHeight, prefDepth); glutGameModeString(glutGamemode); glutEnterGameMode(); ! } else { glutInitWindowSize(gARTCparam.xsize, gARTCparam.ysize); glutCreateWindow(argv[0]); |
From: Philip L. <phi...@us...> - 2004-12-01 20:51:05
|
Update of /cvsroot/artoolkit/artoolkit/examples/simpleVRML In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26821 Modified Files: simpleVRML.c Log Message: Changes to fullscreen (gamemode) glut setup. Index: simpleVRML.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/simpleVRML/simpleVRML.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** simpleVRML.c 1 Dec 2004 04:54:47 -0000 1.1 --- simpleVRML.c 1 Dec 2004 20:50:56 -0000 1.2 *************** *** 79,87 **** // Preferences. ! static BOOL prefWindowed = FALSE; static int prefWidth = 640; // Fullscreen mode width. static int prefHeight = 480; // Fullscreen mode height. ! //static int prefDepth = 32; // Fullscreen mode bit depth. ! //static int prefRefresh = 60; // Fullscreen mode refresh rate. // ARToolKit globals. --- 79,87 ---- // Preferences. ! static BOOL prefWindowed = TRUE; static int prefWidth = 640; // Fullscreen mode width. static int prefHeight = 480; // Fullscreen mode height. ! static int prefDepth = 32; // Fullscreen mode bit depth. ! static int prefRefresh = 0; // Fullscreen mode refresh rate. Set to 0 to use default rate. // ARToolKit globals. *************** *** 436,445 **** // Set up GL context(s) for OpenGL to draw into. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); ! if (!prefWindowed) { // GLUT mono fullscreen. ! //sprintf(glutGamemode, "%ix%i:%i@%i", prefWidth, prefHeight, prefDepth, prefRefresh); ! sprintf(glutGamemode, "%ix%i", prefWidth, prefHeight); glutGameModeString(glutGamemode); glutEnterGameMode(); ! } else { // GLUT mono windowed. glutInitWindowSize(gARTCparam.xsize, gARTCparam.ysize); glutCreateWindow(argv[0]); --- 436,445 ---- // Set up GL context(s) for OpenGL to draw into. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); ! if (!prefWindowed) { ! if (prefRefresh) sprintf(glutGamemode, "%ix%i:%i@%i", prefWidth, prefHeight, prefDepth, prefRefresh); ! else sprintf(glutGamemode, "%ix%i:%i", prefWidth, prefHeight, prefDepth); glutGameModeString(glutGamemode); glutEnterGameMode(); ! } else { glutInitWindowSize(gARTCparam.xsize, gARTCparam.ysize); glutCreateWindow(argv[0]); |
From: Philip L. <phi...@us...> - 2004-12-01 20:37:04
|
Update of /cvsroot/artoolkit/artoolkit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23784 Modified Files: ARToolKit.sln Log Message: Add simpleVRML example. Index: ARToolKit.sln =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/ARToolKit.sln,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ARToolKit.sln 25 Nov 2004 21:41:49 -0000 1.3 --- ARToolKit.sln 1 Dec 2004 20:36:56 -0000 1.4 *************** *** 152,155 **** --- 152,167 ---- EndProjectSection EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libARvrml", "lib\SRC\ARvrml\libarvrml.vcproj", "{C90F035F-437C-4285-BBCA-8DDC70582356}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection + EndProject + Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simpleVRML", "examples\simpleVRML\simpleVRML.vcproj", "{7B5EFC13-7883-82CC-7D72-732240F68F29}" + ProjectSection(ProjectDependencies) = postProject + {C90F035F-437C-4285-BBCA-8DDC70582356} = {C90F035F-437C-4285-BBCA-8DDC70582356} + {8AAAFC7D-0CF2-4E59-BEEA-DD4398CA55BF} = {8AAAFC7D-0CF2-4E59-BEEA-DD4398CA55BF} + {B5E62882-360E-46B2-A97F-50443BB795E3} = {B5E62882-360E-46B2-A97F-50443BB795E3} + {191F78D2-7A53-4EAF-94E9-433DF5496E6E} = {191F78D2-7A53-4EAF-94E9-433DF5496E6E} + EndProjectSection + EndProject Global GlobalSection(SolutionConfiguration) = preSolution *************** *** 305,308 **** --- 317,328 ---- {401D60F6-AF80-481B-A6EB-9FB03130AB1F}.Release (Intel).ActiveCfg = Release|Win32 {401D60F6-AF80-481B-A6EB-9FB03130AB1F}.Release (Intel).Build.0 = Release|Win32 + {C90F035F-437C-4285-BBCA-8DDC70582356}.Debug.ActiveCfg = Debug|Win32 + {C90F035F-437C-4285-BBCA-8DDC70582356}.Release.ActiveCfg = Release|Win32 + {C90F035F-437C-4285-BBCA-8DDC70582356}.Release (Intel).ActiveCfg = Release|Win32 + {C90F035F-437C-4285-BBCA-8DDC70582356}.Release (Intel).Build.0 = Release|Win32 + {7B5EFC13-7883-82CC-7D72-732240F68F29}.Debug.ActiveCfg = Debug|Win32 + {7B5EFC13-7883-82CC-7D72-732240F68F29}.Release.ActiveCfg = Release|Win32 + {7B5EFC13-7883-82CC-7D72-732240F68F29}.Release (Intel).ActiveCfg = Release|Win32 + {7B5EFC13-7883-82CC-7D72-732240F68F29}.Release (Intel).Build.0 = Release|Win32 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution |
From: Philip L. <phi...@us...> - 2004-12-01 20:20:14
|
Update of /cvsroot/artoolkit/artoolkit/examples/twoView In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19625 Modified Files: twoView.c Log Message: Add conditional inclusion of <GL/glext.h>. Index: twoView.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/twoView/twoView.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** twoView.c 30 Nov 2004 04:06:03 -0000 1.3 --- twoView.c 1 Dec 2004 20:20:05 -0000 1.4 *************** *** 38,47 **** #include <stdio.h> // fprintf(), stderr #include <stdlib.h> // malloc(), free(), atexit() ! #ifdef __APPLE__ # include <GLUT/glut.h> # include <OpenGL/glext.h> - #else - # include <GL/glut.h> - # include <GL/glext.h> #endif #include <AR/config.h> --- 38,49 ---- #include <stdio.h> // fprintf(), stderr #include <stdlib.h> // malloc(), free(), atexit() ! #ifndef __APPLE__ ! # include <GL/glut.h> ! # ifdef GL_VERSION_1_2 ! # include <GL/glext.h> ! # endif ! #else # include <GLUT/glut.h> # include <OpenGL/glext.h> #endif #include <AR/config.h> |
From: Philip L. <phi...@us...> - 2004-12-01 19:56:29
|
Update of /cvsroot/artoolkit/artoolkit/examples/simpleVRML In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12338 Modified Files: simpleVRML.vcproj Log Message: Use Multithreaded DLL runtime (fixes crash on fprintf). Index: simpleVRML.vcproj =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/simpleVRML/simpleVRML.vcproj,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** simpleVRML.vcproj 1 Dec 2004 04:54:47 -0000 1.1 --- simpleVRML.vcproj 1 Dec 2004 19:56:19 -0000 1.2 *************** *** 24,28 **** MinimalRebuild="TRUE" BasicRuntimeChecks="3" ! RuntimeLibrary="1" BufferSecurityCheck="FALSE" EnableFunctionLevelLinking="FALSE" --- 24,28 ---- MinimalRebuild="TRUE" BasicRuntimeChecks="3" ! RuntimeLibrary="3" BufferSecurityCheck="FALSE" EnableFunctionLevelLinking="FALSE" *************** *** 74,78 **** AdditionalIncludeDirectories="$(ProjectDir)/../../include;$(ProjectDir)/../../OpenVRML/include;$(ProjectDir)/../../OpenVRML/dependencies/include;$(NOINHERIT)" PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" ! RuntimeLibrary="0" UsePrecompiledHeader="0" WarningLevel="3"/> --- 74,78 ---- AdditionalIncludeDirectories="$(ProjectDir)/../../include;$(ProjectDir)/../../OpenVRML/include;$(ProjectDir)/../../OpenVRML/dependencies/include;$(NOINHERIT)" PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" ! RuntimeLibrary="2" UsePrecompiledHeader="0" WarningLevel="3"/> |
From: Philip L. <phi...@us...> - 2004-12-01 04:55:11
|
Update of /cvsroot/artoolkit/artoolkit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12377 Modified Files: Configure Log Message: Add simpleVRML example. Index: Configure =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/Configure,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Configure 22 Nov 2004 03:41:22 -0000 1.3 --- Configure 1 Dec 2004 04:55:01 -0000 1.4 *************** *** 18,22 **** examples/loadMultiple examples/modeTest examples/multi examples/optical \ examples/paddle examples/paddleDemo examples/paddleInteraction examples/range \ ! examples/relation examples/simple examples/simple2 examples/simpleLite examples/twoView \ " --- 18,23 ---- examples/loadMultiple examples/modeTest examples/multi examples/optical \ examples/paddle examples/paddleDemo examples/paddleInteraction examples/range \ ! examples/relation examples/simple examples/simple2 examples/simpleLite \ ! examples/twoView examples/simpleVRML \ " |
From: Philip L. <phi...@us...> - 2004-12-01 04:55:04
|
Update of /cvsroot/artoolkit/artoolkit/ARToolKit.xcode In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12307 Modified Files: project.pbxproj Log Message: Add simpleVRML example. Index: project.pbxproj =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/ARToolKit.xcode/project.pbxproj,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** project.pbxproj 26 Nov 2004 01:19:36 -0000 1.7 --- project.pbxproj 1 Dec 2004 04:54:54 -0000 1.8 *************** *** 78,81 **** --- 78,82 ---- 4A835647074D914100F58781, 4A835659074D936800F58781, + 4A1309F7075C26F900D62ACD, ); }; *************** *** 123,126 **** --- 124,423 ---- sourceTree = "<group>"; }; + 4A1308AC075BE4A700D62ACD = { + children = ( + 4A1308AF075BE4A700D62ACD, + 4A1308B0075BE4A700D62ACD, + 4A1308B1075BE4A700D62ACD, + 4A1308AE075BE4A700D62ACD, + 4A130A48075C2C1B00D62ACD, + ); + isa = PBXGroup; + path = simpleVRML; + refType = 4; + sourceTree = "<group>"; + }; + 4A1308AE075BE4A700D62ACD = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text; + path = Makefile.in; + refType = 4; + sourceTree = "<group>"; + }; + 4A1308AF075BE4A700D62ACD = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = object.c; + refType = 4; + sourceTree = "<group>"; + }; + 4A1308B0075BE4A700D62ACD = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = object.h; + refType = 4; + sourceTree = "<group>"; + }; + 4A1308B1075BE4A700D62ACD = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.c; + path = simpleVRML.c; + refType = 4; + sourceTree = "<group>"; + }; + 4A1309D5075C25CF00D62ACD = { + isa = PBXFileReference; + lastKnownFileType = folder; + path = Wrl; + refType = 4; + sourceTree = "<group>"; + }; + 4A1309F7075C26F900D62ACD = { + buildPhases = ( + 4A1309FB075C26F900D62ACD, + 4A1309FF075C26F900D62ACD, + 4A130A01075C26F900D62ACD, + 4A130A02075C26F900D62ACD, + ); + buildRules = ( + ); + buildSettings = { + DEPLOYMENT_LOCATION = YES; + DSTROOT = /; + GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO; + GCC_WARN_UNKNOWN_PRAGMAS = NO; + HEADER_SEARCH_PATHS = include; + INSTALL_PATH = "$(SRCROOT)/bin"; + LIBRARY_SEARCH_PATHS = "lib /sw/lib /usr/lib/gcc/darwin/3.3"; + PRODUCT_NAME = simpleVRML; + WARNING_CFLAGS = "-Wmost"; + }; + dependencies = ( + 4A1309F8075C26F900D62ACD, + 4A1309F9075C26F900D62ACD, + 4A1309FA075C26F900D62ACD, + 4A130A0E075C270F00D62ACD, + ); + isa = PBXNativeTarget; + name = simpleVRML; + productName = simpleTest; + productReference = 4A130A0B075C26F900D62ACD; + productType = "com.apple.product-type.tool"; + }; + 4A1309F8075C26F900D62ACD = { + isa = PBXTargetDependency; + target = 4A3F11430649F7BA0042B0D7; + targetProxy = 4A5F9A4C064B4F0600525EC0; + }; + 4A1309F9075C26F900D62ACD = { + isa = PBXTargetDependency; + target = 4A3F1305064A02100042B0D7; + targetProxy = 4A5F9A4E064B4F0600525EC0; + }; + 4A1309FA075C26F900D62ACD = { + isa = PBXTargetDependency; + target = 4A8EA585065873E100ADDDD1; + targetProxy = 4A2244FE0659A32C0014DA8E; + }; + 4A1309FB075C26F900D62ACD = { + buildActionMask = 2147483647; + files = ( + 4A130A10075C273900D62ACD, + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 4A1309FF075C26F900D62ACD = { + buildActionMask = 2147483647; + files = ( + 4A130A0F075C273800D62ACD, + 4A130A11075C273900D62ACD, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 4A130A01075C26F900D62ACD = { + buildActionMask = 2147483647; + files = ( + ); + isa = PBXRezBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 4A130A02075C26F900D62ACD = { + buildActionMask = 2147483647; + files = ( + 4A130A03075C26F900D62ACD, + 4A130A04075C26F900D62ACD, + 4A130A05075C26F900D62ACD, + 4A130A06075C26F900D62ACD, + 4A130A07075C26F900D62ACD, + 4A130A08075C26F900D62ACD, + 4A130A09075C26F900D62ACD, + 4A130A0A075C26F900D62ACD, + 4A130A12075C275900D62ACD, + 4A130A17075C27F900D62ACD, + 4A130A18075C27F900D62ACD, + 4A130A1A075C284C00D62ACD, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + 4A130A03075C26F900D62ACD = { + fileRef = 4A3F1601064A0CE40042B0D7; + isa = PBXBuildFile; + settings = { + }; + }; + 4A130A04075C26F900D62ACD = { + fileRef = 4A3F167F064A0E270042B0D7; + isa = PBXBuildFile; + settings = { + }; + }; + 4A130A05075C26F900D62ACD = { + fileRef = 4A3F14FC064A0C510042B0D7; + isa = PBXBuildFile; + settings = { + }; + }; + 4A130A06075C26F900D62ACD = { + fileRef = 4A3F14FD064A0C510042B0D7; + isa = PBXBuildFile; + settings = { + }; + }; + 4A130A07075C26F900D62ACD = { + fileRef = 4A3F14FE064A0C510042B0D7; + isa = PBXBuildFile; + settings = { + }; + }; + 4A130A08075C26F900D62ACD = { + fileRef = 4A427D120484329800B56093; + isa = PBXBuildFile; + settings = { + }; + }; + 4A130A09075C26F900D62ACD = { + fileRef = 4A427D160484329800B56093; + isa = PBXBuildFile; + settings = { + }; + }; + 4A130A0A075C26F900D62ACD = { + fileRef = 4A66475606598B950061DA76; + isa = PBXBuildFile; + settings = { + }; + }; + 4A130A0B075C26F900D62ACD = { + explicitFileType = "compiled.mach-o.executable"; + includeInIndex = 0; + isa = PBXFileReference; + path = simpleVRML; + refType = 3; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 4A130A0D075C270F00D62ACD = { + containerPortal = 08FB7793FE84155DC02AAC07; + isa = PBXContainerItemProxy; + proxyType = 1; + remoteGlobalIDString = 4A835659074D936800F58781; + remoteInfo = ARvrml; + }; + 4A130A0E075C270F00D62ACD = { + isa = PBXTargetDependency; + target = 4A835659074D936800F58781; + targetProxy = 4A130A0D075C270F00D62ACD; + }; + 4A130A0F075C273800D62ACD = { + fileRef = 4A1308AF075BE4A700D62ACD; + isa = PBXBuildFile; + settings = { + }; + }; + 4A130A10075C273900D62ACD = { + fileRef = 4A1308B0075BE4A700D62ACD; + isa = PBXBuildFile; + settings = { + }; + }; + 4A130A11075C273900D62ACD = { + fileRef = 4A1308B1075BE4A700D62ACD; + isa = PBXBuildFile; + settings = { + }; + }; + 4A130A12075C275900D62ACD = { + fileRef = 4A83565A074D936800F58781; + isa = PBXBuildFile; + settings = { + }; + }; + 4A130A15075C27F900D62ACD = { + isa = PBXFileReference; + lastKnownFileType = "compiled.mach-o.dylib"; + name = "libopenvrml-gl.dylib"; + path = "/sw/lib/libopenvrml-gl.dylib"; + refType = 0; + sourceTree = "<absolute>"; + }; + 4A130A16075C27F900D62ACD = { + isa = PBXFileReference; + lastKnownFileType = "compiled.mach-o.dylib"; + name = libopenvrml.dylib; + path = /sw/lib/libopenvrml.dylib; + refType = 0; + sourceTree = "<absolute>"; + }; + 4A130A17075C27F900D62ACD = { + fileRef = 4A130A15075C27F900D62ACD; + isa = PBXBuildFile; + settings = { + }; + }; + 4A130A18075C27F900D62ACD = { + fileRef = 4A130A16075C27F900D62ACD; + isa = PBXBuildFile; + settings = { + }; + }; + 4A130A19075C284C00D62ACD = { + isa = PBXFileReference; + lastKnownFileType = archive.ar; + name = "libstdc++.a"; + path = "/usr/lib/libstdc++.a"; + refType = 0; + sourceTree = "<absolute>"; + }; + 4A130A1A075C284C00D62ACD = { + fileRef = 4A130A19075C284C00D62ACD; + isa = PBXBuildFile; + settings = { + }; + }; + 4A130A2D075C28C600D62ACD = { + containerPortal = 08FB7793FE84155DC02AAC07; + isa = PBXContainerItemProxy; + proxyType = 1; + remoteGlobalIDString = 4A1309F7075C26F900D62ACD; + remoteInfo = simpleVRML; + }; + 4A130A2E075C28C600D62ACD = { + isa = PBXTargetDependency; + target = 4A1309F7075C26F900D62ACD; + targetProxy = 4A130A2D075C28C600D62ACD; + }; + 4A130A48075C2C1B00D62ACD = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = text.xml; + path = simpleVRML.vcproj; + refType = 4; + sourceTree = "<group>"; + }; 4A1F9DE00756897100DEC369 = { buildPhases = ( *************** *** 1383,1386 **** --- 1680,1686 ---- 4A3F1552064A0C7C0042B0D7 = { children = ( + 4A130A19075C284C00D62ACD, + 4A130A15075C27F900D62ACD, + 4A130A16075C27F900D62ACD, 4A3F1601064A0CE40042B0D7, 4A3F167F064A0E270042B0D7, *************** *** 1390,1394 **** ); isa = PBXGroup; ! name = Frameworks; path = ""; refType = 4; --- 1690,1694 ---- ); isa = PBXGroup; ! name = "External Libraries & Frameworks"; path = ""; refType = 4; *************** *** 1893,1896 **** --- 2193,2197 ---- 4A427CE70484329800B56093, 4A2244930659A20D0014DA8E, + 4A1308AC075BE4A700D62ACD, ); isa = PBXGroup; *************** *** 3055,3062 **** 4A461B5C04843FAA00B56093 = { children = ( 4A461B5E04843FAA00B56093, 4A461B5F04843FAA00B56093, 4A461B6004843FAA00B56093, - 4A461B6104843FAA00B56093, 4A461B7104843FAA00B56093, 4A461B7204843FAA00B56093, --- 3356,3364 ---- 4A461B5C04843FAA00B56093 = { children = ( + 4A1309D5075C25CF00D62ACD, + 4A5103A4075A7E8E0072C3BA, 4A461B5E04843FAA00B56093, 4A461B5F04843FAA00B56093, 4A461B6004843FAA00B56093, 4A461B7104843FAA00B56093, 4A461B7204843FAA00B56093, *************** *** 3095,3237 **** sourceTree = "<group>"; }; - 4A461B6104843FAA00B56093 = { - children = ( - 4AC3C06C075187D00073D2C6, - 4AC3C06D075187D00073D2C6, - 4A461B6204843FAA00B56093, - 4A461B6304843FAA00B56093, - 4A461B6B04843FAA00B56093, - 4A461B6C04843FAA00B56093, - 4A461B6D04843FAA00B56093, - 4A461B6E04843FAA00B56093, - 4A461B6F04843FAA00B56093, - 4A461B7004843FAA00B56093, - ); - isa = PBXGroup; - path = Data; - refType = 4; - sourceTree = "<group>"; - }; - 4A461B6204843FAA00B56093 = { - isa = PBXFileReference; - lastKnownFileType = file; - path = camera_para.dat; - refType = 4; - sourceTree = "<group>"; - }; - 4A461B6304843FAA00B56093 = { - children = ( - 4A461B6404843FAA00B56093, - 4A461B6504843FAA00B56093, - 4A461B6604843FAA00B56093, - 4A461B6704843FAA00B56093, - 4A461B6804843FAA00B56093, - 4A461B6904843FAA00B56093, - 4A461B6A04843FAA00B56093, - ); - isa = PBXGroup; - path = multi; - refType = 4; - sourceTree = "<group>"; - }; - 4A461B6404843FAA00B56093 = { - isa = PBXFileReference; - lastKnownFileType = text; - path = marker.dat; - refType = 4; - sourceTree = "<group>"; - }; - 4A461B6504843FAA00B56093 = { - explicitFileType = text; - isa = PBXFileReference; - path = patt.a; - refType = 4; - sourceTree = "<group>"; - }; - 4A461B6604843FAA00B56093 = { - explicitFileType = text; - isa = PBXFileReference; - path = patt.b; - refType = 4; - sourceTree = "<group>"; - }; - 4A461B6704843FAA00B56093 = { - explicitFileType = text; - fileEncoding = 30; - isa = PBXFileReference; - path = patt.c; - refType = 4; - sourceTree = "<group>"; - }; - 4A461B6804843FAA00B56093 = { - explicitFileType = text; - isa = PBXFileReference; - path = patt.d; - refType = 4; - sourceTree = "<group>"; - }; - 4A461B6904843FAA00B56093 = { - explicitFileType = text; - fileEncoding = 30; - isa = PBXFileReference; - path = patt.f; - refType = 4; - sourceTree = "<group>"; - }; - 4A461B6A04843FAA00B56093 = { - explicitFileType = text; - isa = PBXFileReference; - path = patt.g; - refType = 4; - sourceTree = "<group>"; - }; - 4A461B6B04843FAA00B56093 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = text; - path = object_data; - refType = 4; - sourceTree = "<group>"; - }; - 4A461B6C04843FAA00B56093 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = text; - path = patt.calib; - refType = 4; - sourceTree = "<group>"; - }; - 4A461B6D04843FAA00B56093 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = text; - path = patt.hiro; - refType = 4; - sourceTree = "<group>"; - }; - 4A461B6E04843FAA00B56093 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = text; - path = patt.kanji; - refType = 4; - sourceTree = "<group>"; - }; - 4A461B6F04843FAA00B56093 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = text; - path = patt.sample1; - refType = 4; - sourceTree = "<group>"; - }; - 4A461B7004843FAA00B56093 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = text; - path = patt.sample2; - refType = 4; - sourceTree = "<group>"; - }; 4A461B7104843FAA00B56093 = { isa = PBXFileReference; --- 3397,3400 ---- *************** *** 3452,3455 **** --- 3615,3625 ---- targetProxy = 4A488BAD0751CD59003D46BE; }; + 4A5103A4075A7E8E0072C3BA = { + isa = PBXFileReference; + lastKnownFileType = folder; + path = Data; + refType = 4; + sourceTree = "<group>"; + }; 4A5F9A43064B4EF400525EC0 = { buildActionMask = 2147483647; *************** *** 4526,4530 **** 4A83563E074D90E300F58781, 4A83563F074D90E300F58781, - 4A835640074D90E300F58781, 4A835641074D90E300F58781, 4A835642074D90E300F58781, --- 4696,4699 ---- *************** *** 4559,4575 **** sourceTree = "<group>"; }; - 4A835640074D90E300F58781 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = text; - path = libarvrml.sln; - refType = 4; - sourceTree = "<group>"; - }; 4A835641074D90E300F58781 = { fileEncoding = 30; isa = PBXFileReference; lastKnownFileType = text.xml; ! path = libarvrml.vcproj; refType = 4; sourceTree = "<group>"; --- 4728,4736 ---- sourceTree = "<group>"; }; 4A835641074D90E300F58781 = { fileEncoding = 30; isa = PBXFileReference; lastKnownFileType = text.xml; ! path = libARvrml.vcproj; refType = 4; sourceTree = "<group>"; *************** *** 4596,4599 **** --- 4757,4761 ---- dependencies = ( 4A83565D074D93A900F58781, + 4A130A2E075C28C600D62ACD, ); isa = PBXAggregateTarget; *************** *** 6154,6173 **** sourceTree = "<group>"; }; - 4AC3C06C075187D00073D2C6 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = text; - path = object_data2; - refType = 4; - sourceTree = "<group>"; - }; - 4AC3C06D075187D00073D2C6 = { - fileEncoding = 30; - isa = PBXFileReference; - lastKnownFileType = text; - path = paddle_data; - refType = 4; - sourceTree = "<group>"; - }; 4AC3C076075188AB0073D2C6 = { children = ( --- 6316,6319 ---- *************** *** 6892,6895 **** --- 7038,7042 ---- 4AE2305E0659B7D10047D402 = { children = ( + 4A130A0B075C26F900D62ACD, 4A94DD490756B1EB00D79CD1, 4A1F9E1B07568A0100DEC369, |
From: Philip L. <phi...@us...> - 2004-12-01 04:54:57
|
Update of /cvsroot/artoolkit/artoolkit/examples/simpleVRML In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12261 Added Files: Makefile.in object.h object.c simpleVRML.c simpleVRML.vcproj Log Message: Add simpleVRML example. --- NEW FILE: simpleVRML.vcproj --- <?xml version="1.0" encoding="Windows-1252"?> <VisualStudioProject ProjectType="Visual C++" Version="7.10" Name="simpleVRML" ProjectGUID="{7B5EFC13-7883-82CC-7D72-732240F68F29}" Keyword="Win32Proj"> <Platforms> <Platform Name="Win32"/> </Platforms> <Configurations> <Configuration Name="Debug|Win32" OutputDirectory="Debug" IntermediateDirectory="Debug" ConfigurationType="1" CharacterSet="2"> <Tool Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="$(ProjectDir)/../../include;$(ProjectDir)/../../OpenVRML/include;$(ProjectDir)/../../OpenVRML/dependencies/include;$(NOINHERIT)" PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;OPENVRML_ENABLE_IMAGETEXTURE_NODE;OPENVRML_ENABLE_GZIP" MinimalRebuild="TRUE" BasicRuntimeChecks="3" RuntimeLibrary="1" BufferSecurityCheck="FALSE" EnableFunctionLevelLinking="FALSE" TreatWChar_tAsBuiltInType="TRUE" ForceConformanceInForLoopScope="TRUE" RuntimeTypeInfo="TRUE" WarningLevel="3" DebugInformationFormat="3" CompileAs="2"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" AdditionalDependencies="ws2_32.lib opengl32.lib glu32.lib glut32.lib libjpeg.lib libpng.lib zlib.lib libarvrmld.lib openvrml.lib openvrml-gl.lib antlr.lib regex.lib libARvideod.lib libARd.lib libARgsub_lited.lib" OutputFile="$(ProjectDir)/../../bin/$(ProjectName)d.exe" AdditionalLibraryDirectories="$(ProjectDir)/../../lib;$(ProjectDir)/../../OpenVRML/lib;$(ProjectDir)/../../OpenVRML/dependencies/lib" IgnoreDefaultLibraryNames="libc.lib;libcd.lib;libcmt.lib;libcmtd.lib;msvcrt.lib" SubSystem="1" TargetMachine="1"/> <Tool Name="VCMIDLTool"/> <Tool Name="VCPostBuildEventTool"/> <Tool Name="VCPreBuildEventTool"/> <Tool Name="VCPreLinkEventTool"/> <Tool Name="VCResourceCompilerTool"/> <Tool Name="VCWebServiceProxyGeneratorTool"/> <Tool Name="VCXMLDataGeneratorTool"/> <Tool Name="VCWebDeploymentTool"/> <Tool Name="VCManagedWrapperGeneratorTool"/> <Tool Name="VCAuxiliaryManagedWrapperGeneratorTool"/> </Configuration> <Configuration Name="Release|Win32" OutputDirectory="Release" IntermediateDirectory="Release" ConfigurationType="1" CharacterSet="2"> <Tool Name="VCCLCompilerTool" AdditionalIncludeDirectories="$(ProjectDir)/../../include;$(ProjectDir)/../../OpenVRML/include;$(ProjectDir)/../../OpenVRML/dependencies/include;$(NOINHERIT)" PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" RuntimeLibrary="0" UsePrecompiledHeader="0" WarningLevel="3"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLinkerTool" AdditionalDependencies="ws2_32.lib opengl32.lib glu32.lib glut32.lib libjpeg.lib libpng.lib zlib.lib libARvrml.lib openvrml.lib openvrml-gl.lib antlr.lib regex.lib libARvideo.lib libAR.lib libARgsub_lite.lib" OutputFile="$(ProjectDir)/../../bin/$(ProjectName).exe" LinkIncremental="1" AdditionalLibraryDirectories="$(ProjectDir)/../../lib;$(ProjectDir)/../../OpenVRML/lib;$(ProjectDir)/../../OpenVRML/dependencies/lib" IgnoreDefaultLibraryNames="libc.lib;libcd.lib;libcmtd.lib,libcmt.lib;msvcrtd.lib" SubSystem="1" OptimizeReferences="2" EnableCOMDATFolding="2" TargetMachine="1"/> <Tool Name="VCMIDLTool"/> <Tool Name="VCPostBuildEventTool"/> <Tool Name="VCPreBuildEventTool"/> <Tool Name="VCPreLinkEventTool"/> <Tool Name="VCResourceCompilerTool"/> <Tool Name="VCWebServiceProxyGeneratorTool"/> <Tool Name="VCXMLDataGeneratorTool"/> <Tool Name="VCWebDeploymentTool"/> <Tool Name="VCManagedWrapperGeneratorTool"/> <Tool Name="VCAuxiliaryManagedWrapperGeneratorTool"/> </Configuration> </Configurations> <References> </References> <Files> <Filter Name="Source Files" Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> <File RelativePath=".\object.c"> </File> <File RelativePath=".\simpleVRML.c"> </File> </Filter> <Filter Name="Header Files" Filter="h;hpp;hxx;hm;inl;inc;xsd" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> <File RelativePath=".\object.h"> </File> </Filter> <Filter Name="Resource Files" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"> </Filter> </Files> <Globals> </Globals> </VisualStudioProject> --- NEW FILE: simpleVRML.c --- /* * simpleVRML.c * * Demonstration of ARToolKit with models rendered in VRML. * * Press '?' while running for help on available key commands. * * 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 * 1.0.0 ????-??-?? MB Original from ARToolKit * 1.0.1 2004-10-29 RG Fix for ARToolKit 2.69. * 1.0.2 2004-11-30 PRL Various fixes. * */ /* * * This file is part of ARToolKit. * * ARToolKit is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * ARToolKit is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ARToolKit; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ // ============================================================================ // Includes // ============================================================================ #ifdef _WIN32 # include <windows.h> #endif #include <stdio.h> #include <stdlib.h> #include <string.h> #ifdef __APPLE__ # include <GLUT/glut.h> #else # include <GL/glut.h> #endif #include <AR/config.h> #include <AR/video.h> #include <AR/param.h> // arParamDisp() #include <AR/ar.h> #include <AR/gsub_lite.h> #include <AR/arvrml.h> #include "object.h" // ============================================================================ // Constants // ============================================================================ #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. // ============================================================================ // Global variables // ============================================================================ // Preferences. static BOOL prefWindowed = FALSE; static int prefWidth = 640; // Fullscreen mode width. static int prefHeight = 480; // Fullscreen mode height. //static int prefDepth = 32; // Fullscreen mode bit depth. //static int prefRefresh = 60; // Fullscreen mode refresh rate. // ARToolKit globals. static long gCallCountMarkerDetect = 0; static int gARTThreshhold = 100; static ARParam gARTCparam; static ARUint8 *gARTImage = NULL; static BOOL 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; // ============================================================================ // Functions // ============================================================================ // Sets up gARTCparam. static BOOL demoARSetupCamera(const char *cparam_name, char *vconf) { ARParam wparam; int xsize, ysize; // Open the video path. if (arVideoOpen(vconf) < 0) { fprintf(stderr, "demoARSetupCamera(): Unable to open connection to camera.\n"); return (FALSE); } // 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. if (arParamLoad(cparam_name, 1, &wparam) < 0) { fprintf(stderr, "demoARSetupCamera(): Error loading parameter file %s for camera.\n", cparam_name); return (FALSE); } arParamChangeSize(&wparam, xsize, ysize, &gARTCparam); arInitCparam(&gARTCparam); fprintf(stderr, "*** Camera Parameter ***\n"); arParamDisp(&gARTCparam); if (arVideoCapStart() != 0) { fprintf(stderr, "demoARSetupCamera(): Unable to begin camera data capture.\n"); return (FALSE); } return (TRUE); } static BOOL 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); return (TRUE); } // Report state of ARToolKit global variables arFittingMode, // arImageProcMode, arglDrawMode, arTemplateMatchingMode, arMatchingPCAMode. static void demoARDebugReportMode(void) { if(arFittingMode == AR_FITTING_TO_INPUT ) { fprintf(stderr, "FittingMode (Z): INPUT IMAGE\n"); } else { fprintf(stderr, "FittingMode (Z): COMPENSATED IMAGE\n"); } if( arImageProcMode == AR_IMAGE_PROC_IN_FULL ) { fprintf(stderr, "ProcMode (X) : FULL IMAGE\n"); } else { fprintf(stderr, "ProcMode (X) : HALF IMAGE\n"); } if( arglDrawMode == AR_DRAW_BY_GL_DRAW_PIXELS ) { fprintf(stderr, "DrawMode (C) : GL_DRAW_PIXELS\n"); } else if( arglTexmapMode == AR_DRAW_TEXTURE_FULL_IMAGE ) { fprintf(stderr, "DrawMode (C) : TEXTURE MAPPING (FULL RESOLUTION)\n"); } else { fprintf(stderr, "DrawMode (C) : TEXTURE MAPPING (HALF RESOLUTION)\n"); } if( arTemplateMatchingMode == AR_TEMPLATE_MATCHING_COLOR ) { fprintf(stderr, "TemplateMatchingMode (M) : Color Template\n"); } else { fprintf(stderr, "TemplateMatchingMode (M) : BW Template\n"); } if( arMatchingPCAMode == AR_MATCHING_WITHOUT_PCA ) { fprintf(stderr, "MatchingPCAMode (P) : Without PCA\n"); } else { fprintf(stderr, "MatchingPCAMode (P) : With PCA\n"); } } static void Quit(void) { arglCleanup(gArglSettings); arVideoCapStop(); arVideoClose(); #ifdef _WIN32 CoUninitialize(); #endif exit(0); } static void Keyboard(unsigned char key, int x, int y) { switch (key) { case 0x1B: // Quit. case 'Q': case 'q': Quit(); break; case 'C': case 'c': if( arglDrawMode == AR_DRAW_BY_GL_DRAW_PIXELS ) { arglDrawMode = AR_DRAW_BY_TEXTURE_MAPPING; arglTexmapMode = AR_DRAW_TEXTURE_FULL_IMAGE; } else if( arglTexmapMode == AR_DRAW_TEXTURE_FULL_IMAGE ) { arglTexmapMode = AR_DRAW_TEXTURE_HALF_IMAGE; } else { arglDrawMode = AR_DRAW_BY_GL_DRAW_PIXELS; } fprintf(stderr, "*** Camera - %f (frame/sec)\n", (double)gCallCountMarkerDetect/arUtilTimer()); gCallCountMarkerDetect = 0; arUtilTimerReset(); demoARDebugReportMode(); break; break; #ifdef AR_OPENGL_TEXTURE_RECTANGLE case 'R': case 'r': arglTexRectangle = !arglTexRectangle; fprintf(stderr, "Toggled arglTexRectangle to %d.\n", arglTexRectangle); break; #endif // AR_OPENGL_TEXTURE_RECTANGLE case '?': case '/': printf("Keys:\n"); printf(" q or [esc] Quit demo.\n"); printf(" c Change arglDrawMode and arglTexmapMode.\n"); #ifdef AR_OPENGL_TEXTURE_RECTANGLE printf(" r Toggle arglTexRectangle.\n"); #endif // AR_OPENGL_TEXTURE_RECTANGLE printf(" ? or / Show this help.\n"); printf("\nAdditionally, the ARVideo library supplied the following help text:\n"); arVideoDispOption(); break; default: break; } } static void Idle(void) { static int ms_prev; int ms; 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. int i, j, k; // Find out how long since Idle() last ran. ms = glutGet(GLUT_ELAPSED_TIME); s_elapsed = (float)(ms - ms_prev) * 0.001; if (s_elapsed < 0.01f) return; // Don't update more often than 100 Hz. ms_prev = ms; // Update drawing. arVrmlTimerUpdate(); // Grab a video frame. if ((image = arVideoGetImage()) != NULL) { gARTImage = image; gCallCountMarkerDetect++; // Increment ARToolKit FPS counter. // Detect the markers in the video frame. if (arDetectMarker(gARTImage, gARTThreshhold, &marker_info, &marker_num) < 0) { exit(-1); } // Check for object visibility. gPatt_found = FALSE; // At this stage, no patterns found. for (i = 0; i < gObjectDataCount; i++) { gObjectData[i].visible = 0; // Check through the marker_info array for highest confidence // visible marker matching our object's pattern. k = -1; for (j = 0; j < marker_num; j++) { if (marker_info[j].id == gObjectData[i].id) { if( k == -1 ) k = j; // First marker detected. else if (marker_info[k].cf < marker_info[j].cf) k = j; // Higher confidence marker detected. } } if (k != -1) { // Get the transformation between the marker and the real camera. //fprintf(stderr, "Saw object %d.\n", i); if (gObjectData[i].visible == 0) { arGetTransMat(&marker_info[k], gObjectData[i].marker_center, gObjectData[i].marker_width, gObjectData[i].trans); } else { arGetTransMatCont(&marker_info[k], gObjectData[i].trans, gObjectData[i].marker_center, gObjectData[i].marker_width, gObjectData[i].trans); } gObjectData[i].visible = 1; gPatt_found = TRUE; } } } // Tell GLUT to update the display. glutPostRedisplay(); } // // The function is called on events when the visibility of the // GLUT window changes (including when it first becomes visible). // static void Visibility(int visible) { if (visible == GLUT_VISIBLE) { glutIdleFunc(Idle); } else { glutIdleFunc(NULL); } } // // The function is called when the // GLUT window is resized. // static void Reshape(int w, int h) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Call through to anyone else who needs to know about window sizing here. } // // The function is called when the window needs redrawing. // static void Display(void) { 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(); // 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); arglCameraView(gObjectData[i].trans, m, VIEW_SCALEFACTOR_4); glLoadMatrixd(m); arVrmlDraw(gObjectData[i].vrml_id); } } gPatt_found = FALSE; } // gPatt_found // Any 2D overlays go here. //none glutSwapBuffers(); } int main(int argc, char** argv) { char glutGamemode[32]; const char *cparam_name = "Data/camera_para.dat"; char *vconf = // Camera configuration. #if defined(_WIN32) "showDlg,flipV"; #elif defined(__APPLE__) ""; #else "-dev=/dev/video0 -channel=0 -palette=YUV420P -width=320 -height=240"; #endif // ---------------------------------------------------------------------------- // Library inits. // glutInit(&argc, argv); // ---------------------------------------------------------------------------- // Hardware setup. // if (!demoARSetupCamera(cparam_name, vconf)) { fprintf(stderr, "main(): Unable to set up AR camera.\n"); exit(-1); } demoARDebugReportMode(); #ifdef _WIN32 CoInitialize(NULL); #endif // ---------------------------------------------------------------------------- // Library setup. // // Set up GL context(s) for OpenGL to draw into. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); if (!prefWindowed) { // GLUT mono fullscreen. //sprintf(glutGamemode, "%ix%i:%i@%i", prefWidth, prefHeight, prefDepth, prefRefresh); sprintf(glutGamemode, "%ix%i", prefWidth, prefHeight); glutGameModeString(glutGamemode); glutEnterGameMode(); } else { // GLUT mono windowed. glutInitWindowSize(gARTCparam.xsize, gARTCparam.ysize); glutCreateWindow(argv[0]); } // Setup argl library for current context. if ((gArglSettings = arglSetupForCurrentContext()) == NULL) { fprintf(stderr, "main(): arglSetupForCurrentContext() returned error.\n"); exit(-1); } arUtilTimerReset(); if (!demoARSetupMarkersObjects()) { fprintf(stderr, "main(): Unable to set up AR objects and markers.\n"); } // Register GLUT event-handling callbacks. // NB: Idle() is registered by Visibility. glutDisplayFunc(Display); glutReshapeFunc(Reshape); glutVisibilityFunc(Visibility); glutKeyboardFunc(Keyboard); glutMainLoop(); return (0); } --- NEW FILE: Makefile.in --- UNAME = $(shell uname) AR_HOME = ../.. AR_CPPFLAGS = -I$(AR_HOME)/include AR_LDFLAGS = -L$(AR_HOME)/lib VRML_HOME = /usr ifeq "$(UNAME)" "Darwin" VRML_HOME = /sw endif VRML_CPPFLAGS = VRML_LDFLAGS = -L$(VRML_HOME)/lib CPPFLAGS = $(AR_CPPFLAGS) $(VRML_CPPFLAGS) CFLAGS = @CFLAG@ CXXFLAGS = @CFLAG@ LDFLAGS = $(AR_LDFLAGS) $(VRML_LDFLAGS) @LDFLAG@ LIBS = -lARvrml -lARgsub_lite -lARvideo -lAR \ -lopenvrml -lopenvrml-gl -lstdc++ -ljpeg -lpng -lz -lm \ @LIBS@ AR = ar ARFLAGS = @ARFLAG@ RANLIB = @RANLIB@ TARGET = $(AR_HOME)/bin/simpleVRML HEADERS = \ object.h OBJS = \ object.o \ simpleVRML.o default build all: $(TARGET) $(OBJS) : $(HEADERS) $(TARGET): $(OBJS) $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) clean: -rm -f *.o *~ *.bak -rm $(TARGET) allclean: -rm -f *.o *~ *.bak -rm $(TARGET) -rm -f Makefile --- NEW FILE: object.c --- /* ** ARToolKit object parsing function ** - reads in object data from object file in Data/object_data ** */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <AR/ar.h> #include <AR/arvrml.h> #include "object.h" static char *get_buff(char *buf, int n, FILE *fp) { char *ret; for(;;) { ret = fgets(buf, n, fp); if (ret == NULL) return(NULL); if (buf[0] != '\n' && buf[0] != '#') return(ret); // Skip blank lines and comments. } } ObjectData_T *read_VRMLdata( char *name, int *objectnum ) { FILE *fp; ObjectData_T *object; char buf[256], buf1[256]; int i; printf("Opening model file %s\n", name); if ((fp=fopen(name, "r")) == NULL) return(0); get_buff(buf, 256, fp); if (sscanf(buf, "%d", objectnum) != 1) { fclose(fp); return(0); } printf("About to load %d models.\n", *objectnum); if ((object = (ObjectData_T *)malloc(sizeof(ObjectData_T) * (*objectnum))) == NULL) exit (-1); for (i = 0; i < *objectnum; i++) { get_buff(buf, 256, fp); if (sscanf(buf, "%s %s", buf1, object[i].name) != 2) { fclose(fp); free(object); return(0); } printf("Model %d: %20s\n", i + 1, &(object[i].name[0])); if (strcmp(buf1, "VRML") == 0) { object[i].vrml_id = arVrmlLoadFile(object[i].name); printf("VRML id - %d \n", object[i].vrml_id); if (object[i].vrml_id < 0) { fclose(fp); free(object); return(0); } } else { object[i].vrml_id = -1; } object[i].vrml_id_orig = object[i].vrml_id; object[i].visible = 0; get_buff(buf, 256, fp); if (sscanf(buf, "%s", buf1) != 1) { fclose(fp); free(object); return(0); } if ((object[i].id = arLoadPatt(buf1)) < 0) { fclose(fp); free(object); return(0); } get_buff(buf, 256, fp); if (sscanf(buf, "%lf", &object[i].marker_width) != 1) { fclose(fp); free(object); return(0); } get_buff(buf, 256, fp); if (sscanf(buf, "%lf %lf", &object[i].marker_center[0], &object[i].marker_center[1]) != 2) { fclose(fp); free(object); return(0); } } fclose(fp); return( object ); } --- NEW FILE: object.h --- #ifndef __object_h__ #define __object_h__ #define OBJECT_MAX 30 #ifdef __cplusplus extern "C" { #endif typedef struct { char name[256]; int id; int visible; double marker_coord[4][2]; double trans[3][4]; int vrml_id; int vrml_id_orig; double marker_width; double marker_center[2]; } ObjectData_T; ObjectData_T *read_VRMLdata (char *name, int *objectnum); #ifdef __cplusplus } #endif #endif // __object_h__ |
From: Philip L. <phi...@us...> - 2004-12-01 04:54:49
|
Update of /cvsroot/artoolkit/artoolkit/examples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12241 Modified Files: Makefile.in Log Message: Add simpleVRML example. Index: Makefile.in =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/Makefile.in,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile.in 22 Nov 2004 03:38:40 -0000 1.2 --- Makefile.in 1 Dec 2004 04:54:41 -0000 1.3 *************** *** 32,35 **** --- 32,36 ---- (cd modeTest; make -f Makefile clean) (cd exview; make -f Makefile clean) + (cd simpleVRML; make -f Makefile clean) allclean: *************** *** 49,51 **** --- 50,53 ---- (cd modeTest; make -f Makefile allclean) (cd exview; make -f Makefile allclean) + (cd simpleVRML; make -f Makefile allclean) rm -f Makefile |
From: Philip L. <phi...@us...> - 2004-12-01 04:49:12
|
Update of /cvsroot/artoolkit/artoolkit/lib/SRC/ARvrml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11006/lib/SRC/ARvrml Added Files: libARvrml.vcproj Log Message: Fix references to OpenVRML, use correct C runtime. --- NEW FILE: libARvrml.vcproj --- <?xml version="1.0" encoding="Windows-1252"?> <VisualStudioProject ProjectType="Visual C++" Version="7.10" Name="libARvrml" ProjectGUID="{C90F035F-437C-4285-BBCA-8DDC70582356}" Keyword="Win32Proj"> <Platforms> <Platform Name="Win32"/> </Platforms> <Configurations> <Configuration Name="Debug|Win32" OutputDirectory="Debug" IntermediateDirectory="Debug" ConfigurationType="4" CharacterSet="2"> <Tool Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="$(ProjectDir)..\..\..\include;$(ProjectDir)..\..\..\OpenVRML\include;$(ProjectDir)..\..\..\OpenVRML\dependencies\include" PreprocessorDefinitions="WIN32;_DEBUG;_LIB;S;OPENVRML_ENABLE_IMAGETEXTURE_NODE;OPENVRML_ENABLE_GZIP" BasicRuntimeChecks="3" RuntimeLibrary="3" UsePrecompiledHeader="0" WarningLevel="3" DebugInformationFormat="3" CompileAs="2" DisableSpecificWarnings="4099;4290;4800"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLibrarianTool" OutputFile="$(ProjectDir)..\..\$(ProjectName)d.lib"/> <Tool Name="VCMIDLTool"/> <Tool Name="VCPostBuildEventTool"/> <Tool Name="VCPreBuildEventTool"/> <Tool Name="VCPreLinkEventTool"/> <Tool Name="VCResourceCompilerTool"/> <Tool Name="VCWebServiceProxyGeneratorTool"/> <Tool Name="VCXMLDataGeneratorTool"/> <Tool Name="VCManagedWrapperGeneratorTool"/> <Tool Name="VCAuxiliaryManagedWrapperGeneratorTool"/> </Configuration> <Configuration Name="Release|Win32" OutputDirectory="Release" IntermediateDirectory="Release" ConfigurationType="4" CharacterSet="2"> <Tool Name="VCCLCompilerTool" AdditionalIncludeDirectories="$(ProjectDir)..\..\..\include;$(ProjectDir)..\..\..\OpenVRML\include;$(ProjectDir)..\..\..\OpenVRML\dependencies\include" PreprocessorDefinitions="WIN32;NDEBUG;_LIB" RuntimeLibrary="2" UsePrecompiledHeader="0" WarningLevel="3" DisableSpecificWarnings="4099;4290;4800"/> <Tool Name="VCCustomBuildTool"/> <Tool Name="VCLibrarianTool" OutputFile="$(ProjectDir)..\..\$(ProjectName).lib"/> <Tool Name="VCMIDLTool"/> <Tool Name="VCPostBuildEventTool"/> <Tool Name="VCPreBuildEventTool"/> <Tool Name="VCPreLinkEventTool"/> <Tool Name="VCResourceCompilerTool"/> <Tool Name="VCWebServiceProxyGeneratorTool"/> <Tool Name="VCXMLDataGeneratorTool"/> <Tool Name="VCManagedWrapperGeneratorTool"/> <Tool Name="VCAuxiliaryManagedWrapperGeneratorTool"/> </Configuration> </Configurations> <References> </References> <Files> <Filter Name="Source Files" Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> <File RelativePath=".\arViewer.cpp"> </File> <File RelativePath=".\arViewerCapi.cpp"> </File> </Filter> <Filter Name="Header Files" Filter="h;hpp;hxx;hm;inl;inc;xsd" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> <File RelativePath=".\arViewer.h"> </File> <File RelativePath="..\..\..\include\Ar\arvrml.h"> </File> </Filter> <Filter Name="Resource Files" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"> </Filter> <File RelativePath=".\ReadMe.txt"> </File> </Files> <Globals> </Globals> </VisualStudioProject> |
From: Philip L. <phi...@us...> - 2004-12-01 04:47:53
|
Update of /cvsroot/artoolkit/artoolkit/lib/SRC/ARvrml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10745/lib/SRC/ARvrml Removed Files: libarvrml.vcproj Log Message: Fix case of filename. --- libarvrml.vcproj DELETED --- |
From: Philip L. <phi...@us...> - 2004-12-01 04:43:39
|
Update of /cvsroot/artoolkit/artoolkit/lib/SRC/ARvrml In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9956 Removed Files: libarvrml.sln Log Message: Remove separate .sln file. --- libarvrml.sln DELETED --- |
From: Philip L. <phi...@us...> - 2004-12-01 04:41:28
|
Update of /cvsroot/artoolkit/artoolkit/examples/simpleVRML In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9454/simpleVRML Log Message: Directory /cvsroot/artoolkit/artoolkit/examples/simpleVRML added to the repository |
From: Philip L. <phi...@us...> - 2004-11-30 04:06:30
|
Update of /cvsroot/artoolkit/artoolkit/examples/simpleLite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26718 Modified Files: simpleLite.c Log Message: Bring twoView and simpleLite to same source base. Index: simpleLite.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/simpleLite/simpleLite.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** simpleLite.c 4 Nov 2004 08:51:10 -0000 1.1.1.1 --- simpleLite.c 30 Nov 2004 04:06:11 -0000 1.2 *************** *** 1,4 **** /* ! * gsub_lite_demo.c * * Some code to demonstrate use of gsub_lite's argl*() functions. --- 1,4 ---- /* ! * simpleLite.c * * Some code to demonstrate use of gsub_lite's argl*() functions. *************** *** 15,18 **** --- 15,38 ---- * */ + /* + * + * This file is part of ARToolKit. + * + * ARToolKit is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * ARToolKit is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ARToolKit; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + // ============================================================================ *************** *** 20,24 **** // ============================================================================ - #include <stdio.h> #include <stdlib.h> // malloc(), free() --- 40,43 ---- *************** *** 38,45 **** // ============================================================================ ! #define MY_SCALEFACTOR 0.025 // 1.0 ARToolKit unit becomes 0.025 of my OpenGL units. ! #define MY_CPARAM "Data/camera_para.dat" ! #define MY_PATTERN "Data/patt.hiro" ! #define VIEW_DISTANCE_MIN 0.1 // Objects closer to the camera than this will not be displayed. #define VIEW_DISTANCE_MAX 100.0 // Objects further away from the camera than this will not be displayed. --- 57,61 ---- // ============================================================================ ! #define VIEW_SCALEFACTOR 0.025 // 1.0 ARToolKit unit becomes 0.025 of my OpenGL units. #define VIEW_DISTANCE_MIN 0.1 // Objects closer to the camera than this will not be displayed. #define VIEW_DISTANCE_MAX 100.0 // Objects further away from the camera than this will not be displayed. *************** *** 51,69 **** // Preferences. static BOOL prefWindowed = TRUE; // ARToolKit globals. ! static long gMainCountCallsMarkerDetect = 0; static int gARTThreshhold = 100; - static ARParam gARTCparam; static int gPatt_id; static double gPatt_width = 80.0; static double gPatt_centre[2] = {0.0, 0.0}; static double gPatt_trans[3][4]; static BOOL gPatt_found; ! static ARUint8 *gARTImage = NULL; ! static ARGL_CONTEXT_SETTINGS_REF gContextSettings = NULL; // Other globals. ! static float gDrawRotateAngle; // For use in drawing. // ============================================================================ --- 67,91 ---- // Preferences. static BOOL prefWindowed = TRUE; + static int prefWidth = 640; // Fullscreen mode width. + static int prefHeight = 480; // Fullscreen mode height. + //static int prefDepth = 32; // Fullscreen mode bit depth. + //static int prefRefresh = 60; // Fullscreen mode refresh rate. // ARToolKit globals. ! static long gCallCountMarkerDetect = 0; static int gARTThreshhold = 100; static int gPatt_id; static double gPatt_width = 80.0; static double gPatt_centre[2] = {0.0, 0.0}; + + static ARParam gARTCparam; + static ARUint8 *gARTImage = NULL; static double gPatt_trans[3][4]; static BOOL gPatt_found; ! static ARGL_CONTEXT_SETTINGS_REF gArglSettings = NULL; // Other globals. ! static BOOL gDrawRotate = FALSE; ! static float gDrawRotateAngle = 0; // For use in drawing. // ============================================================================ *************** *** 71,111 **** // ============================================================================ ! BOOL demoARSetupCamera(const unsigned char *cparam_name, ARParam *cparam) { ! // Press the '?' key while running to see what options are accepted. ! #if defined(_WIN32) ! char *vconf = "flipV,showDlg"; ! #elif defined(__APPLE__) ! char *vconf = NULL; ! #else ! char *vconf = NULL; ! #endif ARParam wparam; int xsize, ysize; ! // Open the video path. ! if(arVideoOpen(vconf) < 0) return (FALSE); // Find the size of the window. ! if(arVideoInqSize(&xsize, &ysize) < 0) return (FALSE); ! fprintf(stderr, "demoARSetupCamera(): Image size (x,y) = (%d,%d)\n", xsize, ysize); ! // Set the initial camera parameters. ! if(arParamLoad(cparam_name, 1, &wparam) < 0) { ! fprintf(stderr, "demoARSetupCamera(): Camera parameter load error !!\n"); return (FALSE); } ! arParamChangeSize(&wparam, xsize, ysize, cparam); ! arInitCparam(cparam); fprintf(stderr, "*** Camera Parameter ***\n"); ! arParamDisp(cparam); ! arVideoCapStart(); return (TRUE); } ! BOOL demoARSetupMarker(const unsigned char *patt_name, int *patt_id) { --- 93,185 ---- // ============================================================================ ! // Something to look at, draw a rotating colour cube. ! static void DrawCube(void) { ! // Colour cube data. ! static GLuint polyList = 0; ! float fSize = 0.5f; ! long f, i; ! const GLfloat cube_vertices [8][3] = { ! {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {-1.0, -1.0, 1.0}, {-1.0, 1.0, 1.0}, ! {1.0, 1.0, -1.0}, {1.0, -1.0, -1.0}, {-1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0} }; ! const GLfloat cube_vertex_colors [8][3] = { ! {1.0, 1.0, 1.0}, {1.0, 1.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 1.0, 1.0}, ! {1.0, 0.0, 1.0}, {1.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 1.0} }; ! GLint cube_num_faces = 6; ! const short cube_faces [6][4] = { ! {3, 2, 1, 0}, {2, 3, 7, 6}, {0, 1, 5, 4}, {3, 0, 4, 7}, {1, 2, 6, 5}, {4, 5, 6, 7} }; + if (!polyList) { + polyList = glGenLists (1); + glNewList(polyList, GL_COMPILE); + glBegin (GL_QUADS); + for (f = 0; f < cube_num_faces; f++) + for (i = 0; i < 4; i++) { + glColor3f (cube_vertex_colors[cube_faces[f][i]][0], cube_vertex_colors[cube_faces[f][i]][1], cube_vertex_colors[cube_faces[f][i]][2]); + glVertex3f(cube_vertices[cube_faces[f][i]][0] * fSize, cube_vertices[cube_faces[f][i]][1] * fSize, cube_vertices[cube_faces[f][i]][2] * fSize); + } + glEnd (); + glColor3f (0.0, 0.0, 0.0); + for (f = 0; f < cube_num_faces; f++) { + glBegin (GL_LINE_LOOP); + for (i = 0; i < 4; i++) + glVertex3f(cube_vertices[cube_faces[f][i]][0] * fSize, cube_vertices[cube_faces[f][i]][1] * fSize, cube_vertices[cube_faces[f][i]][2] * fSize); + glEnd (); + } + glEndList (); + } + + glPushMatrix(); // Save world coordinate system. + glTranslatef(0.0, 0.0, 0.5); // Place base of cube on marker surface. + glRotatef(gDrawRotateAngle, 0.0, 0.0, 1.0); // Rotate about z axis. + glDisable(GL_LIGHTING); // Just use colours. + glCallList(polyList); // Draw the cube. + glPopMatrix(); // Restore world coordinate system. + + } + + static void DrawCubeUpdate(float timeDelta) + { + if (gDrawRotate) { + gDrawRotateAngle += timeDelta * 45.0f; // Rotate cube at 45 degrees per second. + if (gDrawRotateAngle > 360.0f) gDrawRotateAngle -= 360.0f; + } + } + + // Sets up gARTCparam. + static BOOL demoARSetupCamera(const unsigned char *cparam_name, char *vconf) + { ARParam wparam; int xsize, ysize; ! // Open the video path. ! if (arVideoOpen(vconf) < 0) { ! fprintf(stderr, "demoARSetupCamera(): Unable to open connection to camera.\n"); ! return (FALSE); ! } // 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. ! if (arParamLoad(cparam_name, 1, &wparam) < 0) { ! fprintf(stderr, "demoARSetupCamera(): Error loading parameter file %s for camera.\n", cparam_name); return (FALSE); } ! arParamChangeSize(&wparam, xsize, ysize, &gARTCparam); ! arInitCparam(&gARTCparam); fprintf(stderr, "*** Camera Parameter ***\n"); ! arParamDisp(&gARTCparam); ! if (arVideoCapStart() != 0) { ! fprintf(stderr, "demoARSetupCamera(): Unable to begin camera data capture.\n"); ! return (FALSE); ! } return (TRUE); } ! static BOOL demoARSetupMarker(const unsigned char *patt_name, int *patt_id) { *************** *** 120,124 **** // Report state of ARToolKit global variables arFittingMode, // arImageProcMode, arglDrawMode, arTemplateMatchingMode, arMatchingPCAMode. ! void demoARDebugReportMode(void) { if(arFittingMode == AR_FITTING_TO_INPUT ) { --- 194,198 ---- // Report state of ARToolKit global variables arFittingMode, // arImageProcMode, arglDrawMode, arTemplateMatchingMode, arMatchingPCAMode. ! static void demoARDebugReportMode(void) { if(arFittingMode == AR_FITTING_TO_INPUT ) { *************** *** 155,159 **** } ! void Keyboard(unsigned char key, int x, int y) { switch (key) { --- 229,233 ---- } ! static void Keyboard(unsigned char key, int x, int y) { switch (key) { *************** *** 161,169 **** case 'Q': case 'q': ! arglCleanup(gContextSettings); arVideoCapStop(); arVideoClose(); exit(0); break; case 'C': case 'c': --- 235,246 ---- case 'Q': case 'q': ! arglCleanup(gArglSettings); arVideoCapStop(); arVideoClose(); exit(0); break; + case ' ': + gDrawRotate = !gDrawRotate; + break; case 'C': case 'c': *************** *** 176,191 **** arglDrawMode = AR_DRAW_BY_GL_DRAW_PIXELS; } ! fprintf(stderr, "*** %f (frame/sec)\n", (double)gMainCountCallsMarkerDetect/arUtilTimer()); ! gMainCountCallsMarkerDetect = 0; demoARDebugReportMode(); break; break; case 'R': case 'r': - #ifdef AR_OPENGL_TEXTURE_RECTANGLE arglTexRectangle = !arglTexRectangle; fprintf(stderr, "Toggled arglTexRectangle to %d.\n", arglTexRectangle); - #endif // AR_OPENGL_TEXTURE_RECTANGLE break; case '?': case '/': --- 253,269 ---- arglDrawMode = AR_DRAW_BY_GL_DRAW_PIXELS; } ! fprintf(stderr, "*** Camera - %f (frame/sec)\n", (double)gCallCountMarkerDetect/arUtilTimer()); ! gCallCountMarkerDetect = 0; ! arUtilTimerReset(); demoARDebugReportMode(); break; break; + #ifdef AR_OPENGL_TEXTURE_RECTANGLE case 'R': case 'r': arglTexRectangle = !arglTexRectangle; fprintf(stderr, "Toggled arglTexRectangle to %d.\n", arglTexRectangle); break; + #endif // AR_OPENGL_TEXTURE_RECTANGLE case '?': case '/': *************** *** 193,198 **** printf(" q or [esc] Quit demo.\n"); printf(" c Change arglDrawMode and arglTexmapMode.\n"); printf(" r Toggle arglTexRectangle.\n"); ! printf(" ? or / Show this help.\n"); printf(" ? or / Show this help.\n"); printf("\nAdditionally, the ARVideo library supplied the following help text:\n"); --- 271,277 ---- printf(" q or [esc] Quit demo.\n"); printf(" c Change arglDrawMode and arglTexmapMode.\n"); + #ifdef AR_OPENGL_TEXTURE_RECTANGLE printf(" r Toggle arglTexRectangle.\n"); ! #endif // AR_OPENGL_TEXTURE_RECTANGLE printf(" ? or / Show this help.\n"); printf("\nAdditionally, the ARVideo library supplied the following help text:\n"); *************** *** 204,208 **** } ! void Idle(void) { static int ms_prev; --- 283,287 ---- } ! static void Idle(void) { static int ms_prev; *************** *** 218,236 **** ms = glutGet(GLUT_ELAPSED_TIME); s_elapsed = (float)(ms - ms_prev) * 0.001; ! if (s_elapsed < 0.01) return; // Don't update more often than 100 Hz. ms_prev = ms; // Update drawing. ! gDrawRotateAngle += s_elapsed * 5.0; // Rotate cube at 5 degrees per second. ! if (gDrawRotateAngle > 360.0) gDrawRotateAngle -= 360.0; // Grab a video frame. ! if((image = arVideoGetImage()) != NULL) { gARTImage = image; ! gMainCountCallsMarkerDetect++; // Increment ARToolKit FPS counter. // Detect the markers in the video frame. ! if(arDetectMarker(gARTImage, gARTThreshhold, &marker_info, &marker_num) < 0) { exit(-1); } --- 297,314 ---- ms = glutGet(GLUT_ELAPSED_TIME); s_elapsed = (float)(ms - ms_prev) * 0.001; ! if (s_elapsed < 0.01f) return; // Don't update more often than 100 Hz. ms_prev = ms; // Update drawing. ! DrawCubeUpdate(s_elapsed); // Grab a video frame. ! if ((image = arVideoGetImage()) != NULL) { gARTImage = image; ! gCallCountMarkerDetect++; // Increment ARToolKit FPS counter. // Detect the markers in the video frame. ! if (arDetectMarker(gARTImage, gARTThreshhold, &marker_info, &marker_num) < 0) { exit(-1); } *************** *** 246,261 **** } ! if(k != -1) { // Get the transformation between the marker and the real camera into gPatt_trans. arGetTransMat(&(marker_info[k]), gPatt_centre, gPatt_width, gPatt_trans); gPatt_found = TRUE; - } else { - gPatt_found = FALSE; } // Tell GLUT the display has changed. glutPostRedisplay(); ! } ! } --- 324,336 ---- } ! if (k != -1) { // Get the transformation between the marker and the real camera into gPatt_trans. arGetTransMat(&(marker_info[k]), gPatt_centre, gPatt_width, gPatt_trans); gPatt_found = TRUE; } // Tell GLUT the display has changed. glutPostRedisplay(); ! } } *************** *** 264,268 **** // GLUT window changes (including when it first becomes visible). // ! void Visibility(int visible) { if (visible == GLUT_VISIBLE) { --- 339,343 ---- // GLUT window changes (including when it first becomes visible). // ! static void Visibility(int visible) { if (visible == GLUT_VISIBLE) { *************** *** 277,281 **** // GLUT window is resized. // ! void Reshape(int w, int h) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); --- 352,356 ---- // GLUT window is resized. // ! static void Reshape(int w, int h) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); *************** *** 290,390 **** } - // Something to look at, draw a rotating colour cube. - void Draw(void) - { - // Colour cube data. - static GLuint polyList = 0; - float fSize = 0.5f; - long f, i; - const GLfloat cube_vertices [8][3] = { - {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {-1.0, -1.0, 1.0}, {-1.0, 1.0, 1.0}, - {1.0, 1.0, -1.0}, {1.0, -1.0, -1.0}, {-1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0} }; - const GLfloat cube_vertex_colors [8][3] = { - {1.0, 1.0, 1.0}, {1.0, 1.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 1.0, 1.0}, - {1.0, 0.0, 1.0}, {1.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 1.0} }; - GLint cube_num_faces = 6; - const short cube_faces [6][4] = { - {3, 2, 1, 0}, {2, 3, 7, 6}, {0, 1, 5, 4}, {3, 0, 4, 7}, {1, 2, 6, 5}, {4, 5, 6, 7} }; - - if (!polyList) { - polyList = glGenLists (1); - glNewList(polyList, GL_COMPILE); - glBegin (GL_QUADS); - for (f = 0; f < cube_num_faces; f++) - for (i = 0; i < 4; i++) { - glColor3f (cube_vertex_colors[cube_faces[f][i]][0], cube_vertex_colors[cube_faces[f][i]][1], cube_vertex_colors[cube_faces[f][i]][2]); - glVertex3f(cube_vertices[cube_faces[f][i]][0] * fSize, cube_vertices[cube_faces[f][i]][1] * fSize, cube_vertices[cube_faces[f][i]][2] * fSize); - } - glEnd (); - glColor3f (0.0, 0.0, 0.0); - for (f = 0; f < cube_num_faces; f++) { - glBegin (GL_LINE_LOOP); - for (i = 0; i < 4; i++) - glVertex3f(cube_vertices[cube_faces[f][i]][0] * fSize, cube_vertices[cube_faces[f][i]][1] * fSize, cube_vertices[cube_faces[f][i]][2] * fSize); - glEnd (); - } - glEndList (); - } - - glPushMatrix(); // Save world coordinate system. - glRotatef(gDrawRotateAngle, 0.0, 0.0, 1.0); // Rotate about z axis. - glDisable(GL_LIGHTING); // Just use colours. - glCallList(polyList); // Draw the cube. - glPopMatrix(); // Restore world coordinate system. - - } - // // The function is called when the window needs redrawing. // ! void Display(void) { - static GLdouble *p = NULL; GLdouble m[16]; ! if (gARTImage) { ! ! // Context setup. ! glDrawBuffer(GL_BACK); ! arglDispImage(gARTImage, &gARTCparam, 1.0, gContextSettings); // zoom = 1.0. ! arVideoCapNext(); ! if (gPatt_found) { ! glClear(GL_DEPTH_BUFFER_BIT); // Clear the buffers for new frame. ! ! 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); ! ! // Load the camera transformation matrix. ! // ARToolKit supplied distance in millimetres, but I want OpenGL to work in metres. ! arglCameraView(gPatt_trans, m, MY_SCALEFACTOR); ! glLoadMatrixd(m); ! ! glTranslatef(0.0, 0.0, 0.5); // Place base of cube on marker surface. ! Draw(); ! ! gPatt_found = FALSE; } ! glutSwapBuffers(); ! } ! } - int main(int argc, char** argv) { - const unsigned char *cparam_name = MY_CPARAM; - const unsigned char *patt_name = MY_PATTERN; char glutGamemode[32]; ! if (!demoARSetupCamera(cparam_name, &gARTCparam)) { fprintf(stderr, "main(): Unable to set up AR camera.\n"); exit(-1); --- 365,442 ---- } // // The function is called when the window needs redrawing. // ! static void Display(void) { 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(); ! // 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 metres. ! arglCameraView(gPatt_trans, m, VIEW_SCALEFACTOR); ! glLoadMatrixd(m); ! ! // All other lighting and geometry goes here. ! DrawCube(); ! ! gPatt_found = FALSE; ! } // gPatt_found ! ! // Any 2D overlays go here. ! //none ! ! glutSwapBuffers(); } int main(int argc, char** argv) { char glutGamemode[32]; + const unsigned char *cparam_name = + "Data/camera_para.dat"; + char *vconf = // Camera configuration. + #if defined(_WIN32) + "showDlg,flipV"; + #elif defined(__APPLE__) + ""; + #else + "-dev=/dev/video0 -channel=0 -palette=YUV420P -width=320 -height=240"; + #endif + const unsigned char *patt_name = "Data/patt.hiro"; ! // ---------------------------------------------------------------------------- ! // Library inits. ! // ! ! glutInit(&argc, argv); ! ! // ---------------------------------------------------------------------------- ! // Hardware setup. ! // ! ! if (!demoARSetupCamera(cparam_name, vconf)) { fprintf(stderr, "main(): Unable to set up AR camera.\n"); exit(-1); *************** *** 395,418 **** exit(-1); } - glutInit(&argc, argv); ! // Set up the OpenGL context. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); if (!prefWindowed) { // GLUT mono fullscreen. //sprintf(glutGamemode, "%ix%i:%i@%i", prefWidth, prefHeight, prefDepth, prefRefresh); ! sprintf(glutGamemode, "%ix%i", gARTCparam.xsize, gARTCparam.ysize); glutGameModeString(glutGamemode); glutEnterGameMode(); } else { // GLUT mono windowed. glutInitWindowSize(gARTCparam.xsize, gARTCparam.ysize); - //glutInitWindowPosition(100, 100); glutCreateWindow(argv[0]); } // Setup argl library for current context. ! if ((gContextSettings = arglSetupForCurrentContext()) == NULL) { fprintf(stderr, "main(): arglSetupForCurrentContext() returned error.\n"); exit(-1); } // Register GLUT event-handling callbacks. --- 447,473 ---- exit(-1); } ! // ---------------------------------------------------------------------------- ! // Library setup. ! // ! ! // Set up GL context(s) for OpenGL to draw into. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); if (!prefWindowed) { // GLUT mono fullscreen. //sprintf(glutGamemode, "%ix%i:%i@%i", prefWidth, prefHeight, prefDepth, prefRefresh); ! sprintf(glutGamemode, "%ix%i", prefWidth, prefHeight); glutGameModeString(glutGamemode); glutEnterGameMode(); } else { // GLUT mono windowed. glutInitWindowSize(gARTCparam.xsize, gARTCparam.ysize); glutCreateWindow(argv[0]); } // Setup argl library for current context. ! if ((gArglSettings = arglSetupForCurrentContext()) == NULL) { fprintf(stderr, "main(): arglSetupForCurrentContext() returned error.\n"); exit(-1); } + arUtilTimerReset(); // Register GLUT event-handling callbacks. |
From: Philip L. <phi...@us...> - 2004-11-30 04:06:15
|
Update of /cvsroot/artoolkit/artoolkit/examples/twoView In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26636 Modified Files: twoView.c Log Message: Bring twoView and simpleLite to same source base. Index: twoView.c =================================================================== RCS file: /cvsroot/artoolkit/artoolkit/examples/twoView/twoView.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** twoView.c 25 Nov 2004 21:42:30 -0000 1.2 --- twoView.c 30 Nov 2004 04:06:03 -0000 1.3 *************** *** 11,14 **** --- 11,34 ---- * */ + /* + * + * This file is part of ARToolKit. + * + * ARToolKit is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * ARToolKit is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ARToolKit; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + // ============================================================================ *************** *** 61,70 **** static GLuint *gDrawListBox = NULL; ! CONTEXT_INFO gContextsActive[CONTEXTSACTIVECOUNTMAX]; int gContextsActiveCount = 0; - static BOOL gAlwaysVisible = FALSE; // Setting this to true will make the program ignore - // events that tell it it is not visible. - // ARToolKit globals. static long gCallCountGetImage = 0; --- 81,87 ---- static GLuint *gDrawListBox = NULL; ! CONTEXT_INFO *gContextsActive; int gContextsActiveCount = 0; // ARToolKit globals. static long gCallCountGetImage = 0; *************** *** 76,80 **** // Other globals. static BOOL gDrawRotate = FALSE; ! static float gDrawRotateAngle; // For use in drawing. // ============================================================================ --- 93,97 ---- // Other globals. static BOOL gDrawRotate = FALSE; ! static float gDrawRotateAngle = 0; // For use in drawing. // ============================================================================ *************** *** 82,86 **** // ============================================================================ ! BOOL DrawCubeInit(int contextsActiveCountMax) { // Allocate room for display lists for all contexts. --- 99,103 ---- // ============================================================================ ! static BOOL DrawCubeInit(int contextsActiveCountMax) { // Allocate room for display lists for all contexts. *************** *** 93,97 **** } ! BOOL DrawCubeSetup(int contextIndex) { // Colour cube data. --- 110,114 ---- } ! static BOOL DrawCubeSetup(int contextIndex) { // Colour cube data. *************** *** 131,135 **** // Something to look at, draw a rotating colour cube. ! void DrawCube(int contextIndex) { // Draw the colour cube. --- 148,152 ---- // Something to look at, draw a rotating colour cube. ! static void DrawCube(int contextIndex) { // Draw the colour cube. *************** *** 142,146 **** } ! void DrawCubeUpdate(float timeDelta) { if (gDrawRotate) { --- 159,163 ---- } ! static void DrawCubeUpdate(float timeDelta) { if (gDrawRotate) { *************** *** 150,154 **** } ! BOOL DrawCubeCleanup(int contextIndex) { if (contextIndex >= gContextsActiveCount) return (FALSE); // Sanity check. --- 167,171 ---- } ! static BOOL DrawCubeCleanup(int contextIndex) { if (contextIndex >= gContextsActiveCount) return (FALSE); // Sanity check. *************** *** 163,167 **** } ! BOOL DrawCubeFinal(void) { if (!gDrawListBox) { --- 180,184 ---- } ! static BOOL DrawCubeFinal(void) { if (!gDrawListBox) { *************** *** 172,176 **** } ! // Function to clean up and then exit. static void Quit(void) { --- 189,194 ---- } ! // Function to clean up and then exit. Will be ! // installed by atexit() and called when program exit()s. static void Quit(void) { *************** *** 195,208 **** // Library finals (in reverse order to inits.) DrawCubeFinal(); - - // Unless we don't have an atexit() function, terminate by falling off end - // (since Quit is called by exit()'s exitfunc.) - #ifdef NOATEXIT - exit(0); - #endif } // Sets up fields ARTVideo, ARTCparam of gContextsActive[0] through gContextsActive[cameraCount - 1]. ! BOOL demoARSetupCameras(const int cameraCount, const unsigned char *cparam_names[], char *vconfs[]) { int i; --- 213,220 ---- // Library finals (in reverse order to inits.) DrawCubeFinal(); } // Sets up fields ARTVideo, ARTCparam of gContextsActive[0] through gContextsActive[cameraCount - 1]. ! static BOOL demoARSetupCameras(const int cameraCount, const unsigned char *cparam_names[], char *vconfs[]) { int i; *************** *** 242,246 **** } ! BOOL demoARSetupMarker(const unsigned char *patt_name, int *patt_id) { --- 254,258 ---- } ! static BOOL demoARSetupMarker(const unsigned char *patt_name, int *patt_id) { *************** *** 255,259 **** // Report state of ARToolKit global variables arFittingMode, // arImageProcMode, arglDrawMode, arTemplateMatchingMode, arMatchingPCAMode. ! void demoARDebugReportMode(void) { if(arFittingMode == AR_FITTING_TO_INPUT ) { --- 267,271 ---- // Report state of ARToolKit global variables arFittingMode, // arImageProcMode, arglDrawMode, arTemplateMatchingMode, arMatchingPCAMode. ! static void demoARDebugReportMode(void) { if(arFittingMode == AR_FITTING_TO_INPUT ) { *************** *** 311,330 **** } ! void Keyboard(unsigned char key, int x, int y) { ! int modifiers, shift, i; ! ! modifiers = glutGetModifiers(); ! shift = (modifiers & GLUT_ACTIVE_SHIFT); // Get status of shift key. switch (key) { ! case 0x1b: // Quit. case 'Q': case 'q': ! #ifdef NOATEXIT ! Quit(); ! #else ! exit(0); ! #endif // NOATEXIT break; case ' ': --- 323,335 ---- } ! static void Keyboard(unsigned char key, int x, int y) { ! int i; switch (key) { ! case 0x1B: // Quit. case 'Q': case 'q': ! exit(0); break; case ' ': *************** *** 345,414 **** gContextsActive[i].callCountMarkerDetect = 0; } demoARDebugReportMode(); break; case 'R': case 'r': - #ifdef AR_OPENGL_TEXTURE_RECTANGLE arglTexRectangle = !arglTexRectangle; fprintf(stderr, "Toggled arglTexRectangle to %d.\n", arglTexRectangle); - #endif // AR_OPENGL_TEXTURE_RECTANGLE break; ! case 'T': ! case 't': ! #ifdef APPLE_TEXTURE_FAST_TRANSFER ! # ifdef GL_APPLE_client_storage ! arglAppleClientStorage = !arglAppleClientStorage; ! fprintf(stderr, "Toggled arglAppleClientStorage to %d.\n", arglAppleClientStorage); ! # endif ! #endif ! break; ! case 'Y': ! case 'y': ! #ifdef APPLE_TEXTURE_FAST_TRANSFER ! # ifdef GL_APPLE_texture_range ! arglAppleTextureRange = !arglAppleTextureRange; ! fprintf(stderr, "Toggled arglAppleTextureRange to %d.\n", arglAppleTextureRange); ! # endif ! #endif ! break; ! case 'U': ! case 'u': ! #ifdef APPLE_TEXTURE_FAST_TRANSFER ! # ifdef GL_APPLE_texture_range ! fprintf(stderr, "Toggled arglAppleTextureRangeStorageHint to "); ! switch (arglAppleTextureRangeStorageHint) { ! case GL_STORAGE_PRIVATE_APPLE: ! arglAppleTextureRangeStorageHint = GL_STORAGE_SHARED_APPLE; ! fprintf(stderr, "GL_STORAGE_SHARED_APPLE.\n"); ! break; ! case GL_STORAGE_SHARED_APPLE: ! arglAppleTextureRangeStorageHint = GL_STORAGE_CACHED_APPLE; ! fprintf(stderr, "GL_STORAGE_CACHED_APPLE.\n"); ! break; ! case GL_STORAGE_CACHED_APPLE: ! default: ! arglAppleTextureRangeStorageHint = GL_STORAGE_PRIVATE_APPLE; ! fprintf(stderr, "GL_STORAGE_PRIVATE_APPLE.\n"); ! break; ! } ! # endif ! #endif ! break; case '?': case '/': ! fprintf(stderr,"Keys:\n"); ! fprintf(stderr," q or [esc] Quit demo.\n"); ! fprintf(stderr," c Change arglDrawMode and arglTexmapMode.\n"); ! fprintf(stderr," r Toggle arglTexRectangle.\n"); ! fprintf(stderr," ? or / Show this help.\n"); ! #ifdef APPLE_TEXTURE_FAST_TRANSFER ! # ifdef GL_APPLE_client_storage ! fprintf(stderr," t Toggle arglAppleClientStorage.\n"); ! # endif // GL_APPLE_client_storage ! # ifdef GL_APPLE_texture_range ! fprintf(stderr," y Toggle arglAppleTextureRange.\n"); ! fprintf(stderr," u Toggle arglAppleTextureRangeStorageHint.\n"); ! # endif // GL_APPLE_texture_range ! #endif APPLE_TEXTURE_FAST_TRANSFER default: break; --- 350,375 ---- gContextsActive[i].callCountMarkerDetect = 0; } + arUtilTimerReset(); demoARDebugReportMode(); break; + #ifdef AR_OPENGL_TEXTURE_RECTANGLE case 'R': case 'r': arglTexRectangle = !arglTexRectangle; fprintf(stderr, "Toggled arglTexRectangle to %d.\n", arglTexRectangle); break; ! #endif // AR_OPENGL_TEXTURE_RECTANGLE case '?': case '/': ! printf("Keys:\n"); ! printf(" q or [esc] Quit demo.\n"); ! printf(" c Change arglDrawMode and arglTexmapMode.\n"); ! #ifdef AR_OPENGL_TEXTURE_RECTANGLE ! printf(" r Toggle arglTexRectangle.\n"); ! #endif // AR_OPENGL_TEXTURE_RECTANGLE ! printf(" ? or / Show this help.\n"); ! printf("\nAdditionally, the ARVideo library supplied the following help text:\n"); ! arVideoDispOption(); ! break; default: break; *************** *** 416,430 **** } ! void Mouse(int button, int state, int x, int y) ! { ! // Nothing here yet. ! } ! ! void Idle(void) { int i; ! static double timeRecentPast; ! double timeNow; ! float timeDelta; ARUint8 *image; --- 377,386 ---- } ! static void Idle(void) { int i; ! static int ms_prev; ! int ms; ! float s_elapsed; ARUint8 *image; *************** *** 434,447 **** // Find out how long since Idle() last ran. ! timeNow = (double)glutGet(GLUT_ELAPSED_TIME) / 1000.0; // Get the current time. ! timeDelta = (float)(timeNow - timeRecentPast); // Work out how long in seconds since the last epoch. ! if (timeDelta < 0.01f) return; // Don't update more often than 100 Hz. ! timeRecentPast = timeNow; // Update drawing. ! DrawCubeUpdate(timeDelta); ! if (!gCallCountGetImage) arUtilTimerReset(); ! gCallCountGetImage++; // Increment ARToolKit FPS counter. for (i = 0; i < gContextsActiveCount; i++) { --- 390,402 ---- // Find out how long since Idle() last ran. ! ms = glutGet(GLUT_ELAPSED_TIME); ! s_elapsed = (float)(ms - ms_prev) * 0.001; ! if (s_elapsed < 0.01f) return; // Don't update more often than 100 Hz. ! ms_prev = ms; // Update drawing. ! DrawCubeUpdate(s_elapsed); ! gCallCountGetImage++; // Increment Idle() counter. for (i = 0; i < gContextsActiveCount; i++) { *************** *** 487,491 **** static void Visibility(int visible) { ! if (gAlwaysVisible || (visible == GLUT_VISIBLE)) { glutIdleFunc(Idle); } else { --- 442,446 ---- static void Visibility(int visible) { ! if (visible == GLUT_VISIBLE) { glutIdleFunc(Idle); } else { *************** *** 498,502 **** // GLUT window is resized. // ! void Reshape(int w, int h) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); --- 453,457 ---- // GLUT window is resized. // ! static void Reshape(int w, int h) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); *************** *** 511,517 **** } ! static void Draw(const int drawContextIndex) { - int i; GLdouble p[16]; GLdouble m[16]; --- 466,471 ---- } ! static void DisplayPerContext(const int drawContextIndex) { GLdouble p[16]; GLdouble m[16]; *************** *** 541,544 **** --- 495,499 ---- //none + // ARToolKit supplied distance in millimetres, but I want OpenGL to work in metres. arglCameraView(gContextsActive[drawContextIndex].patt_trans, m, VIEW_SCALEFACTOR); glLoadMatrixd(m); *************** *** 548,552 **** gContextsActive[drawContextIndex].patt_found = FALSE; ! } // gPatt_found // Any 2D overlays go here. --- 503,507 ---- gContextsActive[drawContextIndex].patt_found = FALSE; ! } // patt_found // Any 2D overlays go here. *************** *** 574,578 **** if ((contextIndex = getContextIndexForCurrentGLUTWindow()) != -1) { ! Draw(contextIndex); glutSwapBuffers(); } --- 529,533 ---- if ((contextIndex = getContextIndexForCurrentGLUTWindow()) != -1) { ! DisplayPerContext(contextIndex); glutSwapBuffers(); } *************** *** 609,618 **** // Register a cleanup function to be called upon exit(). - #ifndef NOATEXIT if (atexit(Quit) < 0) { fprintf(stderr, "main(): Unable to register exit function.\n"); ! exit (-1); // Bail out if we can't even register our exit function. } - #endif // NOATEXIT // Initialise drawing libraries. --- 564,571 ---- // Register a cleanup function to be called upon exit(). if (atexit(Quit) < 0) { fprintf(stderr, "main(): Unable to register exit function.\n"); ! exit(-1); // Bail out if we can't even register our exit function. } // Initialise drawing libraries. *************** *** 627,631 **** // ! if (!demoARSetupCameras(CONTEXTSACTIVECOUNT, cparam_names, vconfs)) { fprintf(stderr, "main(): Unable to set up %d AR cameras.\n", CONTEXTSACTIVECOUNT); --- 580,584 ---- // ! if ((gContextsActive = (CONTEXT_INFO *)calloc(CONTEXTSACTIVECOUNTMAX, sizeof(CONTEXT_INFO))) == NULL) exit(-1); if (!demoARSetupCameras(CONTEXTSACTIVECOUNT, cparam_names, vconfs)) { fprintf(stderr, "main(): Unable to set up %d AR cameras.\n", CONTEXTSACTIVECOUNT); *************** *** 658,662 **** glutReshapeFunc(Reshape); glutVisibilityFunc(Visibility); - glutMouseFunc(Mouse); glutKeyboardFunc(Keyboard); --- 611,614 ---- *************** *** 668,682 **** } } // Register GLUT event-handling callbacks. ! // NB: MainRunLoop() is registered by Visibility. glutMainLoop(); - // All done. Exit the program now. - #ifdef NOATEXIT - Quit(); - #else return (0); - #endif // NOATEXIT - } --- 620,629 ---- } } + arUtilTimerReset(); // Register GLUT event-handling callbacks. ! // NB: Idle() is registered by Visibility. glutMainLoop(); return (0); } |