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

LWLight.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: LWLight.cpp,v 1.1 2002/02/16 12:41:39 tksuoran Exp $
00022 */
00023 
00024 
00025 #include "Teddy/TeddyConfig.h"
00026 #if defined( TEDDY_INCLUDE_LW_SCENE )
00027 
00028 
00029 #include "Teddy/Imports/LWLight.h"
00030 #include "Teddy/Imports/LWMotion.h"
00031 #include "Teddy/Imports/LWModel.h"
00032 #include "Teddy/Imports/LWMotion.h"
00033 #include "Teddy/Imports/LWChannelEnvelope.h"
00034 #include "Teddy/SysSupport/Messages.h"
00035 using namespace Teddy::Graphics;
00036 using namespace Teddy::Materials;
00037 using namespace Teddy::SysSupport;
00038 
00039 
00040 namespace Teddy   {
00041 namespace Imports {
00042 
00043 
00044 LWLight::LWLight():LWInstance(){
00045     light         = NULL;
00046     ambient_color = Color::BLACK;
00047     amb_intensity = 0.0;
00048 }
00049 
00050 void LWLight::setColor( double r, double g, double b ){
00051     this->color = Color( r, g, b );
00052     dmsg( M_LWS, "Light color %f, %f, %f", r, g, b );
00053     
00054 }
00055 
00056 void LWLight::setType                ( int    type                    ){ this->type                    = type;                    }
00057 void LWLight::setFalloffType         ( int    falloff_type            ){ this->falloff_type            = falloff_type;            }
00058 void LWLight::setRange               ( double range                   ){ this->range                   = range;                   }
00059 void LWLight::setConeAngle           ( double cone_angle              ){ this->cone_angle              = cone_angle;              }
00060 void LWLight::setEdgeAngle           ( double edge_angle              ){ this->edge_angle              = edge_angle;              }
00061 void LWLight::setIntensity           ( double intensity               ){ this->intensity               = intensity;               }
00062 void LWLight::setFalloff             ( double falloff                 ){ this->falloff                 = falloff;                 }
00063 void LWLight::setAffectCaustics      ( int    affect_caustics         ){ this->affect_caustics         = affect_caustics;         }
00064 void LWLight::setAffectDiffuse       ( int    affect_diffuse          ){ this->affect_diffuse          = affect_diffuse ;         }
00065 void LWLight::setAffectSpecular      ( int    affect_specular         ){ this->affect_specular         = affect_specular;         }
00066 void LWLight::setAffectOpenGL        ( int    affect_opengl           ){ this->affect_opengl           = affect_opengl  ;         }
00067 void LWLight::setUseConeAngle        ( int    use_cone_angle          ){ this->use_cone_angle          = use_cone_angle         ; }
00068 void LWLight::setLensFlare           ( int    lens_flare              ){ this->lens_flare              = lens_flare             ; }
00069 void LWLight::setFlareIntensity      ( double flare_intensity         ){ this->flare_intensity         = flare_intensity;         }
00070 void LWLight::setFlareDissolve       ( double flare_dissolve          ){ this->flare_dissolve          = flare_dissolve ;         }
00071 void LWLight::setLensFlareFade       ( int    lens_flare_fade         ){ this->lens_flare_fade         = lens_flare_fade;         }
00072 void LWLight::setLensFlareOptions    ( int    lens_flare_options      ){ this->lens_flare_options      = lens_flare_options;      }
00073 void LWLight::setFlareRandStreakInt  ( double flare_rand_streak_int   ){ this->flare_rand_streak_int   = flare_rand_streak_int;   }
00074 void LWLight::setFlareRandStreakDens ( double flare_rand_streak_dens  ){ this->flare_rand_streak_dens  = flare_rand_streak_dens;  }
00075 void LWLight::setFlareRandStreakSharp( double flare_rand_streak_sharp ){ this->flare_rand_streak_sharp = flare_rand_streak_sharp; }
00076 void LWLight::setShadowType          ( int    shadow_type             ){ this->shadow_type             = shadow_type            ; }
00077 void LWLight::setShadowCasting       ( int    shadow_casting          ){ this->shadow_casting          = shadow_casting         ; }
00078 void LWLight::setShadowMapSize       ( int    shadow_map_size         ){ this->shadow_map_size         = shadow_map_size        ; }
00079 void LWLight::setShadowMapAngle      ( double shadow_map_angle        ){ this->shadow_map_angle        = shadow_map_angle       ; }
00080 void LWLight::setShadowFuzziness     ( double shadow_fuzziness        ){ this->shadow_fuzziness        = shadow_fuzziness       ; }
00081 
00082 
00083 Light *LWLight::getLight(){
00084     return this->light;
00085 }
00086 
00087 
00088 void LWLight::genLight(){
00089     light = new Light( getModelName() );
00090     dmsg( M_LWS, "genLight color     % 8.4f, % 8.4f, % 8.4f", color.rgba[0], color.rgba[1], color.rgba[2] );
00091 
00092     switch( type ){
00093     case 0: 
00094         light->setType( Light::TYPE_DIRECTIONAL ); break;  // distant
00095     case 1: 
00096         light->setType( Light::TYPE_POSITIONAL  ); break;  // point
00097     case 2: 
00098         break;  // spot
00099     case 3: 
00100         break;  // linear
00101     case 4: 
00102         break;  // area
00103     default: 
00104         break; //
00105     }
00106 
00107     // vihreä torni
00108     //   0, 65, 33  LW
00109     //   0,113, 57  Teddy
00110 
00111     // valkea kuningas
00112     //  49, 48, 49  LW
00113     //  90, 93, 90  Teddy
00114 
00115     light->setAmbient ( Color::BLACK );
00116     light->setDiffuse ( color );
00117     light->setSpecular( Color::WHITE );
00118     //light->setAttenuation  ( const float constant, const float linear, const float quadratic );
00119     //light->setSpotCutOff   ( const float cutoff_angle );
00120     //light->setSpotExponent ( const float exponent );
00121     //light->setSpotDirection( Teddy::Maths::Vector spot_direction );
00122     light->enable     ();
00123 }
00124 
00125 
00126 };  //  namespace Imports
00127 };  //  namespace Teddy
00128 
00129 
00130 #endif  //  TEDDY_INCLUDE_LW_SCENE