trackrecorder.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 * VCGLib                                                            o o     *
00003 * Visual and Computer Graphics Library                            o     o   *
00004 *                                                                _   O  _   *
00005 * Copyright(C) 2004                                                \/)\/    *
00006 * Visual Computing Lab                                            /\/|      *
00007 * ISTI - Italian National Research Council                           |      *
00008 *                                                                    \      *
00009 * All rights reserved.                                                      *
00010 *                                                                           *
00011 * This program is free software; you can redistribute it and/or modify      *   
00012 * it under the terms of the GNU General Public License as published by      *
00013 * the Free Software Foundation; either version 2 of the License, or         *
00014 * (at your option) any later version.                                       *
00015 *                                                                           *
00016 * This program is distributed in the hope that it will be useful,           *
00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
00019 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)          *
00020 * for more details.                                                         *
00021 *                                                                           *
00022 ****************************************************************************/
00023 /****************************************************************************
00024   History
00025 
00026 $Log: not supported by cvs2svn $
00027 Revision 1.1  2005/04/14 21:23:39  ganovelli
00028 *** empty log message ***
00029 
00030 
00031 
00032 ****************************************************************************/
00033 #ifndef VCGLIB_TRACKRECORDER
00034 #define VCGLIB_TRACKRECORDER
00035 
00036 
00037 #include <wrap/gui/trackball.h>
00038 #include <stdio.h>
00039 #include <time.h>
00040 
00041 namespace vcg{
00042 struct TrackRecorder{
00043 
00044         TrackRecorder(){Stop();}
00045         
00046         FILE * trackfile;
00047         
00048         enum { PLAY,REC,OFF } mode;
00049         int nextTime,   
00050                         startTime;  
00051  
00052         void StartPlaying(char * namefile){
00053                 if(trackfile != NULL) return;
00054 
00055                 trackfile = fopen(namefile,"rb");
00056                 startTime = clock();
00057                 mode = PLAY;
00058                 fread(&nextTime,4,1,trackfile);
00059         } 
00060 
00061         void UpdateTrackball(Trackball & t){
00062 
00063                 while( ( clock()-startTime > nextTime)&& !feof(trackfile)){
00064                                 fread(&t.track,sizeof(float)*4 + sizeof(float)*5,1,trackfile);
00065                                 fread(&nextTime,4,1,trackfile);
00066                 }
00067                 if(feof(trackfile))
00068                         Stop();
00069         }
00070 
00071         void  StartRecording(char * namefile){
00072                 if(trackfile != NULL) return;
00073                 trackfile = fopen(namefile,"wb");       
00074                 startTime = clock();
00075                 mode = REC;
00076         } 
00077 
00078         void  RecordTrackball(Trackball & t){
00079                 nextTime = clock()-startTime;
00080                 fwrite(&nextTime,4,1,trackfile);
00081                 fwrite(&t.track,sizeof(float)*4 + sizeof(float)*5,1,trackfile);
00082         }
00083 
00084         void  Stop(){mode = OFF; trackfile = NULL;};
00085 
00086 };
00087 }
00088 #endif


shape_reconstruction
Author(s): Roberto Martín-Martín
autogenerated on Sat Jun 8 2019 18:37:26