diff options
author | Matt Strapp <matt@mattstrapp.net> | 2021-12-17 13:17:58 -0600 |
---|---|---|
committer | Matt Strapp <matt@mattstrapp.net> | 2021-12-17 13:17:58 -0600 |
commit | e0a8f6b97c473d28af96f28ca6b46d41b91646a3 (patch) | |
tree | 8faef1da18b809c9585c11ba5917f1f8268cddf6 /dev/a6-harold/sky.h | |
parent | Add README (diff) | |
parent | Clarify how to get eye point in Sky::ScreenPtHitsSky (diff) | |
download | csci4611-e0a8f6b97c473d28af96f28ca6b46d41b91646a3.tar csci4611-e0a8f6b97c473d28af96f28ca6b46d41b91646a3.tar.gz csci4611-e0a8f6b97c473d28af96f28ca6b46d41b91646a3.tar.bz2 csci4611-e0a8f6b97c473d28af96f28ca6b46d41b91646a3.tar.lz csci4611-e0a8f6b97c473d28af96f28ca6b46d41b91646a3.tar.xz csci4611-e0a8f6b97c473d28af96f28ca6b46d41b91646a3.tar.zst csci4611-e0a8f6b97c473d28af96f28ca6b46d41b91646a3.zip |
Merge branch 'support-code' of https://github.umn.edu/umn-csci-4611-f21/shared-upstream
Diffstat (limited to '')
-rw-r--r-- | dev/a6-harold/sky.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/dev/a6-harold/sky.h b/dev/a6-harold/sky.h new file mode 100644 index 0000000..06fcca1 --- /dev/null +++ b/dev/a6-harold/sky.h @@ -0,0 +1,52 @@ +/** CSci-4611 Assignment 6: Harold + */ + +#ifndef SKY_H_ +#define SKY_H_ + +#include <mingfx.h> +using namespace mingfx; + +/** Creates, holds, and draws all of the strokes on the sky. + */ +class Sky { +public: + Sky(); + virtual ~Sky(); + + void Init(ShaderProgram *stroke3d_shaderprog); + + /// Projects a 2D normalized screen point (e.g., the mouse position in normalized + /// device coordinates) to a 3D point on the "sky", which is really a huge sphere + /// (radius = 1500) that the viewer is inside. This function should always return + /// true since any screen point can successfully be projected onto the sphere. + /// sky_point is set to the resulting 3D point. Note, this function only checks + /// to see if the ray passing through the screen point intersects the sphere; it + /// does not check to see if the ray hits the ground or anything else first. + bool ScreenPtHitsSky(const Matrix4 &view_matrix, const Matrix4 &proj_matrix, + const Point2 &normalized_screen_pt, Point3 *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 AddSkyStroke(const Matrix4 &view_matrix, const Matrix4 &proj_matrix, + const Mesh &stroke2d_mesh, const Color &stroke_color); + + /// Draws all of the sky strokes + void Draw(const Matrix4 &view_matrix, const Matrix4 &proj_matrix); + +private: + + // Each stroke has a 3D mesh and a color + struct SkyStroke { + Mesh mesh; + Color color; + }; + + // To store a new stroke to draw, add it to this array + std::vector<SkyStroke> strokes_; + + + ShaderProgram *stroke3d_shaderprog_; +}; + +#endif |