Volume Box Offset Into Support Plane


I’m trying to offset my initial cube position into the detected surface by a fixed distance.

If the pose initializer has a support plane, I want to shift the volume box into the surface it has detected.

Currently, during cube positioning, I am taking the cameraPose from STPoseInitializer and adjusting the x coordinate using GLKMatrix4Translate.

However, if I rotate my device 90 degrees and use the same code, instead of the cube moving into the surface, it moves to the side.

How can I translate the cameraPose along the normal of the surface is has detected so it is independent of my device position?


Oops, I think I answered my own question: the translation has to take place in the inverted space.

BOOL invertible;
GLKMatrix4 inv = GLKMatrix4Invert(cameraPose, &invertible);
inv = GLKMatrix4Translate(inv, 0, (* offset *), 0);
cameraPose = GLKMatrix4Invert(inv, &invertible);

This thread was helpful: SDK 0.6 Fix the Cube at a certain distance from the user