
Fri, 07/06/2018 - 11:22
Forums:
Hello. I'd like to translate a AIS_InteractiveObject on button press on a certain distance relative to it's position.
I have came with the following code:
std::vector<Handle(AIS_InteractiveObject)> privateSimpleRig;
void performTestTranslocationOfCylinder(double xc, double yc, double zc)
{
gp_Trsf secondTransformation;
secondTransformation.SetTranslation(gp_Vec(xc, yc, zc));
privateAISContext->SetLocation(privateSimpleRig[2], secondTransformation);
privateAISContext->Redisplay(privateSimpleRig[2],true);
}
And button handler code fragment is:
case 'W': {
performTestTranslocationOfCylinder(0.0, 10.0, 0.0);
break;
}
case 'S': {
performTestTranslocationOfCylinder(0.0, -10.0, 0.0);
break;
}
Location is changed, but figure moves only to 10 points from starting location on btn press. I'd like to make it "travel" over the scene, translate AIS_InteractiveObject with relation to its current location each time button is pressed by a given amount.
I may store a position of figure on scene in a separate variable, but I suppose that this position is stored in ais_shape instance. Probably I should use gp_Trsf in some other way?
Fri, 07/06/2018 - 14:00
I have this code:
But the first time the I call it with
it jumps for 30 units! Further it runs for 10 units. But when I change direction - it translates a figure on a wrong distance.
Mon, 07/09/2018 - 18:54
Removed the line
and it's moving like it should