static void recalc_light(world_t w) { static const vec3_t c_noon = {1.0, 0.87, 1.0}; static const vec3_t c_dusk = {0.8, 0.4, 0.24}; static const vec3_t c_night = {0.05, 0.05, 0.2}; vec3_t color; float lerp; w->lpos[0] = 0.0; w->lpos[1] = sin(w->lightAngle); w->lpos[2] = cos(w->lightAngle); if ( w->lpos[1] >= 0.0 ) { lerp = w->lpos[1]; color[0] = c_dusk[0] + (c_noon[0] - c_dusk[0]) * lerp; color[1] = c_dusk[1] + (c_noon[1] - c_dusk[1]) * lerp; color[2] = c_dusk[2] + (c_noon[2] - c_dusk[2]) * lerp; }else{ lerp = -(w->lpos[1] * 4); if ( lerp > 1.0 ) lerp = 1.0; w->lpos[1] = sin(-w->lightAngle); w->lpos[2] = cos(-w->lightAngle); color[0] = c_dusk[0] + (c_night[0] - c_dusk[0]) * lerp; color[1] = c_dusk[1] + (c_night[1] - c_dusk[1]) * lerp; color[2] = c_dusk[2] + (c_night[2] - c_dusk[2]) * lerp; } light_set_color(w->light, color[0], color[1], color[2]); light_set_pos(w->light, w->lpos); }
static void prepare_frame (uint32_t time_offset, void *params, int iparam, viewpoint *view, lighting *lights) { unsigned int i; float secs = (float) time_offset / 1000.0f; float lookat_y = 0.0f; if (secs > 8) lookat_y = secs - 8; view_set_eye_pos (view, 0, 0, 15); view_set_look_at (view, 0, lookat_y, 0); light_set_pos (lights, 0, 3, 10, 15); for (i = 0; i < active; i++) { pos[i][0] += velocity[i][0]; pos[i][1] += velocity[i][1]; pos[i][2] += velocity[i][2]; velocity[i][1] -= 0.01; if (pos[i][1] < -6) { pos[i][0] = 0; pos[i][1] = -2; pos[i][2] = -4; velocity[i][0] = ((float) (rand() & 255) - 127.5) / 500.0; velocity[i][1] = 0.3; velocity[i][2] = ((float) (rand() & 255) - 127.5) / 500.0; } } if (spawnctr > 6 && active < DUCKS) { pos[active][0] = 0; pos[active][1] = -2; pos[active][2] = -4; velocity[active][0] = ((float) (rand() & 255) - 127.5) / 500.0; velocity[active][1] = 0.3; velocity[active][2] = ((float) (rand() & 255) - 127.5) / 500.0; rotaxis[active][0] = ((float) (rand() & 255) - 127.5) / 127.5; rotaxis[active][1] = ((float) (rand() & 255) - 127.5) / 127.5; rotaxis[active][2] = ((float) (rand() & 255) - 127.5) / 127.5; duck_colour[active] = rand() & 1; vec_normalize (&rotaxis[active][0], &rotaxis[active][0]); active++; spawnctr = 0; } spawnctr += 1; rot1 += 2; }
static void do_feedback (uint32_t time_offset, void *params, int iparam, viewpoint *view, lighting *lights) { uint32 tx_x = 1024, tx_y = 512; float tmp[4], invw; flame_pos[0] = 0; flame_pos[1] = (float) (4500 - ((int) time_offset % 9000)) / 1100.0; flame_pos[2] = 4; view_set_eye_pos (view, 0, 0, -4.5); view_set_look_at (view, 0, 0, 0); light_set_pos (lights, 0, flame_pos[0], flame_pos[1], flame_pos[2]); view_fix (view, lights); light_fix (view, lights); vec_transform3_fipr (&tmp[0], &(*view->camera)[0][0], &flame_pos[0]); tmp[3] = 1.0f; vec_transform_fipr (&flame_pos_xformed[0], &(*view->projection)[0][0], &tmp[0]); invw = 1.0 / flame_pos_xformed[3]; flame_pos_xformed[0] *= invw; flame_pos_xformed[1] *= invw; flame_pos_xformed[2] = invw; /* Render to texture. */ pvr_wait_ready (); pvr_scene_begin_txr (warp_texture[warp_active], &tx_x, &tx_y); #if 0 user_clip.d1 = 0; /* minx. */ user_clip.d2 = 7; /* miny. */ user_clip.d3 = 1; /* maxx. */ user_clip.d4 = 9; /* maxy. */ #endif pvr_list_begin (PVR_LIST_OP_POLY); //pvr_prim (&user_clip, sizeof (pvr_poly_hdr_t)); draw_box (); pvr_list_finish (); pvr_list_begin (PVR_LIST_TR_POLY); //pvr_prim (&user_clip, sizeof (pvr_poly_hdr_t)); draw_cooler (); pvr_list_finish (); pvr_scene_finish (); }