Reputation: 7288
Currently I apply translation to an actor through below code:
vtkSmartPointer<vtkTransform> translation =
vtkSmartPointer<vtkTransform>::New();
translation->PostMultiply(); //this is the key line
translation->Translate(translationVector);
patella->getActor()->SetUserTransform(translation);
However, if I apply
patella->getActor()->SetUserTransform(translation);
again. The actor stays at the same position as if I applied it only once. I know it's because the origin is not updated. Thus, how can I update the origin/actor after each translation?
Upvotes: 1
Views: 1591
Reputation: 695
You want to concatenate the transforms. Something like:
vtkActor* patellaActor = patella->GetActor();
vtkTransform* patellaXfm = patellaActor->GetUserTransform();
if (!patellaXfm) {
patellaActor->SetUserTransform(translation);
} else {
patellaXfm->Concatenate(translation);
}
Upvotes: 2