3D Mainmenu上每个icon的pos,transform变换等属性都是在FPE callback中最后决定的,而每个icon都以一个虚拟的frame做watch frame来做FPE的。通过给这个虚拟frame起timeline来驱动每个icon做transform变换。若要实现每个Icon的无规律差异变换,可考虑在fpe中的变换式子中,加入随机参数修正。
参考修改代码如下:
1.在接口类IVcpPageView中增加纯虚函数声明
virtual void updateShake(void) = 0;
2.在接口类VcpPageView中增加虚函数声明
virtual void updateShake(void);
3.在类VcpRotatePageView中增加虚函数声明
virtual void updateShake(void);
4.在类VcpRotatePageView中增加成员定义
private:
VfxFloatTimeline * m_shakeTimeline;
5.在文件Vcp_page_menu_util.cpp中增加方法定义
void VcpRotatePageView::updateShake(void)
{
m_shakeTimeline->setTarget(getAnimDummyFrame(VCP_PAGE_MENU_GROUP_MAIN));
m_shakeTimeline->setTargetPropertyId(VRT_FRAME_PROPERTY_ID_TRANSFORM_AFFINE_RZ);
m_shakeTimeline->setFromValue(VFX_DEG_TO_RAD(-5));
m_shakeTimeline->setToValue(VFX_DEG_TO_RAD(5));
m_shakeTimeline->setRepeatCount(-1);
m_shakeTimeline->setDuration(150);
m_shakeTimeline->setAutoReversed(VFX_TRUE);
m_shakeTimeline->start();
}
6.在方法VcpRotatePageView::onInit中最后地方增加一句
VFX_OBJ_CREATE(m_shakeTimeline, VfxFloatTimeline, this);
7.修改方法VcpPageMenuView::update,在下面的地方增加一句
if (getDraggingFrame() != NULL)
{
m_pageView->updateScale(MAINMENU_ORGANIZE_DURATION, MAINMENU_DRAGGING_SCALE);
m_pageView->updateShake(); //added
}
8.给VcpPageView类增加虚方法的实现,即在Vcp_Page_menu_util.cpp中增加下面定义。
void VcpPageView::updateShake(void)
{
}
9.修改VcpRotatePageView::fpeMainGroup方法。
请先找到if (VFX_ABS(rotation) < 0.1f && animStruct->cell != animStruct->menuView->getDraggingFrame() )这
个分支
在这个分支里增加代码如下
......
target_frame->pos.y =
static_cast(target_frame->anchor_point.y * MAINMENU_CELL_Y_ANCHOR_RATIO + animStruct->menuView->m_height / 2);
//added start
if(animStruct->menuView->getDraggingFrame())
{
VfxMatrix4x4 MyTransform, left_Transform1, right_Transform2, rotateMatrix;
VfxFloat tx, ty, rz;
rz = watch_frame->transform.data.affine.rz;
tx = (VfxFloat)(target_frame->bounds.size.width)/2;
ty = (VfxFloat)(target_frame->bounds.size.height)/2;
left_Transform1.setTranslation(tx, ty, 0);
right_Transform2.setTranslation(-tx, -ty, 0);
MyTransform.setRotateByZ(rz);
rotateMatrix = left_Transform1 * MyTransform * right_Transform2;
target_frame->pos.x = 0;
target_frame->pos.y = 0;
VfxMatrix4x4 model, totalProject;
/*model.setTranslation(target_frame->fpe_user_0 + watch_frame->fpe_user_0,
target_frame->anchor_point.y * MAINMENU_CELL_Y_ANCHOR_RATIO, 0);*/
model.setTranslation(target_frame->fpe_user_0 + watch_frame->fpe_user_0 - animStruct->menuView->m_width / 2,
target_frame->anchor_point.y * MAINMENU_CELL_Y_ANCHOR_RATIO -animStruct->menuView->m_height / 2, 0);
totalProject = *(animStruct->transform) * model * rotateMatrix;
VfxTransform tempTransform;
totalProject.initMatrix3x3(tempTransform.data.matrix3x3);
tempTransform.type = VFX_TRANSFORM_TYPE_MATRIX3X3;
tempTransform.initVrtTransform(target_frame->transform);
}
//added end
......
参考修改代码如下:
1.在接口类IVcpPageView中增加纯虚函数声明
virtual void updateShake(void) = 0;
2.在接口类VcpPageView中增加虚函数声明
virtual void updateShake(void);
3.在类VcpRotatePageView中增加虚函数声明
virtual void updateShake(void);
4.在类VcpRotatePageView中增加成员定义
private:
VfxFloatTimeline * m_shakeTimeline;
5.在文件Vcp_page_menu_util.cpp中增加方法定义
void VcpRotatePageView::updateShake(void)
{
m_shakeTimeline->setTarget(getAnimDummyFrame(VCP_PAGE_MENU_GROUP_MAIN));
m_shakeTimeline->setTargetPropertyId(VRT_FRAME_PROPERTY_ID_TRANSFORM_AFFINE_RZ);
m_shakeTimeline->setFromValue(VFX_DEG_TO_RAD(-5));
m_shakeTimeline->setToValue(VFX_DEG_TO_RAD(5));
m_shakeTimeline->setRepeatCount(-1);
m_shakeTimeline->setDuration(150);
m_shakeTimeline->setAutoReversed(VFX_TRUE);
m_shakeTimeline->start();
}
6.在方法VcpRotatePageView::onInit中最后地方增加一句
VFX_OBJ_CREATE(m_shakeTimeline, VfxFloatTimeline, this);
7.修改方法VcpPageMenuView::update,在下面的地方增加一句
if (getDraggingFrame() != NULL)
{
m_pageView->updateScale(MAINMENU_ORGANIZE_DURATION, MAINMENU_DRAGGING_SCALE);
m_pageView->updateShake(); //added
}
8.给VcpPageView类增加虚方法的实现,即在Vcp_Page_menu_util.cpp中增加下面定义。
void VcpPageView::updateShake(void)
{
}
9.修改VcpRotatePageView::fpeMainGroup方法。
请先找到if (VFX_ABS(rotation) < 0.1f && animStruct->cell != animStruct->menuView->getDraggingFrame() )这
个分支
在这个分支里增加代码如下
......
target_frame->pos.y =
static_cast(target_frame->anchor_point.y * MAINMENU_CELL_Y_ANCHOR_RATIO + animStruct->menuView->m_height / 2);
//added start
if(animStruct->menuView->getDraggingFrame())
{
VfxMatrix4x4 MyTransform, left_Transform1, right_Transform2, rotateMatrix;
VfxFloat tx, ty, rz;
rz = watch_frame->transform.data.affine.rz;
tx = (VfxFloat)(target_frame->bounds.size.width)/2;
ty = (VfxFloat)(target_frame->bounds.size.height)/2;
left_Transform1.setTranslation(tx, ty, 0);
right_Transform2.setTranslation(-tx, -ty, 0);
MyTransform.setRotateByZ(rz);
rotateMatrix = left_Transform1 * MyTransform * right_Transform2;
target_frame->pos.x = 0;
target_frame->pos.y = 0;
VfxMatrix4x4 model, totalProject;
/*model.setTranslation(target_frame->fpe_user_0 + watch_frame->fpe_user_0,
target_frame->anchor_point.y * MAINMENU_CELL_Y_ANCHOR_RATIO, 0);*/
model.setTranslation(target_frame->fpe_user_0 + watch_frame->fpe_user_0 - animStruct->menuView->m_width / 2,
target_frame->anchor_point.y * MAINMENU_CELL_Y_ANCHOR_RATIO -animStruct->menuView->m_height / 2, 0);
totalProject = *(animStruct->transform) * model * rotateMatrix;
VfxTransform tempTransform;
totalProject.initMatrix3x3(tempTransform.data.matrix3x3);
tempTransform.type = VFX_TRANSFORM_TYPE_MATRIX3X3;
tempTransform.initVrtTransform(target_frame->transform);
}
//added end
......