+
+static void update(float dt)
+{
+ Vec3 dir;
+
+ if(keystate['D'])
+ dir.x += cow_speed * dt;
+ if(keystate['A'])
+ dir.x -= cow_speed * dt;
+ if(keystate['W'])
+ dir.z -= cow_speed * dt;
+ if(keystate['S'])
+ dir.z += cow_speed * dt;
+
+ Vec3 *pos = move_camera ? &cam_pos : &cow_pos;
+ float theta = cam_theta / 180.0 * M_PI;
+ pos->x += dir.x * cos(theta) - dir.z * sin(theta);
+ pos->z += dir.x * sin(theta) + dir.z * cos(theta);
+}
+
+static void display()
+{
+ static float prev_tsec;
+ time_sec = glfwGetTime();
+ float dt = time_sec - prev_tsec;
+ prev_tsec = time_sec;
+
+ update(dt);
+
+ cam_pos.y = terrain.get_height(cam_pos) + 0.5;
+ camera->set_orbit_params(cam_theta, cam_phi, cam_dist);
+ camera->set_position(cam_pos.x, cam_pos.y, cam_pos.z);
+
+ gfx_clear(0.1, 0.1, 0.1);
+
+ printf("fog_density: %f\n", fog_density);
+ terrain_rend->fog_density = fog_density;
+ terrain_rend->draw();
+
+ cow_pos.y = terrain.get_height(cow_pos);
+ cow_object->transform.translation(cow_pos);
+ cow_rend->draw();
+}
\ No newline at end of file