summaryrefslogtreecommitdiff
path: root/scene.cpp
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2011-04-09 20:22:13 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2011-04-09 20:22:13 +0200
commit3817acdb49d775edb23fafbed70095be8f648ed6 (patch)
tree088d94ebd9f767e84263e1400db336930a7324cd /scene.cpp
parente19c3838a4d89fb0640ed563ffdf58cd125cde7f (diff)
Terrain multitexturing.
Diffstat (limited to 'scene.cpp')
-rw-r--r--scene.cpp7
1 files changed, 4 insertions, 3 deletions
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);
}