summaryrefslogtreecommitdiffstats
path: root/dev/MinGfx/src/ray.h
diff options
context:
space:
mode:
authorKT <tran0563@umn.edu>2021-09-21 10:05:57 -0500
committerKT <tran0563@umn.edu>2021-09-21 10:05:57 -0500
commita75b08b76f91451bb586b154fdca872955d8a57a (patch)
treedd1c30f65162c1e12b8f6481bbd102d69f5c7196 /dev/MinGfx/src/ray.h
parentUpload a1 (diff)
downloadcsci4611-a75b08b76f91451bb586b154fdca872955d8a57a.tar
csci4611-a75b08b76f91451bb586b154fdca872955d8a57a.tar.gz
csci4611-a75b08b76f91451bb586b154fdca872955d8a57a.tar.bz2
csci4611-a75b08b76f91451bb586b154fdca872955d8a57a.tar.lz
csci4611-a75b08b76f91451bb586b154fdca872955d8a57a.tar.xz
csci4611-a75b08b76f91451bb586b154fdca872955d8a57a.tar.zst
csci4611-a75b08b76f91451bb586b154fdca872955d8a57a.zip
publish a2
Diffstat (limited to 'dev/MinGfx/src/ray.h')
-rw-r--r--dev/MinGfx/src/ray.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/dev/MinGfx/src/ray.h b/dev/MinGfx/src/ray.h
index 8e84546..d1b41b6 100644
--- a/dev/MinGfx/src/ray.h
+++ b/dev/MinGfx/src/ray.h
@@ -33,14 +33,13 @@ namespace mingfx {
Example:
~~~
// Create a pick ray from the mouse position
- void MyGraphicsApp::OnLeftMouseDown(const Point2 &pos) {
- Point2 mouse_xy = PixelsToNormalizedDeviceCoords(pos);
- float mouse_z = ReadZValueAtPixel(pos);
- Point3 mouse_3d = GfxMath::ScreenToNearPlane(view_matrix, proj_matrix, mouse_xy, mouse_z);
+ void MyGraphicsApp::OnLeftMouseDown(const Point2 &mouse_in_2d_pixels) {
+ Point2 mouse_in_2d_ndc = PixelsToNormalizedDeviceCoords(mouse_in_2d_pixels);
+ Point3 mouse_in_3d = GfxMath::ScreenToNearPlane(view_matrix, proj_matrix, mouse_in_2d_ndc);
Matrix4 camera_matrix = view_matrix.Inverse();
Point3 eye = camera_matrix.ColumnToPoint3(3);
- Ray pick_ray(eye, mouse_3d - eye);
+ Ray pick_ray(eye, mouse_in_3d - eye);
// check to see if the ray intersects a sphere
float t;