00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef NL_PS_RIBBON_H
00027 #define NL_PS_RIBBON_H
00028
00029 #include "3d/ps_particle_basic.h"
00030 #include "3d/ps_ribbon_base.h"
00031 #include "3d/vertex_buffer.h"
00032 #include "3d/vertex_buffer.h"
00033 #include "3d/primitive_block.h"
00034 #include "nel/misc/vector.h"
00035 #include <hash_map>
00036
00037
00038 namespace NL3D
00039 {
00040
00045 class CPSRibbon : public CPSRibbonBase,
00046 public CPSColoredParticle,
00047 public CPSSizedParticle,
00048 public CPSMaterial,
00049 public CPSTexturedParticleNoAnim
00050 {
00051 public:
00054
00061 CPSRibbon();
00063 ~CPSRibbon();
00065 virtual void serial(NLMISC::IStream &f) throw(NLMISC::EStream);
00066
00067 NLMISC_DECLARE_CLASS(CPSRibbon);
00069
00070
00073
00076 virtual void setColorFading(bool onOff = true)
00077 {
00078 _ColorFading = onOff;
00079 touch();
00080 }
00081
00084 virtual bool getColorFading(void) const
00085 {
00086 return _ColorFading;
00087 }
00088
00093 virtual void setSystemBasis(bool yes) {}
00094
00096 virtual bool isInSystemBasis(void) const { return true; }
00097
00098
00099
00103
00104
00106
00108 virtual void step(TPSProcessPass pass, TAnimationTime ellapsedTime, TAnimationTime realEt);
00109
00111 virtual bool hasTransparentFaces(void);
00112
00114 virtual bool hasOpaqueFaces(void);
00115
00116 virtual uint32 getMaxNumFaces(void) const;
00117
00118
00120 void setTexture(NLMISC::CSmartPtr<ITexture> tex) { _Tex = tex; touch(); }
00122 void setTexFactor(float uFactor = 1.f, float vFactor = 1.f)
00123 {
00124 _UFactor = uFactor;
00125 _VFactor = vFactor;
00126 touch();
00127 }
00128
00129 float getUFactor(void) const { return _UFactor; }
00130
00131 float getVFactor(void) const { return _VFactor; }
00133 ITexture *getTexture(void) { return _Tex; }
00134 const ITexture *getTexture(void) const { return _Tex; }
00135
00143 void setShape(const NLMISC::CVector *shape, uint32 nbPointsInShape);
00144
00146 uint32 getNbVerticesInShape(void) const { return _Shape.size(); }
00147
00152 void getShape(NLMISC::CVector *shape) const;
00153
00157 static const NLMISC::CVector Losange[];
00159 static const uint NbVerticesInLosange;
00161 static const NLMISC::CVector HeightSides[];
00163 static const uint NbVerticesInHeightSide;
00165 static const NLMISC::CVector Pentagram[];
00166 static const uint NbVerticesInPentagram;
00168 static const NLMISC::CVector Triangle[];
00169 static const uint NbVerticesInTriangle;
00171 protected:
00173
00174
00175
00176
00177
00178
00180 virtual void newElement(CPSLocated *emitterLocated, uint32 emitterIndex) ;
00182 virtual void deleteElement(uint32 index);
00184 virtual void resize(uint32 size);
00186 virtual CPSLocated *getSizeOwner(void) { return _Owner; }
00188 virtual CPSLocated *getColorOwner(void) { return _Owner; }
00189 private:
00190
00192 virtual void updateMatAndVbForColor(void);
00193
00195 void displayRibbons(uint32 nbRibbons, uint32 srcStep);
00196
00207 struct CVBnPB
00208 {
00209 CVertexBuffer VB;
00210 CPrimitiveBlock PB;
00211 };
00212
00213 typedef std::hash_map<uint, CVBnPB> TVBMap;
00214
00216 static TVBMap _VBMap;
00217 static TVBMap _FadedVBMap;
00218 static TVBMap _ColoredVBMap;
00219 static TVBMap _FadedColoredVBMap;
00220
00222 static TVBMap _TexVBMap;
00223 static TVBMap _TexFadedVBMap;
00224 static TVBMap _TexColoredVBMap;
00225 static TVBMap _TexFadedColoredVBMap;
00226
00228 CVBnPB &getVBnPB();
00229
00231 uint getNumRibbonsInVB() const;
00233
00234 CSmartPtr<ITexture> _Tex;
00235 std::vector<NLMISC::CVector> _Shape;
00236 float _UFactor, _VFactor;
00237
00238
00239 bool _ColorFading : 1;
00240 bool _GlobalColor : 1;
00241 bool _Touch : 1;
00242
00243 void touch() { _Touch = true; }
00244
00245 void updateMaterial();
00246 void updateTexturedMaterial();
00247 void updateUntexturedMaterial();
00248 void setupGlobalColor();
00249 void setupTexturedGlobalColor();
00250 void setupUntexturedGlobalColor();
00251 void setupTextureMatrix();
00252
00254 uint getNumVerticesInSlice() const;
00255 };
00256
00257
00258 }
00259
00260
00261 #endif // NL_PS_RIBBON_H
00262
00263