Пример #1
0
Bool
fxGlideIsPolygonBased(AnimScreen *as, AnimWindow *aw)
{
   if (aw->curAnimEffect == AnimEffectGlide3D1)
     return animGetF(as, aw, ANIM_SCREEN_OPTION_GLIDE1_THICKNESS) > 1e-5;
   else
     return animGetF(as, aw, ANIM_SCREEN_OPTION_GLIDE2_THICKNESS) > 1e-5;
}
static float
fxZoomGetSpringiness (CompWindow *w)
{
    ANIM_WINDOW(w);

    if (aw->com.curAnimEffect == AnimEffectZoom)
	return 2 * animGetF (w, ANIM_SCREEN_OPTION_ZOOM_SPRINGINESS);
    else if (aw->com.curAnimEffect == AnimEffectSidekick)
	return 1.6 * animGetF (w, ANIM_SCREEN_OPTION_SIDEKICK_SPRINGINESS);
    else
	return 0.0f;
}
Пример #3
0
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
fxSidekickInit (CompWindow * w)
{
    ANIM_WINDOW(w);

    // determine number of rotations randomly in [0.9, 1.1] range
    aw->numZoomRotations =
	animGetF (w, ANIM_SCREEN_OPTION_SIDEKICK_NUM_ROTATIONS) *
	(1.0f + 0.2f * rand() / RAND_MAX - 0.1f);

    float winCenterX = WIN_X(w) + WIN_W(w) / 2.0;
    float iconCenterX = aw->com.icon.x + aw->com.icon.width / 2.0;

    // if window is to the right of icon, rotate clockwise instead
    // to make rotation look more pleasant
    if (winCenterX > iconCenterX)
	aw->numZoomRotations *= -1;

    return fxZoomInit (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);

}
Пример #6
0
Bool
fxCurvedFoldModelStep(CompScreen *s, CompWindow *w, float time)
{
    if (!defaultAnimStep(s, w, time))
        return FALSE;

    ANIM_SCREEN(s);
    ANIM_WINDOW(w);

    Model *model = aw->model;

    float forwardProgress;
    if ((aw->curWindowEvent == WindowEventMinimize ||
            aw->curWindowEvent == WindowEventUnminimize) &&
            animGetB(as, aw, ANIM_SCREEN_OPTION_CURVED_FOLD_Z2TOM))
    {
        float dummy;
        fxZoomAnimProgress(as, aw, &forwardProgress, &dummy, TRUE);
    }
    else
        forwardProgress = defaultAnimProgress(aw);

    float curveMaxAmp =
        animGetF(as, aw, ANIM_SCREEN_OPTION_CURVED_FOLD_AMP) * WIN_W(w) *
        pow(WIN_H(w) / (s->height * 1.2f), 0.7);
    int i;
    for (i = 0; i < model->numObjects; i++)
        fxCurvedFoldModelStepObject
        (w,
         model,
         &model->objects[i],
         forwardProgress,
         curveMaxAmp);

    return TRUE;
}
Пример #7
0
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);
}
Пример #8
0
static void
fxGlideGetParams(AnimScreen *as,
                 AnimWindow *aw,
                 float      *finalDistFac,
                 float      *finalRotAng,
                 float      *thickness)
{
   if (aw->curAnimEffect == AnimEffectGlide3D1)
     {
        *finalDistFac = animGetF(as, aw, ANIM_SCREEN_OPTION_GLIDE1_AWAY_POS);
        *finalRotAng = animGetF(as, aw, ANIM_SCREEN_OPTION_GLIDE1_AWAY_ANGLE);
        *thickness = animGetF(as, aw, ANIM_SCREEN_OPTION_GLIDE1_THICKNESS);
     }
   else
     {
        *finalDistFac = animGetF(as, aw, ANIM_SCREEN_OPTION_GLIDE2_AWAY_POS);
        *finalRotAng = animGetF(as, aw, ANIM_SCREEN_OPTION_GLIDE2_AWAY_ANGLE);
        *thickness = animGetF(as, aw, ANIM_SCREEN_OPTION_GLIDE2_THICKNESS);
     }
}
void
fxAirplaneLinearAnimStepPolygon (CompWindow *w,
				   PolygonObject *p,
				   float forwardProgress)
{
    ANIMADDON_WINDOW (w);

    float airplanePathLength =
	animGetF (w, ANIMADDON_SCREEN_OPTION_AIRPLANE_PATHLENGTH);
    Bool airplaneFly2TaskBar =
	animGetB (w, ANIMADDON_SCREEN_OPTION_AIRPLANE_FLY2TOM);

    AirplaneEffectParameters *aep = p->effectParameters;
    if (!aep)
	return;

    /*  Phase1: folding: flaps, folding center, folding wings.
     *  Phase2: rotate and fly.
     */

    if (forwardProgress > p->moveStartTime &&
	forwardProgress < aep->moveStartTime4)
	// Phase1: folding: flaps, center, wings.
    {
	float moveProgress1 = forwardProgress - p->moveStartTime;
	if (p->moveDuration > 0)
	    moveProgress1 /= p->moveDuration;
	else
	    moveProgress1 = 0;
	if (moveProgress1 < 0)
	    moveProgress1 = 0;
	else if (moveProgress1 > 1)
	    moveProgress1 = 1;

	float moveProgress2 = forwardProgress - aep->moveStartTime2;
	if (aep->moveDuration2 > 0)
	    moveProgress2 /= aep->moveDuration2;
	else
	    moveProgress2 = 0;
	if (moveProgress2 < 0)
	    moveProgress2 = 0;
	else if (moveProgress2 > 1)
	    moveProgress2 = 1;

	float moveProgress3 = forwardProgress - aep->moveStartTime3;
	if (aep->moveDuration3 > 0)
	    moveProgress3 /= aep->moveDuration3;
	else
	    moveProgress3 = 0;
	if (moveProgress3 < 0)
	    moveProgress3 = 0;
	else if (moveProgress3 > 1)
	    moveProgress3 = 1;

	p->centerPos.x = p->centerPosStart.x;
	p->centerPos.y = p->centerPosStart.y;
	p->centerPos.z = p->centerPosStart.z;

	p->rotAngle = moveProgress1 * p->finalRotAng;
	aep->rotAngleA = moveProgress2 * aep->finalRotAngA;
	aep->rotAngleB = moveProgress3 * aep->finalRotAngB;

	aep->flyRotation.x = 0;
	aep->flyRotation.y = 0;
	aep->flyRotation.z = 0;
	aep->flyScale = 0;
    }
    else if (forwardProgress >= aep->moveStartTime4)
	// Phase2: rotate and fly 
    {
	float moveProgress4 = forwardProgress - aep->moveStartTime4;
	if (aep->moveDuration4 > 0)
	    moveProgress4 /= aep->moveDuration4;
	if (moveProgress4 < 0)
	    moveProgress4 = 0;
	else if (moveProgress4 > 1)
	    moveProgress4 = 1;

	float moveProgress5 = forwardProgress - (aep->moveStartTime4 + .01);
	if (aep->moveDuration5 > 0)
	    moveProgress5 /= aep->moveDuration5;
	if (moveProgress5 < 0)
	    moveProgress5 = 0;
	else if (moveProgress5 > 1)
	    moveProgress5 = 1;


	p->rotAngle = p->finalRotAng;
	aep->rotAngleA = aep->finalRotAngA;
	aep->rotAngleB = aep->finalRotAngB;

	aep->flyRotation.x = moveProgress4 * aep->flyFinalRotation.x;
	aep->flyRotation.y = moveProgress4 * aep->flyFinalRotation.y;

	// flying path

	float icondiffx = 0;
	aep->flyTheta = moveProgress5 * -M_PI_2 * airplanePathLength;
	aep->centerPosFly.x = w->screen->width * .4 * sin (2 * aep->flyTheta);

	if (((aw->com->curWindowEvent == WindowEventMinimize ||
	      aw->com->curWindowEvent == WindowEventUnminimize) &&
	     airplaneFly2TaskBar) ||
	    aw->com->curWindowEvent == WindowEventOpen ||
	    aw->com->curWindowEvent == WindowEventClose)
	{
	    // flying path ends at icon/pointer

	    int sign = 1;
	    if (aw->com->curWindowEvent == WindowEventUnminimize ||
		aw->com->curWindowEvent == WindowEventOpen)
		sign = -1;

	    icondiffx =
		(((aw->com->icon.x + aw->com->icon.width / 2)
		  - (p->centerPosStart.x +
		     sign * w->screen->width * .4 *
		     sin (2 * -M_PI_2 * airplanePathLength))) *
		 moveProgress5);
	    aep->centerPosFly.y =
		((aw->com->icon.y + aw->com->icon.height / 2) -
		 p->centerPosStart.y) *
		-sin (aep->flyTheta / airplanePathLength);
	}
	else
	{
	    if (p->centerPosStart.y < w->screen->height * .33 ||
		p->centerPosStart.y > w->screen->height * .66)
		aep->centerPosFly.y =
		    w->screen->height * .6 * sin (aep->flyTheta / 3.4);
	    else
		aep->centerPosFly.y =
		    w->screen->height * .4 * sin (aep->flyTheta / 3.4);
	    if (p->centerPosStart.y < w->screen->height * .33)
		aep->centerPosFly.y *= -1;
	}

	aep->flyFinalRotation.z =
	    ((atan (2.0) + M_PI_2) * sin (aep->flyTheta) - M_PI_2) * 180 / M_PI;
	aep->flyFinalRotation.z += 90;


	if (aw->com->curWindowEvent == WindowEventMinimize ||
	    aw->com->curWindowEvent == WindowEventClose)
	{
	    aep->flyFinalRotation.z *= -1;
	}
	else if (aw->com->curWindowEvent == WindowEventUnminimize ||
		 aw->com->curWindowEvent == WindowEventOpen)
	{
	    aep->centerPosFly.x *= -1;
	}

	aep->flyRotation.z = aep->flyFinalRotation.z;

	p->centerPos.x = p->centerPosStart.x + aep->centerPosFly.x + icondiffx;
	p->centerPos.y = p->centerPosStart.y + aep->centerPosFly.y;
	p->centerPos.z = p->centerPosStart.z + aep->centerPosFly.z;

	aep->flyScale = moveProgress5 * aep->flyFinalScale;
    }
}
Bool
fxAirplaneInit (CompWindow * w)
{
    if (!polygonsAnimInit (w))
	return FALSE;

    if (!tessellateIntoAirplane (w))
	return FALSE;

    ANIMADDON_WINDOW (w);

    float airplanePathLength =
	animGetF (w, ANIMADDON_SCREEN_OPTION_AIRPLANE_PATHLENGTH);

    PolygonSet *pset = aw->eng.polygonSet;
    PolygonObject *p = pset->polygons;

    float winLimitsW;		// boundaries of polygon tessellation
    float winLimitsH;

    winLimitsW = BORDER_W (w);
    winLimitsH = BORDER_H (w);

    float H4 = (float)winLimitsH / 4;
    float H6 = (float)winLimitsH / 6;

    int i;
    for (i = 0; i < pset->nPolygons; i++, p++)
    {
	if (!p->effectParameters)
	{
	    p->effectParameters = calloc (1, sizeof (AirplaneEffectParameters));
	}
	if (!p->effectParameters)
	{
	    compLogMessage ("animation", CompLogLevelError,
			    "Not enough memory");
	    return FALSE;
	}

	AirplaneEffectParameters *aep = p->effectParameters;

	p->moveStartTime = 0.00;
	p->moveDuration = 0.19;

	aep->moveStartTime2 = 0.19;
	aep->moveDuration2 = 0.19;

	aep->moveStartTime3 = 0.38;
	aep->moveDuration3 = 0.19;

	aep->moveStartTime4 = 0.58;
	aep->moveDuration4 = 0.09;

	aep->moveDuration5 = 0.41;

	aep->flyFinalRotation.x = 90;
	aep->flyFinalRotation.y = 10;

	aep->flyTheta = 0;

	aep->centerPosFly.x = 0;
	aep->centerPosFly.y = 0;
	aep->centerPosFly.z = 0;

	aep->flyScale = 0;
	aep->flyFinalScale = 6 * (winLimitsW / (w->screen->width / 2));

	switch (i)
	{
	case 0:
	    p->rotAxisOffset.x = -H4;
	    p->rotAxisOffset.y = H4;

	    p->rotAxis.x = 1.00;
	    p->rotAxis.y = 1.00;
	    p->rotAxis.z = 0.00;

	    p->finalRotAng = 179.5;

	    aep->rotAxisOffsetA.x = 0;
	    aep->rotAxisOffsetA.y = 0;

	    aep->rotAxisA.x = 1.00;
	    aep->rotAxisA.y = 0.00;
	    aep->rotAxisA.z = 0.00;

	    aep->finalRotAngA = 84;

	    aep->rotAxisOffsetB.x = 0;
	    aep->rotAxisOffsetB.y = 0;

	    aep->rotAxisB.x = 0.00;
	    aep->rotAxisB.y = 0.00;
	    aep->rotAxisB.z = 0.00;

	    aep->finalRotAngB = 0;
	    break;

	case 1:
	    p->rotAxisOffset.x = -H4;
	    p->rotAxisOffset.y = H4;

	    p->rotAxis.x = 1.00;
	    p->rotAxis.y = 1.00;
	    p->rotAxis.z = 0.00;

	    p->finalRotAng = 179.5;

	    aep->rotAxisOffsetA.x = 0;
	    aep->rotAxisOffsetA.y = 0;

	    aep->rotAxisA.x = 1.00;
	    aep->rotAxisA.y = 0.00;
	    aep->rotAxisA.z = 0.00;

	    aep->finalRotAngA = 84;

	    aep->rotAxisOffsetB.x = 0;
	    aep->rotAxisOffsetB.y = H6;

	    aep->rotAxisB.x = 1.00;
	    aep->rotAxisB.y = 0.00;
	    aep->rotAxisB.z = 0.00;

	    aep->finalRotAngB = -84;
	    break;

	case 2:
	    p->moveDuration = 0.00;

	    p->rotAxisOffset.x = 0;
	    p->rotAxisOffset.y = 0;

	    p->rotAxis.x = 0.00;
	    p->rotAxis.y = 0.00;
	    p->rotAxis.z = 0.00;

	    p->finalRotAng = 0;

	    aep->rotAxisOffsetA.x = 0;
	    aep->rotAxisOffsetA.y = 0;

	    aep->rotAxisA.x = 1.00;
	    aep->rotAxisA.y = 0.00;
	    aep->rotAxisA.z = 0.00;

	    aep->finalRotAngA = 84;

	    aep->rotAxisOffsetB.x = 0;
	    aep->rotAxisOffsetB.y = H6;

	    aep->rotAxisB.x = 1.00;
	    aep->rotAxisB.y = 0.00;
	    aep->rotAxisB.z = 0.00;

	    aep->finalRotAngB = -84;
	    break;

	case 3:
	    p->moveDuration = 0.00;

	    p->rotAxisOffset.x = 0;
	    p->rotAxisOffset.y = 0;

	    p->rotAxis.x = 0.00;
	    p->rotAxis.y = 0.00;
	    p->rotAxis.z = 0.00;

	    p->finalRotAng = 0;

	    aep->rotAxisOffsetA.x = 0;
	    aep->rotAxisOffsetA.y = 0;

	    aep->rotAxisA.x = 1.00;
	    aep->rotAxisA.y = 0.00;
	    aep->rotAxisA.z = 0.00;

	    aep->finalRotAngA = 84;

	    aep->moveDuration3 = 0.00;

	    aep->rotAxisOffsetB.x = 0;
	    aep->rotAxisOffsetB.y = 0;

	    aep->rotAxisB.x = 0.00;
	    aep->rotAxisB.y = 0.00;
	    aep->rotAxisB.z = 0.00;

	    aep->finalRotAngB = 0;
	    break;

	case 4:
	    p->moveDuration = 0.00;

	    p->rotAxisOffset.x = 0;
	    p->rotAxisOffset.y = 0;

	    p->rotAxis.x = 0.00;
	    p->rotAxis.y = 0.00;
	    p->rotAxis.z = 0.00;

	    p->finalRotAng = 0;

	    aep->rotAxisOffsetA.x = 0;
	    aep->rotAxisOffsetA.y = 0;

	    aep->rotAxisA.x = 1.00;
	    aep->rotAxisA.y = 0.00;
	    aep->rotAxisA.z = 0.00;

	    aep->finalRotAngA = -84;

	    aep->moveDuration3 = 0.00;

	    aep->rotAxisOffsetB.x = 0;
	    aep->rotAxisOffsetB.y = 0;

	    aep->rotAxisB.x = 0.00;
	    aep->rotAxisB.y = 0.00;
	    aep->rotAxisB.z = 0.00;

	    aep->finalRotAngB = 0;
	    break;

	case 5:
	    p->moveDuration = 0.00;

	    p->rotAxisOffset.x = 0;
	    p->rotAxisOffset.y = 0;

	    p->rotAxis.x = 0.00;
	    p->rotAxis.y = 0.00;
	    p->rotAxis.z = 0.00;

	    p->finalRotAng = 0;

	    aep->rotAxisOffsetA.x = 0;
	    aep->rotAxisOffsetA.y = 0;

	    aep->rotAxisA.x = 1.00;
	    aep->rotAxisA.y = 0.00;
	    aep->rotAxisA.z = 0.00;

	    aep->finalRotAngA = -84;

	    aep->rotAxisOffsetB.x = 0;
	    aep->rotAxisOffsetB.y = -H6;

	    aep->rotAxisB.x = 1.00;
	    aep->rotAxisB.y = 0.00;
	    aep->rotAxisB.z = 0.00;

	    aep->finalRotAngB = 84;
	    break;

	case 6:
	    p->rotAxisOffset.x = -H4;
	    p->rotAxisOffset.y = -H4;

	    p->rotAxis.x = 1.00;
	    p->rotAxis.y = -1.00;
	    p->rotAxis.z = 0.00;

	    p->finalRotAng = -179.5;

	    aep->rotAxisOffsetA.x = 0;
	    aep->rotAxisOffsetA.y = 0;

	    aep->rotAxisA.x = 1.00;
	    aep->rotAxisA.y = 0.00;
	    aep->rotAxisA.z = 0.00;

	    aep->finalRotAngA = -84;

	    aep->rotAxisOffsetB.x = 0;
	    aep->rotAxisOffsetB.y = -H6;

	    aep->rotAxisB.x = 1.00;
	    aep->rotAxisB.y = 0.00;
	    aep->rotAxisB.z = 0.00;

	    aep->finalRotAngB = 84;
	    break;

	case 7:
	    p->rotAxisOffset.x = -H4;
	    p->rotAxisOffset.y = -H4;

	    p->rotAxis.x = 1.00;
	    p->rotAxis.y = -1.00;
	    p->rotAxis.z = 0.00;

	    p->finalRotAng = -179.5;

	    aep->rotAxisOffsetA.x = 0;
	    aep->rotAxisOffsetA.y = 0;

	    aep->rotAxisA.x = 1.00;
	    aep->rotAxisA.y = 0.00;
	    aep->rotAxisA.z = 0.00;

	    aep->finalRotAngA = -84;

	    aep->rotAxisOffsetB.x = 0;
	    aep->rotAxisOffsetB.y = 0;

	    aep->rotAxisB.x = 0.00;
	    aep->rotAxisB.y = 0.00;
	    aep->rotAxisB.z = 0.00;

	    aep->finalRotAngB = 0;
	    break;
	}
    }

    if (airplanePathLength >= 1)
	pset->allFadeDuration = 0.30f / airplanePathLength;
    else
	pset->allFadeDuration = 0.30f;

    pset->doDepthTest = TRUE;
    pset->doLighting = TRUE;
    pset->correctPerspective = CorrectPerspectivePolygon;

    pset->extraPolygonTransformFunc =
	&AirplaneExtraPolygonTransformFunc;

    // Duration extension
    aw->com->animTotalTime *= 2 + airplanePathLength;
    aw->com->animRemainingTime = aw->com->animTotalTime;

    return TRUE;
}
Пример #11
0
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;
}