ps_fan_light.h

Go to the documentation of this file.
00001 
00005 /* Copyright, 2001 Nevrax Ltd.
00006  *
00007  * This file is part of NEVRAX NEL.
00008  * NEVRAX NEL is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2, or (at your option)
00011  * any later version.
00012 
00013  * NEVRAX NEL is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * General Public License for more details.
00017 
00018  * You should have received a copy of the GNU General Public License
00019  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00020  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00021  * MA 02111-1307, USA.
00022  */
00023 
00024 #ifndef NL_PS_FAN_LIGHT_H
00025 #define NL_PS_FAN_LIGHT_H
00026 
00027 #include "nel/3d/ps_particle_basic.h"
00028 #include "nel/3d/vertex_buffer.h"
00029 #include "nel/3d/index_buffer.h"
00030 
00031 #include <vector>
00032 
00033 
00034 namespace NL3D
00035 {
00036 
00037 
00040 
00044 class CPSFanLight : public CPSParticle, public CPSColoredParticle
00045                   , public CPSSizedParticle, public CPSRotated2DParticle
00046                   , public CPSMaterial, public CPSTexturedParticleNoAnim
00047 {
00048 public:
00049     NLMISC_DECLARE_CLASS(CPSFanLight);
00050     virtual bool        completeBBox(NLMISC::CAABBox &box) const;
00052 
00053 
00054     CPSFanLight(uint32 nbFans = 7);
00056     ~CPSFanLight();
00057     void                serial(NLMISC::IStream &f) throw(NLMISC::EStream);
00059 
00060     // Set the number of fans used for drawing (minimum is 3, maximum is 128)
00061     void                setNbFans(uint32 nbFans);
00062 
00067     void                setPhaseSmoothness(uint32 smoothNess)
00068     {
00069         nlassert(smoothNess < 32);
00070         _PhaseSmoothness = smoothNess;
00071     }
00072 
00074     uint32              getPhaseSmoothness(void) const { return _PhaseSmoothness;}
00075 
00077     void                setMoveIntensity(float intensity) { _MoveIntensity = intensity; }
00078 
00080     float               getMoveIntensity(void) const      { return _MoveIntensity; }
00081 
00082     // Get the number of fans used for drawing
00083     uint32              getNbFans(void) const
00084     {
00085         return _NbFans;
00086     }
00087 
00092     void                setPhaseSpeed(float multiplier);
00093 
00095     float               getPhaseSpeed(void) const { return _PhaseSpeed / 256.0f; }
00096 
00097     // update the material and the vb so that they match the color scheme. Inherited from CPSColoredParticle
00098     virtual void        updateMatAndVbForColor(void);
00099 
00100 
00102     static void         initFanLightPrecalc(void);
00103 
00105     virtual bool        hasTransparentFaces(void);
00106 
00108     virtual bool        hasOpaqueFaces(void);
00109 
00110 
00112     virtual uint32      getNumWantedTris() const;
00113 
00115     void setTexture(CSmartPtr<ITexture> tex)
00116     {
00117         _Tex = tex;
00118     }
00119 
00121     ITexture *getTexture(void)
00122     {
00123         return _Tex;
00124     }
00125     const ITexture *getTexture(void) const
00126     {
00127         return _Tex;
00128     }
00129 
00131     virtual bool hasLightableFaces() {  return false; }
00132 
00133     // from CPSParticle
00134     virtual bool supportGlobalColorLighting() const { return true; }
00135 
00136     virtual void            enumTexs(std::vector<NLMISC::CSmartPtr<ITexture> > &dest, IDriver &drv);
00137 
00138     // from CPSParticle
00139     virtual void            setZBias(float value) { CPSMaterial::setZBias(value); }
00140     virtual float           getZBias() const { return CPSMaterial::getZBias(); }
00141 
00142 protected:
00143     void                newElement(const CPSEmitterInfo &info);
00144     void                deleteElement(uint32);
00145     virtual void resize(uint32 size);
00146     virtual CPSLocated *getColorOwner(void) { return _Owner; }
00147     virtual CPSLocated *getSizeOwner(void) { return _Owner; }
00148     virtual CPSLocated *getAngle2DOwner(void) { return _Owner; }
00149 private:
00150     friend class CPSFanLightHelper;
00151     typedef CHashMap<uint, CVertexBuffer>  TVBMap;
00152     typedef CHashMap<uint, CIndexBuffer >  TIBMap;
00153 private:
00154     uint32                      _NbFans;
00155     uint32                      _PhaseSmoothness;
00156     float                       _MoveIntensity;
00157     NLMISC::CSmartPtr<ITexture> _Tex;
00158     float                       _PhaseSpeed;
00159     //
00160     static uint8                _RandomPhaseTab[32][128];
00161 
00162     static TVBMap               _VBMap; // fanlight, no texture
00163     static TVBMap               _TexVBMap; // fanlight, textured
00164     static TVBMap               _ColoredVBMap; // fanlight, no texture, varying color
00165     static TVBMap               _ColoredTexVBMap; // fanlight, textured, varying color
00166     static TIBMap               _IBMap;
00167 
00168     static bool _RandomPhaseTabInitialized;
00169 private:
00171     virtual void init(void);
00172     virtual void draw(bool opaque);
00173     // setup and get the needed vb for display
00174     void getVBnIB(CVertexBuffer *&vb, CIndexBuffer *&ib);
00175     uint getNumFanlightsInVB() const;
00176     void setupMaterial();
00177 
00178 };
00179 
00180 
00181 } // NL3D
00182 
00183 
00184 #endif // NL_PS_FAN_LIGHT_H
00185 
00186 /* End of ps_fan_light.h */

Generated on Thu Jan 7 08:26:19 2010 for NeL by  doxygen 1.6.1