summaryrefslogtreecommitdiffstats
path: root/dev/a6-harold/sky.cc
diff options
context:
space:
mode:
authorKiet Tran <kietatr@gmail.com>2021-11-29 13:36:54 -0600
committerKiet Tran <kietatr@gmail.com>2021-11-29 13:36:54 -0600
commit3e757dbc71682972899a48651710c5d8280c3cee (patch)
treed0c5ebba6dbad61920e07b2eae5843c1a2a2766d /dev/a6-harold/sky.cc
parentUpdate artrender_app.cc (diff)
downloadcsci4611-3e757dbc71682972899a48651710c5d8280c3cee.tar
csci4611-3e757dbc71682972899a48651710c5d8280c3cee.tar.gz
csci4611-3e757dbc71682972899a48651710c5d8280c3cee.tar.bz2
csci4611-3e757dbc71682972899a48651710c5d8280c3cee.tar.lz
csci4611-3e757dbc71682972899a48651710c5d8280c3cee.tar.xz
csci4611-3e757dbc71682972899a48651710c5d8280c3cee.tar.zst
csci4611-3e757dbc71682972899a48651710c5d8280c3cee.zip
Publish A6
Diffstat (limited to '')
-rw-r--r--dev/a6-harold/sky.cc74
1 files changed, 74 insertions, 0 deletions
diff --git a/dev/a6-harold/sky.cc b/dev/a6-harold/sky.cc
new file mode 100644
index 0000000..0819ebe
--- /dev/null
+++ b/dev/a6-harold/sky.cc
@@ -0,0 +1,74 @@
+/** CSci-4611 Assignment 6: Harold
+ */
+
+#include "sky.h"
+
+
+Sky::Sky() {
+
+}
+
+
+Sky::~Sky() {
+
+}
+
+void Sky::Init(ShaderProgram *stroke3d_shaderprog) {
+ stroke3d_shaderprog_ = 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 Sky::ScreenPtHitsSky(const Matrix4 &view_matrix, const Matrix4 &proj_matrix,
+ const Point2 &normalized_screen_pt, Point3 *sky_point)
+{
+ // TODO: Stitch together your worksheet implementation of this method
+ return true;
+}
+
+
+
+
+/// 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,
+ const Mesh &stroke2d_mesh, const Color &stroke_color)
+{
+ // TODO: Create a new SkyStroke and add it to the strokes_ array.
+
+
+
+
+
+
+
+
+
+
+}
+
+
+/// Draws all of the sky strokes
+void Sky::Draw(const Matrix4 &view_matrix, const Matrix4 &proj_matrix) {
+
+ // Precompute matrices needed in the shader
+ Matrix4 model_matrix; // identity
+ Matrix4 modelview_matrix = view_matrix * model_matrix;
+
+ // Draw sky meshes
+ stroke3d_shaderprog_->UseProgram();
+ stroke3d_shaderprog_->SetUniform("modelViewMatrix", modelview_matrix);
+ stroke3d_shaderprog_->SetUniform("projectionMatrix", proj_matrix);
+ for (int i=0; i<strokes_.size(); i++) {
+ stroke3d_shaderprog_->SetUniform("strokeColor", strokes_[i].color);
+ strokes_[i].mesh.Draw();
+ }
+ stroke3d_shaderprog_->StopProgram();
+}
+