From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/ps__util_8h-source.html | 282 +++++++++++++++++++++++++++++++ 1 file changed, 282 insertions(+) create mode 100644 docs/doxygen/nel/ps__util_8h-source.html (limited to 'docs/doxygen/nel/ps__util_8h-source.html') diff --git a/docs/doxygen/nel/ps__util_8h-source.html b/docs/doxygen/nel/ps__util_8h-source.html new file mode 100644 index 00000000..3a80563b --- /dev/null +++ b/docs/doxygen/nel/ps__util_8h-source.html @@ -0,0 +1,282 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# 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  
+

ps_util.h

Go to the documentation of this file.
00001 
+00007 /* Copyright, 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_PS_UTIL_H
+00027 #define NL_PS_UTIL_H
+00028 
+00029 #include "nel/misc/types_nl.h"
+00030 #include "nel/misc/aabbox.h"
+00031 #include "nel/misc/vector.h"
+00032 #include "nel/misc/rgba.h"
+00033 
+00034 
+00035 
+00036 namespace NLMISC
+00037 {
+00038         class CMatrix;
+00039         class NLMISC::CVector;
+00040 };
+00041 
+00042 namespace NL3D 
+00043 {
+00044 
+00045 
+00046         class CFontGenerator;
+00047         class CFontManager;
+00048         class IDriver;
+00049 
+00050 
+00057 struct CPSUtil
+00058 {
+00059 public:
+00061 
+00062         static void registerSerialParticleSystem(void);
+00063 
+00065 
+00066         static void displayBBox(NL3D::IDriver *driver, const NLMISC::CAABBox &box, NLMISC::CRGBA col = NLMISC::CRGBA::White);
+00067 
+00069         static void displaySphere(NL3D::IDriver &driver, float radius, const NLMISC::CVector &center, uint nbSubdiv = 4, NLMISC::CRGBA color = NLMISC::CRGBA::White);
+00070 
+00071 
+00075         static void displayDisc(NL3D::IDriver &driver, float radius, const NLMISC::CVector &center, const NLMISC::CMatrix &mat, uint nbSubdiv = 32, NLMISC::CRGBA color = NLMISC::CRGBA::White);
+00076 
+00077 
+00081         static void displayCylinder(NL3D::IDriver &driver, const NLMISC::CVector &center, const NLMISC::CMatrix &mat, const NLMISC::CVector &dim, uint nbSubdiv = 32, NLMISC::CRGBA color = NLMISC::CRGBA::White);
+00082 
+00084         static void display3DQuad(NL3D::IDriver &driver, const NLMISC::CVector &c1, const NLMISC::CVector &c2
+00085                                                                 ,const NLMISC::CVector &c3,  const NLMISC::CVector &c4, NLMISC::CRGBA color = NLMISC::CRGBA::White);
+00086                                                         
+00087 
+00089         inline static void addRadiusToAABBox(NLMISC::CAABBox &box, float radius);
+00090          
+00092         static void displayBasis(NL3D::IDriver *driver, const NLMISC::CMatrix &modelMat, const NLMISC::CMatrix &m, float size, CFontGenerator &fg, CFontManager &fm);
+00093 
+00094 
+00105         static void displayArrow(NL3D::IDriver *driver, const NLMISC::CVector &start, const NLMISC::CVector &v, float size, NLMISC::CRGBA col1, NLMISC::CRGBA col2);
+00106 
+00108         static void print(NL3D::IDriver *driver, const std::string &text, CFontGenerator &fg, CFontManager &fm, const NLMISC::CVector &pos, float size);
+00109 
+00110 
+00115         static void buildSchmidtBasis(const NLMISC::CVector &v, NLMISC::CMatrix &dest);  
+00116 
+00117 
+00121         static inline float getCos(sint32 angle) 
+00122         { 
+00123                 nlassert(_CosTableInitialized == true);
+00124                 return _CosTable[angle & 0xff];
+00125         }
+00126 
+00130         static inline float getSin(sint32 angle) 
+00131         { 
+00132                 nlassert(_CosTableInitialized == true);
+00133                 return _SinTable[angle & 0xff];
+00134         }
+00135 
+00139         static void initFastCosNSinTable(void);
+00140 
+00141 
+00146         static inline float buildPerlinNoise(NLMISC::CVector &pos, uint nbOctaves);
+00147 
+00151         static void initPerlinNoiseTable(void);
+00152                 
+00153 
+00154 private:        
+00155         static void registerForces();
+00156         static void registerParticles();
+00157         static void registerEmitters();
+00158         static void registerZones();
+00159         static void registerAttribs();
+00160 
+00161         static bool _CosTableInitialized;       
+00162         static bool _PerlinNoiseTableInitialized;       
+00163         // a table for fast cosine lookup
+00164         static float _CosTable[256];
+00165         // a table for fast sinus lookup
+00166         static float _SinTable[256];
+00167         static float _PerlinNoiseTab[1024];
+00168         // used by perlin noise to compute each octave          
+00169         static float getInterpolatedNoise(const NLMISC::CVector &pos);
+00170         // get non interpolated noise 
+00171         static float getPerlinNoise(uint x, uint y, uint z);
+00172 };
+00173 
+00175 // inline implementation //
+00177 
+00178 inline void CPSUtil::addRadiusToAABBox(NLMISC::CAABBox &box, float radius)
+00179 {
+00180         box.setHalfSize(box.getHalfSize() + NLMISC::CVector(radius, radius, radius) );
+00181 }
+00182 
+00183 
+00184 // get non interpolated noise 
+00185 inline float CPSUtil::getPerlinNoise(uint x, uint y, uint z)
+00186 {
+00187         return _PerlinNoiseTab[(x ^ y ^ z) & 1023];
+00188 }
+00189 
+00190 
+00191 inline float CPSUtil::getInterpolatedNoise(const NLMISC::CVector &pos)
+00192 {
+00193         uint x = (uint) pos.x
+00194                 , y = (uint) pos.y
+00195                 , z = (uint) pos.z;
+00196 
+00197         // we want to avoid costly ctor call there...
+00198         float fx = pos.x - x
+00199                   , fy = pos.y - y
+00200                   , fz = pos.z - z;
+00201 
+00202         // we use the following topology to get the value :
+00203         //
+00204         //
+00205         //  z
+00206         //  | 7-----6
+00207         //   /     /
+00208         //  4-----5 |
+00209         //  |     | |
+00210         //  |  3  | |2
+00211         //  |     | /
+00212         //  0_____1/__x
+00213 
+00214         
+00215         const float v0 = getPerlinNoise(x, y, z)
+00216                  ,v1 = getPerlinNoise(x + 1, y, z)
+00217                  ,v2 = getPerlinNoise(x + 1, y + 1, z)
+00218                  ,v3 = getPerlinNoise(x, y + 1, z)
+00219                  ,v4 = getPerlinNoise(x, y, z + 1)
+00220                  ,v5 = getPerlinNoise(x + 1, y, z + 1)
+00221                  ,v6 = getPerlinNoise(x + 1, y + 1, z + 1)
+00222                  ,v7 = getPerlinNoise(x, y + 1, z + 1);
+00223 
+00224         
+00225         const float h1  = fx * v1 + (1.f - fx) * v0
+00226                                 ,h2 = fx * v3 + (1.f - fx) * v2 
+00227                                 ,h3  = fx * v5 + (1.f - fx) * v4
+00228                                 ,h4 = fx * v7 + (1.f - fx )* v6; 
+00229 
+00230     const float c1  = fy * h2 + (1.f - fy) * h1
+00231                        ,c2  = fy * h4 + (1.f - fy) * h3;
+00232 
+00233         return fz * c2 + (1.f - fz) * c1;
+00234 }
+00235 
+00236 
+00237 inline float CPSUtil::buildPerlinNoise(NLMISC::CVector &pos, uint numOctaves)
+00238 {
+00239         nlassert(_PerlinNoiseTableInitialized);
+00240 
+00241         float result = 0;
+00242         float fact = .5f;
+00243         float scale = 1.f;
+00244 
+00245         for (uint k = 0; k < numOctaves; k++)
+00246         {
+00247                 result += fact * getInterpolatedNoise(scale * pos);
+00248                 fact *= .5f;
+00249                 scale *= 1.2537f;
+00250         }       
+00251         return result;
+00252 }
+00253 
+00254 
+00255 
+00256 
+00257 
+00258 
+00259 } // NL3D
+00260 
+00261 
+00262 #endif // NL_PS_UTIL_H
+00263 
+00264 /* End of ps_util.h */
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1