Added follow cam
Added "Controlled" mesh classes Added Global Lighting Class Added Gamepad controls Split terrain nodes into Height and Perlin classes Fixed Splitmesh node stuff
This commit is contained in:
36
Graphics2/HeightMapTerrainNode.cpp
Normal file
36
Graphics2/HeightMapTerrainNode.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
#include "HeightMapTerrainNode.h"
|
||||
|
||||
#define WORLD_HEIGHT 1024
|
||||
|
||||
HeightMapTerrainNode::HeightMapTerrainNode(wstring name, wstring heightMap, wstring seed, float waterHeight, int widthX, int widthZ, int cellSizeX, int cellSizeZ) : TerrainNode(name, seed, waterHeight, widthX, widthZ, cellSizeX, cellSizeZ)
|
||||
{
|
||||
_heightMap = heightMap;
|
||||
if (!LoadHeightMap(_heightMap))
|
||||
{
|
||||
_initError = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool HeightMapTerrainNode::LoadHeightMap(wstring heightMapFilename)
|
||||
{
|
||||
unsigned int mapSize = _gridCols * _gridRows;
|
||||
USHORT* rawFileValues = new USHORT[mapSize];
|
||||
|
||||
std::ifstream inputHeightMap;
|
||||
inputHeightMap.open(heightMapFilename.c_str(), std::ios_base::binary);
|
||||
if (!inputHeightMap)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
inputHeightMap.read((char*)rawFileValues, mapSize * 2);
|
||||
inputHeightMap.close();
|
||||
|
||||
// Normalise BYTE values to the range 0.0f - 1.0f;
|
||||
for (unsigned int i = 0; i < mapSize; i++)
|
||||
{
|
||||
_heightValues.push_back((float)rawFileValues[i] / 65536);
|
||||
}
|
||||
delete[] rawFileValues;
|
||||
return true;
|
||||
}
|
Reference in New Issue
Block a user