
Fri, 12/13/2024 - 09:43
I have an `AIS_Shape` representing a cube as theCubeShape ( refer `Cylinder_cube.gltf`).
I created a new point at position (7.0, 0.0, 0.0) and converted it into an `AIS_Shape` as thePointShape.
I then added `theCubeShape` as a child to `thePointShape` using the APIs AddChildWithCurrentTransformation and AddChild of `AIS_Shape`.
When exporting to a GLTF file, I expected the child's (`theCubeShape`) translation values to update relative to the parent's (`thePointShape`) position. Initially, the translation values were `"translation": [6, 0, 0]`, and I anticipated the new values to be `"translation": [-1, 0, 0]`. However, this update did not occur.
How can I properly add the child so that, upon exporting to GLTF, the child's translation values are correctly adjusted relative to the parent?
In other words,
I have an AIS object displayed in the viewer, and I want to create another object as its parent at a specific position relative to the existing AIS object.
I need to set the child's position relative to the new parent's position without altering the current position of the child object.
Additionally, I want to export this setup to a GLTF file, where I expect the child's translation values in the GLTF to reflect the new parent-child relationship. How can I achieve this?
Mon, 12/30/2024 - 20:44
You can try this, It may work.
const gp_Trsf& cTrans = child->LocalTransformation();
// After setting parent location
const gp_Trsf& pTrans = parent->Transformation().Inverted();
gp_Trsf newChildTrans = cTrans*pTrans; // Multiplication Order not sure;
child->SetLocalTranformation(newChildTrans);