Show
Ignore:
Timestamp:
04/22/09 17:46:24 (5 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/tcb.cpp

    r1563 r10076  
    7878 */ 
    7979Lib3dsBool 
    80 lib3ds_tcb_read(Lib3dsTcb *tcb, FILE *f) 
     80lib3ds_tcb_read(Lib3dsTcb *tcb, iostream *strm) 
    8181{ 
    8282  Lib3dsWord flags; 
    8383   
    84   tcb->frame=lib3ds_intd_read(f); 
    85   tcb->flags=flags=lib3ds_word_read(f); 
     84  tcb->frame=lib3ds_intd_read(strm); 
     85  tcb->flags=flags=lib3ds_word_read(strm); 
    8686  if (flags&LIB3DS_USE_TENSION) { 
    87     tcb->tens=lib3ds_float_read(f); 
     87    tcb->tens=lib3ds_float_read(strm); 
    8888  } 
    8989  if (flags&LIB3DS_USE_CONTINUITY) { 
    90     tcb->cont=lib3ds_float_read(f); 
     90    tcb->cont=lib3ds_float_read(strm); 
    9191  } 
    9292  if (flags&LIB3DS_USE_BIAS) { 
    93     tcb->bias=lib3ds_float_read(f); 
     93    tcb->bias=lib3ds_float_read(strm); 
    9494  } 
    9595  if (flags&LIB3DS_USE_EASE_TO) { 
    96     tcb->ease_to=lib3ds_float_read(f); 
     96    tcb->ease_to=lib3ds_float_read(strm); 
    9797  } 
    9898  if (flags&LIB3DS_USE_EASE_FROM) { 
    99     tcb->ease_from=lib3ds_float_read(f); 
     99    tcb->ease_from=lib3ds_float_read(strm); 
    100100  } 
    101   if (ferror(f)) { 
     101 
     102  if (strm->fail()){ 
    102103    return(LIB3DS_FALSE); 
    103104  } 
     
    110111 */ 
    111112Lib3dsBool 
    112 lib3ds_tcb_write(Lib3dsTcb *tcb, FILE *f) 
     113lib3ds_tcb_write(Lib3dsTcb *tcb, iostream *strm) 
    113114{ 
    114   lib3ds_intd_write(tcb->frame,f); 
    115   lib3ds_word_write(tcb->flags,f); 
     115  lib3ds_intd_write(tcb->frame,strm); 
     116  lib3ds_word_write(tcb->flags,strm); 
    116117  if (tcb->flags&LIB3DS_USE_TENSION) { 
    117     lib3ds_float_write(tcb->tens,f); 
     118    lib3ds_float_write(tcb->tens,strm); 
    118119  } 
    119120  if (tcb->flags&LIB3DS_USE_CONTINUITY) { 
    120     lib3ds_float_write(tcb->cont,f); 
     121    lib3ds_float_write(tcb->cont,strm); 
    121122  } 
    122123  if (tcb->flags&LIB3DS_USE_BIAS) { 
    123     lib3ds_float_write(tcb->bias,f); 
     124    lib3ds_float_write(tcb->bias,strm); 
    124125  } 
    125126  if (tcb->flags&LIB3DS_USE_EASE_TO) { 
    126     lib3ds_float_write(tcb->ease_to,f); 
     127    lib3ds_float_write(tcb->ease_to,strm); 
    127128  } 
    128129  if (tcb->flags&LIB3DS_USE_EASE_FROM) { 
    129     lib3ds_float_write(tcb->ease_from,f); 
     130    lib3ds_float_write(tcb->ease_from,strm); 
    130131  } 
    131   if (ferror(f)) { 
     132  if (strm->fail()){ 
    132133    return(LIB3DS_FALSE); 
    133134  }