erebus

view liberebus/src/scene.h @ 45:bab25c0ce337

started gmath conversion
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 29 Dec 2015 12:19:53 +0200
parents 2e817711d0f6
children
line source
1 #ifndef SCENE_H_
2 #define SCENE_H_
4 #include <stdio.h>
5 #include <vector>
6 #include <list>
7 #include "snode.h"
8 #include "camera.h"
9 #include "color.h"
11 struct Environment {
12 Color bgcolor;
13 Color ambient;
14 // TODO map & image-based lighting
16 Environment();
17 };
19 struct ObjectInstance {
20 Object *obj;
21 SceneNode *node;
22 };
24 class Scene {
25 private:
26 Environment env;
28 std::vector<Object*> objects;
29 std::vector<SceneNode*> nodes;
31 SceneNode *root;
33 Camera *active_cam;
35 public:
36 Scene();
37 ~Scene();
39 void clear();
41 void set_env(const Environment &env);
42 Environment &get_env();
43 const Environment &get_env() const;
45 Color get_env_color() const;
46 Color get_env_color(const Ray &ray) const;
48 void add_object(Object *obj);
49 int get_object_count() const;
50 Object *get_object(int idx) const;
52 void add_node(SceneNode *node);
53 int get_node_count() const;
54 SceneNode *get_node(int idx) const;
56 void use_camera(Camera *cam);
57 Camera *get_active_camera() const;
59 std::list<ObjectInstance> gen_light_list() const;
61 void update(long msec = 0);
63 bool intersect(const Ray &ray, RayHit *hit) const;
65 bool load(const char *fname);
66 bool load(FILE *fp);
68 bool proc_cmd(int argc, char **argv);
69 };
71 #endif // SCENE_H_