00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef NL_PATCHDLM_CONTEXT_H
00027 #define NL_PATCHDLM_CONTEXT_H
00028
00029 #include "nel/misc/types_nl.h"
00030 #include "nel/misc/object_vector.h"
00031 #include "3d/tess_list.h"
00032 #include "nel/misc/bsphere.h"
00033 #include "nel/misc/aabbox.h"
00034 #include "nel/misc/rgba.h"
00035 #include "3d/landscape_def.h"
00036
00037
00038 namespace NL3D
00039 {
00040
00041
00042 class CPatch;
00043 class CTextureDLM;
00044 class CPointLight;
00045 class CPatchDLMContextList;
00046
00047
00055 class CPatchDLMPointLight
00056 {
00057 public:
00058
00059 float R, G, B;
00060
00061 bool IsSpot;
00062
00063 CVector Pos;
00064
00065 CVector Dir;
00066
00067 float CosMax;
00068
00069 float CosMin;
00070
00071 float OOCosDelta;
00072
00073 float AttMax;
00074
00075 float AttMin;
00076
00077 float OOAttDelta;
00078
00079
00080
00081 NLMISC::CBSphere BSphere;
00082
00083
00084 NLMISC::CAABBox BBox;
00085
00086
00087 public:
00088
00089 void compile(const CPointLight &pl, NLMISC::CRGBA landDiffMat, float maxAttEnd= 30.f);
00090 };
00091
00092
00093
00100 class CPatchDLMContext : public CTessNodeList
00101 {
00102 public:
00103
00104 struct CVertex
00105 {
00106 CVector Pos;
00107 CVector Normal;
00108 };
00109
00111 enum TCompileType {ModulateTileColor=0, ModulateTextureFar, ModulateConstant, NoModulate};
00112
00113 public:
00114
00117 uint TextPosX, TextPosY, Width, Height;
00119 float DLMUScale, DLMVScale, DLMUBias, DLMVBias;
00121 uint8 MinU8, MaxU8;
00122 uint8 MinV8, MaxV8;
00123
00127 uint OldPointLightCount;
00128 uint CurPointLightCount;
00129
00130
00131 public:
00132
00134 CPatchDLMContext();
00136 ~CPatchDLMContext();
00137
00143 bool generate(CPatch *patch, CTextureDLM *textureDLM, CPatchDLMContextList *ctxList);
00144
00148 void clearLighting();
00149
00153 void addPointLightInfluence(const CPatchDLMPointLight &pl);
00154
00162 void compileLighting(TCompileType compType, NLMISC::CRGBA modulateCte= NLMISC::CRGBA::White);
00163
00164 CPatch *getPatch() const {return _Patch;}
00165
00166
00167 uint getMemorySize() const;
00168
00169
00170 private:
00171
00173 CPatch *_Patch;
00175 CTextureDLM *_DLMTexture;
00176
00177 CPatchDLMContextList *_DLMContextList;
00178
00180 NLMISC::CObjectVector<CVertex> _Vertices;
00181
00183 NLMISC::CObjectVector<CRGBA> _LightMap;
00184
00186 struct CCluster
00187 {
00188
00189 NLMISC::CBSphere BSphere;
00190
00191 uint NSkips;
00192
00193 uint16 X, Y;
00194 };
00195
00197 NLMISC::CObjectVector<CCluster> _Clusters;
00198
00199
00200 bool _IsSrcTextureFullBlack;
00201
00202 bool _IsDstTextureFullBlack;
00203
00204
00205
00206 #ifndef NL_DLM_TILE_RES
00207
00208 NLMISC::CObjectVector<uint16, false> _LowResTileColors;
00209 #endif
00210
00211
00215 NLMISC::CObjectVector<CRGBA> _TextureFar;
00216
00217
00218 private:
00219
00220
00221 void computeTextureFar();
00222
00223
00224 static const CRGBA *computeTileFarSrcDeltas(sint nRot, bool is256x256, uint8 uvOff, const CRGBA *srcPixel, sint &srcDeltaX, sint &srcDeltaY);
00225 static void copyTileToTexture(const CRGBA *srcPixel, sint srcDeltaX, sint srcDeltaY, CRGBA *dstPixel, uint dstStride);
00226 static void blendTileToTexture(const CRGBA *srcPixel, sint srcDeltaX, sint srcDeltaY, CRGBA *dstPixel, uint dstStride);
00227
00228 };
00229
00230
00231
00233
00234 {
00235 };
00236
00237
00238
00239 }
00240
00241
00242 #endif // NL_PATCHDLM_CONTEXT_H
00243
00244