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.h,v 1.3 2002/03/12 10:46:06 tksuoran Exp $ 00022 */ 00023 00024 00025 #ifndef TEDDY__IMPORTS__LW_SCENE_PARSER_H 00026 #define TEDDY__IMPORTS__LW_SCENE_PARSER_H 00027 00028 00029 #include "Teddy/TeddyConfig.h" 00030 #if defined( TEDDY_INCLUDE_LW_SCENE ) 00031 00032 00033 #include "Teddy/Graphics/Color.h" 00034 #include "Teddy/Imports/LWSceneTokens.h" 00035 #include "Teddy/MixIn/Options.h" 00036 #include "Teddy/MixIn/Tick.h" 00037 #include "Teddy/Models/Grid.h" 00038 #include "Teddy/Scenes/Scene.h" 00039 #include "Teddy/SysSupport/StdMap.h" 00040 00041 00042 namespace Teddy { 00043 namespace Imports { 00044 00045 00046 class LWBone; 00047 class LWCamera; 00048 class LWChannelEnvelope; 00049 class LWInstance; 00050 class LWLight; 00051 class LWMotion; 00052 class LWSceneFile; 00053 00054 00055 /* 00056 struct less_str { 00057 bool operator()( char *a, char *b ) const { 00058 if( strcmp(a,b) < 0 ){ 00059 return true; 00060 }else{ 00061 return false; 00062 } 00063 } 00064 };*/ 00065 00066 00067 typedef map<int, LWInstance*> int_to_LWInstance; 00068 typedef map<int, LWLight *> int_to_LWLight; 00069 typedef map<int, LWCamera *> int_to_LWCamera; 00070 00071 00080 class LWSceneParser : public Teddy::MixIn::Tick { 00081 public: 00082 static const int OPT_GRID; 00083 static const int OPT_DARK_GRID; 00084 00085 public: 00086 LWSceneParser( Teddy::Scenes::Scene *scene, Teddy::Scenes::Camera *camera, const char *fname, Teddy::MixIn::Options options ); 00087 00088 void reset (); 00089 void play (); 00090 void stop (); 00091 void update (); 00092 void setMultiplier( float multiplier ); 00093 float getMultiplier(); 00094 float getTime (); 00095 virtual void tick (); 00096 Teddy::Graphics::Color getZenithColor(); 00097 Teddy::Graphics::Color getSkyColor (); 00098 Teddy::Graphics::Color getGroundColor(); 00099 Teddy::Graphics::Color getNadirColor (); 00100 Teddy::Models::Grid *getGrid (); 00101 00102 protected: 00103 00104 protected: 00105 void readFile ( const char *fname ); 00106 void postProcess(); 00107 00108 protected: 00109 // Playback 00110 bool playing; 00111 float multiplier; 00112 float stop_time; 00113 float start_time; 00114 float last_used_time; 00115 00116 // Parsing 00117 Teddy::MixIn::Options options; 00118 LWSceneFile *file; 00119 int lws_version; 00120 Teddy::Models::Grid *grid; 00121 00122 // Scenes 00123 int first_frame; 00124 int last_frame; 00125 int frame_step; 00126 int frames_per_second; 00127 int preview_first_frame; 00128 int preview_last_frame; 00129 int preview_frame_step; 00130 int current_frame; 00131 00132 // Objects 00133 Teddy::Scenes::Scene *scene; 00134 Teddy::Scenes::Camera *camera; 00135 LWInstance *current_object; // Current object 00136 LWMotion *current_motion; // Current motion for current object 00137 int num_channels; // Number of channels in current motion 00138 int read_channels; // Number of channels processed 00139 LWChannelEnvelope *current_channel_envelope; // Current channel envelope of current motion 00140 int num_channel_keys; // Number of keys in current channel envelope 00141 int read_channel_keys; // Number of channel keys processed 00142 LWBone *current_bone; // Current bone 00143 00144 void resolveParent( LWInstance *object ); 00145 00146 // Lights - global 00147 Teddy::Graphics::Color ambient_color; 00148 double amb_intensity; // envelope not yet supported 00149 bool enable_lens_flare; // default true 00150 bool enable_shadow_maps; // default true 00151 00152 // Lights 00153 LWLight *current_light; 00154 00155 // Cameras 00156 LWCamera *current_camera; 00157 00158 // Options (Layout) 00159 int grid_number; 00160 float grid_size; 00161 00162 // Effects 00163 Teddy::Graphics::Color zenith_color; 00164 Teddy::Graphics::Color sky_color; 00165 Teddy::Graphics::Color ground_color; 00166 Teddy::Graphics::Color nadir_color; 00167 00168 // Containers 00169 int next_object; 00170 int next_light; 00171 int next_camera; 00172 int_to_LWInstance objects; 00173 int_to_LWLight lights; 00174 int_to_LWCamera cameras; 00175 00176 protected: 00177 // Scenes 00178 void LWSC(); 00179 void FirstFrame(); 00180 void LastFrame(); 00181 void FrameStep(); 00182 void FramesPerSecond(); 00183 void PreviewFirstFrame(); 00184 void PreviewLastFrame(); 00185 void PreviewFrameStep(); 00186 void CurrentFrame(); 00187 void Plugin(); 00188 void EndPlugin(); 00189 00190 // Objects 00191 void AddNullObject(); 00192 void LoadObject(); 00193 void LoadObjectLayer(); 00194 void ShowObject(); 00195 void ObjectMotion(); 00196 void ObjectDissolve(); 00197 void SubdivisionOrder(); 00198 void SubPatchLevel(); 00199 void ShadowOptions(); 00200 void DistanceDissolve(); 00201 void MaxDissolveDistance(); 00202 void ParticleSize(); 00203 void LineSize(); 00204 void PolygonSize(); 00205 void UnseenByRays(); 00206 void UnseenByCamera(); 00207 void UnaffectedByFog(); 00208 void AffectedByFog(); 00209 void ExcludeLight(); 00210 void ObjPolygonEdges(); 00211 void ObjEdgeColor(); 00212 void PolygonEdgeFlags(); 00213 void PolygonEdgeThickness(); 00214 void PolygonEdgesZScale(); 00215 void EdgeNominalDistance(); 00216 00217 void DisplacementMap(); 00218 void ClipMap(); 00219 void TextureImage(); 00220 void TextureFlags(); 00221 void TextureAxis(); 00222 void TextureSize(); 00223 void TextureCenter(); 00224 void TextureFalloff(); 00225 void TextureVelocity(); 00226 void TextureAmplitude(); 00227 void TextureValue(); 00228 void TextureInt(); 00229 void TextureFloat(); 00230 00231 // (for lights and 00232 void PivotPosition(); 00233 void ParentItem(); 00234 void Behaviors(); 00235 void NumChannels(); 00236 void Channel(); 00237 void Envelope(); 00238 void Key(); 00239 void LockedChannels(); 00240 void ParentObject(); 00241 void TargetObject(); 00242 void GoalObject(); 00243 void SchematicPosition(); 00244 00245 void MorphAmount(); 00246 void MorphTarget(); 00247 void MorphSurfaces(); 00248 00249 void UseBonesFrom(); 00250 void BoneFalloffType(); 00251 void AddBone(); 00252 void BoneName(); 00253 void ShowBone(); 00254 void BoneActive(); 00255 void BoneRestPosition(); 00256 void BoneRestDirection(); 00257 void BoneRestLength(); 00258 void BoneStrength(); 00259 void ScaleBoneStrength(); 00260 void BoneLimitedRange(); 00261 void BoneMinRange(); 00262 void BoneMaxRange(); 00263 void BoneMotion(); 00264 void HController(); 00265 void PController(); 00266 void BController(); 00267 void HLimits(); 00268 void PLimits(); 00269 void BLimits(); 00270 void IKAnchor(); 00271 00272 // Lights - global 00273 void AmbientColor(); 00274 void AmbIntensity(); 00275 void AmbientIntensity(); 00276 void GlobalFlareIntensity(); 00277 void EnableLensFlares(); 00278 void EnableShadowMaps(); 00279 00280 // Lights 00281 void AddLight(); 00282 void ShowLight(); 00283 void LightName(); 00284 void LightMotion(); 00285 void LightColor(); 00286 void LightType(); 00287 void LightFalloffType(); 00288 void LightRange(); 00289 void LightConeAngle(); 00290 void LightEdgeAngle(); 00291 void LightIntensity(); 00292 void Falloff(); 00293 void AffectCaustics(); 00294 void AffectDiffuse(); 00295 void AffectSpecular(); 00296 void AffectOpenGL(); 00297 void ConeAngle(); 00298 void EdgeAngle(); 00299 void UseConeAngle(); 00300 void LensFlare(); 00301 void FlareIntensity(); 00302 void FlareDissolve(); 00303 void LensFlareFade(); 00304 void LensFlareOptions(); 00305 void FlareRandStreakInt(); 00306 void FlareRandStreakDens(); 00307 void FlareRandStreakSharp(); 00308 void ShadowType(); 00309 void ShadowCasting(); 00310 void ShadowMapSize(); 00311 void ShadowMapAngle(); 00312 void ShadowFuzziness(); 00313 00314 // Cameras 00315 void AddCamera(); 00316 void CameraName(); 00317 void ShowCamera(); 00318 void CameraMotion(); 00319 void ZoomFactor(); 00320 void MotionBlur(); 00321 void BlurLength(); 00322 void DepthofField(); 00323 void FocalDistance(); 00324 void LensFStop(); 00325 00326 void ResolutionMultiplier(); 00327 void Resolution(); 00328 void FrameSize(); 00329 void CustomSize(); 00330 void FilmSize(); 00331 void NTSCWidescreen(); 00332 void PixelAspect(); 00333 void PixelAspectRatio(); 00334 void CustomPixelRatio(); 00335 void LimitedRegion(); 00336 void MaskPosition(); 00337 void ApertureHeight(); 00338 void RegionLimits(); 00339 void SegmentMemory(); 00340 void Antialiasing(); 00341 void EnhancedAA(); 00342 void FilterType(); 00343 void AdaptiveSampling(); 00344 void AdaptiveThreshold(); 00345 void FieldRendering(); 00346 void ReverseFields(); 00347 00348 // Effects 00349 void BGImage(); 00350 void FGImage(); 00351 void FGAlphaImage(); 00352 void FGDissolve(); 00353 void FGFaderAlphaMode(); 00354 void ImageSequenceInfo(); 00355 void ForegroundKey(); 00356 void LowClipColor(); 00357 void HighClipColor(); 00358 void SolidBackdrop(); 00359 void BackdropColor(); 00360 void ZenithColor(); 00361 void SkyColor(); 00362 void GroundColor(); 00363 void NadirColor(); 00364 void SkySqueezeAmount(); 00365 void GroundSqueezeAmount(); 00366 void FogType(); 00367 void FogMinDist(); 00368 void FogMaxDist(); 00369 void FogMinAmount(); 00370 void FogMaxAmount(); 00371 void FogColor(); 00372 void BackdropFog(); 00373 void DitherIntensity(); 00374 void AnimatedDither(); 00375 void Saturation(); 00376 void GlowEffect(); 00377 void GlowIntensity(); 00378 void GlowRadius(); 00379 00380 // Render 00381 void RenderMode(); 00382 void RayTraceEffects(); 00383 void RayTraceOptimization(); 00384 void RayRecursionLimit(); 00385 void DataOverlay(); 00386 void DataOverlayLabel(); 00387 void OutputFilenameFormat(); 00388 void SaveRGB(); 00389 void SaveAlpha(); 00390 void SaveANIMFileName(); 00391 void LockANIMPaletteFrame(); 00392 void BeginANIMLoopFrame(); 00393 void SaveRGBImagesPrefix(); 00394 void RGBImageFormat(); 00395 void SaveAlphaImagesPrefix(); 00396 void AlphaImageFormat(); 00397 void AlphaMode(); 00398 void SaveFramestoresComment(); 00399 void FullSceneParamEval(); 00400 00401 // Layout Options 00402 void ViewConfiguration(); 00403 void DefineView(); 00404 void ViewMode(); 00405 void ViewAimpoint(); 00406 void ViewRotation(); 00407 void ViewZoomFactor(); 00408 00409 void LayoutGrid(); 00410 void GridNumber(); 00411 void GridSize(); 00412 void CameraViewBG(); 00413 void ShowMotionPath(); 00414 void ShowSafeAreas(); 00415 void ShowBGImage(); 00416 void ShowFogRadius(); 00417 void ShowFogEffect(); 00418 void ShowRedraw(); 00419 void ShowFieldChart(); 00420 00421 void CurrentObject(); 00422 void CurrentLight(); 00423 void CurrentCamera(); 00424 void GraphEditorData(); 00425 void GraphEditorFavorites(); 00426 }; 00427 00428 00429 }; // namespace Imports 00430 }; // namespace Teddy 00431 00432 00433 #endif // TEDDY_INCLUDE_LW_SCENE 00434 #endif // TEDDY__IMPORTS__LW_SCENE_PARSER_H 00435