rayzor
diff src/modeller.cc @ 17:79609d482762
the renderer renders, also fixed an unnoticed matrix conversion problem between scenegraph and min3d
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 14 Apr 2014 07:34:45 +0300 |
parents | be616b58df99 |
children | 5380ff64e83f |
line diff
1.1 --- a/src/modeller.cc Sun Apr 13 09:54:51 2014 +0300 1.2 +++ b/src/modeller.cc Mon Apr 14 07:34:45 2014 +0300 1.3 @@ -11,7 +11,7 @@ 1.4 1.5 struct ModellerImpl { 1.6 int mx, my; 1.7 - float cam_theta, cam_phi, cam_dist; 1.8 + float cam_theta, cam_phi, cam_dist, cam_fov; 1.9 Camera *viewport_cam; 1.10 1.11 struct m3d_image rbuf; 1.12 @@ -41,6 +41,7 @@ 1.13 1.14 mod->cam_phi = 25; 1.15 mod->cam_dist = 5; 1.16 + mod->cam_fov = 50.0; 1.17 1.18 m3d_init(); 1.19 mod->rbuf.pixels = fb_pixels; 1.20 @@ -50,7 +51,7 @@ 1.21 1.22 m3d_matrix_mode(M3D_PROJECTION); 1.23 m3d_load_identity(); 1.24 - m3d_perspective(50.0, (float)fb_width / (float)fb_height, 0.5, 500.0); 1.25 + m3d_perspective(mod->cam_fov, (float)fb_width / (float)fb_height, 0.5, 500.0); 1.26 1.27 m3d_enable(M3D_CULL_FACE); 1.28 return true; 1.29 @@ -155,11 +156,14 @@ 1.30 scene->set_active_camera(mod->viewport_cam); 1.31 } 1.32 Vector3 dir; 1.33 - dir.x = sin(DEG2RAD(mod->cam_theta)) * cos(DEG2RAD(mod->cam_phi)) * mod->cam_dist; 1.34 - dir.y = sin(DEG2RAD(mod->cam_phi)); 1.35 - dir.z = cos(DEG2RAD(mod->cam_theta)) * cos(DEG2RAD(mod->cam_phi)) * mod->cam_dist; 1.36 + float theta = -DEG2RAD(mod->cam_theta); 1.37 + float phi = DEG2RAD(mod->cam_phi); 1.38 + dir.x = sin(theta) * cos(phi) * mod->cam_dist; 1.39 + dir.y = sin(phi) * mod->cam_dist; 1.40 + dir.z = cos(theta) * cos(phi) * mod->cam_dist; 1.41 mod->viewport_cam->set_position(dir); 1.42 mod->viewport_cam->set_target(Vector3(0, 0, 0)); 1.43 + mod->viewport_cam->set_fov(DEG2RAD(mod->cam_fov)); 1.44 1.45 rs->message(message_atom("start")); 1.46 }