00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "Teddy/TeddyConfig.h"
00026 #if defined( TEDDY_INCLUDE_LW_SCENE )
00027
00028
00029 #include "Teddy/Imports/LWFile.h"
00030 #include "Teddy/Imports/LWLayer.h"
00031 #include "Teddy/Imports/LWModel.h"
00032 #include "Teddy/Imports/LWSurface.h"
00033 #include "Teddy/Imports/LWSurfaceBlok.h"
00034 #include "Teddy/SysSupport/Messages.h"
00035 #include "Teddy/SysSupport/StdIO.h"
00036 using namespace Teddy::SysSupport;
00037
00038
00039 namespace Teddy {
00040 namespace Imports {
00041
00042
00044 LWSurfaceBlok::LWSurfaceBlok( LWSurface *surface ){
00045 this->f = surface->getLayer()->getModel()->getFile();
00046 this->surface = surface;
00047 texture_channel = 0;
00048 enable = 0;
00049 opacity_type = 0;
00050 opacity = 0;
00051 opacity_envelope = 0;
00052 displacement_axis = 0;
00053
00054 texture_center = Vector(0,0,0);
00055 texture_center_envelope = 0;
00056 texture_size = Vector(1,1,1);
00057 texture_size_envelope = 0;
00058 texture_rotation = Vector(0,0,0);
00059 texture_rotation_envelope = 0;
00060 texture_falloff_type = 0;
00061 texture_falloff = Vector(0,0,0);
00062 texture_falloff_envelope = 0;
00063 texture_coordinate_system = 0;
00064
00065 texture_projection_mode = 0;
00066 texture_major_axis = 0;
00067 texture_image_map = 0;
00068 texture_width_wrap = 0;
00069 texture_height_wrap = 0;
00070 texture_wrap_width_cycles = 0;
00071 texture_wrap_width_cycles_envelope = 0;
00072 texture_wrap_height_cycles = 0;
00073 texture_wrap_height_cycles_envelope = 0;
00074 texture_antialiasing_type = 0;
00075 texture_antialiasing_strength = 0;
00076 texture_pixel_blending = 0;
00077 texture_stack = 0;
00078 texture_amplitude = 0;
00079 texture_amplitude_envelope = 0;
00080 texture_negative = 0;
00081 procedural_axis = 0;
00082 gradient_range_start = 0;
00083 gradient_range_end = 0;
00084 gradient_repeat = 0;
00085 }
00086
00087
00163 void LWSurfaceBlok::processBlok(){
00164 ID4 blok_type = f->read_ID4();
00165 ID4 blok_ordinal = f->read_ID4();
00166 bool header_done = false;
00167 ID4 subchunk;
00168 U2 length;
00169
00170 while( f->domainLeft() > 0 ){
00171
00172 subchunk = f->read_ID4();
00173 length = f->read_U2();
00174 f->pushDomain( length );
00175
00176 dmsg( M_LWO,
00177 "LWO2::SURF::BLOK::%s::%s (%d bytes)",
00178 did( blok_type ),
00179 did( subchunk ),
00180 length
00181 );
00182
00183
00184 if( header_done == false ){
00185 switch( subchunk ){
00186 case ID_CHAN: readChannel_ID4 (); break;
00187 case ID_ENAB: readEnable_U2 (); break;
00188 case ID_OPAC: readOpacity_U2_FP4_VX (); break;
00189 case ID_AXIS: readDisplacementAxis_U2(); break;
00190 default: header_done = true; break;
00191 }
00192 }
00193
00194
00195 if( header_done == true ){
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212 switch( blok_type ){
00213
00214
00215
00216
00217
00218
00219
00220 case ID_IMAP:
00221 switch( subchunk ){
00222 case ID_TMAP: readTextureMap ( ID_IMAP ); break;
00223 case ID_PROJ: readTextureProjectionMode_U2 (); break;
00224 case ID_AXIS: readTextureMajorAxis_U2 (); break;
00225 case ID_IMAG: readTextureImageMap_VX (); break;
00226 case ID_WRAP: readTextureWrapOptions_U2_U2 (); break;
00227 case ID_WRPW: readTextureWrapWidthAmount_FP4_VX (); break;
00228 case ID_WRPH: readTextureWrapHeightAmount_FP4_VX (); break;
00229 case ID_VMAP: readTextureUV_VertexMap_S0 (); break;
00230 case ID_AAST: readTextureAntialiasingStrength_U2_FP4(); break;
00231 case ID_PIXB: readTexturePixelBlending_U2 (); break;
00232 case ID_STCK: readTextureStack_VX (); break;
00233 case ID_TAMP: readTextureAmplitude_FP4_VX (); break;
00234 case ID_NEGA: readTextureNegative_U2 (); break;
00235
00236
00237 default:
00238 dmsg( M_LWO, "FIX End IMAP, to %s", did(subchunk) );
00239 applyAttributes( blok_type );
00240 blok_type = subchunk;
00241 break;
00242 }
00243 break;
00244
00245
00246
00247
00248
00249
00250
00251 case ID_PROC:
00252 switch( subchunk ){
00253 case ID_TMAP: readTextureMap ( ID_PROC ); break;
00254 case ID_AXIS: readProceduralAxis_U2 (); break;
00255 case ID_VALU: readProceduralBasicValue_FP4_1_or_3(); break;
00256 case ID_FUNC: readProceduralAlgorithm_S0_data (); break;
00257
00258
00259 default:
00260 dmsg( M_LWO, "FIX End PROC, to %s", did(subchunk) );
00261 applyAttributes( blok_type );
00262 blok_type = subchunk;
00263 break;
00264 }
00265 break;
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278 case ID_GRAD:
00279 switch( subchunk ){
00280 case ID_PNAM: readGradientParameter_S0 (); break;
00281 case ID_INAM: readGradientItem_S0 (); break;
00282 case ID_GRST: readGradientRangeStart_FP4 (); break;
00283 case ID_GREN: readGradientRangeEnd_FP4 (); break;
00284 case ID_GRPT: readGradientRepeat_U2 (); break;
00285 case ID_FKEY: readGradientKeys_FP4_data_FP4 (); break;
00286 case ID_IKEY: readGradientKeyParameters_data_U2 (); break;
00287
00288
00289 default:
00290 dmsg( M_LWO, "FIX End GRAD, to %s", did(subchunk) );
00291 applyAttributes( blok_type );
00292 blok_type = subchunk;
00293 break;
00294 }
00295 break;
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307 case ID_SHDR:
00308 switch( subchunk ){
00309 case ID_FUNC: readShaderAlgorithm_S0_data (); break;
00310
00311
00312 default:
00313 dmsg( M_LWO, "FIX End SHDR, to %s", did(subchunk) );
00314 applyAttributes( blok_type );
00315 blok_type = subchunk;
00316 break;
00317 }
00318 break;
00319
00320
00321 default:
00322 dmsg( M_LWO,
00323 "LWO2::SURF::BLOK parser confused by blok type %s",
00324 did(blok_type)
00325 );
00326 break;
00327 }
00328 }
00329
00330 f->popDomain( true );
00331 }
00332 applyAttributes( blok_type );
00333 }
00334
00335
00336 void LWSurfaceBlok::applyAttributes( ID4 type ){
00337 switch( type ){
00338 case ID_IMAP: applyImageMap (); break;
00339 case ID_PROC: applyProcedural(); break;
00340 case ID_GRAD: applyGradient (); break;
00341 case ID_SHDR: applyShader (); break;
00342 default:
00343 dmsg( M_LWO, "Unknown BLOK attribute %s", type );
00344 break;
00345 }
00346 }
00347
00348
00361 void LWSurfaceBlok::readTextureMap( ID4 parent ){
00362 ID4 subchunk;
00363 U2 length;
00364
00365 while( f->domainLeft() > 0 ){
00366
00367 subchunk = f->read_ID4();
00368 length = f->read_U2();
00369
00370 dmsg( M_LWO,
00371 "LWO2::SURF::BLOK::%s::TMAP::%s (%d bytes)",
00372 did( parent ),
00373 did( subchunk ),
00374 length
00375 );
00376
00377 f->pushDomain( length );
00378 switch( subchunk ){
00379 case ID_CNTR: readTextureCenter_VEC12_VX (); break;
00380 case ID_SIZE: readTextureSize_VEC12_VX (); break;
00381 case ID_ROTA: readTextureRotation_VEC12_VX (); break;
00382 case ID_OREF: readTextureReferenceObject_S0 (); break;
00383 case ID_FALL: readTextureFalloff_U2_VEC12_VX (); break;
00384 case ID_CSYS: readTextureCoordinateSystem_U2 (); break;
00385
00386
00387 default:
00388 dmsg( M_LWO, "Unknown TMAP::%s", did(subchunk) );
00389 break;
00390 }
00391 f->popDomain( true );
00392 }
00393 }
00394
00395
00407 void LWSurfaceBlok::readChannel_ID4(){
00408 texture_channel = f->read_ID4();
00409 }
00410
00411
00419 void LWSurfaceBlok::readEnable_U2(){
00420 enable = f->read_U2();
00421 }
00422
00423
00448 void LWSurfaceBlok::readOpacity_U2_FP4_VX(){
00449 opacity_type = f->read_U2 ();
00450 opacity = f->read_FP4();
00451 opacity_envelope = f->read_VX ();
00452 }
00453
00454
00464 void LWSurfaceBlok::readDisplacementAxis_U2(){
00465 displacement_axis = f->read_U2();
00466 }
00467
00468
00481 void LWSurfaceBlok::readTextureCenter_VEC12_VX(){
00482 texture_center = f->read_VEC12();
00483 texture_center_envelope = f->read_VX ();
00484 }
00485
00486
00487 void LWSurfaceBlok::readTextureSize_VEC12_VX(){
00488 texture_size = f->read_VEC12();
00489 texture_size_envelope = f->read_VX ();
00490 }
00491
00492 void LWSurfaceBlok::readTextureRotation_VEC12_VX(){
00493 texture_rotation = f->read_VEC12();
00494 texture_rotation_envelope = f->read_VX ();
00495 }
00496
00497
00509 void LWSurfaceBlok::readTextureReferenceObject_S0(){
00510 texture_reference_object = f->read_S0();
00511 }
00512
00513
00532 void LWSurfaceBlok::readTextureFalloff_U2_VEC12_VX(){
00533 texture_falloff_type = f->read_U2 ();
00534 texture_falloff = f->read_VEC12();
00535 texture_falloff_envelope = f->read_VX ();
00536 }
00537
00538
00548 void LWSurfaceBlok::readTextureCoordinateSystem_U2(){
00549 texture_coordinate_system = f->read_U2();
00550 }
00551
00552
00595 void LWSurfaceBlok::readTextureProjectionMode_U2(){
00596 texture_projection_mode = f->read_U2();
00597 }
00598
00599
00608 void LWSurfaceBlok::readTextureMajorAxis_U2(){
00609 texture_major_axis = f->read_U2();
00610 }
00611
00612
00620 void LWSurfaceBlok::readTextureImageMap_VX(){
00621 texture_image_map = f->read_VX();
00622 }
00623
00624
00652 void LWSurfaceBlok::readTextureWrapOptions_U2_U2(){
00653 texture_width_wrap = f->read_U2();
00654 texture_height_wrap = f->read_U2();
00655 }
00656
00657
00666 void LWSurfaceBlok::readTextureWrapWidthAmount_FP4_VX(){
00667 texture_wrap_width_cycles = f->read_FP4();
00668 texture_wrap_width_cycles_envelope = f->read_VX ();
00669 }
00670
00671
00672 void LWSurfaceBlok::readTextureWrapHeightAmount_FP4_VX(){
00673 texture_wrap_height_cycles = f->read_FP4();
00674 texture_wrap_height_cycles_envelope = f->read_VX ();
00675 }
00676
00677
00686 void LWSurfaceBlok::readTextureUV_VertexMap_S0(){
00687 texture_uv_vertex_map = f->read_S0();
00688 }
00689
00690
00701 void LWSurfaceBlok::readTextureAntialiasingStrength_U2_FP4(){
00702 texture_antialiasing_type = f->read_U2 ();
00703 texture_antialiasing_strength = f->read_FP4();
00704 }
00705
00706
00717 void LWSurfaceBlok::readTexturePixelBlending_U2(){
00718 texture_pixel_blending = f->read_U2();
00719 }
00720
00721
00729 void LWSurfaceBlok::readTextureStack_VX(){
00730 texture_stack = f->read_VX();
00731 }
00732
00733
00743 void LWSurfaceBlok::readTextureAmplitude_FP4_VX(){
00744 texture_amplitude = f->read_FP4();
00745 texture_amplitude_envelope = f->read_VX ();
00746 }
00747
00748
00749 void LWSurfaceBlok::readTextureNegative_U2(){
00750 texture_negative = f->read_U2();
00751 }
00752
00753
00762 void LWSurfaceBlok::readProceduralAxis_U2(){
00763 procedural_axis = f->read_U2();
00764 }
00765
00775 void LWSurfaceBlok::readProceduralBasicValue_FP4_1_or_3(){
00776
00777 }
00778
00779
00790 void LWSurfaceBlok::readProceduralAlgorithm_S0_data(){
00791 procedural_algorithm = f->read_S0();
00792
00793 }
00794
00795
00815 void LWSurfaceBlok::readGradientParameter_S0(){
00816 gradient_parameter = f->read_S0();
00817 }
00818
00819
00828 void LWSurfaceBlok::readGradientItem_S0(){
00829 gradient_item = f->read_S0();
00830 }
00831
00832
00842 void LWSurfaceBlok::readGradientRangeStart_FP4(){
00843 gradient_range_start = f->read_FP4();
00844 }
00845
00846 void LWSurfaceBlok::readGradientRangeEnd_FP4(){
00847 gradient_range_end = f->read_FP4();
00848 }
00849
00850
00857 void LWSurfaceBlok::readGradientRepeat_U2(){
00858 gradient_repeat = f->read_U2();
00859 }
00860
00861
00876 void LWSurfaceBlok::readGradientKeys_FP4_data_FP4(){
00877
00878 }
00879
00880
00892 void LWSurfaceBlok::readGradientKeyParameters_data_U2(){
00893
00894 }
00895
00896
00906 void LWSurfaceBlok::readShaderAlgorithm_S0_data(){
00907 shader_algorithm = f->read_S0();
00908
00909 }
00910
00911
00912 };
00913 };
00914
00915
00916 #endif // TEDDY_INCLUDE_LW_SCENE
00917