diff options
author | Matt Strapp <matt@mattstrapp.net> | 2021-12-17 20:09:45 -0600 |
---|---|---|
committer | Matt Strapp <matt@mattstrapp.net> | 2021-12-17 20:09:45 -0600 |
commit | 3d48a55104ae3796331263af87113cf02dbf6986 (patch) | |
tree | 1df2d8499de3446de64a5a58c73a3eab68b3f6e7 /dev/a6-harold/sky.cc | |
parent | Merge branch 'support-code' of https://github.umn.edu/umn-csci-4611-f21/share... (diff) | |
download | csci4611-submission-p6.0.tar csci4611-submission-p6.0.tar.gz csci4611-submission-p6.0.tar.bz2 csci4611-submission-p6.0.tar.lz csci4611-submission-p6.0.tar.xz csci4611-submission-p6.0.tar.zst csci4611-submission-p6.0.zip |
Signed-off-by: Matt Strapp <matt@mattstrapp.net>
Diffstat (limited to 'dev/a6-harold/sky.cc')
-rw-r--r-- | dev/a6-harold/sky.cc | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/dev/a6-harold/sky.cc b/dev/a6-harold/sky.cc index bc08ca0..8b04a69 100644 --- a/dev/a6-harold/sky.cc +++ b/dev/a6-harold/sky.cc @@ -34,12 +34,12 @@ bool Sky::ScreenPtHitsSky(const Matrix4 &view_matrix, const Matrix4 &proj_matrix Point3 eye = camera_matrix.ColumnToPoint3(3); // TODO: Stitch together your worksheet implementation of this method - return true; + Point3 mouseIn3d = GfxMath::ScreenToNearPlane(view_matrix, proj_matrix, normalized_screen_pt); + Ray eyeThroughMouse = Ray(eye, (mouseIn3d - eye).ToUnit()); + float t; + return eyeThroughMouse.IntersectSphere(Point3::Origin(), 1500, &t, sky_point); } - - - /// Creates a new sky stroke mesh by projecting each vertex of the 2D mesh /// onto the sky dome and saving the result as a new 3D mesh. void Sky::AddSkyStroke(const Matrix4 &view_matrix, const Matrix4 &proj_matrix, @@ -47,15 +47,19 @@ void Sky::AddSkyStroke(const Matrix4 &view_matrix, const Matrix4 &proj_matrix, { // TODO: Create a new SkyStroke and add it to the strokes_ array. + Mesh sky = stroke2d_mesh; + std::vector<Point3> sky_points; + for (int i = 0; i < sky.num_vertices(); i++) { + Point3 sky_point; + ScreenPtHitsSky(view_matrix, proj_matrix, Point2(sky.read_vertex_data(i)[0], sky.read_vertex_data(i)[1]), &sky_point); + sky_points.push_back(sky_point); + } + sky.SetVertices(sky_points); - - - - - - - - + SkyStroke sky_stroke; + sky_stroke.mesh = sky; + sky_stroke.color = stroke_color; + strokes_.push_back(sky_stroke); } |