erebus
diff liberebus/src/erebus.cc @ 19:6204e4d3f445
scene loading
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 27 May 2014 07:43:55 +0300 |
parents | 09028848f276 |
children | c8a6fb04fefa |
line diff
1.1 --- a/liberebus/src/erebus.cc Mon May 26 23:34:12 2014 +0300 1.2 +++ b/liberebus/src/erebus.cc Tue May 27 07:43:55 2014 +0300 1.3 @@ -203,33 +203,9 @@ 1.4 delete ctx->scn; 1.5 ctx->scn = new Scene; 1.6 1.7 - // XXX for now just create a test scene here 1.8 - Sphere *sph = new Sphere; 1.9 - sph->mtl.set_attrib("diffuse", Color(1.0, 0.3, 0.2)); 1.10 - SceneNode *sph_node = new SceneNode(sph); 1.11 - ctx->scn->add_object(sph); 1.12 - ctx->scn->add_node(sph_node); 1.13 - 1.14 - Box *box = new Box; 1.15 - box->mtl.set_attrib("diffuse", Color(0.9, 0.8, 0.75)); 1.16 - SceneNode *box_node = new SceneNode(box); 1.17 - box_node->set_position(Vector3(0, -1.25, 0)); 1.18 - box_node->set_scaling(Vector3(5, 0.5, 5)); 1.19 - ctx->scn->add_object(box); 1.20 - ctx->scn->add_node(box_node); 1.21 - 1.22 - Sphere *lt = new Sphere; 1.23 - lt->mtl.set_attrib("emissive", Color(10, 10, 10)); 1.24 - SceneNode *lt_node = new SceneNode(lt); 1.25 - lt_node->set_position(Vector3(-15, 15, -10)); 1.26 - lt_node->set_scaling(Vector3(8, 8, 8)); 1.27 - ctx->scn->add_object(lt); 1.28 - ctx->scn->add_node(lt_node); 1.29 - 1.30 - TargetCamera *cam = new TargetCamera(Vector3(0, 4, -8), Vector3(0, 0, 0)); 1.31 - //ctx->scn->add_object(cam); 1.32 - ctx->scn->use_camera(cam); 1.33 - 1.34 + if(!ctx->scn->load(fname)) { 1.35 + return -1; 1.36 + } 1.37 return 0; 1.38 } 1.39 1.40 @@ -317,8 +293,8 @@ 1.41 Vector3 cpos = cam->get_position(); 1.42 float mag = cpos.length(); 1.43 1.44 - float theta = atan2(cpos.z / mag, cpos.x / mag) + DEG_TO_RAD(dx * 0.5); 1.45 - float phi = acos(cpos.y / mag) + DEG_TO_RAD(dy * 0.5); 1.46 + float theta = atan2(cpos.z / mag, cpos.x / mag) - DEG_TO_RAD(dx * 0.5); 1.47 + float phi = acos(cpos.y / mag) - DEG_TO_RAD(dy * 0.5); 1.48 1.49 if(phi < 0) phi = 0; 1.50 if(phi > M_PI) phi = M_PI;