I'm using wikitude and I need to get the screen coordinates of the recognized marker. I have converted the projectionViewMatrix to GLKMatrix4 and I've tried this code I've found on multiple sites:
let point = Point3D(x: m.m.12, y: m.m.13, z: m.m.14)//m is the matrix
let x = round(((CGFloat(point.x)+1)/2)*self.view.frame.width)
let y = round(((1-CGFloat(point.y))/2)*self.view.frame.height)
The thing is that if I center the marker than the view, I'm moving with those coordinates calculated, is centered too and when I move the marker the view moves in the right direction but it is moving "too fast" so it not stays on the marker but runs out of the screen in the direction I moved the marker.
Edit: This is the code I use to convert the pointer wikitude provides us to GLKMatrix4:
-(instancetype)initWithCArray:(const float *)pointer{
self = [super init];
if(self != nil){
glkMatrix = GLKMatrix4Identity;
memcpy(glkMatrix.m, pointer, 16*sizeof(float));
}
return self;
}