My Project
DetailTextureFactory.h
1 #pragma once
2 #include "TextureFactory.h"
3 #include "TextureEntity.h"
4 #include <list>
5 #include <vector>
6 
7 
8 namespace ParaTerrain
9 {
10 #define MAX_NUM_TEXTURE_LAYERS 4
11 class TextureFactory;
12 using namespace std;
13 using namespace ParaEngine;
14 
28 {
29 public:
31  ~CDetailTextureFactory(void);
32 public:
34  string m_sFileName;
38  float m_fTileSize;
39 
44  {
45  /*
46  * if the index is negative at m_TexturesMatrix[x,y], it means that there is no
47  * detailed texture at the tile [x,y] and that the low-res texture should be used instead */
48  short layers[MAX_NUM_TEXTURE_LAYERS];
49  };
54 
61  {
63  int nIndex;
65  asset_ptr<TextureEntity> pTexture;
69  DWORD nHitCount;
70  TextureCacheItem(int nIndex, TextureEntity * pTexture)
71  {
72  this->nIndex = nIndex;
73  this->pTexture = pTexture;
74  this->nHitCount = 1<<31;
75  }
77  void OnHit(){
78  this->nHitCount |= 1<<31;
79  }
81  void FrameMove(){
82  if(this->nHitCount<0x0000ffff)
83  this->nHitCount --;
84  else
85  this->nHitCount = this->nHitCount>>1;
86  }
87  };
89  list <TextureCacheItem> m_CachedTextureItems;
90 
92  vector <string> m_listTextures;
93 
94 private:
97  void DeleteOldestCacheItem();
98 
99 public:
105  void Init(int numTiles, float fTileSize);
106 
108  void cleanup();
109 
111  void DeleteAllTextures();
112 
116  int GetTextureIDAt(float originX, float originY, short nLayer=0);
117 
121  void AdvanceFrame();
122 
123 public:
124  TextureEntity * GetTexture(int index);
125 
126  void UnloadTexture(int index);
127 };
128 }
Which DXT Compression to Use? Obviously, there are some trade-offs between the different formats whic...
Definition: TextureEntity.h:29
index to he texture list for each layer
Definition: DetailTextureFactory.h:43
Definition: SceneObject.h:15
a cached texture item
Definition: DetailTextureFactory.h:60
different physics engine has different winding order.
Definition: EventBinding.h:32
float m_fTileSize
the size of each tile in world unit.
Definition: DetailTextureFactory.h:38
vector< string > m_listTextures
all texture file path lists.
Definition: DetailTextureFactory.h:92
int nIndex
index of the item, into the m_listTextures
Definition: DetailTextureFactory.h:63
void FrameMove()
this is called every rendering frame.
Definition: DetailTextureFactory.h:81
HighResTextureInfo * m_TexturesMatrix
a m_nTileNumX*m_nTileNumY matrix, with the cell storing the texture index.
Definition: DetailTextureFactory.h:53
this class implements a texture factory class for detailed tile based terrain surface texture...
Definition: DetailTextureFactory.h:27
void OnHit()
on hit
Definition: DetailTextureFactory.h:77
int m_nTileNum
the number of tiles in the x or y direction.They must be equal.
Definition: DetailTextureFactory.h:36
asset_ptr< TextureEntity > pTexture
the texture object
Definition: DetailTextureFactory.h:65
int m_nNumTextureCache
maximum number of tile textures to cache in memory
Definition: DetailTextureFactory.h:56
string m_sFileName
the low-res texture file path
Definition: DetailTextureFactory.h:34
list< TextureCacheItem > m_CachedTextureItems
all cached items
Definition: DetailTextureFactory.h:89
DWORD nHitCount
a bits mask of number of times that this texture is hit in the last 32 render frames.
Definition: DetailTextureFactory.h:69