lib/tdl-util.c
/**
 * Returns the next tracked point in the file.
 * If the end of the file is reached, the file cursor will be
 * moved back to the beginning of the file.
 *
 * @param int fd - a file descripter pointing to the file.
 *		  float* pos - the array that the position will be stored. Should be length 3.
 *		  float* orient - the array that the orientation will be stored. Should be length 16.
 *
 * @return int - -1 if the file could not be read.
 * 				  0 if the operation was normal.
 *				  1 if the end of the file was reached and the cursor was reset.
 *
 */
Returns the next tracked point in the file.
If the end of the file is reached, the file cursor will be
moved back to the beginning of the file.

@param int fd - a file descripter pointing to the file.
float* pos - the array that the position will be stored. Should be length 3.
float* orient - the array that the orientation will be stored. Should be length 16.

@return int - -1 if the file could not be read.
0 if the operation was normal.
1 if the end of the file was reached and the cursor was reset.
Returns the next tracked point in the file . If the end of the file is reached the file cursor will be moved back to the beginning of the file . @param int fd - a file descripter pointing to the file . float * pos - the array that the position will be stored . Should be length 3 . float * orient - the array that the orientation will be stored . Should be length 16 . @return int - - 1 if the file could not be read . 0 if the operation was normal . 1 if the end of the file was reached and the cursor was reset .
int tdl_read(FILE *f, float pos[3], float orient[9])
{
#ifdef _WIN32
	msg(MSG_ERROR, "This function is not defined on Windows.");
	return -1;
#else
	const int posSize = 3*(signed int)sizeof(float);
	const int orientSize = 9*(signed int)sizeof(float);
	int readVal = fread(pos, posSize, 1, f);
	if(feof(f))
		return 1; 
	if(readVal < 1)
	{
		perror("Reading position failed");
		return -1;
	}
	readVal = fread(orient, orientSize, 1, f);
	if(feof(f))
		return 1; 
	if(readVal < 1)
	{
		perror("Reading orientation failed");
		return -1;
	}
	return 0; 
#endif
}
int tdl_read ( FILE * f , float pos [ 3 ] , float orient [ 9 ] ) { #ifdef _WIN32 msg ( MSG_ERROR , " " ) ; return -1 ; #else const int posSize = 3 * ( signed int ) sizeof ( float ) ; const int orientSize = 9 * ( signed int ) sizeof ( float ) ; int readVal = fread ( pos , posSize , 1 , f ) ; if ( feof ( f ) ) return 1 ; if ( readVal < 1 ) { perror ( " " ) ; return -1 ; } readVal = fread ( orient , orientSize , 1 , f ) ; if ( feof ( f ) ) return 1 ; if ( readVal < 1 ) { perror ( " " ) ; return -1 ; } return 0 ; #endif }
Returns the next tracked point in the file.
Returns the next tracked point in the file .
// EOF // EOF // success