Apply flame motion elements when generating flame sequence for animation

This commit is contained in:
Simon Detheridge 2015-07-02 18:01:37 +01:00
parent 679a8b4129
commit f606986b7d
2 changed files with 82 additions and 2 deletions

View File

@ -478,6 +478,8 @@ public:
{
for (size_t i = 0; i < TotalXformCount(); i++)
GetTotalXform(i)->DeleteMotionElements();
m_FlameMotionElements.clear();
}
/// <summary>
@ -1291,6 +1293,82 @@ public:
point.m_Z -= m_CamZPos;
}
#define APP_FMP(x) x += param.second * Interpolater<T>::MotionFuncs(motion.m_MotionFunc, motion.m_MotionFreq * blend)
/// <summary>
/// Update ember parameters based on stored motion elements
/// </summary>
/// <param name="blend">The time percentage value which dictates how much of a percentage of 360 degrees it should be rotated and the time position for the motion elements</param>
void ApplyFlameMotion(T blend)
{
for (size_t i = 0; i < m_FlameMotionElements.size(); ++i)
{
const FlameMotion<T> &motion = m_FlameMotionElements[i];
for (size_t j = 0; j < motion.m_MotionParams.size(); ++j)
{
const pair<eFlameMotionParam, T> &param = motion.m_MotionParams[j];
switch (param.first)
{
case FLAME_MOTION_ZOOM:
APP_FMP(m_Zoom);
break;
case FLAME_MOTION_ZPOS:
APP_FMP(m_CamZPos);
break;
case FLAME_MOTION_PERSPECTIVE:
APP_FMP(m_CamPerspective);
break;
case FLAME_MOTION_YAW:
APP_FMP(m_CamYaw);
break;
case FLAME_MOTION_PITCH:
APP_FMP(m_CamPitch);
break;
case FLAME_MOTION_DEPTH_BLUR:
APP_FMP(m_CamDepthBlur);
break;
case FLAME_MOTION_CENTER_X:
APP_FMP(m_CenterX);
break;
case FLAME_MOTION_CENTER_Y:
APP_FMP(m_CenterY);
break;
case FLAME_MOTION_ROTATE:
APP_FMP(m_Rotate);
break;
case FLAME_MOTION_HUE:
APP_FMP(m_Hue);
break;
case FLAME_MOTION_BRIGHTNESS:
APP_FMP(m_Brightness);
break;
case FLAME_MOTION_GAMMA:
APP_FMP(m_Gamma);
break;
case FLAME_MOTION_GAMMA_THRESH:
APP_FMP(m_GammaThresh);
break;
case FLAME_MOTION_HIGHLIGHT_POWER:
APP_FMP(m_HighlightPower);
break;
case FLAME_MOTION_BACKGROUND_R:
APP_FMP(m_Background.r);
break;
case FLAME_MOTION_BACKGROUND_G:
APP_FMP(m_Background.g);
break;
case FLAME_MOTION_BACKGROUND_B:
APP_FMP(m_Background.b);
break;
case FLAME_MOTION_VIBRANCY:
APP_FMP(m_Vibrancy);
break;
}
}
}
}
/// <summary>
/// Clear this ember and set to either reasonable or unreasonable default values.
/// </summary>

View File

@ -1010,11 +1010,13 @@ public:
if (!xform1->m_Motion.empty())
xform2->ApplyMotion(*xform1, blend);
xform2->DeleteMotionElements();
}
rotated.ApplyFlameMotion(blend);
rotated.RotateAffines(-blend * 360);//Rotate the affines.
rotated.DeleteMotionElements(); // delete all motion elements from the looped flame
}
/// <summary>