void HorizontalFoldsAnim::initGrid () { mGridWidth = 2; if (mCurWindowEvent == WindowEventShade || mCurWindowEvent == WindowEventUnshade) mGridHeight = 3 + 2 * optValI (AnimationOptions::HorizontalFoldsNumFolds); else mGridHeight = 1 + 2 * optValI (AnimationOptions::HorizontalFoldsNumFolds); }
bool SidekickAnim::isZoomFromCenter () { return (optValI (AnimationOptions::SidekickZoomFromCenter) == AnimationOptions::ZoomFromCenterOn || ((mCurWindowEvent == WindowEventMinimize || mCurWindowEvent == WindowEventUnminimize) && optValI (AnimationOptions::SidekickZoomFromCenter) == AnimationOptions::SidekickZoomFromCenterMinimizeUnminimizeOnly) || ((mCurWindowEvent == WindowEventOpen || mCurWindowEvent == WindowEventClose) && optValI (AnimationOptions::SidekickZoomFromCenter) == AnimationOptions::SidekickZoomFromCenterOpenCloseOnly)); }
BurnAnim::BurnAnim (CompWindow *w, WindowEvent curWindowEvent, float duration, const AnimEffect info, const CompRect &icon) : Animation::Animation (w, curWindowEvent, duration, info, icon), ParticleAnim::ParticleAnim (w, curWindowEvent, duration, info, icon) { mDirection = getActualAnimDirection ((AnimDirection) optValI (AnimationaddonOptions::FireDirection), false); if (optValB (AnimationaddonOptions::FireConstantSpeed)) { int winHeight = w->height () + w->output ().top + w->output ().bottom; mTotalTime *= winHeight / 500.0; mRemainingTime *= winHeight / 500.0; } mMysticalFire = optValB (AnimationaddonOptions::FireMystical); mLife = optValF (AnimationaddonOptions::FireLife); mColor = optValC (AnimationaddonOptions::FireColor); mSize = optValF (AnimationaddonOptions::FireSize); mHasSmoke = optValB (AnimationaddonOptions::FireSmoke); mFirePSId = mHasSmoke ? 1 : 0; mSmokePSId = 0; int numFireParticles = optValI (AnimationaddonOptions::FireParticles); float slowDown = optValF (AnimationaddonOptions::FireSlowdown); // Light ParticleSystem is for smoke, which is optional. // Dark ParticleSystem is for fire. initLightDarkParticles (mHasSmoke ? numFireParticles / 10 : 0, numFireParticles, slowDown / 2.0f, slowDown); }
BeamUpAnim::BeamUpAnim (CompWindow *w, WindowEvent curWindowEvent, float duration, const AnimEffect info, const CompRect &icon) : Animation::Animation (w, curWindowEvent, duration, info, icon), ParticleAnim::ParticleAnim (w, curWindowEvent, duration, info, icon) { mLife = optValF (AnimationaddonOptions::BeamLife); mColor = optValC (AnimationaddonOptions::BeamColor); mSize = optValF (AnimationaddonOptions::BeamSize); mSpacing = optValI (AnimationaddonOptions::BeamSpacing); mSlowdown = optValF (AnimationaddonOptions::BeamSlowdown); }
void HorizontalFoldsAnim::step () { GridZoomAnim::step (); CompRect winRect (mAWindow->savedRectsValid () ? mAWindow->saveWinRect () : mWindow->geometry ()); CompRect inRect (mAWindow->savedRectsValid () ? mAWindow->savedInRect () : mWindow->inputRect ()); CompRect outRect (mAWindow->savedRectsValid () ? mAWindow->savedOutRect () : mWindow->outputRect ()); CompWindowExtents outExtents (mAWindow->savedRectsValid () ? mAWindow->savedOutExtents () : mWindow->output ()); int wx = winRect.x (); int wy = winRect.y (); int oy = outRect.y (); int owidth = outRect.width (); int oheight = outRect.height (); float winHeight = 0; if (mCurWindowEvent == WindowEventShade || mCurWindowEvent == WindowEventUnshade) { winHeight = winRect.height (); } else { winHeight = inRect.height (); } int nHalfFolds = 2.0 * optValI (AnimationOptions::HorizontalFoldsNumFolds); float foldMaxAmp = 0.3 * pow ((winHeight / nHalfFolds) / ::screen->height (), 0.3) * optValF (AnimationOptions::HorizontalFoldsAmpMult); float forwardProgress = getActualProgress (); float sinForProg = sin (forwardProgress * M_PI / 2); GridModel::GridObject *object = mModel->objects (); unsigned int n = mModel->numObjects (); for (unsigned int i = 0; i < n; ++i, ++object) { Point3d &objPos = object->position (); if (i % 2 == 0) // object is at the left side { float objGridY = object->gridPosition ().y (); int rowNo = (int)i / mGridWidth; float origy = (wy + (oheight * objGridY - outExtents.top) * mModel->scale ().y ()); if (mCurWindowEvent == WindowEventShade || mCurWindowEvent == WindowEventUnshade) { // Execute shade mode if (objGridY == 0) { objPos.setY (oy); objPos.setZ (0); } else if (objGridY == 1) { objPos.setY ( (1 - forwardProgress) * origy + forwardProgress * (oy + mDecorTopHeight + mDecorBottomHeight)); objPos.setZ (0); } else { float relDistToFoldCenter = (rowNo % 2 == 1 ? 0.5 : 0); objPos.setY ( (1 - forwardProgress) * origy + forwardProgress * (oy + mDecorTopHeight)); objPos.setZ ( getObjectZ (mModel, forwardProgress, sinForProg, relDistToFoldCenter, foldMaxAmp)); } } else { // Execute normal mode float relDistToFoldCenter = (rowNo % 2 == 0 ? 0.5 : 0); objPos.setY ( (1 - forwardProgress) * origy + forwardProgress * (inRect.y () + inRect.height () / 2.0)); objPos.setZ ( getObjectZ (mModel, forwardProgress, sinForProg, relDistToFoldCenter, foldMaxAmp)); } } else // object is at the right side { // Set y/z position to the y/z position of the object at the left // on the same row (previous object) Point3d &leftObjPos = (object - 1)->position (); objPos.setY (leftObjPos.y ()); objPos.setZ (leftObjPos.z ()); } float origx = (wx + (owidth * object->gridPosition ().x () - outExtents.left) * mModel->scale ().x ()); objPos.setX (origx); } }
void DominoAnim::init () { bool isRazr = (typeid (*this) == typeid (RazrAnim)); int fallDir; if (isRazr) fallDir = getActualAnimDirection ((AnimDirection) optValI (AnimationaddonOptions::RazrDirection), true); else fallDir = getActualAnimDirection ((AnimDirection) optValI (AnimationaddonOptions::DominoDirection), 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; CompRect outRect (mAWindow->savedRectsValid () ? mAWindow->savedOutRect () : mWindow->outputRect ()); // Determine sensible domino piece sizes if (fallDir == AnimDirectionDown || fallDir == AnimDirectionUp) { if (minCellSize > outRect.width ()) minCellSize = outRect.width (); if (outRect.width () / defaultGridSize < minCellSize) gridSizeX = (int)(outRect.width () / minCellSize); else gridSizeX = defaultGridSize; gridCellW = outRect.width () / gridSizeX; gridSizeY = (int)(outRect.height () / (gridCellW * cellAspectRatio)); if (gridSizeY == 0) gridSizeY = 1; gridCellH = outRect.height () / gridSizeY; fallDirGridSize = gridSizeY; } else { if (minCellSize > outRect.height ()) minCellSize = outRect.height (); if (outRect.height () / defaultGridSize < minCellSize) gridSizeY = (int)(outRect.height () / minCellSize); else gridSizeY = defaultGridSize; gridCellH = outRect.height () / gridSizeY; gridSizeX = (int)(outRect.width () / (gridCellH * cellAspectRatio)); if (gridSizeX == 0) gridSizeX = 1; gridCellW = outRect.width () / gridSizeX; fallDirGridSize = gridSizeX; } minDistStartEdge = (1.0 / fallDirGridSize) / 2; float thickness = MIN (gridCellW, gridCellH) / 3.5; if (!tessellateIntoRectangles (gridSizeX, gridSizeY, thickness)) return; 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.setY (-gridCellHalfH); else { posY = -(gridCellHalfH + thickness); posZ = gridCellHalfH - thickness / 2; } break; case AnimDirectionLeft: rotAxisY = -1; if (isRazr) rotAxisOff.setX (gridCellHalfW); else { posX = gridCellHalfW + thickness; posZ = gridCellHalfW - thickness / 2; } nFallingColumns = gridSizeY; break; case AnimDirectionUp: rotAxisX = 1; if (isRazr) rotAxisOff.setY (gridCellHalfH); else { posY = gridCellHalfH + thickness; posZ = gridCellHalfH - thickness / 2; } break; case AnimDirectionRight: rotAxisY = 1; if (isRazr) rotAxisOff.setX (-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[nFallingColumns]; for (int i = 0; i < nFallingColumns; i++) riseTimeRandSeed[i] = RAND_FLOAT (); foreach (PolygonObject *p, mPolygons) { p->rotAxis.set (rotAxisX, rotAxisY, 0); p->finalRelPos.set (posX, posY, 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 = rotAxisOff; } 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; }