Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CGPoint touchIn3D;
- touchIn3D.x = (touchingPoint.x / [UIScreen mainScreen].bounds.size.width) * 2.0f - 1.0f;
- touchIn3D.y = (touchingPoint.y / [UIScreen mainScreen].bounds.size.height) * -2.0f + 1.0f;
- NGLmat4 *toWorldNotInversed = [camera matrixViewProjection];
- NGLmat4 *toWorld = calloc(1,sizeof(NGLmat4));
- nglMatrixInverse(*toWorldNotInversed,*toWorld);
- NGLvec4 from, to;
- from.x = *toWorld[0] * touchIn3D.x + *toWorld[1] * touchIn3D.y - *toWorld[2] + *toWorld[3];
- from.y = *toWorld[4] * touchIn3D.x + *toWorld[5] * touchIn3D.y - *toWorld[6] + *toWorld[7];
- from.z = *toWorld[8] * touchIn3D.x + *toWorld[9] * touchIn3D.y - *toWorld[10] + *toWorld[11];
- from.w = *toWorld[12] * touchIn3D.x + *toWorld[13] * touchIn3D.y - *toWorld[14] + *toWorld[15];
- to.x = *toWorld[0] * touchIn3D.x + *toWorld[1] * touchIn3D.y + *toWorld[2] + *toWorld[3];
- to.y = *toWorld[4] * touchIn3D.x + *toWorld[5] * touchIn3D.y + *toWorld[6] + *toWorld[7];
- to.z = *toWorld[8] * touchIn3D.x + *toWorld[9] * touchIn3D.y + *toWorld[10] + *toWorld[11];
- to.w = *toWorld[12] * touchIn3D.x + *toWorld[13] * touchIn3D.y + *toWorld[14] + *toWorld[15];
- NSLog(@"from: %f %f %f %f", from.x, from.y, from.z, from.w);
- NSLog(@"to : %f %f %f %f", to.x, to.y, to.z, to.w);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement