My Project
TextureCell.h
1 #pragma once
2 #include "TerrainCommon.h"
3 #include "DetailTexture.h"
4 #include "Texture.h"
5 #include "Terrain.h"
6 
7 namespace ParaEngine
8 {
9  class CParaFile;
10 }
11 namespace ParaTerrain
12 {
13  using namespace ParaEngine;
15 
27  {
28  public:
29  typedef std::vector<DetailTexture*> DetailTextureArray_type;
31  TextureCell();
34  TextureCell(int index);
35  ~TextureCell();
37  void SetTexture(Texture * pTexture);
39 
43  void AddDetail(DetailTexture * pDetailTexture);
44 
47  bool RemoveDetail(int nIndex);
50  bool RemoveAllDetail();
51 
53  DeviceTexturePtr_type BindTexture();
55  DeviceTexturePtr_type BindMask();
56 
58  int GetNumberOfDetails();
62  DeviceTexturePtr_type BindMask(int index);
66  DeviceTexturePtr_type BindDetail(int index);
68  void UnbindAll();
72  DetailTexture *GetDetail(int index);
76  DetailTexture *GetDetail(Texture * pTexture);
80  int GetDetailIndex(Texture * pTexture);
81 
90  int NormalizeMask(int index, float fScale=1.0f);
91 
96 
99 
101  void WriteMask(CParaFile& file, Terrain * pTerrain);
103  void ReadMask(CParaFile& file, Terrain * pTerrain);
104 
106  void ResizeTextureMaskWidth(int nWidth);
107 
109  void FlipHorizontal();
111  void FlipVertical();
113  int GetDetailTextureImageWidth(int detailIndex);
115  int GetDetailTextureImageHeight(int detailIndex);
117  int GetDetailTextureImageBitsPerPixel(int detailIndex);
119  static int GetDetailMaskImageWidth(int detailIndex);
121  static int GetDetailMaskImageHeight(int detailIndex);
123  int GetDetailMaskImageBitsPerPixel(int detailIndex);
124 
131 
134  void OptimizeLayer();
135  private:
136  DetailTexture * m_pBaseLayer;
137  DetailTextureArray_type m_DetailTextures;
138  int m_Index;
139  };
140 }
void UnbindAll()
Unbinds the overall texture and all DetailTexture masks and detail textures.
Definition: TextureCell.cpp:285
int GetNumberOfDetails()
Gets the number of DetailTexture layers that have been added.
Definition: TextureCell.cpp:246
Definition: SceneObject.h:15
DeviceTexturePtr_type BindTexture()
Binds the overall texture to a texture object. Used for rendering.
Definition: TextureCell.cpp:250
bool RemoveDetail(int nIndex)
remove a detailed texture by local index.
Definition: TextureCell.cpp:323
bool RemoveAllDetail()
remove all detailed textures.
Definition: TextureCell.cpp:341
Texture * GetTexture()
Gets the overall base detail texture&#39;s texture object.
Definition: TextureCell.cpp:41
DetailTexture * GetDetailBase()
get the base detailed texture.
Definition: TextureCell.cpp:36
different physics engine has different winding order.
Definition: EventBinding.h:32
int GetDetailMaskImageBitsPerPixel(int detailIndex)
Gets the color depth of the specified detail texture mask.
Definition: TextureCell.cpp:88
static int GetDetailMaskImageWidth(int detailIndex)
Gets the width of the specified detail texture mask in pixels.
Definition: TextureCell.cpp:78
Definition: mdx.h:48
void OptimizeLayer()
optimize layers in the cell, by removing those layers whose texture mask is constant 0...
Definition: TextureCell.cpp:294
void AddDetail(DetailTexture *pDetailTexture)
Adds a new detail texture layer to this cell.
Definition: TextureCell.cpp:241
int GetDetailIndex(Texture *pTexture)
same as GetDetail(), except that the local detail texture index is returned.
Definition: TextureCell.cpp:225
int GetDetailTextureImageHeight(int detailIndex)
Gets the height of the specified detail texture in pixels.
Definition: TextureCell.cpp:59
void FlipHorizontal()
Performs Texture::FlipHorizontal on the overall texture and all DetailTexture layers.
Definition: TextureCell.cpp:117
DeviceTexturePtr_type BindMask()
Binds the overall mask to a texture object.Used for rendering.
Definition: TextureCell.cpp:258
Represents a square region on a Terrain surface that is textured.
Definition: TextureCell.h:26
int GetBaseTextureImageHeight()
Gets the height of the overall texture in pixels.
Definition: TextureCell.cpp:101
int GetDetailTextureImageBitsPerPixel(int detailIndex)
Gets the color depth of the specified detail texture.
Definition: TextureCell.cpp:68
int GetBaseTextureImageBitsPerPixel()
Gets the color depth of the overall texture.
Definition: TextureCell.cpp:109
int GetDetailTextureImageWidth(int detailIndex)
Gets the width of the specified detail texture in pixels.
Definition: TextureCell.cpp:50
int NormalizeMask(int index, float fScale=1.0f)
normalize the given texture mask layer, so that the alpha of the specified layer is unchanged(or scal...
Definition: TextureCell.cpp:375
void SetTexture(Texture *pTexture)
Sets the overall Texture for this cell.
Definition: TextureCell.cpp:186
it presents a real or virtual file in ParaEngine.
Definition: ParaFile.h:31
void WriteMask(CParaFile &file, Terrain *pTerrain)
optimize and then write to disk.
Definition: TextureCell.cpp:133
TextureCell()
Constructs an empty TextureCell.
Definition: TextureCell.cpp:17
A DetailTexture is a "layer" that can be painted onto to put texture "splats" on a terrain surface...
Definition: DetailTexture.h:23
void FlipVertical()
Performs Texture::FlipVertical on the overall texture and all DetailTexture layers.
Definition: TextureCell.cpp:125
void ResizeTextureMaskWidth(int nWidth)
resize all texture mask width of all layers
Definition: TextureCell.cpp:353
static int GetDetailMaskImageHeight(int detailIndex)
Gets the height of the specified detail texture mask in pixels.
Definition: TextureCell.cpp:83
int GetBaseTextureImageWidth()
Gets the width of the overall texture in pixels.
Definition: TextureCell.cpp:93
DetailTexture * GetDetail(int index)
Gets the specified DetailTexture layer.
Definition: TextureCell.cpp:203
This class represents a single, contiguous chunk of terrain and is the primary public interface to De...
Definition: Terrain.h:386
void ReadMask(CParaFile &file, Terrain *pTerrain)
read mask file from disk.
Definition: TextureCell.cpp:150
DeviceTexturePtr_type BindDetail(int index)
Binds the detail texture of the specified DetailTexture layer.
Definition: TextureCell.cpp:276