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;
99 mat->set_texture(tex[i], TEXTYPE_DIFFUSE);
100 face[i]->set_texture_addressing(TEXADDR_CLAMP);
101 scene->add_object(face[i]);
105 static void make_particles(Scene *scene) {
106 MotionController mc(CTRL_LIN, TIME_FREE);
108 mc.set_control_axis(CTRL_Y);
110 ParticleSystem *galaxy = new ParticleSystem("data/galaxy.psys");
111 galaxy->add_controller(mc, CTRL_ROTATION);
112 scene->add_particle_sys(galaxy);
114 galaxy = new ParticleSystem("data/galaxy.psys");
115 mc.set_origin(half_pi);
116 galaxy->add_controller(mc, CTRL_ROTATION);
117 scene->add_particle_sys(galaxy);
119 ParticleSystem *stars = new ParticleSystem("data/stars.psys");
120 scene->add_particle_sys(stars);
123 #define MIN(a, b) ((a) < (b) ? (a) : (b))
125 static void draw_design(float t) {
126 static const float des_fill = 3.0;
127 static const float yoffs = des_sz * 0.8;// + des_sz / 8.0;
128 static const Vector2 szvec(des_sz / 2, des_sz / 2);
129 static const float phase_offs = half_pi;
130 static const float x = des_sz;
131 static const float bar_len = 0.95;
133 static const float leave_start = 19.0;
134 static const float leave_dur = 4.0;
137 if(t < leave_start) {
138 fill_t = MIN(1.0, t / des_fill);
140 fill_t = 1.0 - (t - leave_start) / leave_dur;
143 set_zbuffering(false);
145 set_alpha_blending(true);
146 set_blend_func(BLEND_ONE_MINUS_DST_COLOR, BLEND_ZERO);
148 for(int i=0; i<des_count; i++) {
149 if((float)i / (float)des_count > fill_t) break;
150 Vector2 pos(x + des_sz * (float)i, yoffs);
152 glMatrixMode(GL_MODELVIEW);
154 glTranslatef(pos.x, pos.y, 0);
155 glRotatef(100.0 * cos(t * 3.0 + (float)i * phase_offs), 0, 0, 1);
156 glTranslatef(-pos.x, -pos.y, 0);
158 float sz = sin(t * 4.0 + (float)i * phase_offs) * 0.25 + 0.5;
159 draw_scr_quad(pos - szvec * sz, pos + szvec * sz, 1.0, false);
160 draw_scr_quad(pos - szvec * sz * 0.7, pos + szvec * sz * 0.7, 1.0, false);
162 pos = Vector2(1.0, 1.0) - pos;
163 glMatrixMode(GL_MODELVIEW);
165 glTranslatef(pos.x, pos.y, 0);
166 glRotatef(100.0 * cos(t * 3.0 + (float)i * phase_offs), 0, 0, 1);
167 glTranslatef(-pos.x, -pos.y, 0);
169 draw_scr_quad(pos - szvec * sz, pos + szvec * sz, 1.0, false);
170 draw_scr_quad(pos - szvec * sz * 0.7, pos + szvec * sz * 0.7, 1.0, false);
173 float bar_rest = 1.0 - bar_len;
174 float bar_start = bar_rest / 2.0;
175 float bar_end = bar_start + bar_len * fill_t;
176 draw_scr_quad(Vector2(bar_start, yoffs - 0.002), Vector2(bar_end, yoffs + 0.002));
177 draw_scr_quad(Vector2(1.0 - bar_start, 1.0 - yoffs + 0.002), Vector2(1.0 - bar_end, 1.0 - yoffs - 0.002));
179 set_alpha_blending(false);
181 set_zbuffering(true);