1 #include "..\include\raMain.h" 11 m_tileSize = tileSize;
14 m_nIndices = 6 * (m_width - 1) * (m_depth - 1);
25 for(
int z = 0; z < m_depth; z++)
27 for(
int x = 0; x < m_width; x++)
31 h(((
float)x / (m_width - 1)),
32 ((
float)z / (m_depth - 1)));
36 ((
float)x / (m_width - 1)),
37 ((
float)z / (m_depth - 1)));
51 for(
int z = 0; z < m_depth - 1; z++)
53 for(
int x = 0; x < m_width - 1; x++)
71 LPCSTR heightTexture, LPCSTR bumpMapTexture) :
74 m_PixelFormat = PixelFormat;
77 LARGE_INTEGER FileSize;
81 hFile = CreateFile(heightTexture, FILE_READ_DATA, FILE_SHARE_READ, NULL,
82 OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
84 GetFileSizeEx(hFile, &FileSize);
85 nByte = FileSize.LowPart;
86 m_pHeightMap =
new BYTE[nByte];
88 ReadFile(hFile, m_pHeightMap, nByte, &nBytesRead, NULL);
90 assert(nBytesRead > 0);
93 hFile = CreateFile(bumpMapTexture, FILE_READ_DATA, FILE_SHARE_READ, NULL,
94 OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);
96 GetFileSizeEx(hFile, &FileSize);
97 nByte = FileSize.LowPart;
98 m_pBumpData =
new BYTE[nByte];
100 ReadFile(hFile, m_pBumpData, nByte, &nBytesRead, NULL);
108 float raHeightMap::h(
float x,
float z)
110 int w = m_PixelFormat;
118 return m_pHeightMap[3 * ((UINT)x * w + (UINT)z)] / 255.0f;
120 raVector3 raHeightMap::normal(
float x,
float z)
122 int w = m_PixelFormat;
127 float r = m_pBumpData[3 * ((UINT)x * w + (UINT)z) + 0];
128 float g = m_pBumpData[3 * ((UINT)x * w + (UINT)z) + 1];
129 float b = m_pBumpData[3 * ((UINT)x * w + (UINT)z) + 2];
VERTEXPOSITIONNORMALTEXTURED * m_pVertices
raVector3 raVector3Normalize(const raVector3 &v)
SDKMESH_SUBSET * m_pSubsets
virtual void SetupVertices()
raHeightMap(raSmartPointer< raDirectX > dx, int width, int depth, raMaterial *mat, float tileSize=1.0f, int PixelFormat=1024, LPCSTR heightTexture="raGrafik\eightmap.raw", LPCSTR bumpMapTexture="raGrafik\eightNormals.raw")
virtual void SetupIndices()
raHoehenfeld(raSmartPointer< raDirectX > dx, int width, int depth, raMaterial *mat, float tileSize=1.0f)