Example #1
0
void
GridAnim::updateBB (CompOutput &output)
{
    GridModel::GridObject *object = mModel->mObjects;
    for (unsigned int i = 0; i < mModel->mNumObjects; i++, object++)
    {
	mAWindow->expandBBWithPoint (object->position ().x () + 0.5,
				     object->position ().y () + 0.5);
    }
}
Example #2
0
void
GhostAnim::step ()
{
    float t = 1. - progressLinear ();
    if (mCurWindowEvent == WindowEventClose)
	t = 1. - t;

    CompRect winRect (mAWindow->savedRectsValid () ?
                      mAWindow->saveWinRect () :
                      mWindow->geometry ());
    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 owidth = outRect.width ();
    int oheight = outRect.height ();

    AnimJCScreen *ajs = AnimJCScreen::get (screen);

    float waveAmp = 3 * ajs->optionGetGhostAmplitude ();
    float waveLengthX1 = 0.4;
    float waveLengthX2 = 0.3;
    float waveLengthY1 = 0.45;
    float waveLengthY2 = 0.35;
    float wavePositionX1 =  0.25 * t * ajs->optionGetGhostWaveSpeed ();
    float wavePositionX2 = -0.25 * t * ajs->optionGetGhostWaveSpeed ();
    float wavePositionY1 =  0.25 * t * ajs->optionGetGhostWaveSpeed ();
    float wavePositionY2 = -0.25 * t * ajs->optionGetGhostWaveSpeed ();

    GridModel::GridObject *object = mModel->objects ();
    unsigned int n = mModel->numObjects ();
    for (unsigned int i = 0; i < n; i++, object++)
    {
	Point3d &objPos = object->position ();

	float origx = wx + mModel->scale ().x () *
		(owidth * object->gridPosition ().x () -
		outExtents.left);

	float origy = wy + mModel->scale ().y () *
		(oheight * object->gridPosition ().y () -
		outExtents.top);

	float x = object->gridPosition ().x ();
	float y = object->gridPosition ().y ();

	float distFromWaveX1 = x - wavePositionX1;
	float distFromWaveX2 = x - wavePositionX2;
	float distFromWaveY1 = y - wavePositionY1;
	float distFromWaveY2 = y - wavePositionY2;

	objPos.setX (origx +
		     waveAmp * sin (distFromWaveX1 / waveLengthX1 * 2 * M_PI) +
		     waveAmp * sin (distFromWaveX2 / waveLengthX2 * 2 * M_PI));

	objPos.setY (origy +
		     waveAmp * sin (distFromWaveY1 / waveLengthY1 * 2 * M_PI) +
		     waveAmp * sin (distFromWaveY2 / waveLengthY2 * 2 * M_PI));

	objPos.setZ (0);
    }
}
Example #3
0
void
RollUpAnim::step ()
{
    float forwardProgress = progressEaseInEaseOut ();
    bool fixedInterior = optValB (AnimationOptions::RollupFixedInterior);

    CompRect outRect (mAWindow->savedRectsValid () ?
		      mAWindow->savedOutRect () :
		      mWindow->outputRect ());

    int ox = outRect.x ();
    int oy = outRect.y ();
    int owidth = outRect.width ();
    int oheight = outRect.height ();

    GridModel::GridObject *object = mModel->objects ();
    unsigned int n = mModel->numObjects ();
    for (unsigned int i = 0; i < n; i++, object++)
    {
	// Executing shade mode

	Point3d &objPos = object->position ();

	if (i % 2 == 0) // object is at the left side
	{
	    float objGridY = object->gridPosition ().y ();

	    if (objGridY == 0)
	    {
		objPos.setY (oy);
	    }
	    else if (objGridY == 1)
	    {
		objPos.setY (
		    (1 - forwardProgress) * (oy + oheight * objGridY) +
		    forwardProgress * (oy +
				       mDecorTopHeight + mDecorBottomHeight));
	    }
	    else
	    {
		// find position in window contents
		// (window contents correspond to 0.0-1.0 range)
		float relPosInWinContents =
		    (objGridY * oheight -
		     mDecorTopHeight) / mWindow->height ();

		if (relPosInWinContents > forwardProgress)
		{
		    objPos.setY (
			(1 - forwardProgress) * (oy + oheight * objGridY) +
			forwardProgress * (oy + mDecorTopHeight));

		    if (fixedInterior)
			object->offsetTexCoordForQuadBefore ().
			    setY (-forwardProgress * mWindow->height ());
		}
		else
		{
		    objPos.setY (oy + mDecorTopHeight);
		    if (!fixedInterior)
			object->offsetTexCoordForQuadAfter ().
			    setY ((forwardProgress - relPosInWinContents) *
				  mWindow->height ());
		}
	    }
	}
	else // object is at the right side
	{
	    // Set y position to the y position of the object at the left
	    // on the same row (previous object)
	    objPos.setY ((object - 1)->position ().y ());

	    // Also copy offset texture y coordinates
	    object->offsetTexCoordForQuadBefore ().
		setY ((object - 1)->offsetTexCoordForQuadBefore ().y ());
	    object->offsetTexCoordForQuadAfter ().
		setY ((object - 1)->offsetTexCoordForQuadAfter ().y ());
	}

	float origx = ox + owidth * object->gridPosition ().x ();

	objPos.setX (origx);
    }
}
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);
    }
}
Example #5
0
void
RaindropAnim::step ()
{
    float t = 1. - progressLinear ();
    if (mCurWindowEvent == WindowEventClose)
	t = 1. - t;

    CompRect winRect (mAWindow->savedRectsValid () ?
                      mAWindow->saveWinRect () :
                      mWindow->geometry ());
    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 owidth = outRect.width ();
    int oheight = outRect.height ();

    AnimJCScreen *ajs = AnimJCScreen::get (screen);

    float waveLength = ajs->optionGetRaindropWavelength ();
    int numWaves = ajs->optionGetRaindropNumWaves ();
    float waveAmp = (pow ((float)oheight / ::screen->height (), 0.4) * 0.08) *
	    ajs->optionGetRaindropAmplitude ();
    float wavePosition = -waveLength * numWaves +
	    (1. + waveLength * numWaves) * t;

    GridModel::GridObject *object = mModel->objects ();
    unsigned int n = mModel->numObjects ();
    for (unsigned int i = 0; i < n; i++, object++)
    {
	Point3d &objPos = object->position ();

        float origx = wx + mModel->scale ().x () *
		(owidth * object->gridPosition ().x () -
		outExtents.left);
        objPos.setX (origx);

	float origy = wy + mModel->scale ().y () *
		(oheight * object->gridPosition ().y () -
		outExtents.top);
        objPos.setY (origy);

	// find distance to center in grid terms
	float gridDistance = sqrt (pow (object->gridPosition ().x ()-0.5, 2) +
			           pow (object->gridPosition ().y ()-0.5, 2)) *
			     sqrt (2);

	float distFromWave = gridDistance - wavePosition;
	if (distFromWave < waveLength*numWaves && distFromWave > 0)
	    objPos.setZ (waveAmp *
		    sin (3.14159265 * distFromWave / waveLength / numWaves) *
		    pow (sin (3.14159265 * distFromWave / waveLength), 2));
	else
	    objPos.setZ (0);
    }
}
Example #6
0
void
FlickerSingleAnim::step ()
{
    int layer = MultiAnim <FlickerSingleAnim,5>::getCurrAnimNumber (mAWindow);

    CompRect winRect (mAWindow->savedRectsValid () ?
                      mAWindow->saveWinRect () :
                      mWindow->geometry ());
    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 owidth = outRect.width ();
    int oheight = outRect.height ();

    float t = 1 - progressLinear ();
    if (mCurWindowEvent == WindowEventClose)
	t = 1 - t;

    float amplitude = AnimJCScreen::get (screen)->optionGetFlickerAmplitude ();
    float waveLength = 0.4;
    float wavePosition = -waveLength + (1. + waveLength) * t;

    float displacement = 0;

    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) // left side; reuse old displacement on right side
	{
	    float distFromWave = object->gridPosition ().y () - wavePosition;

	    if (distFromWave > 0 && distFromWave <= waveLength)
	    {
		displacement = amplitude * sin (distFromWave/waveLength * M_PI);
	    }
	    else
	    {
		displacement = 0;
	    }
	}

        float x = wx + mModel->scale ().x () *
            (owidth * object->gridPosition ().x () - outExtents.left);

	float y = wy + mModel->scale ().y () *
	    (oheight * object->gridPosition ().y () - outExtents.top);

	switch (layer)
	{
	    case 1:
		x -= displacement;
		break;
	    case 2:
		x += displacement;
		break;
	    case 3:
		y -= displacement;
		break;
	    case 4:
		y += displacement;
		break;
	    default:
		break;
	}

        objPos.setX (x);
	objPos.setY (y);
	objPos.setZ (0);
    }
}