3 static void make_skycube(Scene *scene);
4 static void make_particles(Scene *scene);
5 static void draw_design(float t);
7 static const float des_sz = 0.1;
8 static const int des_count = (int)(1.0 / des_sz);
9 static const float des_offs = des_sz;
13 SpacePart::SpacePart() : ScenePart("space", new Scene) {
15 TargetCamera *cam = new TargetCamera(Vector3(0, 15, -5));
17 TargetCamera *cam = new TargetCamera(Vector3(0, 30, -250));
19 cam->set_fov(DEG_TO_RAD(50));
20 scene->add_camera(cam);
22 PointLight *lt = new PointLight(Vector3(10, 100, -100));
25 scene->set_ambient_light(0.1);
28 make_particles(scene);
30 MotionController cam_x, cam_y, cam_z;
32 cam_x = MotionController(CTRL_COS, TIME_FREE);
33 cam_x.set_sin_func(0.7, 250);
34 cam_x.set_control_axis(CTRL_X);
36 cam_z = MotionController(CTRL_SIN, TIME_FREE);
37 cam_z.set_sin_func(0.9, 120);
38 cam_z.set_control_axis(CTRL_Z);
40 cam_y = MotionController(CTRL_SIN, TIME_FREE);
41 cam_y.set_sin_func(0.5, 40);
42 cam_y.set_control_axis(CTRL_Y);
45 cam->add_controller(cam_x, CTRL_TRANSLATION);
46 cam->add_controller(cam_z, CTRL_TRANSLATION);
47 cam->add_controller(cam_y, CTRL_TRANSLATION);
50 scene->set_background(0.5);
52 //scene->render_sequence(0, 15000, 25);
56 SpacePart::~SpacePart() {
59 void SpacePart::draw_part() {
60 float t = (float)time / 1000.0;
62 ScenePart::draw_part();
66 static void make_skycube(Scene *scene) {
67 const float size = 1000;
71 face[0] = new ObjPlane(Vector3(0, -1, 0), Vector2(size, size), 0);
72 face[0]->translate(Vector3(0, size / 2, 0));
73 tex[0] = get_texture("data/img/nebula_py.jpg");
75 face[1] = new ObjPlane(Vector3(0, 1, 0), Vector2(size, size), 0);
76 face[1]->translate(Vector3(0, -size / 2, 0));
77 tex[1] = get_texture("data/img/nebula_ny.jpg");
79 face[2] = new ObjPlane(Vector3(0, 0, -1), Vector2(size, size), 0);
80 face[2]->translate(Vector3(0, 0, size / 2));
81 tex[2] = get_texture("data/img/nebula_pz.jpg");
83 face[3] = new ObjPlane(Vector3(0, 0, 1), Vector2(size, size), 0);
84 face[3]->translate(Vector3(0, 0, -size / 2));
85 tex[3] = get_texture("data/img/nebula_nz.jpg");
87 face[4] = new ObjPlane(Vector3(-1, 0, 0), Vector2(size, size), 0);
88 face[4]->translate(Vector3(size / 2, 0, 0));
89 tex[4] = get_texture("data/img/nebula_px.jpg");
91 face[5] = new ObjPlane(Vector3(1, 0, 0), Vector2(size, size), 0);
92 face[5]->translate(Vector3(-size / 2, 0, 0));
93 tex[5] = get_texture("data/img/nebula_nx.jpg");
95 for(int i=0; i<6; i++) {
96 Material *mat = face[i]->get_material_ptr();
97 mat->emissive_color = 1.0;
98 mat->set_texture(tex[i], TEXTYPE_DIFFUSE);
99 face[i]->set_texture_addressing(TEXADDR_CLAMP);
100 scene->add_object(face[i]);
104 static void make_particles(Scene *scene) {
105 MotionController mc(CTRL_LIN, TIME_FREE);
107 mc.set_control_axis(CTRL_Y);
109 ParticleSystem *galaxy = new ParticleSystem("data/galaxy.psys");
110 galaxy->add_controller(mc, CTRL_ROTATION);
111 scene->add_particle_sys(galaxy);
113 galaxy = new ParticleSystem("data/galaxy.psys");
114 mc.set_origin(half_pi);
115 galaxy->add_controller(mc, CTRL_ROTATION);
116 scene->add_particle_sys(galaxy);
118 ParticleSystem *stars = new ParticleSystem("data/stars.psys");
119 scene->add_particle_sys(stars);
122 #define MIN(a, b) ((a) < (b) ? (a) : (b))
124 static void draw_design(float t) {
125 static const float des_fill = 3.0;
126 static const float yoffs = des_sz * 0.8;// + des_sz / 8.0;
127 static const Vector2 szvec(des_sz / 2, des_sz / 2);
128 static const float phase_offs = half_pi;
129 static const float x = des_sz;
130 static const float bar_len = 0.95;
132 static const float leave_start = 19.0;
133 static const float leave_dur = 4.0;
136 if(t < leave_start) {
137 fill_t = MIN(1.0, t / des_fill);
139 fill_t = 1.0 - (t - leave_start) / leave_dur;
142 set_zbuffering(false);
144 set_alpha_blending(true);
145 set_blend_func(BLEND_ONE_MINUS_DST_COLOR, BLEND_ZERO);
147 for(int i=0; i<des_count; i++) {
148 if((float)i / (float)des_count > fill_t) break;
149 Vector2 pos(x + des_sz * (float)i, yoffs);
151 glMatrixMode(GL_MODELVIEW);
153 glTranslatef(pos.x, pos.y, 0);
154 glRotatef(100.0 * cos(t * 3.0 + (float)i * phase_offs), 0, 0, 1);
155 glTranslatef(-pos.x, -pos.y, 0);
157 float sz = sin(t * 4.0 + (float)i * phase_offs) * 0.25 + 0.5;
158 draw_scr_quad(pos - szvec * sz, pos + szvec * sz, 1.0, false);
159 draw_scr_quad(pos - szvec * sz * 0.7, pos + szvec * sz * 0.7, 1.0, false);
161 pos = Vector2(1.0, 1.0) - pos;
162 glMatrixMode(GL_MODELVIEW);
164 glTranslatef(pos.x, pos.y, 0);
165 glRotatef(100.0 * cos(t * 3.0 + (float)i * phase_offs), 0, 0, 1);
166 glTranslatef(-pos.x, -pos.y, 0);
168 draw_scr_quad(pos - szvec * sz, pos + szvec * sz, 1.0, false);
169 draw_scr_quad(pos - szvec * sz * 0.7, pos + szvec * sz * 0.7, 1.0, false);
172 float bar_rest = 1.0 - bar_len;
173 float bar_start = bar_rest / 2.0;
174 float bar_end = bar_start + bar_len * fill_t;
175 draw_scr_quad(Vector2(bar_start, yoffs - 0.002), Vector2(bar_end, yoffs + 0.002));
176 draw_scr_quad(Vector2(1.0 - bar_start, 1.0 - yoffs + 0.002), Vector2(1.0 - bar_end, 1.0 - yoffs - 0.002));
178 set_alpha_blending(false);
180 set_zbuffering(true);