Controlling scanning cube and coordinate space


#1

Hi,

I have an iOS app based on the Swift 4 sample application. I have implemented the changes in this thread to make a fixed size and placement scanning cube:

But is it also possible to change the perspective (orientation) of the scanning cube, so it does not follow the device, but it is always following gravity. I.e. cube aligned with horizon instead of device. This should also result in a scanned model that always has X and Y axis along the ground plane.

Any help appriciated, especially in Swift 4 compatible form :slight_smile:


#2

Anybody that can help with this? I find it very difficult to figure out the various poses and orientations.

I am just looking to make a simple fixed cube for both placement and scanning, and have the built-up model follow the physical model.

I suspect it is fairly easy, but with documentation or tutorials, it seems very difficult to get anywhere :slight_smile:


#3

Aligning to gravity is based upon the motion data output from the IMU. By default, the sample code will align to gravity unless you changed lastGravity.

Using the motion data you get lastGravity like this in swift 4:

lastGravity = GLKVector3Make(Float(motion.gravity.x), Float(motion.gravity.y), Float(motion.gravity.z))

To have the cube stay fixed to the position of the scanner change lastGravity like this:

// no gravity in cube
lastGravity = GLKVector3Make (-1.0, 0.0, 0.0)