Bool fxExplodeInit (CompWindow *w) { if (!polygonsAnimInit (w)) return FALSE; CompScreen *s = w->screen; ANIM_WINDOW (w); const BananaValue * option_explode_gridx = bananaGetOption (bananaIndex, "explode_gridx", s->screenNum); const BananaValue * option_explode_gridy = bananaGetOption (bananaIndex, "explode_gridy", s->screenNum); const BananaValue * option_explode_spokes = bananaGetOption (bananaIndex, "explode_spokes", s->screenNum); const BananaValue * option_explode_tiers = bananaGetOption (bananaIndex, "explode_tiers", s->screenNum); const BananaValue * option_explode_thickness = bananaGetOption (bananaIndex, "explode_thickness", s->screenNum); const BananaValue * option_explode_tessellation = bananaGetOption (bananaIndex, "explode_tessellation", s->screenNum); switch (option_explode_tessellation->i) { case PolygonTessRect: if (!tessellateIntoRectangles (w, option_explode_gridx->i, option_explode_gridy->i, option_explode_thickness->f)) return FALSE; break; case PolygonTessHex: if (!tessellateIntoHexagons (w, option_explode_gridx->i, option_explode_gridy->i, option_explode_thickness->f)) return FALSE; break; case PolygonTessGlass: if (!tessellateIntoGlass (w, option_explode_spokes->i, option_explode_tiers->i, option_explode_thickness->f)) return FALSE; break; default: return FALSE; } PolygonSet *pset = aw->eng.polygonSet; PolygonObject *p = pset->polygons; double sqrt2 = sqrt (2); int i; for (i = 0; i < pset->nPolygons; i++, p++) { p->rotAxis.x = RAND_FLOAT (); p->rotAxis.y = RAND_FLOAT (); p->rotAxis.z = RAND_FLOAT (); float screenSizeFactor = (0.8 * DEFAULT_Z_CAMERA * s->width); float speed = screenSizeFactor / 10 * (0.2 + RAND_FLOAT ()); float xx = 2 * (p->centerRelPos.x - 0.5); float yy = 2 * (p->centerRelPos.y - 0.5); float x = speed * 2 * (xx + 0.5 * (RAND_FLOAT () - 0.5)); float y = speed * 2 * (yy + 0.5 * (RAND_FLOAT () - 0.5)); float distToCenter = sqrt (xx * xx + yy * yy) / sqrt2; float moveMult = 1 - distToCenter; moveMult = moveMult < 0 ? 0 : moveMult; float zbias = 0.1; float z = speed * 10 * (zbias + RAND_FLOAT () * pow (moveMult, 0.5)); p->finalRelPos.x = x; p->finalRelPos.y = y; p->finalRelPos.z = z; p->finalRotAng = RAND_FLOAT () * 540 - 270; } pset->allFadeDuration = 0.3f; pset->doDepthTest = TRUE; pset->doLighting = TRUE; pset->correctPerspective = CorrectPerspectivePolygon; pset->backAndSidesFadeDur = 0.2f; aw->com.animTotalTime /= EXPLODE_PERCEIVED_T; aw->com.animRemainingTime = aw->com.animTotalTime; return TRUE; }
Bool fxSkewerInit (CompWindow *w) { if (!polygonsAnimInit (w)) return FALSE; CompScreen *s = w->screen; ANIM_WINDOW (w); aw->com.animTotalTime /= SKEWER_PERCEIVED_T; aw->com.animRemainingTime = aw->com.animTotalTime; const BananaValue * option_skewer_direction = bananaGetOption (bananaIndex, "skewer_direction", s->screenNum); const BananaValue * option_skewer_tessellation = bananaGetOption (bananaIndex, "skewer_tessellation", s->screenNum); const BananaValue * option_skewer_thickness = bananaGetOption (bananaIndex, "skewer_thickness", s->screenNum); const BananaValue * option_skewer_rotation = bananaGetOption (bananaIndex, "skewer_rotation", s->screenNum); const BananaValue * option_skewer_gridx = bananaGetOption (bananaIndex, "skewer_gridx", s->screenNum); const BananaValue * option_skewer_gridy = bananaGetOption (bananaIndex, "skewer_gridy", s->screenNum); float thickness = option_skewer_thickness->f; int rotation = option_skewer_rotation->i; int gridSizeX = option_skewer_gridx->i; int gridSizeY = option_skewer_gridy->i; int dir[2]; // directions array int c = 0; // number of directions getDirection (dir, &c, option_skewer_direction->i); if (option_skewer_tessellation->i == PolygonTessHex) { if (!tessellateIntoHexagons (w, gridSizeX, gridSizeY, thickness)) return FALSE; } else { if (!tessellateIntoRectangles (w, gridSizeX, gridSizeY, thickness)) return FALSE; } PolygonSet *pset = aw->eng.polygonSet; PolygonObject *p = pset->polygons; int times[pset->nPolygons]; int last_time = pset->nPolygons - 1; int i; for (i = 0; i < pset->nPolygons; i++) times[i] = i; for (i = 0; i < pset->nPolygons; i++, p++) { if (c > 0) { switch (dir[(int)floor (RAND_FLOAT () * c)]) { case 0: // left p->finalRelPos.x = -s->width; p->rotAxis.x = rotation; break; case 1: // right p->finalRelPos.x = s->width; p->rotAxis.x = rotation; break; case 2: // up p->finalRelPos.y = -s->height; p->rotAxis.y = rotation; break; case 3: // down p->finalRelPos.y = s->height; p->rotAxis.y = rotation; break; case 4: // in p->finalRelPos.z = -.8 * DEFAULT_Z_CAMERA * s->width; p->rotAxis.x = rotation; p->rotAxis.y = rotation; break; case 5: // out p->finalRelPos.z = .8 * DEFAULT_Z_CAMERA * s->width; p->rotAxis.x = rotation; p->rotAxis.y = rotation; break; } p->finalRotAng = rotation; } // if no direction is set - just fade // choose random start_time int rand_time = floor (RAND_FLOAT () * last_time); p->moveStartTime = 0.8 / (float)pset->nPolygons * times[rand_time]; p->moveDuration = 1 - p->moveStartTime; p->fadeStartTime = p->moveStartTime + 0.2; p->fadeDuration = 1 - p->fadeStartTime; times[rand_time] = times[last_time]; // copy last one over times[rand_time] last_time--; //descrease last_time } pset->doDepthTest = TRUE; pset->doLighting = TRUE; pset->correctPerspective = CorrectPerspectiveWindow; return TRUE; }
void fxSkewerInit(CompScreen *s, CompWindow *w) { ANIM_SCREEN (s); ANIM_WINDOW (w); aw->animTotalTime /= SKEWER_PERCEIVED_T; aw->animRemainingTime = aw->animTotalTime; float thickness = animGetF (as, aw, ANIM_SCREEN_OPTION_SKEWER_THICKNESS); int rotation = animGetI (as, aw, ANIM_SCREEN_OPTION_SKEWER_ROTATION); int gridSizeX = animGetI (as, aw, ANIM_SCREEN_OPTION_SKEWER_GRIDSIZE_X); int gridSizeY = animGetI (as, aw, ANIM_SCREEN_OPTION_SKEWER_GRIDSIZE_Y); int dir[2]; // directions array int c = 0; // number of directions getDirection (dir, &c, animGetI (as, aw, ANIM_SCREEN_OPTION_SKEWER_DIRECTION)); if (animGetI (as, aw, ANIM_SCREEN_OPTION_SKEWER_TESS) == PolygonTessHex) { if (!tessellateIntoHexagons (w, gridSizeX, gridSizeY, thickness)) return; } else { if (!tessellateIntoRectangles (w, gridSizeX, gridSizeY, thickness)) return; } PolygonSet *pset = aw->polygonSet; PolygonObject *p = pset->polygons; int times[pset->nPolygons]; int last_time = pset->nPolygons - 1; int i; for (i = 0; i < pset->nPolygons; i++) times[i] = i; for (i = 0; i < pset->nPolygons; i++, p++) { if (c > 0) { switch (dir[(int)floor (RAND_FLOAT () * c)]) { case 0: // left p->finalRelPos.x = -s->width; p->rotAxis.x = rotation; break; case 1: // right p->finalRelPos.x = s->width; p->rotAxis.x = rotation; break; case 2: // up p->finalRelPos.y = -s->height; p->rotAxis.y = rotation; break; case 3: // down p->finalRelPos.y = s->height; p->rotAxis.y = rotation; break; case 4: // in p->finalRelPos.z = -.8 * DEFAULT_Z_CAMERA * s->width; p->rotAxis.x = rotation; p->rotAxis.y = rotation; break; case 5: // out p->finalRelPos.z = .8 * DEFAULT_Z_CAMERA * s->width; p->rotAxis.x = rotation; p->rotAxis.y = rotation; break; } p->finalRotAng = rotation; } // if no direction is set - just fade // choose random start_time int rand_time = floor (RAND_FLOAT () * last_time); p->moveStartTime = 0.8 / (float)pset->nPolygons * times[rand_time]; p->moveDuration = 1 - p->moveStartTime; p->fadeStartTime = p->moveStartTime + 0.2; p->fadeDuration = 1 - p->fadeStartTime; times[rand_time] = times[last_time]; // copy last one over times[rand_time] last_time--; //descrease last_time } pset->doDepthTest = TRUE; pset->doLighting = TRUE; pset->correctPerspective = CorrectPerspectiveWindow; }