Show
Ignore:
Timestamp:
04/22/09 17:46:24 (6 years ago)
Author:
robert
Message:

From Neil Hughes, converted across to use istream for reading data from file to enable reading .3ds files over http (use OSG's libcurl plugin).

From Robert Osfield, ammendments of the above to better support reading of files from local directories.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/src/osgPlugins/3ds/tracks.cpp

    r3237 r10076  
    197197 */ 
    198198Lib3dsBool 
    199 lib3ds_bool_track_read(Lib3dsBoolTrack *track, FILE *f) 
     199lib3ds_bool_track_read(Lib3dsBoolTrack *track, iostream *strm) 
    200200{ 
    201201  int keys; 
     
    203203  Lib3dsBoolKey *k; 
    204204 
    205   track->flags=lib3ds_word_read(f); 
    206   lib3ds_dword_read(f); 
    207   lib3ds_dword_read(f); 
    208   keys=lib3ds_intd_read(f); 
     205  track->flags=lib3ds_word_read(strm); 
     206  lib3ds_dword_read(strm); 
     207  lib3ds_dword_read(strm); 
     208  keys=lib3ds_intd_read(strm); 
    209209 
    210210  for (i=0; i<keys; ++i) { 
    211211    k=lib3ds_bool_key_new(); 
    212     if (!lib3ds_tcb_read(&k->tcb, f)) { 
     212    if (!lib3ds_tcb_read(&k->tcb, strm)) { 
    213213      return(LIB3DS_FALSE); 
    214214    } 
     
    224224 */ 
    225225Lib3dsBool 
    226 lib3ds_bool_track_write(Lib3dsBoolTrack *track, FILE *f) 
     226lib3ds_bool_track_write(Lib3dsBoolTrack *track, iostream *strm) 
    227227{ 
    228228  Lib3dsBoolKey *k; 
     
    231231    ++num; 
    232232  } 
    233   lib3ds_word_write((Lib3dsWord)track->flags,f); 
    234   lib3ds_dword_write(0,f); 
    235   lib3ds_dword_write(0,f); 
    236   lib3ds_dword_write(num,f); 
     233  lib3ds_word_write((Lib3dsWord)track->flags,strm); 
     234  lib3ds_dword_write(0,strm); 
     235  lib3ds_dword_write(0,strm); 
     236  lib3ds_dword_write(num,strm); 
    237237 
    238238  for (k=track->keyL; k; k=k->next) { 
    239     if (!lib3ds_tcb_write(&k->tcb,f)) { 
     239    if (!lib3ds_tcb_write(&k->tcb,strm)) { 
    240240      return(LIB3DS_FALSE); 
    241241    } 
     
    501501 */ 
    502502Lib3dsBool 
    503 lib3ds_lin1_track_read(Lib3dsLin1Track *track, FILE *f) 
     503lib3ds_lin1_track_read(Lib3dsLin1Track *track, iostream *strm) 
    504504{ 
    505505  int keys; 
     
    507507  Lib3dsLin1Key *k; 
    508508 
    509   track->flags=lib3ds_word_read(f); 
    510   lib3ds_dword_read(f); 
    511   lib3ds_dword_read(f); 
    512   keys=lib3ds_intd_read(f); 
     509  track->flags=lib3ds_word_read(strm); 
     510  lib3ds_dword_read(strm); 
     511  lib3ds_dword_read(strm); 
     512  keys=lib3ds_intd_read(strm); 
    513513 
    514514  for (i=0; i<keys; ++i) { 
    515515    k=lib3ds_lin1_key_new(); 
    516     if (!lib3ds_tcb_read(&k->tcb, f)) { 
     516    if (!lib3ds_tcb_read(&k->tcb, strm)) { 
    517517      return(LIB3DS_FALSE); 
    518518    } 
    519     k->value=lib3ds_float_read(f); 
     519    k->value=lib3ds_float_read(strm); 
    520520    lib3ds_lin1_track_insert(track, k); 
    521521  } 
     
    529529 */ 
    530530Lib3dsBool 
    531 lib3ds_lin1_track_write(Lib3dsLin1Track *track, FILE *f) 
     531lib3ds_lin1_track_write(Lib3dsLin1Track *track, iostream *strm) 
    532532{ 
    533533  Lib3dsLin1Key *k; 
     
    536536    ++num; 
    537537  } 
    538   lib3ds_word_write((Lib3dsWord)track->flags,f); 
    539   lib3ds_dword_write(0,f); 
    540   lib3ds_dword_write(0,f); 
    541   lib3ds_dword_write(num,f); 
     538  lib3ds_word_write((Lib3dsWord)track->flags,strm); 
     539  lib3ds_dword_write(0,strm); 
     540  lib3ds_dword_write(0,strm); 
     541  lib3ds_dword_write(num,strm); 
    542542 
    543543  for (k=track->keyL; k; k=k->next) { 
    544     if (!lib3ds_tcb_write(&k->tcb,f)) { 
     544    if (!lib3ds_tcb_write(&k->tcb,strm)) { 
    545545      return(LIB3DS_FALSE); 
    546546    } 
    547     lib3ds_float_write(k->value,f); 
     547    lib3ds_float_write(k->value,strm); 
    548548  } 
    549549  return(LIB3DS_TRUE); 
     
    810810 */ 
    811811Lib3dsBool 
    812 lib3ds_lin3_track_read(Lib3dsLin3Track *track, FILE *f) 
     812lib3ds_lin3_track_read(Lib3dsLin3Track *track, iostream *strm) 
    813813{ 
    814814  int keys; 
     
    816816  Lib3dsLin3Key *k; 
    817817 
    818   track->flags=lib3ds_word_read(f); 
    819   lib3ds_dword_read(f); 
    820   lib3ds_dword_read(f); 
    821   keys=lib3ds_intd_read(f); 
     818  track->flags=lib3ds_word_read(strm); 
     819  lib3ds_dword_read(strm); 
     820  lib3ds_dword_read(strm); 
     821  keys=lib3ds_intd_read(strm); 
    822822 
    823823  for (i=0; i<keys; ++i) { 
    824824    k=lib3ds_lin3_key_new(); 
    825     if (!lib3ds_tcb_read(&k->tcb, f)) { 
     825    if (!lib3ds_tcb_read(&k->tcb, strm)) { 
    826826      return(LIB3DS_FALSE); 
    827827    } 
    828828    for (j=0; j<3; ++j) { 
    829       k->value[j]=lib3ds_float_read(f); 
     829      k->value[j]=lib3ds_float_read(strm); 
    830830    } 
    831831    lib3ds_lin3_track_insert(track, k); 
     
    840840 */ 
    841841Lib3dsBool 
    842 lib3ds_lin3_track_write(Lib3dsLin3Track *track, FILE *f) 
     842lib3ds_lin3_track_write(Lib3dsLin3Track *track, iostream *strm) 
    843843{ 
    844844  Lib3dsLin3Key *k; 
     
    847847    ++num; 
    848848  } 
    849   lib3ds_word_write((Lib3dsWord)track->flags,f); 
    850   lib3ds_dword_write(0,f); 
    851   lib3ds_dword_write(0,f); 
    852   lib3ds_dword_write(num,f); 
     849  lib3ds_word_write((Lib3dsWord)track->flags,strm); 
     850  lib3ds_dword_write(0,strm); 
     851  lib3ds_dword_write(0,strm); 
     852  lib3ds_dword_write(num,strm); 
    853853 
    854854  for (k=track->keyL; k; k=k->next) { 
    855     if (!lib3ds_tcb_write(&k->tcb,f)) { 
     855    if (!lib3ds_tcb_write(&k->tcb,strm)) { 
    856856      return(LIB3DS_FALSE); 
    857857    } 
    858     lib3ds_vector_write(k->value,f); 
     858    lib3ds_vector_write(k->value,strm); 
    859859  } 
    860860  return(LIB3DS_TRUE); 
     
    11571157 */ 
    11581158Lib3dsBool 
    1159 lib3ds_quat_track_read(Lib3dsQuatTrack *track, FILE *f) 
     1159lib3ds_quat_track_read(Lib3dsQuatTrack *track, iostream *strm) 
    11601160{ 
    11611161  int keys; 
     
    11631163  Lib3dsQuatKey *k; 
    11641164 
    1165   track->flags=lib3ds_word_read(f); 
    1166   lib3ds_dword_read(f); 
    1167   lib3ds_dword_read(f); 
    1168   keys=lib3ds_intd_read(f); 
     1165  track->flags=lib3ds_word_read(strm); 
     1166  lib3ds_dword_read(strm); 
     1167  lib3ds_dword_read(strm); 
     1168  keys=lib3ds_intd_read(strm); 
    11691169 
    11701170  for (i=0; i<keys; ++i) { 
    11711171    k=lib3ds_quat_key_new(); 
    1172     if (!lib3ds_tcb_read(&k->tcb, f)) { 
     1172    if (!lib3ds_tcb_read(&k->tcb, strm)) { 
    11731173      return(LIB3DS_FALSE); 
    11741174    } 
    1175     k->angle=lib3ds_float_read(f); 
     1175    k->angle=lib3ds_float_read(strm); 
    11761176    for (j=0; j<3; ++j) { 
    1177       k->axis[j]=lib3ds_float_read(f); 
     1177      k->axis[j]=lib3ds_float_read(strm); 
    11781178    } 
    11791179    lib3ds_quat_track_insert(track, k); 
     
    11881188 */ 
    11891189Lib3dsBool 
    1190 lib3ds_quat_track_write(Lib3dsQuatTrack *track, FILE *f) 
     1190lib3ds_quat_track_write(Lib3dsQuatTrack *track, iostream *strm) 
    11911191{ 
    11921192  Lib3dsQuatKey *k; 
     
    11951195    ++num; 
    11961196  } 
    1197   lib3ds_word_write((Lib3dsWord)track->flags,f); 
    1198   lib3ds_dword_write(0,f); 
    1199   lib3ds_dword_write(0,f); 
    1200   lib3ds_dword_write(num,f); 
     1197  lib3ds_word_write((Lib3dsWord)track->flags,strm); 
     1198  lib3ds_dword_write(0,strm); 
     1199  lib3ds_dword_write(0,strm); 
     1200  lib3ds_dword_write(num,strm); 
    12011201 
    12021202  for (k=track->keyL; k; k=k->next) { 
    1203     if (!lib3ds_tcb_write(&k->tcb,f)) { 
     1203    if (!lib3ds_tcb_write(&k->tcb,strm)) { 
    12041204      return(LIB3DS_FALSE); 
    12051205    } 
    1206     lib3ds_float_write(k->angle,f); 
    1207     lib3ds_vector_write(k->axis,f); 
     1206    lib3ds_float_write(k->angle,strm); 
     1207    lib3ds_vector_write(k->axis,strm); 
    12081208  } 
    12091209  return(LIB3DS_TRUE); 
     
    13651365 */ 
    13661366Lib3dsBool 
    1367 lib3ds_morph_track_read(Lib3dsMorphTrack *, FILE *) 
     1367lib3ds_morph_track_read(Lib3dsMorphTrack *, iostream *strm) 
    13681368{ 
    13691369  /* FIXME: */ 
     
    13761376 */ 
    13771377Lib3dsBool 
    1378 lib3ds_morph_track_write(Lib3dsMorphTrack *, FILE *) 
     1378lib3ds_morph_track_write(Lib3dsMorphTrack *, iostream *strm) 
    13791379{ 
    13801380  /* FIXME: */