# 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  

texture_far.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000 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_TEXTURE_FAR_H
00027 #define NL_TEXTURE_FAR_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 #include "nel/3d/texture.h"
00031 #include "nel/misc/rect.h"
00032 
00033 // Define the number of tile per tile far texture 
00034 #define NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT 2                                                                                                              // 2 (shit)
00035 
00036 // Same by precomputed values
00037 #define NL_NUM_FAR_PATCHES_BY_EDGE (1<<NL_NUM_FAR_PATCHES_BY_EDGE_SHIFT)                                                // 4 patches by edges
00038 #define NL_NUM_FAR_PATCHES_BY_EDGE_MASK (NL_NUM_FAR_PATCHES_BY_EDGE-1)                                                  // 0x3 (mask)
00039 #define NL_NUM_FAR_PATCHES_BY_TEXTURE (NL_NUM_FAR_PATCHES_BY_EDGE*NL_NUM_FAR_PATCHES_BY_EDGE)   // 16 patches by CTextureFar
00040 
00041 namespace NLMISC
00042 {
00043         class CRGBA;
00044 }
00045 
00046 namespace NL3D 
00047 {
00048 
00049 class CPatch;
00050 class CTileFarBank;
00051 class CTileColor;
00052 class CTileLumel;
00053 
00068 class CTextureFar : public ITexture
00069 {
00070 public:
00072         struct CPatchIdent
00073         {
00075                 CPatchIdent () {};
00076 
00078                 CPatchIdent (CPatch* patch)
00079                 {
00080                         Patch=patch;
00081                 }
00082 
00083                 // Data
00084 
00085                 // Patch pointer
00086                 CPatch* Patch;
00087         };
00088 
00090         CTextureFar()
00091         {
00092                 // This texture is releasable. It doesn't stays in standard memory after been uploaded into video memory.
00093                 setReleasable (true);
00094         }
00095 
00104         void                                            setSizeOfFarPatch (sint width, sint height);
00105 
00116         bool                                            addPatch (CPatch *pPatch, float& far1UScale, float& far1VScale, float& far1UBias, float& far1VBias, bool& bRot);
00117 
00121         bool                                            removePatch (CPatch *pPatch);
00122 
00128         virtual void                            doGenerate();
00129 
00130         // Data
00131 
00136         std::vector<CPatchIdent>        _Patches;
00137 
00138         // Count of patch stored in this texture
00139         uint32                                          _PatchCount;
00140 
00142         CTileFarBank*                           _Bank;
00143 
00144 private:
00146         uint32                                          _OriginalWidth;
00147         uint32                                          _OriginalHeight;
00148 
00152         void rebuildRectangle (uint x, uint y);
00153 
00155         virtual void    serial(NLMISC::IStream &f) throw(NLMISC::EStream) {};
00156 
00157         // Some static buffers
00158         static NLMISC::CRGBA _LightmapExpanded[];
00159         static CTileLumel _LumelExpanded[];
00160 
00161         NLMISC_DECLARE_CLASS(CTextureFar);
00162 };
00163 
00164 } // NL3D
00165 
00166 // For NL3D_drawFarTileInFarTexture external call
00167 struct NL3D_CComputeTileFar
00168 {
00169 public:
00170         // TileFar pixels
00171         const NLMISC::CRGBA*            SrcDiffusePixels;
00172 
00173         // TileFar pixels
00174         const NLMISC::CRGBA*            SrcAdditivePixels;
00175 
00176         // Source deltaY
00177         sint32                                          SrcDeltaX;
00178 
00179         // Source deltaY
00180         sint32                                          SrcDeltaY;
00181 
00182         // Source lighting
00183         const NLMISC::CRGBA*            SrcLightingPixels;
00184 
00185         // Delta Y for lighting
00186         sint32                                          SrcLightingDeltaY;
00187 
00188         // TileFar pixels
00189         NLMISC::CRGBA*                          DstPixels;
00190 
00191         // Destination deltaX
00192         sint32                                          DstDeltaX;
00193 
00194         // Destination deltaY
00195         sint32                                          DstDeltaY;
00196 
00197         // Size
00198         sint32                                          Size;
00199 };
00200 
00201 // For NL3D_expandLightmap external call
00202 struct NL3D_CExpandLightmap
00203 {
00204 public:
00205         // CTileColor array.
00206         const NL3D::CTileColor*         ColorTile;
00207 
00208         // CTileLumel array. Same resolution than destination buffer
00209         const NL3D::CTileLumel*         LumelTile;
00210 
00211         // Width of the array
00212         uint32                                          Width;
00213 
00214         // Height of the array
00215         uint32                                          Height;
00216 
00217         // Mul factor for the size (1, 2 or 4)
00218         uint32                                          MulFactor;
00219 
00220         // Static light color
00221         const NLMISC::CRGBA*            StaticLightColor;
00222 
00223         // Destination array
00224         NLMISC::CRGBA*                          DstPixels;
00225 };
00226         
00227 // Extern ASM functions
00228 extern "C" void NL3D_expandLightmap (const NL3D_CExpandLightmap* pLightmap);
00229 extern "C" void NL3D_drawFarTileInFarTexture (const NL3D_CComputeTileFar* pTileFar);
00230 extern "C" void NL3D_drawFarTileInFarTextureAdditive (const NL3D_CComputeTileFar* pTileFar);
00231 extern "C" void NL3D_drawFarTileInFarTextureAlpha (const NL3D_CComputeTileFar* pTileFar);
00232 extern "C" void NL3D_drawFarTileInFarTextureAdditiveAlpha (const NL3D_CComputeTileFar* pTileFar);
00233 
00234 #endif // NL_TEXTURE_FAR_H
00235 
00236 /* End of texture_far.h */