Advertisement
faenil

Untitled

Oct 18th, 2011
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. //Reverse Viewport transformation
  2. qreal conv_x = ( (mousex / (854.0/2.0)) -1);
  3. qreal conv_y = ( (mousey / (480.0/2.0)) -1);
  4.  
  5. //Get viewport points as begin and end of the ray
  6. QVector4D nearPlane(conv_x, conv_y, -1, 0.0);
  7. QVector4D farPlane(conv_x, conv_y, +1, 0.0);
  8.  
  9. //Multiply per the inverted ModelView matrix, to get world space coordinates of those points
  10. QVector4D nearPlane2 = cam_m.inverted() * nearPlane;
  11. QVector4D farPlane2 = cam_m.inverted() * farPlane;
  12.  
  13.  
  14. //direction, farPlane - nearPlane
  15. QVector4D direction = farPlane2 - nearPlane2;
  16.  
  17.  
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement