ps_shockwave.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_SHOCKWAVE_H
00025 #define NL_PS_SHOCKWAVE_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 namespace NL3D
00032 {
00033 
00034 class CPSShockWave : public CPSParticle, public CPSSizedParticle
00035                     , public CPSColoredParticle, public CPSTexturedParticle
00036                     , public CPSRotated3DPlaneParticle, public CPSRotated2DParticle
00037                     , public CPSMaterial
00038 {
00039 public:
00045     CPSShockWave(uint nbSeg = 9, float radiusCut = 0.8f , CSmartPtr<ITexture> tex = NULL);
00046 
00050     void setNbSegs(uint nbSeg);
00051 
00053     uint getNbSegs(void) const { return _NbSeg; }
00054 
00058     void setRadiusCut(float aRatio);
00059 
00061     float getRadiusCut(void) const { return _RadiusCut; }
00062 
00064     virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream);
00065 
00066     NLMISC_DECLARE_CLASS(CPSShockWave);
00067 
00069     virtual bool completeBBox(NLMISC::CAABBox &box) const  ;
00070 
00072     virtual bool hasTransparentFaces(void);
00073 
00075     virtual bool hasOpaqueFaces(void);
00076 
00078     virtual uint32 getNumWantedTris() const;
00079 
00081     void            setUFactor(float value);
00082 
00084     float           getUFactor(void) const { return _UFactor; }
00085 
00087     virtual bool hasLightableFaces() {  return false; }
00088 
00089     // from CPSParticle
00090     virtual bool supportGlobalColorLighting() const { return true; }
00091 
00092     // from CPSLocatedBindable
00093     virtual void enumTexs(std::vector<NLMISC::CSmartPtr<ITexture> > &dest, IDriver &drv);
00094 
00095     // from CPSParticle
00096     virtual void setZBias(float value) { CPSMaterial::setZBias(value); }
00097     virtual float getZBias() const { return CPSMaterial::getZBias(); }
00098 
00099 protected:
00100 
00104     void            updateVbColNUVForRender(uint32 startIndex, uint32 size, uint32 srcStep, CVertexBuffer &vb, IDriver &drv);
00105 
00107     virtual void    updateMatAndVbForColor(void);
00108 
00110     virtual void    updateMatAndVbForTexture(void);
00111 
00114     virtual void    newElement(const CPSEmitterInfo &info);
00115 
00120     virtual void    deleteElement(uint32 index) ;
00121 
00125     virtual void    resize(uint32 size);
00126 
00127     virtual CPSLocated *getColorOwner(void) { return _Owner; }
00128     virtual CPSLocated *getSizeOwner(void) { return _Owner; }
00129     virtual CPSLocated *getAngle2DOwner(void) { return _Owner; }
00130     virtual CPSLocated *getPlaneBasisOwner(void) { return _Owner; }
00131     virtual CPSLocated *getTextureIndexOwner(void) { return _Owner; }
00132 
00133 private:
00134     typedef CHashMap<uint, CVertexBuffer> TVBMap;
00135     typedef CHashMap<uint, CIndexBuffer> TPBMap;
00136 private:
00137     static TPBMap _PBMap; // the primitive blocks
00138     static TVBMap _VBMap; // vb ith unanimated texture
00139     static TVBMap _AnimTexVBMap; // vb ith unanimated texture
00140     static TVBMap _ColoredVBMap; // vb ith unanimated texture
00141     static TVBMap _ColoredAnimTexVBMap; // vb ith unanimated texture
00142     // the number of seg in the shockwave
00143     uint32 _NbSeg;
00144     // ratio to get the inner circle radius from the outter circle radius
00145     float _RadiusCut;
00146     // texture factor
00147     float        _UFactor;
00148 private:
00149     friend class CPSShockWaveHelper;
00150     // setup and get the needed vb for display
00151     void getVBnPB(CVertexBuffer *&vb, CIndexBuffer *&pb);
00152     // get the number of shockwave that can be stored in the current vb
00153     uint getNumShockWavesInVB() const;
00154     //
00155     void setupUFactor();
00156     virtual void draw(bool opaque);
00158     virtual void    init(void);
00159 
00160 };
00161 
00162 } // NL3D
00163 
00164 
00165 #endif // NL_PS_SHOCKWAVE_H
00166 
00167 /* End of ps_particle.h */

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