Added heightmap

This commit is contained in:
2016-05-25 11:31:37 +02:00
parent 47c228205a
commit 965b54c901
12 changed files with 154 additions and 23 deletions
+7 -9
View File
@@ -11,9 +11,13 @@ World::World() : player(Player::getInstance())
std::ifstream file("worlds/world1.json");
if(!file.is_open())
std::cout<<"Uhoh, can't open file\n";
json::Value v = json::readJson(file);
std::cout<<v;
file.close();
heightmap = new HeightMap(v["world"]["heightmap"].asString());
heightmap->SetTexture(v["world"]["texture"].asString());
player.position.x = v["player"]["startposition"][0];
player.position.y = v["player"]["startposition"][1];
player.position.z = v["player"]["startposition"][2];
@@ -51,14 +55,8 @@ void World::draw()
float lightAmbient[4] = { 0.5, 0.5, 0.5, 1 };
glLightfv(GL_LIGHT0, GL_AMBIENT, lightAmbient);
glColor3f(0.5f, 0.9f, 0.5f);
glNormal3f(0, 1, 0);
glBegin(GL_QUADS);
glVertex3f(-50, 0, -50);
glVertex3f(-50, 0, 50);
glVertex3f(50, 0, 50);
glVertex3f(50, 0, -50);
glEnd();
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
heightmap->Draw();
for (auto e : entities)
e->draw();