00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef NL_CLOUD_H
00027 #define NL_CLOUD_H
00028
00029
00030
00031 #include "3d/camera.h"
00032 #include "3d/material.h"
00033 #include "3d/texture.h"
00034 #include "3d/texture_mem.h"
00035 #include "3d/vertex_buffer.h"
00036 #include "nel/misc/smart_ptr.h"
00037 #include "nel/misc/geom_ext.h"
00038
00039 namespace NL3D
00040 {
00041
00042
00043 class CNoise3d;
00044 class CCloudScape;
00045 struct SCloudTexture3D;
00046 struct SCloudTextureClamp;
00047
00048
00049 class CCloud
00050 {
00051 public:
00052
00053 CCloud (CCloudScape *pCloudScape);
00054
00055 ~CCloud ();
00056
00057 void init (uint32 nVoxelW, uint32 nVoxelH, uint32 nVoxelD, float rBaseFreq, uint32 nNbOctave);
00058 void generate (CNoise3d &noise);
00059 void light ();
00060
00061 void reset (NL3D::CCamera *pViewer);
00062
00063 void anim (double dt, double dt2);
00064
00065
00066 void disp ();
00067 void dispXYZ (NL3D::CMaterial *pMat = NULL);
00068
00069
00070
00071 void genBill (NL3D::CCamera *pViewer, uint32 nBillSize=128);
00072
00073
00074 void dispBill (NL3D::CCamera *pViewer);
00075
00076
00077
00078 float getX() { return _Pos.x; }
00079 float getLastX() { return _LastX; }
00080 float getY() { return _Pos.y; }
00081 float getZ() { return _Pos.z; }
00082
00083 float getSizeX() { return _Size.x; }
00084 float getSizeY() { return _Size.y; }
00085 float getSizeZ() { return _Size.z; }
00086
00087 void setX(float x) { _Pos.x = x; _LastX = x; }
00088 void setY(float y) { _Pos.y = y; }
00089 void setZ(float z) { _Pos.z = z; }
00090
00091 void setSizeX(float x) { _Size.x = x; }
00092 void setSizeY(float y) { _Size.y = y; }
00093 void setSizeZ(float z) { _Size.z = z; }
00094
00095 void setTexClamp (SCloudTextureClamp &t) { _CloudTexClamp = &t; }
00096 void setTex3DTemp (SCloudTexture3D &t) { _CloudTexTmp = &t; }
00097
00098 void setLooping () { _WaitState = 2; }
00099
00100 uint32 getBillSize() { return _BillSize; }
00101
00102 uint32 getMemSize ()
00103 {
00104 return _OldBillSize*_OldBillSize*4 + _BillSize*_BillSize*4;
00105 }
00106
00107
00108 double Time, FuturTime;
00109
00110 NLMISC::CRGBA CloudDiffuse;
00111 NLMISC::CRGBA CloudAmbient;
00112 uint8 CloudPower;
00113 uint8 CloudDistAtt;
00114
00115 uint8 LastCloudPower;
00116 private:
00117
00118 void setMode2D ();
00119
00120
00121
00122 void calcBill (const NLMISC::CVector &Viewer, const NLMISC::CVector &Center, const NLMISC::CVector &Size,
00123 NLMISC::CVector &I, NLMISC::CVector &J, NLMISC::CVector &K,
00124 float &Left, float &Right, float &Top, float &Bottom, float &Near, float &Far);
00125
00126 private:
00127
00128 uint32 _Width, _Height, _Depth;
00129 uint32 _NbW, _NbH;
00130
00131 NLMISC::CVector _Size;
00132 NLMISC::CVector _Pos;
00133 float _LastX;
00134
00135 float _BaseFreq;
00136 uint32 _NbOctave;
00137 double *_UStart, *_VStart, *_WStart;
00138
00139 CCloudScape *_CloudScape;
00140 SCloudTexture3D *_CloudTexTmp;
00141 SCloudTextureClamp *_CloudTexClamp;
00142
00143
00144
00145
00146 uint32 _BillSize;
00147 uint8 *_MemBill;
00148 NLMISC::CSmartPtr<NL3D::CTextureMem> _TexBill;
00149
00150
00151 uint32 _OldBillSize;
00152 uint8 *_MemOldBill;
00153 NLMISC::CSmartPtr<NL3D::CTextureMem> _TexOldBill;
00154
00155 uint8 _WaitState;
00156
00157
00158
00159 NLMISC::CVector _BillViewer, _BillCenter, _BillOldCenter;
00160
00161 private:
00162
00163 NL3D::IDriver *_Driver;
00164 };
00165
00166
00167
00168 }
00169
00170 #endif // NL_CLOUD_H
00171