rayzor

diff src/modeller.cc @ 15:be616b58df99

continued the renderer slightly
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 13 Apr 2014 09:54:36 +0300
parents a9a948809c6f
children 79609d482762
line diff
     1.1 --- a/src/modeller.cc	Sun Apr 13 08:06:21 2014 +0300
     1.2 +++ b/src/modeller.cc	Sun Apr 13 09:54:36 2014 +0300
     1.3 @@ -12,6 +12,7 @@
     1.4  struct ModellerImpl {
     1.5  	int mx, my;
     1.6  	float cam_theta, cam_phi, cam_dist;
     1.7 +	Camera *viewport_cam;
     1.8  
     1.9  	struct m3d_image rbuf;
    1.10  
    1.11 @@ -36,6 +37,8 @@
    1.12  	mod = new ModellerImpl;
    1.13  	memset(mod, 0, sizeof *mod);
    1.14  
    1.15 +	mod->viewport_cam = new Camera;
    1.16 +
    1.17  	mod->cam_phi = 25;
    1.18  	mod->cam_dist = 5;
    1.19  
    1.20 @@ -138,11 +141,28 @@
    1.21  			break;
    1.22  
    1.23  		case 'r':
    1.24 -		case 'R':
    1.25 +		case 'p':
    1.26  			if(kb_isdown(KB_ALT) || kb_isdown(KB_CTRL)) {
    1.27 +		case KB_F5:
    1.28 +		case KB_F6:
    1.29  				Screen *rs = get_screen("renderer");
    1.30  				if(rs) {
    1.31  					activate_screen(rs);
    1.32 +
    1.33 +					if(key == 'r' || key == KB_F5) {
    1.34 +						// start a rendering, and make sure there is a camera
    1.35 +						if(!scene->get_active_camera()) {
    1.36 +							scene->set_active_camera(mod->viewport_cam);
    1.37 +						}
    1.38 +						Vector3 dir;
    1.39 +						dir.x = sin(DEG2RAD(mod->cam_theta)) * cos(DEG2RAD(mod->cam_phi)) * mod->cam_dist;
    1.40 +						dir.y = sin(DEG2RAD(mod->cam_phi));
    1.41 +						dir.z = cos(DEG2RAD(mod->cam_theta)) * cos(DEG2RAD(mod->cam_phi)) * mod->cam_dist;
    1.42 +						mod->viewport_cam->set_position(dir);
    1.43 +						mod->viewport_cam->set_target(Vector3(0, 0, 0));
    1.44 +
    1.45 +						rs->message(message_atom("start"));
    1.46 +					}
    1.47  				} else {
    1.48  					printlog("failed to find renderer screen!\n");
    1.49  				}