From 3817acdb49d775edb23fafbed70095be8f648ed6 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sat, 9 Apr 2011 20:22:13 +0200 Subject: Terrain multitexturing. --- scene.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'scene.cpp') diff --git a/scene.cpp b/scene.cpp index d6cfd80..199471f 100644 --- a/scene.cpp +++ b/scene.cpp @@ -8,7 +8,7 @@ #define inrange(a, b, c) ((a) >= (b) && (a) <= (c)) Scene::Scene() { - SDL_Surface *hm = IMG_Load("heightmap10.png"); + SDL_Surface *hm = IMG_Load("heightmap.png"); float *heightmap = new float[hm->w * hm->h]; for(int x = 0; x < hm->w; x++) { for(int y = 0; y < hm->h; y++) { @@ -28,6 +28,7 @@ Scene::~Scene() { } void Scene::lookat() { + const float cam_height = 1.7; /* calculate cartesian coordinates for the center vector where yaw is Φ and pitch is θ * x = cos Φ sin θ * y = cos θ @@ -35,10 +36,10 @@ void Scene::lookat() { */ Vector3 center(sinf(pitch) * cosf(yaw), cosf(pitch), sinf(pitch) * sinf(yaw)); center += pos; - center.y += 1; + center.y += cam_height; //Vector3 up(cosf(yaw) * cosf(pitch), sinf(pitch), sinf(yaw) * cosf(pitch)); Vector3 up(-cosf(pitch) * cosf(yaw), sinf(pitch), -cosf(pitch) * sinf(yaw)); - gluLookAt(pos.x, pos.y+1, pos.z, + gluLookAt(pos.x, pos.y+cam_height, pos.z, center.x, center.y, center.z, up.x, up.y, up.z); } -- cgit v1.2.3