added 3dengfx into the repo, probably not the correct version for this
[summerhack] / src / 3dengfx / src / 3dengfx / 3dscene.hpp
1 /*
2 This file is part of the 3dengfx, realtime visualization system.
3
4 Copyright (c) 2004, 2005 John Tsiombikas <nuclear@siggraph.org>
5
6 3dengfx is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 3dengfx is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with 3dengfx; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20 #ifndef _3DSCENE_HPP_
21 #define _3DSCENE_HPP_
22
23 #include <list>
24 #include "camera.hpp"
25 #include "light.hpp"
26 #include "object.hpp"
27 #include "psys.hpp"
28 #include "gfx/curves.hpp"
29
30 struct ShadowVolume {
31         TriMesh *shadow_mesh;
32         const Light *light;
33 };
34
35 class Scene {
36 private:
37         Light **lights;
38         int lcount, max_lights;
39
40         std::list<Camera *> cameras;
41         TargetCamera *cubic_cam[6];
42         std::list<Object*> objects;
43         std::list<ShadowVolume> static_shadow_volumes;
44         std::list<Curve*> curves;
45         std::list<ParticleSystem*> psys;
46         
47         bool manage_data;
48         const Camera *active_camera;
49         bool shadows;
50         bool light_halos;
51         float halo_size;
52         Color ambient_light;
53         bool use_fog;
54         Color fog_color;
55         float near_fog_range, far_fog_range;
56         bool auto_clear;
57         Color bg_color;
58         mutable bool first_render;
59         mutable unsigned long frame_count;
60         mutable unsigned long poly_count;
61         unsigned long scene_poly_count;
62         bool frustum_cull;
63         
64         void place_cube_camera(const Vector3 &pos);
65         bool render_all_cube_maps(unsigned long msec = XFORM_LOCAL_PRS) const;
66                 
67 public:
68
69         Scene();
70         ~Scene();
71
72         void set_poly_count(unsigned long pcount);
73         unsigned long get_poly_count() const;
74         unsigned long get_frame_poly_count() const;
75
76         void add_camera(Camera *cam);
77         void add_light(Light *light);
78         void add_object(Object *obj);
79         void add_static_shadow_volume(TriMesh *mesh, const Light *light);
80         void add_curve(Curve *curve);
81         void add_particle_sys(ParticleSystem *p);
82
83         void add_skycube(scalar_t size, Texture *cubemap);
84
85         bool remove_light(const Light *light);
86         bool remove_object(const Object *obj);
87         bool remove_particle_sys(const ParticleSystem *p);
88
89         Camera *get_camera(const char *name);
90         Light *get_light(const char *name);
91         Object *get_object(const char *name);
92         Curve *get_curve(const char *name);
93         ParticleSystem *get_particle_sys(const char *name);
94
95         XFormNode *get_node(const char *name);
96
97         std::list<Object*> *get_object_list();
98         std::list<Camera*> *get_camera_list();
99
100         void set_active_camera(const Camera *cam);
101         Camera *get_active_camera() const;
102
103         void set_shadows(bool enable);
104         void set_halo_drawing(bool enable);
105         void set_halo_size(float size);
106         void set_ambient_light(Color ambient);
107         Color get_ambient_light() const;
108         void set_fog(bool enable, Color fog_color = Color(0l), float near_fog = 0.0f, float far_fog = 1000.0f);
109         void set_auto_clear(bool enable);
110         void set_background(const Color &bg);
111         void set_frustum_culling(bool enable);
112
113         // render states
114         void setup_lights(unsigned long msec = XFORM_LOCAL_PRS) const;
115
116         void render(unsigned long msec = XFORM_LOCAL_PRS) const;
117         void render_objects(unsigned long msec = XFORM_LOCAL_PRS) const;
118         void render_particles(unsigned long msec = XFORM_LOCAL_PRS) const;
119         void render_svol(int lidx, unsigned long msec = XFORM_LOCAL_PRS) const;
120         void render_cube_map(Object *obj, unsigned long msec = XFORM_LOCAL_PRS) const;
121
122         void render_sequence(unsigned long start, unsigned long end, int fps = 30, const char *out_dir = "frames");
123 };
124
125 #endif  // _3DSCENE_HPP_