doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MegaTexture.h
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 
30 public:
31  int x, y;
32 };
33 
34 static const int TILE_PER_LEVEL = 4;
35 static const int MAX_MEGA_CHANNELS = 3; // normal, diffuse, specular
36 static const int MAX_LEVELS = 12;
37 static const int MAX_LEVEL_WIDTH = 512;
38 static const int TILE_SIZE = MAX_LEVEL_WIDTH / TILE_PER_LEVEL;
39 
40 class idMegaTexture;
41 
43 public:
45 
47  int tilesWide;
48  int tilesHigh;
49 
51  idTextureTile tileMap[TILE_PER_LEVEL][TILE_PER_LEVEL];
52 
53  float parms[4];
54 
55  void UpdateForCenter( float center[2] );
56  void UpdateTile( int localX, int localY, int globalX, int globalY );
57  void Invalidate();
58 };
59 
60 typedef struct {
61  int tileSize;
62  int tilesWide;
63  int tilesHigh;
65 
66 
68 public:
69  bool InitFromMegaFile( const char *fileBase );
70  void SetMappingForSurface( const srfTriangles_t *tri ); // analyzes xyz and st to create a mapping
71  void BindForViewOrigin( const idVec3 origin ); // binds images and sets program parameters
72  void Unbind(); // removes texture bindings
73 
74  static void MakeMegaTexture_f( const idCmdArgs &args );
75 private:
76 friend class idTextureLevel;
77  void SetViewOrigin( const idVec3 origin );
79  static void GenerateMegaPreview( const char *fileName );
80 
82 
84 
86 
88 
89  int numLevels;
90  idTextureLevel levels[MAX_LEVELS]; // 0 is the highest resolution
92 
98 };
99 
void SetMappingForSurface(const srfTriangles_t *tri)
idVec3 currentViewOrigin
Definition: MegaTexture.h:85
Definition: Image.h:146
const srfTriangles_t * currentTriMapping
Definition: MegaTexture.h:83
idFile * fileHandle
Definition: MegaTexture.h:81
float parms[4]
Definition: MegaTexture.h:53
void UpdateForCenter(float center[2])
megaTextureHeader_t header
Definition: MegaTexture.h:91
Definition: Vector.h:316
idMegaTexture * mega
Definition: MegaTexture.h:44
idTextureLevel levels[MAX_LEVELS]
Definition: MegaTexture.h:90
idImage * image
Definition: MegaTexture.h:50
static void MakeMegaTexture_f(const idCmdArgs &args)
static idCVar r_megaTextureLevel
Definition: MegaTexture.h:93
Definition: File.h:50
void BindForViewOrigin(const idVec3 origin)
static void GenerateMegaMipMaps(megaTextureHeader_t *header, idFile *file)
static idCVar r_skipMegaTexture
Definition: MegaTexture.h:96
void SetViewOrigin(const idVec3 origin)
static idCVar r_showMegaTextureLabels
Definition: MegaTexture.h:95
static idCVar r_showMegaTexture
Definition: MegaTexture.h:94
void UpdateTile(int localX, int localY, int globalX, int globalY)
float localViewToTextureCenter[2][4]
Definition: MegaTexture.h:87
static idCVar r_terrainScale
Definition: MegaTexture.h:97
idTextureTile tileMap[TILE_PER_LEVEL][TILE_PER_LEVEL]
Definition: MegaTexture.h:51
bool InitFromMegaFile(const char *fileBase)
Definition: MegaTexture.cpp:87
static void GenerateMegaPreview(const char *fileName)