Tue, 09/07/2021 - 12:52
I want to make the shape rotate around an axis parallel to the Y-axis.
The final result is right,but the animation process is wrong,the shape will translate and rotate in the same time.It's because the shape will first dot translate Mat to XYZ then rotate then translate to the original position?
How to deal it? please
Best regard.
gp_Trsf start_pnt, end_pnt;
gp_Vec tempVec = gp_Vec(0,1,0);
gp_Ax1 tempAx1 = gp_Ax1(gp_Pnt(10,0,0), tempVec);
end_pnt.SetRotation(tempAx1, 1.57);
Handle(AIS_Animation) ais_animation = new AIS_Animation("obj1");
Handle(AIS_AnimationObject) ais_ao = new AIS_AnimationObject("obj1", m_occView->getOpenCascadeCtrl()->GetAISContext(), shapeDoor, start_pnt, end_pnt);
ais_ao->SetOwnDuration(0.5);
ais_animation->Add(ais_ao);
double duration = ais_animation->Duration();
ais_animation->StartTimer(0, 1.0, true);
while (!ais_animation->IsStopped())
{
ais_animation->UpdateTimer();
m_occView->getOpenCascadeCtrl()->GetAISContext()->UpdateCurrentViewer();
}
Wed, 09/15/2021 - 10:10
One of the problems here is that gp_Trsf defined from axis and rotation angle does not keeps transformation path, only final result which is decomposed in a different way. AIS_AnimationObject performs linear interpolation between two gp_Trsf decomposed into translation, rotation and scale parts.
There are several options to achieve desired animation:
- Define an object from an origin matching rotation axis.
- Subclass AIS_Animation and define your own transformation logic.
- Decompose a complex transformation into several smaller steps.