rayzor
changeset 20:6b11a3f8706e
foo
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 15 Apr 2014 01:36:03 +0300 |
parents | 252999cd1a3f |
children | 8c4859442200 |
files | src/scene.cc src/scene.h |
diffstat | 2 files changed, 36 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- a/src/scene.cc Tue Apr 15 00:59:37 2014 +0300 1.2 +++ b/src/scene.cc Tue Apr 15 01:36:03 2014 +0300 1.3 @@ -254,3 +254,33 @@ 1.4 } 1.5 return hit && hit->obj; 1.6 } 1.7 + 1.8 +bool Scene::load(const char *fname) 1.9 +{ 1.10 + FILE *fp = fopen(fname, "r"); 1.11 + if(!fp) { 1.12 + return false; 1.13 + } 1.14 + bool res = load(fp); 1.15 + fclose(fp); 1.16 + return res; 1.17 +} 1.18 + 1.19 +bool Scene::save(const char *fname) const 1.20 +{ 1.21 + FILE *fp = fopen(fname, "w"); 1.22 + if(!fp) { 1.23 + return false; 1.24 + } 1.25 + bool res = save(fp); 1.26 + fclose(fp); 1.27 + return res; 1.28 +} 1.29 + 1.30 +bool Scene::load(FILE *fp) 1.31 +{ 1.32 + char *block; 1.33 + while((block = get_next_block(fp))) { 1.34 + 1.35 + } 1.36 +}
2.1 --- a/src/scene.h Tue Apr 15 00:59:37 2014 +0300 2.2 +++ b/src/scene.h Tue Apr 15 01:36:03 2014 +0300 2.3 @@ -70,6 +70,12 @@ 2.4 int get_selection(int idx = 0) const; 2.5 2.6 bool intersect(const Ray &ray, RayHit *hit = 0) const; 2.7 + 2.8 + bool load(const char *fname); 2.9 + bool save(const char *fname) const; 2.10 + 2.11 + bool load(FILE *fp); 2.12 + bool save(FILE *fp) const; 2.13 }; 2.14 2.15 #endif // SCENE_H_