# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

flare_shape.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000, 2001 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #ifndef NL_FLARE_SHAPE_H
00027 #define NL_FLARE_SHAPE_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 #include "nel/misc/class_id.h"
00031 #include "nel/3d/animation_time.h"
00032 #include "3d/shape.h"
00033 #include "3d/texture.h"
00034 #include "3d/track.h"
00035 
00036 
00037 
00038 namespace NL3D {
00039 
00040 
00041 // class id for flares
00042 const NLMISC::CClassId FlareModelClassId =  NLMISC::CClassId(0x6d674c32, 0x53b961a0);
00043 
00044 // max number of flares
00045 const uint MaxFlareNum= 10;
00046 
00053 class CFlareShape : public IShape
00054 {
00055 public:
00056         NLMISC_DECLARE_CLASS(CFlareShape);
00057 
00059 
00060 
00061                 CFlareShape();
00062 
00064                 void serial(NLMISC::IStream &f) throw(NLMISC::EStream);
00066 
00067 
00069         virtual CTransformShape         *createInstance(CScene &scene);
00070 
00072         virtual bool                            clip(const std::vector<CPlane>  &pyramid, const CMatrix &worldMatrix);
00073 
00074 
00076         virtual void                            render(IDriver *drv, CTransformShape *trans, bool opaquePass) {}
00077 
00079         virtual void                            getAABBox(NLMISC::CAABBox &bbox) const;
00080 
00082         virtual float                           getNumTriangles (float distance);
00083 
00085         virtual void                            flushTextures (IDriver &driver);
00086 
00091         void                                            setTexture(uint index, ITexture *tex) 
00092         { 
00093                 nlassert(index < MaxFlareNum);
00094                 _Tex[index] = tex; 
00095         }
00096 
00100         ITexture                                        *getTexture(uint index) 
00101         { 
00102                 nlassert(index < MaxFlareNum);
00103                 return _Tex[index];
00104         }
00105 
00107         const ITexture                          *getTexture(uint index) const 
00108         { 
00109                 nlassert(index < MaxFlareNum);
00110                 return _Tex[index]; 
00111         }
00112 
00116         void                                            setSize(uint index, float size) 
00117         { 
00118                 nlassert(index < MaxFlareNum);
00119                 _Size[index]  = size; 
00120         }
00121 
00125         float                                           getSize(uint index) const 
00126         { 
00127                 return _Size[index]; 
00128         }
00129 
00134         void                                            setRelativePos(uint index, float pos)
00135         {
00136                 nlassert(index < MaxFlareNum);
00137                 _Pos[index] = pos;
00138         }
00139 
00141         float                                           getRelativePos(uint index) const
00142         {
00143                 nlassert(index < MaxFlareNum);
00144                 return _Pos[index];
00145         }
00146 
00148         void                                            setColor(NLMISC::CRGBA col) 
00149         {               
00150                 _Color = col; 
00151         }
00152 
00154         NLMISC::CRGBA                           getColor(void) const 
00155         { 
00156                 return _Color; 
00157         }
00158 
00160         void                                            setFlareSpacing(float spacing)
00161         {
00162                 _Spacing = spacing;
00163         }
00164 
00168         float                                           getFlareSpacing(void) const
00169         {
00170                 return _Spacing;
00171         }
00172 
00174         void                                            setPersistence(TAnimationTime persistence) 
00175         {       
00176                 _Persistence = persistence; 
00177         }
00178 
00182         TAnimationTime                          getPersistence(void) const 
00183         { 
00184                 return _Persistence; 
00185         }
00186 
00187 
00189         void                                            setAttenuable(bool enable = true)       { _Attenuable = enable; }
00190 
00192         bool                                            getAttenuable(void) const                       { return _Attenuable;   }
00193 
00195         void                                            setAttenuationRange(float range)    { _AttenuationRange = range; }
00196 
00198         float                                           getAttenuationRange(void) const         { return _AttenuationRange; }
00199 
00200 
00202         void                                            setFirstFlareKeepSize(bool enable = true) { _FirstFlareKeepSize = enable; }
00203 
00205         bool                                            getFirstFlareKeepSize(void) const                 { return _FirstFlareKeepSize; }
00206 
00208         void                                            enableDazzle(bool enable = true)                  { _DazzleEnabled = enable; }
00209         
00211         bool                                            hasDazzle(void) const   {  return _DazzleEnabled; }
00212 
00216         void                                            setDazzleColor(NLMISC::CRGBA col) { _DazzleColor = col; }
00217 
00221         NLMISC::CRGBA                           getDazzleColor(void) const { return _DazzleColor; }
00222 
00227         void                                            setDazzleAttenuationRange(float range) { _DazzleAttenuationRange = range; }
00228 
00230         float                                           getDazzleAttenuationRange(void) const { return _DazzleAttenuationRange; }
00231 
00235         void                                            setMaxViewDist(float dist) { _MaxViewDist = dist; }
00236 
00237 
00239         float                                           getMaxViewDist(void) const { return _MaxViewDist; }
00240 
00244         void                                            setMaxViewDistRatio(float ratio) { _MaxViewDistRatio = ratio; }
00245 
00247         float                                           getMaxViewDistRatio(void) const  { return  _MaxViewDistRatio; }
00248 
00253         void                                            setFlareAtInfiniteDist(bool enabled = true) { _InfiniteDist = enabled; }
00254 
00256         bool                                            getFlareAtInfiniteDist(void) const                      { return _InfiniteDist; }
00257 
00259         CTrackDefaultVector                     _DefaultPos;
00260 
00261 
00263         // @{
00264         CTrackDefaultVector*    getDefaultPos ()                {return &_DefaultPos;}
00265         // @}
00266 
00267 
00268 protected:
00269         friend class CFlareModel;       
00270         NLMISC::CSmartPtr<ITexture> _Tex[MaxFlareNum];
00271         NLMISC::CRGBA                           _Color;
00272         NLMISC::CRGBA                           _DazzleColor;
00273         float                                           _Size[MaxFlareNum];
00274         float                                           _Pos[MaxFlareNum];
00275         TAnimationTime                          _Persistence;
00276         float                                           _Spacing;
00277         bool                                        _Attenuable;
00278         float                                       _AttenuationRange;
00279         bool                                            _FirstFlareKeepSize;
00280         bool                                            _DazzleEnabled;
00281         float                                           _DazzleAttenuationRange;
00282         float                                           _MaxViewDist;
00283         float                                           _MaxViewDistRatio;                              
00284         bool                                            _InfiniteDist;
00285 };
00286 
00287 
00288 } // NL3D
00289 
00290 
00291 #endif // NL_FLARE_SHAPE_H
00292 
00293 /* End of flare_shape.h */