void Terrain::Load() { std::cout << "Loading Terrain" << std::endl; Texture* heightmap = new Texture(); heightmap->SetFile(sFilepath); heightmap->Load(); iWidth = heightmap->GetWidth(); iLength = heightmap->GetHeight(); pHeights = new float*[iLength]; for(int i = 0; i < iLength; i++) { pHeights[i] = new float[iWidth]; } vNormals = new glm::vec3*[iLength]; for(int i = 0; i < iLength; i++) { vNormals[i] = new glm::vec3[iWidth]; } for(int y = 0; y < iLength; y++) { for(int x = 0; x < iWidth; x++) { unsigned char color = heightmap->GetData()[3 * (y * iWidth + x)]; float h = fScale * ((color / 255.0f) - 0.5f); SetHeight(x, y, h); } } delete heightmap; ComputeNormals(); }