
Untitled
By: a guest on
May 5th, 2012 | syntax:
None | size: 0.54 KB | hits: 17 | expires: Never
Converting touch screen coordinates to 3d Opengl world coordinates on iphone
touchLocation.y = [[self view] bounds].size.height - touchLocation.y;
CGFloat scale = [[UIScreen mainScreen] scale];
touchLocation.y *= scale;
touchLocation.y *= scale;
Vector3 near, far;
gluUnProject(touchLocation.x, touchLocation.y, 0, _modelview, _projection, _viewport, &near.x, &near.y, &near.z);
gluUnProject(touchLocation.x, touchLocation.y, 1, _modelview, _projection, _viewport, &far.x, &far.y, &far.z);
return MakeRay(near, Vector3Subtract(far, near));