Advertisement
Guest User

Untitled

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