Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

LWSceneParser.cpp

Go to the documentation of this file.
00001 
00002 /*
00003     TEDDY - General graphics application library
00004     Copyright (C) 1999-2002  Timo Suoranta
00005     tksuoran@cc.helsinki.fi
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2.1 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021     $Id: LWSceneParser.cpp,v 1.3 2002/03/12 10:46:06 tksuoran Exp $
00022 */
00023 
00024 
00025 #include "Teddy/TeddyConfig.h"
00026 #if defined( TEDDY_INCLUDE_LW_SCENE )
00027 
00028 
00029 #include "Teddy/Imports/LWBone.h"
00030 #include "Teddy/Imports/LWCamera.h"
00031 #include "Teddy/Imports/LWInstance.h"
00032 #include "Teddy/Imports/LWLight.h"
00033 #include "Teddy/Imports/LWModel.h"
00034 #include "Teddy/Imports/LWSceneFile.h"
00035 #include "Teddy/Imports/LWSceneParser.h"
00036 #include "Teddy/Imports/LWSceneTokens.h"
00037 #include "Teddy/Materials/Material.h"
00038 #include "Teddy/Models/Grid.h"
00039 #include "Teddy/Models/Model.h"
00040 #include "Teddy/Scenes/Scene.h"
00041 #include "Teddy/SysSupport/Messages.h"
00042 #include "Teddy/SysSupport/FileScan.h"
00043 #include "Teddy/SysSupport/StdSDL.h"
00044 using namespace Teddy::Materials;
00045 using namespace Teddy::Models;
00046 using namespace Teddy::Scenes;
00047 using namespace Teddy::SysSupport;
00048 
00049 
00050 namespace Teddy   {
00051 namespace Imports {
00052 
00053 
00054 const int LWSceneParser::OPT_GRID      = (1ul<<1ul);
00055 const int LWSceneParser::OPT_DARK_GRID = (1ul<<2ul);
00056 
00057 
00058 LWSceneParser::LWSceneParser( Scene *scene, Camera *camera, const char *fname, Options options )
00059 :
00060 options(options),
00061 scene  (scene  ),
00062 camera (camera )
00063 {
00064     file        = NULL;
00065     lws_version = 0;
00066     next_object = 0;
00067     next_light  = 0;
00068     next_camera = 0;
00069     grid_number = 16;
00070     grid_size   = 1.0f;
00071 
00072     playing     = false;
00073     multiplier  = 0.001f;
00074     stop_time   = 0;
00075     start_time  = 0;
00076 
00077     zenith_color = Color::DARK_BLUE;
00078     sky_color    = Color::LIGHT_BLUE;
00079     ground_color = Color::LIGHT_CYAN;
00080     nadir_color  = Color::DARK_GREEN;
00081     grid         = NULL;
00082 
00083     readFile   ( fix_file_name("Data/lws/",fname) );
00084     postProcess();
00085     reset      ();
00086 }
00087 
00088 
00089 void LWSceneParser::reset(){
00090     stop_time  = 0;
00091     start_time = float(SDL_GetTicks()) * multiplier;
00092     update();
00093 }
00094 
00095 
00096 void LWSceneParser::stop(){
00097     if( playing == true ){
00098         playing   = false;
00099         stop_time = start_time - float(SDL_GetTicks()) * multiplier;
00100     }
00101 }
00102 
00103 void LWSceneParser::play(){
00104     if( playing == false ){
00105         playing    = true;
00106         start_time = float(SDL_GetTicks()) * multiplier + stop_time;
00107     }
00108 }
00109 
00110 
00111 void LWSceneParser::setMultiplier( float new_mult ){
00112     bool do_play = playing;
00113     stop();
00114     this->multiplier  = new_mult;
00115     if( do_play ){
00116         play();
00117     }
00118 }
00119 
00120 
00121 float LWSceneParser::getMultiplier(){
00122     return this->multiplier;
00123 }
00124 
00125 
00126 /*virtual*/ void LWSceneParser::tick(){
00127     if( playing == false ){
00128         return;
00129     }
00130     update();
00131 }
00132 
00133 
00134 float LWSceneParser::getTime(){
00135     return last_used_time;
00136 }
00137 
00138 
00139 void LWSceneParser::update(){
00140     float time = playing ? float(SDL_GetTicks()) * multiplier - start_time : stop_time;
00141 
00142     if( playing==true ){
00143         float max_time = 1.0f / float(frames_per_second) * float(preview_last_frame);
00144         if( time<0 ){
00145             if( multiplier<0 ){
00146                 multiplier = -multiplier;
00147                 stop();
00148                 reset();
00149             }
00150             float time = playing ? float(SDL_GetTicks()) * multiplier - start_time : stop_time;
00151         }else if( time>max_time ){
00152             reset();
00153             time = float(SDL_GetTicks()) * multiplier - start_time;
00154         }
00155     }
00156 
00157     this->last_used_time = time;
00158 
00159     int_to_LWInstance::iterator o_it = objects.begin();
00160     while( o_it != objects.end() ){
00161         LWInstance *object = (*o_it).second;
00162         if( object != NULL ){
00163             object->setTime( time );
00164         }
00165         o_it++;
00166     }
00167 
00168     int_to_LWLight::iterator l_it = lights.begin();
00169     while( l_it != lights.end() ){
00170         LWLight *light = (*l_it).second;
00171         if( light != NULL ){
00172             light->setTime( time );
00173         }
00174         l_it++;
00175     }
00176 /*
00177     int_to_LWCamera::iterator c_it = cameras.begin();
00178     while( c_it != cameras.end() ){
00179         LWCamera *cam = (*c_it).second;
00180         if( cam != NULL ){
00181             cam->setTime( time );
00182         }
00183         c_it++;
00184     }
00185     */
00186 }
00187 
00188 
00189 Grid *LWSceneParser::getGrid(){
00190     return this->grid;
00191 }
00192 
00193 void LWSceneParser::postProcess(){
00194     unsigned long counter = 0;
00195     dmsg( M_LWS, "Postprocessing stage has %d objects to do.", objects.size() );
00196     int_to_LWInstance::iterator o_it = objects.begin();
00197     while( o_it != objects.end() ){
00198         dmsg( M_LWS, "Postprocessing object %d", ++counter );
00199         LWInstance *object = (*o_it).second;
00200         if( object != NULL ){
00201             std::string &model_name = object->getModelName();
00202             Model *model = NULL;
00203             if( model_name.size() > 0 ){
00204                 model = new LWModel( object->getModelName(), 0 );
00205             }else{
00206                 model = new Model("LWNULL");
00207             }
00208             object->setModel( model  );
00209             object->setTime ( 0      );
00210             resolveParent   ( object );
00211             scene->add      ( model  );
00212         }
00213         o_it++;
00214     }
00215 
00216     dmsg( M_LWS, "grid_number %d grid_size % 8.4f", grid_number, grid_size );
00217     this->grid = new Grid( grid_number, grid_number, grid_size, grid_size );
00218     dmsg( M_LWS, "grid done" );
00219 
00220     scene->setAmbientColor( ambient_color * amb_intensity );
00221     int_to_LWLight::iterator l_it = lights.begin();
00222     while( l_it != lights.end() ){
00223         LWLight *light = (*l_it).second;
00224         if( light != NULL ){
00225             dmsg( M_LWS, "Generating LightWave light" );
00226             light ->genLight();
00227             light ->setModel( light->getLight() );
00228             light ->setTime ( 0                 );
00229             scene ->add     ( light->getLight() );
00230             resolveParent   ( light             );
00231         }
00232         l_it++;
00233     }
00234 
00235     int_to_LWCamera::iterator c_it = cameras.begin();
00236     while( c_it != cameras.end() ){
00237         LWCamera *cam = (*c_it).second;
00238         if( cam != NULL ){
00239             cam->setCamera( camera );
00240             cam->setTime  ( 0 );
00241             resolveParent( cam );
00242         }
00243         c_it++;
00244     }
00245 }
00246 
00247 
00248 void LWSceneParser::resolveParent( LWInstance *object ){
00249     unsigned long  all_bits  = object->getParentObjectId();
00250     if( all_bits == 0xffffffff ){
00251         return;
00252     }
00253     unsigned long  item_type = (0xf0000000 & all_bits) >> 28;
00254     unsigned long  item_num  = (0x0fffffff & all_bits);
00255     LWInstance    *parent    = NULL;
00256 
00257     switch( item_type ){
00258 
00259     case 1: {  //  Object
00260         int_to_LWInstance::iterator i_it = objects.find( item_num );
00261         if( i_it != objects.end() ){
00262             parent = (*i_it).second;
00263         }else{
00264             emsg( M_LWS, "Parent object %d not found", item_num );
00265         }
00266         break;
00267     }
00268 
00269     case 2: {  //  Light
00270         int_to_LWLight::iterator l_it = lights.find( item_num );
00271         if( l_it != lights.end() ){
00272             parent = (*l_it).second;
00273         }else{
00274             emsg( M_LWS, "Parent light %d not found", item_num );
00275         }
00276         break;
00277     }
00278 
00279     case 3: {  //  Camera
00280         int_to_LWCamera::iterator c_it = cameras.find( item_num );
00281         if( c_it != cameras.end() ){
00282             parent = (*c_it).second;
00283         }else{
00284             emsg( M_LWS, "Parent camera %d not found", item_num );
00285         }
00286         break;
00287     }
00288 
00289     case 4: {  //  Bone
00290         unsigned long  bone_num  = (0x0fff0000 & all_bits);
00291         unsigned long  obj_num   = (0x0000ffff & all_bits);
00292         int_to_LWInstance::iterator i_it = objects.find( obj_num );
00293         if( i_it != objects.end() ){
00294             LWInstance *obj = (*i_it).second;
00295             if( obj != NULL ){
00296                 parent = obj->getBone( bone_num );
00297             }else{
00298                 emsg( M_LWS, "Parent object %d found NULL", obj_num );
00299             }
00300         }else{
00301             emsg( M_LWS, "Parent object %d not found", obj_num );
00302         }
00303         break;
00304     }
00305 
00306     default:
00307         emsg( M_LWS, "Unknown item type %d", item_type );
00308         break;
00309     }
00310 
00311     object->setParentObject( parent );
00312 }
00313 
00314 
00315 void LWSceneParser::readFile( const char *fname ){
00316     dmsg( M_LWS, "Reading file %s", fname );
00317     file      = new LWSceneFile( fname ); 
00318     bool cont = true;
00319 
00320     if( file->isOk() == false ){
00321         emsg( M_LWS, "Read file %s not found", fname );
00322         return;
00323     }
00324 
00325     //  Read the file
00326     while( cont ){
00327         LwsToken token = file->read_token();
00328 
00329         switch( token ){
00330         //  Scene
00331         case LWS_LWSC                    : LWSC                   (); break;
00332         case LWS_FIRST_FRAME             : FirstFrame             (); break;
00333         case LWS_LAST_FRAME              : LastFrame              (); break;
00334         case LWS_FRAME_STEP              : FrameStep              (); break;
00335         case LWS_FRAMES_PER_SECOND       : FramesPerSecond        (); break;
00336         case LWS_PREVIEW_FIRST_FRAME     : PreviewFirstFrame      (); break;
00337         case LWS_PREVIEW_LAST_FRAME      : PreviewLastFrame       (); break;
00338         case LWS_PREVIEW_FRAME_STEP      : PreviewFrameStep       (); break;
00339         case LWS_CURRENT_FRAME           : CurrentFrame           (); break;
00340         case LWS_PLUGIN                  : Plugin                 (); break;
00341         case LWS_END_PLUGIN              : EndPlugin              (); break;
00342 
00343         //  Objects
00344         case LWS_ADD_NULL_OBJECT         : AddNullObject          (); break;
00345         case LWS_LOAD_OBJECT             : LoadObject             (); break;
00346         case LWS_LOAD_OBJECT_LAYER       : LoadObjectLayer        (); break;
00347         case LWS_SHOW_OBJECT             : ShowObject             (); break;
00348         case LWS_OBJECT_MOTION           : ObjectMotion           (); break;
00349         case LWS_OBJECT_DISSOLVE         : ObjectDissolve         (); break;
00350         case LWS_SUBDIVISION_ORDER       : SubdivisionOrder       (); break;
00351         case LWS_SUB_PATCH_LEVEL         : SubPatchLevel          (); break;
00352         case LWS_SHADOW_OPTIONS          : ShadowOptions          (); break;
00353         case LWS_DISTANCE_DISSOLVE       : DistanceDissolve       (); break;
00354         case LWS_MAX_DISSOLVE_DISTANCE   : MaxDissolveDistance    (); break;
00355         case LWS_PARTICLE_SIZE           : ParticleSize           (); break;
00356         case LWS_LINE_SIZE               : LineSize               (); break;
00357         case LWS_POLYGON_SIZE            : PolygonSize            (); break;
00358         case LWS_UNSEEN_BY_RAYS          : UnseenByRays           (); break;
00359         case LWS_UNSEEN_BY_CAMERA        : UnseenByCamera         (); break;
00360         case LWS_UNAFFECTED_BY_FOG       : UnaffectedByFog        (); break;
00361         case LWS_AFFECTED_BY_FOG         : AffectedByFog          (); break;
00362         case LWS_OBJ_POLYGON_EDGES       : ObjPolygonEdges        (); break;
00363         case LWS_OBJ_EDGE_COLOR          : ObjEdgeColor           (); break;
00364         case LWS_EXCLUDE_LIGHT           : ExcludeLight           (); break;
00365         case LWS_POLYGON_EDGE_FLAGS      : PolygonEdgeFlags       (); break;
00366         case LWS_POLYGON_EDGE_THICKNESS  : PolygonEdgeThickness   (); break;
00367         case LWS_POLYGON_EDGES_Z_SCALE   : PolygonEdgesZScale     (); break;
00368         case LWS_EDGE_NOMINAL_DISTANCE   : EdgeNominalDistance    (); break;
00369 
00370         case LWS_DISPLACEMENT_MAP        : DisplacementMap        (); break;
00371         case LWS_CLIP_MAP                : ClipMap                (); break;
00372         case LWS_TEXTURE_IMAGE           : TextureImage           (); break;
00373         case LWS_TEXTURE_FLAGS           : TextureFlags           (); break;
00374         case LWS_TEXTURE_AXIS            : TextureAxis            (); break;
00375         case LWS_TEXTURE_SIZE            : TextureSize            (); break;
00376         case LWS_TEXTURE_CENTER          : TextureCenter          (); break;
00377         case LWS_TEXTURE_FALLOFF         : TextureFalloff         (); break;
00378         case LWS_TEXTURE_VELOCITY        : TextureVelocity        (); break;
00379         case LWS_TEXTURE_AMPLITUDE       : TextureAmplitude       (); break;
00380         case LWS_TEXTURE_VALUE           : TextureValue           (); break;
00381         case LWS_TEXTURE_INT             : TextureInt             (); break;
00382         case LWS_TEXTURE_FLOAT           : TextureFloat           (); break;
00383 
00384         //  (for lights and cameras as well)
00385         case LWS_PIVOT_POSITION          : PivotPosition          (); break;
00386         case LWS_PARENT_ITEM             : ParentItem             (); break;
00387         case LWS_BEHAVIORS               : Behaviors              (); break;
00388         case LWS_NUM_CHANNELS            : NumChannels            (); break;
00389         case LWS_CHANNEL                 : Channel                (); break;
00390         case LWS_ENVELOPE                : Envelope               (); break;
00391         case LWS_KEY                     : Key                    (); break;
00392         case LWS_LOCKED_CHANNELS         : LockedChannels         (); break;
00393         case LWS_PARENT_OBJECT           : ParentObject           (); break;
00394         case LWS_TARGET_OBJECT           : TargetObject           (); break;
00395         case LWS_GOAL_OBJECT             : GoalObject             (); break;
00396         case LWS_SCHEMATIC_POSITION      : SchematicPosition      (); break;
00397 
00398         case LWS_MORPH_AMOUNT            : MorphAmount            (); break;
00399         case LWS_MORPH_TARGET            : MorphTarget            (); break;
00400         case LWS_MORPH_SURFACES          : MorphSurfaces          (); break;
00401 
00402         case LWS_USE_BONES_FROM          : UseBonesFrom           (); break;
00403         case LWS_BONE_FALLOFF_TYPE       : BoneFalloffType        (); break;
00404         case LWS_ADD_BONE                : AddBone                (); break;
00405         case LWS_BONE_NAME               : BoneName               (); break;
00406         case LWS_SHOW_BONE               : ShowBone               (); break;
00407         case LWS_BONE_ACTIVE             : BoneActive             (); break;
00408         case LWS_BONE_REST_POSITION      : BoneRestPosition       (); break;
00409         case LWS_BONE_REST_DIRECTION     : BoneRestDirection      (); break;
00410         case LWS_BONE_REST_LENGTH        : BoneRestLength         (); break;
00411         case LWS_BONE_STRENGTH           : BoneStrength           (); break;
00412         case LWS_SCALE_BONE_STRENGTH     : ScaleBoneStrength      (); break;
00413         case LWS_BONE_LIMITED_RANGE      : BoneLimitedRange       (); break;
00414         case LWS_BONE_MIN_RANGE          : BoneMinRange           (); break;
00415         case LWS_BONE_MAX_RANGE          : BoneMaxRange           (); break;
00416         case LWS_BONE_MOTION             : BoneMotion             (); break;
00417         case LWS_H_CONTROLLER            : HController            (); break;
00418         case LWS_P_CONTROLLER            : PController            (); break;
00419         case LWS_B_CONTROLLER            : BController            (); break;
00420         case LWS_H_LIMITS                : HLimits                (); break;
00421         case LWS_P_LIMITS                : PLimits                (); break;
00422         case LWS_B_LIMITS                : BLimits                (); break;
00423         case LWS_IK_ANCHOR               : IKAnchor               (); break;
00424 
00425         //  Lights - global
00426         case LWS_AMBIENT_COLOR           : AmbientColor           (); break;
00427         case LWS_AMBIENT_INTENSITY       : AmbientIntensity       (); break;
00428         case LWS_GLOBAL_FLARE_INTENSITY  : GlobalFlareIntensity   (); break;
00429         case LWS_ENABLE_LENS_FLARES      : EnableLensFlares       (); break;
00430         case LWS_ENABLE_SHADOW_MAPS      : EnableShadowMaps       (); break;
00431 
00432         //  Lights
00433         case LWS_ADD_LIGHT               : AddLight               (); break;
00434         case LWS_SHOW_LIGHT              : ShowLight              (); break;
00435         case LWS_LIGHT_NAME              : LightName              (); break;
00436         case LWS_LIGHT_MOTION            : LightMotion            (); break;
00437         case LWS_LIGHT_COLOR             : LightColor             (); break;
00438         case LWS_LIGHT_TYPE              : LightType              (); break;
00439         case LWS_LIGHT_FALLOFF_TYPE      : LightFalloffType       (); break;
00440         case LWS_LIGHT_RANGE             : LightRange             (); break;
00441         case LWS_LIGHT_CONE_ANGLE        : LightConeAngle         (); break;
00442         case LWS_LIGHT_EDGE_ANGLE        : LightEdgeAngle         (); break;
00443         case LWS_LIGHT_INTENSITY         : LightIntensity         (); break;
00444         case LWS_FALLOFF                 : Falloff                (); break;
00445         case LWS_AFFECT_CAUSTICS         : AffectCaustics         (); break;
00446         case LWS_AFFECT_DIFFUSE          : AffectDiffuse          (); break;
00447         case LWS_AFFECT_SPECULAR         : AffectSpecular         (); break;
00448         case LWS_AFFECT_OPEN_GL          : AffectOpenGL           (); break;
00449         case LWS_USE_CONE_ANGLE          : UseConeAngle           (); break;
00450         case LWS_LENS_FLARE              : LensFlare              (); break;
00451         case LWS_FLARE_INTENSITY         : FlareIntensity         (); break;
00452         case LWS_FLARE_DISSOLVE          : FlareDissolve          (); break;
00453         case LWS_LENS_FLARE_FADE         : LensFlareFade          (); break;
00454         case LWS_LENS_FLARE_OPTIONS      : LensFlareOptions       (); break;
00455         case LWS_FLARE_RAND_STREAK_INT   : FlareRandStreakInt     (); break;
00456         case LWS_FLARE_RAND_STREAK_DENS  : FlareRandStreakDens    (); break;
00457         case LWS_FLARE_RAND_STREAK_SHARP : FlareRandStreakSharp   (); break;
00458         case LWS_SHADOW_TYPE             : ShadowType             (); break;
00459         case LWS_SHADOW_CASTING          : ShadowCasting          (); break;
00460         case LWS_SHADOW_MAP_SIZE         : ShadowMapSize          (); break;
00461         case LWS_SHADOW_MAP_ANGLE        : ShadowMapAngle         (); break;
00462         case LWS_SHADOW_FUZZINESS        : ShadowFuzziness        (); break;
00463 
00464         //  Cameras
00465         case LWS_ADD_CAMERA              : AddCamera              (); break;
00466         case LWS_CAMERA_NAME             : CameraName             (); break;
00467         case LWS_SHOW_CAMERA             : ShowCamera             (); break;
00468         case LWS_CAMERA_MOTION           : CameraMotion           (); break;
00469         case LWS_ZOOM_FACTOR             : ZoomFactor             (); break;
00470         case LWS_MOTION_BLUR             : MotionBlur             (); break;
00471         case LWS_BLUR_LENGTH             : BlurLength             (); break;
00472         case LWS_DEPTH_OF_FIELD          : DepthofField           (); break;
00473         case LWS_FOCAL_DISTANCE          : FocalDistance          (); break;
00474         case LWS_LENS_F_STOP             : LensFStop              (); break;
00475 
00476         case LWS_RESOLUTION_MULTIPLIER   : ResolutionMultiplier   (); break;
00477         case LWS_RESOLUTION              : Resolution             (); break;
00478         case LWS_FRAME_SIZE              : FrameSize              (); break;
00479         case LWS_CUSTOM_SIZE             : CustomSize             (); break;
00480         case LWS_FILM_SIZE               : FilmSize               (); break;
00481         case LWS_NTSC_WIDE_SCREEN        : NTSCWidescreen         (); break;
00482         case LWS_PIXEL_ASPECT            : PixelAspect            (); break;
00483         case LWS_PIXEL_ASPECT_RATIO      : PixelAspectRatio       (); break;
00484         case LWS_CUSTOM_PIXEL_RATIO      : CustomPixelRatio       (); break;
00485         case LWS_LIMITED_REGION          : LimitedRegion          (); break;
00486         case LWS_MASK_POSITION           : MaskPosition           (); break;
00487         case LWS_APERTURE_HEIGHT         : ApertureHeight         (); break;
00488         case LWS_REGION_LIMITS           : RegionLimits           (); break;
00489         case LWS_SEGMENT_MEMORY          : SegmentMemory          (); break;
00490         case LWS_ANTI_ALIASING           : Antialiasing           (); break;
00491         case LWS_ENHANCED_AA             : EnhancedAA             (); break;
00492         case LWS_FILTER_TYPE             : FilterType             (); break;
00493         case LWS_ADAPTIVE_SAMPLING       : AdaptiveSampling       (); break;
00494         case LWS_ADAPTIVE_THRESHOLD      : AdaptiveThreshold      (); break;
00495         case LWS_FIELD_RENDERING         : FieldRendering         (); break;
00496         case LWS_REVERSE_FIELDS          : ReverseFields          (); break;
00497 
00498         //  Effects
00499         case LWS_BG_IMAGE                : BGImage                (); break;
00500         case LWS_FG_IMAGE                : FGImage                (); break;
00501         case LWS_FG_ALPHA_IMAGE          : FGAlphaImage           (); break;
00502         case LWS_FG_DISSOLVE             : FGDissolve             (); break;
00503         case LWS_FG_FADER_ALPHA_MODE     : FGFaderAlphaMode       (); break;
00504         case LWS_IMAGE_SEQUENCE_INFO     : ImageSequenceInfo      (); break;
00505         case LWS_FOREGROUND_KEY          : ForegroundKey          (); break;
00506         case LWS_LOW_CLIP_COLOR          : LowClipColor           (); break;
00507         case LWS_HIGH_CLIP_COLOR         : HighClipColor          (); break;
00508         case LWS_SOLID_BACKDROP          : SolidBackdrop          (); break;
00509         case LWS_BACKDROP_COLOR          : BackdropColor          (); break;
00510         case LWS_ZENITH_COLOR            : ZenithColor            (); break;
00511         case LWS_SKY_COLOR               : SkyColor               (); break;
00512         case LWS_GROUND_COLOR            : GroundColor            (); break;
00513         case LWS_NADIR_COLOR             : NadirColor             (); break;
00514         case LWS_SKY_SQUEEZE_AMOUNT      : SkySqueezeAmount       (); break;
00515         case LWS_GROUND_SQUEEZE_AMOUNT   : GroundSqueezeAmount    (); break;
00516         case LWS_FOG_TYPE                : FogType                (); break;
00517         case LWS_FOG_MIN_DIST            : FogMinDist             (); break;
00518         case LWS_FOG_MAX_DIST            : FogMaxDist             (); break;
00519         case LWS_FOG_MIN_AMOUNT          : FogMinAmount           (); break;
00520         case LWS_FOG_MAX_AMOUNT          : FogMaxAmount           (); break;
00521         case LWS_FOG_COLOR               : FogColor               (); break;
00522         case LWS_BACKDROP_FOG            : BackdropFog            (); break;
00523         case LWS_DITHER_INTENSITY        : DitherIntensity        (); break;
00524         case LWS_ANIMATED_DITHER         : AnimatedDither         (); break;
00525         case LWS_SATURATION              : Saturation             (); break;
00526         case LWS_GLOW_EFFECT             : GlowEffect             (); break;
00527         case LWS_GLOW_INTENSITY          : GlowIntensity          (); break;
00528         case LWS_GLOW_RADIUS             : GlowRadius             (); break;
00529 
00530         //  Render
00531         case LWS_RENDER_MODE             : RenderMode             (); break;
00532         case LWS_RAY_TRACE_EFFECTS       : RayTraceEffects        (); break;
00533         case LWS_RAY_TRACE_OPTIMIZATION  : RayTraceOptimization   (); break;
00534         case LWS_RAY_RECURSION_LIMIT     : RayRecursionLimit      (); break;
00535         case LWS_DATA_OVERLAY            : DataOverlay            (); break;
00536         case LWS_DATA_OVERLAY_LABEL      : DataOverlayLabel       (); break;
00537         case LWS_OUTPUT_FILENAME_FORMAT  : OutputFilenameFormat   (); break;
00538         case LWS_SAVE_RGB                : SaveRGB                (); break;
00539         case LWS_SAVE_ALPHA              : SaveAlpha              (); break;
00540         case LWS_SAVE_ANIM_FILE_NAME     : SaveANIMFileName       (); break;
00541         case LWS_LOCK_ANIM_PALETTE_FRAME : LockANIMPaletteFrame   (); break;
00542         case LWS_BEGIN_ANIM_LOOP_FRAME   : BeginANIMLoopFrame     (); break;
00543         case LWS_SAVE_RGB_IMAGES_PREFIX  : SaveRGBImagesPrefix    (); break;
00544         case LWS_RGB_IMAGE_FORMAT        : RGBImageFormat         (); break;
00545         case LWS_SAVE_ALPHA_IMAGES_PREFIX: SaveAlphaImagesPrefix  (); break;
00546         case LWS_ALPHA_IMAGE_FORMAT      : AlphaImageFormat       (); break;
00547         case LWS_ALPHA_MODE              : AlphaMode              (); break;
00548         case LWS_SAVE_FRAMESTORES_COMMENT: SaveFramestoresComment (); break;
00549         case LWS_FULL_SCENE_PARAM_EVAL   : FullSceneParamEval     (); break;
00550 
00551         //  Layout Options
00552         case LWS_VIEW_CONFIGURATION      : ViewConfiguration      (); break;
00553         case LWS_DEFINE_VIEW             : DefineView             (); break;
00554         case LWS_VIEW_MODE               : ViewMode               (); break;
00555         case LWS_VIEW_AIMPOINT           : ViewAimpoint           (); break;
00556         case LWS_VIEW_ROTATION           : ViewRotation           (); break;
00557         case LWS_VIEW_ZOOM_FACTOR        : ViewZoomFactor         (); break;
00558 
00559         case LWS_LAYOUT_GRID             : LayoutGrid             (); break;
00560         case LWS_GRID_NUMBER             : GridNumber             (); break;
00561         case LWS_GRID_SIZE               : GridSize               (); break;
00562         case LWS_CAMERA_VIEW_BG          : CameraViewBG           (); break;
00563         case LWS_SHOW_MOTION_PATH        : ShowMotionPath         (); break;
00564         case LWS_SHOW_SAFE_AREAS         : ShowSafeAreas          (); break;
00565         case LWS_SHOW_BG_IMAGE           : ShowBGImage            (); break;
00566         case LWS_SHOW_FOG_RADIUS         : ShowFogRadius          (); break;
00567         case LWS_SHOW_FOG_EFFECT         : ShowFogEffect          (); break;
00568         case LWS_SHOW_REDRAW             : ShowRedraw             (); break;
00569         case LWS_SHOW_FIELD_CHART        : ShowFieldChart         (); break;
00570 
00571         case LWS_CURRENT_OBJECT          : CurrentObject          (); break;
00572         case LWS_CURRENT_LIGHT           : CurrentLight           (); break;
00573         case LWS_CURRENT_CAMERA          : CurrentCamera          (); break;
00574         case LWS_MAP_EDITOR_DATA         : GraphEditorData        (); break;
00575         case LWS_GRAPH_EDITOR_FAVORITES  : GraphEditorFavorites   (); break;
00576 
00577         case LWS_EOF:
00578             dmsg( M_LWS, "LWS_EOF" );
00579             cont = false;
00580             break;
00581 
00582         case LWS_ERROR:
00583             dmsg( M_LWS, "LWS_ERROR" );
00584             cont = false;
00585             break;
00586 
00587         case LWS_UNKNOWN:
00588             dmsg( M_LWS, "LWS_UNKNOWN" );
00589             break;
00590 
00591         default:
00592             dmsg( M_LWS, "default case" );
00593             break;
00594         }
00595     }
00596     dmsg( M_LWS, "Reading file %s done", fname );
00597 }
00598 
00599 
00600 };  //  namespace Imports
00601 };  //  namespace Teddy
00602 
00603 
00604 #if 0
00605 
00606 //  Compute Hermite spline coeficients for t, where 0 <= t <= 1.
00607 static void Hermite (
00608     double  t,
00609     double *h1,
00610     double *h2,
00611     double *h3,
00612     double *h4
00613 ){
00614     double t2;
00615     double t3;
00616     double z;
00617 
00618     t2 = t * t;
00619     t3 = t * t2;
00620     z  = 3.0 * t2 - t3 - t3;
00621 
00622     *h1 = 1.0 - z;
00623     *h2 = z;
00624     *h3 = t3 - t2 - t2 + t;
00625     *h4 = t3 - t2;
00626 }
00627 
00628 
00629 //  Compute the motion channel vector for the given step.  Step can be
00630 //  fractional but values correspond to frames.
00631 void MotionCalcStep (
00632     Motion  *mot,
00633     ChanVec  resVec,
00634     double   step
00635 ){
00636     KeyFrame *key0, *key1;
00637     double    t, h1, h2, h3, h4, res, d10;
00638     double    dd0a, dd0b, ds1a, ds1b;
00639     double    adj0, adj1, dd0, ds1;
00640     int       i, tlength;
00641 
00642     //  If there is but one key, the values are constant.
00643     if( mot->keys == 1 ){
00644         for( i=0; i<9; i++ ){
00645             resVec[i] = mot->keylist[0].cv[i];
00646         }
00647         return;
00648     }
00649 
00650     if( step > mot->steps ){
00651         step = mot->steps;
00652     }
00653 
00654     //  Get keyframe pair to evaluate.  This should be within the range
00655     //  of the motion or this will raise an illegal access.
00656     key0 = mot->keylist;
00657     while( step > key0[1].step ){
00658         key0 ++;
00659     }
00660     key1  = key0 + 1;
00661     step -= key0->step;
00662 
00663     // Get tween length and fractional tween position.
00664     tlength = key1->step - key0->step;
00665     t       = step / tlength;
00666 
00667     //  Precompute spline coefficients.
00668     if( !key1->linear ){
00669         Hermite (t, &h1, &h2, &h3, &h4);
00670         dd0a = (1.0 - key0->tens) * (1.0 + key0->cont) * (1.0 + key0->bias);
00671         dd0b = (1.0 - key0->tens) * (1.0 - key0->cont) * (1.0 - key0->bias);
00672         ds1a = (1.0 - key1->tens) * (1.0 - key1->cont) * (1.0 + key1->bias);
00673         ds1b = (1.0 - key1->tens) * (1.0 + key1->cont) * (1.0 - key1->bias);
00674 
00675         if( key0->step != 0 ){
00676             adj0 = tlength / (double)(key1->step - (key0-1)->step);
00677         }
00678         if( key1->step != mot->steps ){
00679             adj1 = tlength / (double)((key1+1)->step - key0->step);
00680         }
00681     }
00682 
00683     //  Compute the channel components.
00684     for( i=0; i<NUM_CHAN; i++ ){
00685         d10 = key1->cv[i] - key0->cv[i];
00686 
00687         if( !key1->linear ){
00688             if( key0->step == 0){
00689                 dd0 = .5 * (dd0a + dd0b) * d10;
00690             }else{
00691                 dd0 = adj0 * (dd0a * (key0->cv[i] - (key0-1)->cv[i]) + dd0b * d10);
00692             }
00693 
00694             if( key1->step == mot->steps ){
00695                 ds1 = .5 * (ds1a + ds1b) * d10;
00696             }else{
00697                 ds1 = adj1 * (ds1a * d10 + ds1b * ((key1+1)->cv[i] - key1->cv[i]));
00698             }
00699 
00700             res = key0->cv[i] * h1 + key1->cv[i] * h2 + dd0 * h3 + ds1 * h4;
00701         }else{
00702             res = key0->cv[i] + t * d10;
00703         }
00704 
00705         resVec[i] = res;
00706     }
00707 }
00708 
00709 #endif  //  0
00710 
00711 
00712 #endif  //  TEDDY_INCLUDE_LW_SCENE