void fxHorizontalFoldsInitGrid(CompWindow * w, int *gridWidth, int *gridHeight) { ANIM_WINDOW(w); *gridWidth = 2; if (aw->com.curWindowEvent == WindowEventShade || aw->com.curWindowEvent == WindowEventUnshade) *gridHeight = 3 + 2 * animGetI(w, ANIM_SCREEN_OPTION_HORIZONTAL_FOLDS_NUM_FOLDS); else *gridHeight = 1 + 2 * animGetI(w, ANIM_SCREEN_OPTION_HORIZONTAL_FOLDS_NUM_FOLDS); }
Bool fxShatterInit(CompWindow * w) { CompScreen *s = w->screen; ANIMPLUS_DISPLAY (s->display); ANIMPLUS_WINDOW (w); if (!ad->animAddonFunc->polygonsAnimInit(w)) return FALSE; // CompScreen *s = w->screen; int i,static_polygon; int screen_height = s->outputDev[outputDeviceForWindow(w)].height; ad->animAddonFunc->tessellateIntoGlass( w, animGetI( w, ANIMPLUS_SCREEN_OPTION_SHATTER_NUM_SPOKES), animGetI( w, ANIMPLUS_SCREEN_OPTION_SHATTER_NUM_TIERS), 1); //can't really see how thick it is... PolygonSet *pset = aw->eng->polygonSet; PolygonObject *p = pset->polygons; for (i = 0; i < pset->nPolygons; i++, p++) { p->rotAxis.x = 0; p->rotAxis.y = 0; p->rotAxis.z = 1; static_polygon = 1; p->finalRelPos.x = 0; p->finalRelPos.y = static_polygon * (-p->centerPosStart.y + screen_height); p->finalRelPos.z = 0; if (p->finalRelPos.y) p->finalRotAng = RAND_FLOAT() * 120 * ( RAND_FLOAT() < 0.5 ? -1 : 1 ); } pset->allFadeDuration = 0.4f; pset->backAndSidesFadeDur = 0.2f; pset->doDepthTest = TRUE; pset->doLighting = TRUE; pset->correctPerspective = CorrectPerspectivePolygon; aw->com->animTotalTime /= EXPLODE_PERCEIVED_T; aw->com->animRemainingTime = aw->com->animTotalTime; return TRUE; }
Bool fxBlindsInit( CompWindow * w) { CompScreen *s = w->screen; ANIMPLUS_DISPLAY (s->display); ANIMPLUS_WINDOW (w); if (!ad->animAddonFunc->polygonsAnimInit (w)) return FALSE; ad->animAddonFunc->tessellateIntoRectangles(w, animGetI( w, ANIMPLUS_SCREEN_OPTION_BLINDS_GRIDX), 1, animGetF( w, ANIMPLUS_SCREEN_OPTION_BLINDS_THICKNESS)); PolygonSet *pset = aw->eng->polygonSet; PolygonObject *p = pset->polygons; int i; for (i = 0; i < pset->nPolygons; i++, p++) { //rotate around y axis p->rotAxis.x = 0; p->rotAxis.y = 1; p->rotAxis.z = 0; //dont translate the pieces p->finalRelPos.x = 0; p->finalRelPos.y = 0; p->finalRelPos.z = 0; int numberOfHalfTwists = animGetI( w, ANIMPLUS_SCREEN_OPTION_BLINDS_HALFTWISTS); p->finalRotAng = 180 * numberOfHalfTwists ; } pset->allFadeDuration = 0.4f; pset->backAndSidesFadeDur = 0.2f; pset->doDepthTest = TRUE; pset->doLighting = TRUE; pset->correctPerspective = CorrectPerspectivePolygon; aw->com->animTotalTime /= EXPLODE_PERCEIVED_T; aw->com->animRemainingTime = aw->com->animTotalTime; return TRUE; }
Bool fxZoomInit (CompWindow * w) { ANIM_WINDOW(w); if ((aw->com.curAnimEffect == AnimEffectSidekick && (animGetI (w, ANIM_SCREEN_OPTION_SIDEKICK_ZOOM_FROM_CENTER) == ZoomFromCenterOn || ((aw->com.curWindowEvent == WindowEventMinimize || aw->com.curWindowEvent == WindowEventUnminimize) && animGetI (w, ANIM_SCREEN_OPTION_SIDEKICK_ZOOM_FROM_CENTER) == ZoomFromCenterMin) || ((aw->com.curWindowEvent == WindowEventOpen || aw->com.curWindowEvent == WindowEventClose) && animGetI (w, ANIM_SCREEN_OPTION_SIDEKICK_ZOOM_FROM_CENTER) == ZoomFromCenterCreate))) || (aw->com.curAnimEffect == AnimEffectZoom && (animGetI (w, ANIM_SCREEN_OPTION_ZOOM_FROM_CENTER) == ZoomFromCenterOn || ((aw->com.curWindowEvent == WindowEventMinimize || aw->com.curWindowEvent == WindowEventUnminimize) && animGetI (w, ANIM_SCREEN_OPTION_ZOOM_FROM_CENTER) == ZoomFromCenterMin) || ((aw->com.curWindowEvent == WindowEventOpen || aw->com.curWindowEvent == WindowEventClose) && animGetI (w, ANIM_SCREEN_OPTION_ZOOM_FROM_CENTER) == ZoomFromCenterCreate)))) { aw->com.icon.x = WIN_X(w) + WIN_W(w) / 2 - aw->com.icon.width / 2; aw->com.icon.y = WIN_Y(w) + WIN_H(w) / 2 - aw->com.icon.height / 2; } // allow extra time for spring damping / deceleration if ((aw->com.curWindowEvent == WindowEventUnminimize || aw->com.curWindowEvent == WindowEventOpen) && fxZoomGetSpringiness (w) > 1e-4) { aw->com.animTotalTime /= SPRINGY_ZOOM_PERCEIVED_T; } else if ((aw->com.curAnimEffect == AnimEffectZoom || aw->com.curAnimEffect == AnimEffectSidekick) && (aw->com.curWindowEvent == WindowEventOpen || aw->com.curWindowEvent == WindowEventClose)) { aw->com.animTotalTime /= NONSPRINGY_ZOOM_PERCEIVED_T; } else { aw->com.animTotalTime /= ZOOM_PERCEIVED_T; } aw->com.animRemainingTime = aw->com.animTotalTime; aw->com.usingTransform = TRUE; return defaultAnimInit (w); }
static void applyFlyinTransform (CompWindow *w) { ANIMSIM_WINDOW (w); CompTransform *transform = &aw->com->transform; float offsetX, offsetY; float xTrans, yTrans; float forwardProgress; int direction = animGetI (w, ANIMSIM_SCREEN_OPTION_FLYIN_DIRECTION); switch (direction) { case 0: offsetX = 0; offsetY = animGetF (w, ANIMSIM_SCREEN_OPTION_FLYIN_DISTANCE); break; case 1: offsetX = animGetF (w, ANIMSIM_SCREEN_OPTION_FLYIN_DISTANCE); offsetY = 0; break; case 2: offsetX = 0; offsetY = -animGetF (w, ANIMSIM_SCREEN_OPTION_FLYIN_DISTANCE); break; case 3: offsetX = -animGetF (w, ANIMSIM_SCREEN_OPTION_FLYIN_DISTANCE); offsetY = 0; break; case 4: offsetX = animGetF (w, ANIMSIM_SCREEN_OPTION_FLYIN_DIRECTION_X); offsetY = animGetF (w, ANIMSIM_SCREEN_OPTION_FLYIN_DIRECTION_Y); break; default: return; } forwardProgress = fxFlyinAnimProgress (w); xTrans = -(forwardProgress * offsetX); yTrans = -(forwardProgress * offsetY); Point3d translation = {xTrans, yTrans, 0}; // animation movement matrixTranslate (transform, translation.x, translation.y, translation.z); }
void fxHorizontalFoldsModelStep(CompWindow * w, float time) { defaultAnimStep(w, time); ANIM_WINDOW(w); Model *model = aw->com.model; float winHeight = 0; if (aw->com.curWindowEvent == WindowEventShade || aw->com.curWindowEvent == WindowEventUnshade) { winHeight = (w)->height; } else { winHeight = BORDER_H(w); } int nHalfFolds = 2.0 * animGetI(w, ANIM_SCREEN_OPTION_HORIZONTAL_FOLDS_NUM_FOLDS); float foldMaxAmp = 0.3 * pow((winHeight / nHalfFolds) / w->screen->height, 0.3) * animGetF(w, ANIM_SCREEN_OPTION_HORIZONTAL_FOLDS_AMP_MULT); float forwardProgress = getProgressAndCenter(w, NULL); float sinForProg = sin(forwardProgress * M_PI / 2); Object *object = model->objects; int i; for (i = 0; i < model->numObjects; i++, object++) fxHorizontalFoldsModelStepObject(w, model, object, forwardProgress, sinForProg, foldMaxAmp, i / model->gridWidth); }
Bool fxDominoInit (CompWindow * w) { if (!polygonsAnimInit (w)) return FALSE; ANIMADDON_DISPLAY (w->screen->display); ANIMADDON_WINDOW (w); Bool isRazr = (aw->com->curAnimEffect == AnimEffectRazr); int fallDir; if (isRazr) fallDir = ad->animBaseFunctions->getActualAnimDirection (w, animGetI (w, ANIMADDON_SCREEN_OPTION_RAZR_DIRECTION), TRUE); else fallDir = ad->animBaseFunctions->getActualAnimDirection (w, animGetI (w, ANIMADDON_SCREEN_OPTION_DOMINO_DIRECTION), TRUE); int defaultGridSize = 20; float minCellSize = 30; int gridSizeX; int gridSizeY; int fallDirGridSize; float minDistStartEdge; // half piece size in [0,1] range float gridCellW; float gridCellH; float cellAspectRatio = 1.25; if (isRazr) cellAspectRatio = 1; // Determine sensible domino piece sizes if (fallDir == AnimDirectionDown || fallDir == AnimDirectionUp) { if (minCellSize > BORDER_W(w)) minCellSize = BORDER_W(w); if (BORDER_W(w) / defaultGridSize < minCellSize) gridSizeX = (int)(BORDER_W(w) / minCellSize); else gridSizeX = defaultGridSize; gridCellW = BORDER_W(w) / gridSizeX; gridSizeY = (int)(BORDER_H(w) / (gridCellW * cellAspectRatio)); if (gridSizeY == 0) gridSizeY = 1; gridCellH = BORDER_H(w) / gridSizeY; fallDirGridSize = gridSizeY; } else { if (minCellSize > BORDER_H(w)) minCellSize = BORDER_H(w); if (BORDER_H(w) / defaultGridSize < minCellSize) gridSizeY = (int)(BORDER_H(w) / minCellSize); else gridSizeY = defaultGridSize; gridCellH = BORDER_H(w) / gridSizeY; gridSizeX = (int)(BORDER_W(w) / (gridCellH * cellAspectRatio)); if (gridSizeX == 0) gridSizeX = 1; gridCellW = BORDER_W(w) / gridSizeX; fallDirGridSize = gridSizeX; } minDistStartEdge = (1.0 / fallDirGridSize) / 2; float thickness = MIN(gridCellW, gridCellH) / 3.5; if (!tessellateIntoRectangles(w, gridSizeX, gridSizeY, thickness)) return FALSE; float rotAxisX = 0; float rotAxisY = 0; Point3d rotAxisOff = { 0, 0, thickness / 2 }; float posX = 0; // position of standing piece float posY = 0; float posZ = 0; int nFallingColumns = gridSizeX; float gridCellHalfW = gridCellW / 2; float gridCellHalfH = gridCellH / 2; switch (fallDir) { case AnimDirectionDown: rotAxisX = -1; if (isRazr) rotAxisOff.y = -gridCellHalfH; else { posY = -(gridCellHalfH + thickness); posZ = gridCellHalfH - thickness / 2; } break; case AnimDirectionLeft: rotAxisY = -1; if (isRazr) rotAxisOff.x = gridCellHalfW; else { posX = gridCellHalfW + thickness; posZ = gridCellHalfW - thickness / 2; } nFallingColumns = gridSizeY; break; case AnimDirectionUp: rotAxisX = 1; if (isRazr) rotAxisOff.y = gridCellHalfH; else { posY = gridCellHalfH + thickness; posZ = gridCellHalfH - thickness / 2; } break; case AnimDirectionRight: rotAxisY = 1; if (isRazr) rotAxisOff.x = -gridCellHalfW; else { posX = -(gridCellHalfW + thickness); posZ = gridCellHalfW - thickness / 2; } nFallingColumns = gridSizeY; break; } float fadeDuration; float riseDuration; float riseTimeRandMax = 0.2; if (isRazr) { riseDuration = (1 - riseTimeRandMax) / fallDirGridSize; fadeDuration = riseDuration / 2; } else { fadeDuration = 0.18; riseDuration = 0.2; } float *riseTimeRandSeed = calloc(nFallingColumns, sizeof(float)); if (!riseTimeRandSeed) // TODO: log error here return FALSE; int i; for (i = 0; i < nFallingColumns; i++) riseTimeRandSeed[i] = RAND_FLOAT(); PolygonSet *pset = aw->eng.polygonSet; PolygonObject *p = pset->polygons; for (i = 0; i < pset->nPolygons; i++, p++) { p->rotAxis.x = rotAxisX; p->rotAxis.y = rotAxisY; p->rotAxis.z = 0; p->finalRelPos.x = posX; p->finalRelPos.y = posY; p->finalRelPos.z = posZ; // dist. from rise-start / fall-end edge in window ([0,1] range) float distStartEdge = 0; // dist. from edge perpendicular to movement (for move start time) // so that same the blocks in same row/col. appear to knock down // the next one float distPerpEdge = 0; switch (fallDir) { case AnimDirectionUp: distStartEdge = p->centerRelPos.y; distPerpEdge = p->centerRelPos.x; break; case AnimDirectionRight: distStartEdge = 1 - p->centerRelPos.x; distPerpEdge = p->centerRelPos.y; break; case AnimDirectionDown: distStartEdge = 1 - p->centerRelPos.y; distPerpEdge = p->centerRelPos.x; break; case AnimDirectionLeft: distStartEdge = p->centerRelPos.x; distPerpEdge = p->centerRelPos.y; break; } float riseTimeRand = riseTimeRandSeed[(int)(distPerpEdge * nFallingColumns)] * riseTimeRandMax; p->moveDuration = riseDuration; float mult = 1; if (fallDirGridSize > 1) mult = ((distStartEdge - minDistStartEdge) / (1 - 2 * minDistStartEdge)); if (isRazr) { p->moveStartTime = mult * (1 - riseDuration - riseTimeRandMax) + riseTimeRand; p->fadeStartTime = p->moveStartTime + riseDuration / 2; p->finalRotAng = -180; p->rotAxisOffset.x = rotAxisOff.x; p->rotAxisOffset.y = rotAxisOff.y; p->rotAxisOffset.z = rotAxisOff.z; } else { p->moveStartTime = mult * (1 - riseDuration - riseTimeRandMax) + riseTimeRand; p->fadeStartTime = p->moveStartTime + riseDuration - riseTimeRand + 0.03; p->finalRotAng = -90; } if (p->fadeStartTime > 1 - fadeDuration) p->fadeStartTime = 1 - fadeDuration; p->fadeDuration = fadeDuration; } free(riseTimeRandSeed); pset->doDepthTest = TRUE; pset->doLighting = TRUE; pset->correctPerspective = CorrectPerspectivePolygon; aw->com->animTotalTime /= DOMINO_PERCEIVED_T; aw->com->animRemainingTime = aw->com->animTotalTime; 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; }