rayzor

view src/scene.h @ 21:8c4859442200

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 15 Apr 2014 20:52:05 +0300
parents 6b11a3f8706e
children
line source
1 #ifndef SCENE_H_
2 #define SCENE_H_
4 #include <stdio.h>
5 #include <string>
6 #include "vector.h"
7 #include "snode.h"
8 #include "object.h"
9 #include "light.h"
10 #include "camera.h"
11 #include "raytrace.h"
13 enum { SCN_BG_LOW, SCN_BG_MID, SCN_BG_HIGH };
15 class Scene {
16 private:
17 char *name;
18 vector<SceneNode*> nodes;
20 vector<Object*> objects;
21 vector<Light*> lights;
22 vector<Camera*> cameras;
23 Camera *active_cam;
25 Vector3 bg[3];
26 Vector3 ambient;
27 float fog_exp;
29 vector<int> sel;
31 public:
32 Scene();
33 ~Scene();
35 void clear();
37 void set_name(const char *name);
38 const char *get_name() const;
40 void set_background(const Vector3 &col, int idx = -1);
41 const Vector3 &get_background(int idx = -1) const;
42 Vector3 get_background(const Ray &ray) const;
44 void set_ambient(const Vector3 &col);
45 const Vector3 &get_ambient() const;
47 void add(SceneNode *node);
49 int get_node_count() const;
50 int get_object_count() const;
51 int get_light_count() const;
52 int get_camera_count() const;
54 SceneNode *get_node(int idx);
55 const SceneNode *get_node(int idx) const;
56 Object *get_object(int idx);
57 const Object *get_object(int idx) const;
58 Light *get_light(int idx);
59 const Light *get_light(int idx) const;
60 Camera *get_camera(int idx);
61 const Camera *get_camera(int idx) const;
63 void set_active_camera(Camera *cam);
64 Camera *get_active_camera() const;
66 void draw() const;
68 void select(int s);
69 void clear_selection();
70 int get_selection_count() const;
71 int get_selection(int idx = 0) const;
73 bool intersect(const Ray &ray, RayHit *hit = 0) const;
75 bool load(const char *fname);
76 bool save(const char *fname) const;
78 bool load(FILE *fp);
79 bool save(FILE *fp) const;
80 };
82 #endif // SCENE_H_