Changeset 10076 for OpenSceneGraph/trunk/src/osgPlugins/3ds/atmosphere.cpp
- Timestamp:
- 04/22/09 17:46:24 (4 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/src/osgPlugins/3ds/atmosphere.cpp
r1563 r10076 34 34 35 35 static Lib3dsBool 36 fog_read(Lib3dsFog *fog, FILE *f)36 fog_read(Lib3dsFog *fog, iostream *strm) 37 37 { 38 38 Lib3dsChunk c; 39 39 Lib3dsWord chunk; 40 40 41 if (!lib3ds_chunk_read_start(&c, LIB3DS_FOG, f)) {41 if (!lib3ds_chunk_read_start(&c, LIB3DS_FOG, strm)) { 42 42 return(LIB3DS_FALSE); 43 43 } 44 fog->near_plane=lib3ds_float_read( f);45 fog->near_density=lib3ds_float_read( f);46 fog->far_plane=lib3ds_float_read( f);47 fog->far_density=lib3ds_float_read( f);48 lib3ds_chunk_read_tell(&c, f);49 50 while ((chunk=lib3ds_chunk_read_next(&c, f))!=0) {44 fog->near_plane=lib3ds_float_read(strm); 45 fog->near_density=lib3ds_float_read(strm); 46 fog->far_plane=lib3ds_float_read(strm); 47 fog->far_density=lib3ds_float_read(strm); 48 lib3ds_chunk_read_tell(&c, strm); 49 50 while ((chunk=lib3ds_chunk_read_next(&c, strm))!=0) { 51 51 switch (chunk) { 52 52 case LIB3DS_LIN_COLOR_F: … … 54 54 int i; 55 55 for (i=0; i<3; ++i) { 56 fog->col[i]=lib3ds_float_read( f);56 fog->col[i]=lib3ds_float_read(strm); 57 57 } 58 58 } … … 70 70 } 71 71 72 lib3ds_chunk_read_end(&c, f);72 lib3ds_chunk_read_end(&c, strm); 73 73 return(LIB3DS_TRUE); 74 74 } … … 76 76 77 77 static Lib3dsBool 78 layer_fog_read(Lib3dsLayerFog *fog, FILE *f)78 layer_fog_read(Lib3dsLayerFog *fog, iostream *strm) 79 79 { 80 80 Lib3dsChunk c; 81 81 Lib3dsWord chunk; 82 82 83 if (!lib3ds_chunk_read_start(&c, LIB3DS_LAYER_FOG, f)) {83 if (!lib3ds_chunk_read_start(&c, LIB3DS_LAYER_FOG, strm)) { 84 84 return(LIB3DS_FALSE); 85 85 } 86 fog->near_y=lib3ds_float_read( f);87 fog->far_y=lib3ds_float_read( f);88 fog->density=lib3ds_float_read( f);89 fog->flags=lib3ds_dword_read( f);90 lib3ds_chunk_read_tell(&c, f);91 92 while ((chunk=lib3ds_chunk_read_next(&c, f))!=0) {86 fog->near_y=lib3ds_float_read(strm); 87 fog->far_y=lib3ds_float_read(strm); 88 fog->density=lib3ds_float_read(strm); 89 fog->flags=lib3ds_dword_read(strm); 90 lib3ds_chunk_read_tell(&c, strm); 91 92 while ((chunk=lib3ds_chunk_read_next(&c, strm))!=0) { 93 93 switch (chunk) { 94 94 case LIB3DS_LIN_COLOR_F: 95 lib3ds_rgb_read(fog->col, f);95 lib3ds_rgb_read(fog->col,strm); 96 96 break; 97 97 case LIB3DS_COLOR_F: 98 lib3ds_rgb_read(fog->col, f);98 lib3ds_rgb_read(fog->col,strm); 99 99 break; 100 100 default: … … 103 103 } 104 104 105 lib3ds_chunk_read_end(&c, f);105 lib3ds_chunk_read_end(&c, strm); 106 106 return(LIB3DS_TRUE); 107 107 } … … 109 109 110 110 static Lib3dsBool 111 distance_cue_read(Lib3dsDistanceCue *cue, FILE *f)111 distance_cue_read(Lib3dsDistanceCue *cue, iostream *strm) 112 112 { 113 113 Lib3dsChunk c; 114 114 Lib3dsWord chunk; 115 115 116 if (!lib3ds_chunk_read_start(&c, LIB3DS_DISTANCE_CUE, f)) {116 if (!lib3ds_chunk_read_start(&c, LIB3DS_DISTANCE_CUE, strm)) { 117 117 return(LIB3DS_FALSE); 118 118 } 119 cue->near_plane=lib3ds_float_read( f);120 cue->near_dimming=lib3ds_float_read( f);121 cue->far_plane=lib3ds_float_read( f);122 cue->far_dimming=lib3ds_float_read( f);123 lib3ds_chunk_read_tell(&c, f);124 125 while ((chunk=lib3ds_chunk_read_next(&c, f))!=0) {119 cue->near_plane=lib3ds_float_read(strm); 120 cue->near_dimming=lib3ds_float_read(strm); 121 cue->far_plane=lib3ds_float_read(strm); 122 cue->far_dimming=lib3ds_float_read(strm); 123 lib3ds_chunk_read_tell(&c, strm); 124 125 while ((chunk=lib3ds_chunk_read_next(&c, strm))!=0) { 126 126 switch (chunk) { 127 127 case LIB3DS_DCUE_BGND: … … 135 135 } 136 136 137 lib3ds_chunk_read_end(&c, f);137 lib3ds_chunk_read_end(&c, strm); 138 138 return(LIB3DS_TRUE); 139 139 } … … 144 144 */ 145 145 Lib3dsBool 146 lib3ds_atmosphere_read(Lib3dsAtmosphere *atmosphere, FILE *f)146 lib3ds_atmosphere_read(Lib3dsAtmosphere *atmosphere, iostream *strm) 147 147 { 148 148 Lib3dsChunk c; 149 149 150 if (!lib3ds_chunk_read(&c, f)) {150 if (!lib3ds_chunk_read(&c, strm)) { 151 151 return(LIB3DS_FALSE); 152 152 } … … 155 155 case LIB3DS_FOG: 156 156 { 157 lib3ds_chunk_read_reset(&c, f);158 if (!fog_read(&atmosphere->fog, f)) {157 lib3ds_chunk_read_reset(&c, strm); 158 if (!fog_read(&atmosphere->fog, strm)) { 159 159 return(LIB3DS_FALSE); 160 160 } … … 163 163 case LIB3DS_LAYER_FOG: 164 164 { 165 lib3ds_chunk_read_reset(&c, f);166 if (!layer_fog_read(&atmosphere->layer_fog, f)) {165 lib3ds_chunk_read_reset(&c, strm); 166 if (!layer_fog_read(&atmosphere->layer_fog, strm)) { 167 167 return(LIB3DS_FALSE); 168 168 } … … 171 171 case LIB3DS_DISTANCE_CUE: 172 172 { 173 lib3ds_chunk_read_reset(&c, f);174 if (!distance_cue_read(&atmosphere->dist_cue, f)) {173 lib3ds_chunk_read_reset(&c, strm); 174 if (!distance_cue_read(&atmosphere->dist_cue, strm)) { 175 175 return(LIB3DS_FALSE); 176 176 } … … 202 202 */ 203 203 Lib3dsBool 204 lib3ds_atmosphere_write(Lib3dsAtmosphere *atmosphere, FILE *f)204 lib3ds_atmosphere_write(Lib3dsAtmosphere *atmosphere, iostream *strm) 205 205 { 206 206 if (atmosphere->fog.use) { /*---- LIB3DS_FOG ----*/ 207 207 Lib3dsChunk c; 208 208 c.chunk=LIB3DS_FOG; 209 if (!lib3ds_chunk_write_start(&c, f)) {209 if (!lib3ds_chunk_write_start(&c,strm)) { 210 210 return(LIB3DS_FALSE); 211 211 } 212 lib3ds_float_write(atmosphere->fog.near_plane, f);213 lib3ds_float_write(atmosphere->fog.near_density, f);214 lib3ds_float_write(atmosphere->fog.far_plane, f);215 lib3ds_float_write(atmosphere->fog.far_density, f);212 lib3ds_float_write(atmosphere->fog.near_plane,strm); 213 lib3ds_float_write(atmosphere->fog.near_density,strm); 214 lib3ds_float_write(atmosphere->fog.far_plane,strm); 215 lib3ds_float_write(atmosphere->fog.far_density,strm); 216 216 { 217 217 Lib3dsChunk c; 218 218 c.chunk=LIB3DS_COLOR_F; 219 219 c.size=18; 220 lib3ds_chunk_write(&c, f);221 lib3ds_rgb_write(atmosphere->fog.col, f);220 lib3ds_chunk_write(&c,strm); 221 lib3ds_rgb_write(atmosphere->fog.col,strm); 222 222 } 223 223 if (atmosphere->fog.fog_background) { … … 225 225 c.chunk=LIB3DS_FOG_BGND; 226 226 c.size=6; 227 lib3ds_chunk_write(&c, f);228 } 229 if (!lib3ds_chunk_write_end(&c, f)) {227 lib3ds_chunk_write(&c,strm); 228 } 229 if (!lib3ds_chunk_write_end(&c,strm)) { 230 230 return(LIB3DS_FALSE); 231 231 } … … 236 236 c.chunk=LIB3DS_LAYER_FOG; 237 237 c.size=40; 238 lib3ds_chunk_write(&c, f);239 lib3ds_float_write(atmosphere->layer_fog.near_y, f);240 lib3ds_float_write(atmosphere->layer_fog.far_y, f);241 lib3ds_float_write(atmosphere->layer_fog.near_y, f);242 lib3ds_dword_write(atmosphere->layer_fog.flags, f);238 lib3ds_chunk_write(&c,strm); 239 lib3ds_float_write(atmosphere->layer_fog.near_y,strm); 240 lib3ds_float_write(atmosphere->layer_fog.far_y,strm); 241 lib3ds_float_write(atmosphere->layer_fog.near_y,strm); 242 lib3ds_dword_write(atmosphere->layer_fog.flags,strm); 243 243 { 244 244 Lib3dsChunk c; 245 245 c.chunk=LIB3DS_COLOR_F; 246 246 c.size=18; 247 lib3ds_chunk_write(&c, f);248 lib3ds_rgb_write(atmosphere->fog.col, f);247 lib3ds_chunk_write(&c,strm); 248 lib3ds_rgb_write(atmosphere->fog.col,strm); 249 249 } 250 250 } … … 253 253 Lib3dsChunk c; 254 254 c.chunk=LIB3DS_DISTANCE_CUE; 255 if (!lib3ds_chunk_write_start(&c, f)) {255 if (!lib3ds_chunk_write_start(&c,strm)) { 256 256 return(LIB3DS_FALSE); 257 257 } 258 lib3ds_float_write(atmosphere->dist_cue.near_plane, f);259 lib3ds_float_write(atmosphere->dist_cue.near_dimming, f);260 lib3ds_float_write(atmosphere->dist_cue.far_plane, f);261 lib3ds_float_write(atmosphere->dist_cue.far_dimming, f);258 lib3ds_float_write(atmosphere->dist_cue.near_plane,strm); 259 lib3ds_float_write(atmosphere->dist_cue.near_dimming,strm); 260 lib3ds_float_write(atmosphere->dist_cue.far_plane,strm); 261 lib3ds_float_write(atmosphere->dist_cue.far_dimming,strm); 262 262 if (atmosphere->dist_cue.cue_background) { 263 263 Lib3dsChunk c; 264 264 c.chunk=LIB3DS_DCUE_BGND; 265 265 c.size=6; 266 lib3ds_chunk_write(&c, f);267 } 268 if (!lib3ds_chunk_write_end(&c, f)) {266 lib3ds_chunk_write(&c,strm); 267 } 268 if (!lib3ds_chunk_write_end(&c,strm)) { 269 269 return(LIB3DS_FALSE); 270 270 } … … 275 275 c.chunk=LIB3DS_USE_FOG; 276 276 c.size=6; 277 lib3ds_chunk_write(&c, f);277 lib3ds_chunk_write(&c,strm); 278 278 } 279 279 … … 282 282 c.chunk=LIB3DS_USE_LAYER_FOG; 283 283 c.size=6; 284 lib3ds_chunk_write(&c, f);284 lib3ds_chunk_write(&c,strm); 285 285 } 286 286 … … 289 289 c.chunk=LIB3DS_USE_V_GRADIENT; 290 290 c.size=6; 291 lib3ds_chunk_write(&c, f);291 lib3ds_chunk_write(&c,strm); 292 292 } 293 293
