summaryrefslogtreecommitdiffstats
path: root/dev/a6-harold/ground.h
diff options
context:
space:
mode:
authorJessie Speert <speer034@umn.edu>2021-04-12 15:41:35 -0700
committerJessie Speert <speer034@umn.edu>2021-04-12 15:41:35 -0700
commitcce47f292f7327ab7f11eb277ab6f03dbf19b7f1 (patch)
tree8238f9564e0c3f89a7cb4dd3a13051f24fe6e3a9 /dev/a6-harold/ground.h
parentUploading Assignment 5 (and worksheet) (diff)
downloadcsci4611-cce47f292f7327ab7f11eb277ab6f03dbf19b7f1.tar
csci4611-cce47f292f7327ab7f11eb277ab6f03dbf19b7f1.tar.gz
csci4611-cce47f292f7327ab7f11eb277ab6f03dbf19b7f1.tar.bz2
csci4611-cce47f292f7327ab7f11eb277ab6f03dbf19b7f1.tar.lz
csci4611-cce47f292f7327ab7f11eb277ab6f03dbf19b7f1.tar.xz
csci4611-cce47f292f7327ab7f11eb277ab6f03dbf19b7f1.tar.zst
csci4611-cce47f292f7327ab7f11eb277ab6f03dbf19b7f1.zip
Added assignment 6 directory and worksheet
Diffstat (limited to '')
-rw-r--r--dev/a6-harold/ground.h63
1 files changed, 63 insertions, 0 deletions
diff --git a/dev/a6-harold/ground.h b/dev/a6-harold/ground.h
new file mode 100644
index 0000000..0cc18dd
--- /dev/null
+++ b/dev/a6-harold/ground.h
@@ -0,0 +1,63 @@
+/** CSci-4611 Assignment 6: Harold
+ */
+
+#ifndef GROUND_H_
+#define GROUND_H_
+
+#include <mingfx.h>
+using namespace mingfx;
+
+#include "edge_mesh.h"
+
+/** The ground is represented with a triangle mesh. 2D "screen space" strokes
+ are used to modify the vertices based on user input so that the user can create
+ a 3D landscape of hills and valleys.
+ */
+class Ground {
+public:
+ Ground();
+ virtual ~Ground();
+
+ /// Call from InitOpenGL() to initialize shaders, etc.
+ void Init(const std::vector<std::string> &search_path);
+
+ /// Projects a 2D normalized screen point (e.g., the mouse position in normalized
+ /// device coordinates) to a 3D point on the ground. Returns true and sets ground_point
+ /// to be equal to the result if the conversion is successful. Returns false if
+ /// the screen point does not project onto the ground.
+ bool ScreenPtHitsGround(const Matrix4 &view_matrix, const Matrix4 &proj_matrix,
+ const Point2 &normalized_screen_pt, Point3 *ground_point);
+
+ /// Modifies the vertices of the ground mesh to create a hill or valley based
+ /// on the input stroke. The 2D path of the stroke on the screen is passed
+ /// in, this is the centerline of the stroke mesh that is actually drawn on
+ /// the screen while the user is drawing.
+ void ReshapeGround(const Matrix4 &view_matrix, const Matrix4 &proj_matrix,
+ const std::vector<Point2> &stroke2d);
+
+ /// Draws the ground mesh with toon shading
+ void Draw(const Matrix4 &view_matrix, const Matrix4 &proj_matrix, const Color &ground_color);
+
+
+ Mesh* mesh_ptr();
+
+private:
+
+ // This is the actual triangle mesh for the ground
+ Mesh ground_mesh_;
+ // We also maintain a corresponding "edge mesh" in order to do the
+ // silhouette outlines like in assignment 5
+ EdgeMesh ground_edge_mesh_;
+
+ // The ground rendering is based on the artsy shader from assignment 5
+ ShaderProgram artsy_shaderprog_;
+ ShaderProgram outline_shaderprog_;
+ Texture2D diffuse_ramp_;
+ Texture2D specular_ramp_;
+ Point3 light_pos_;
+
+ // for debugging only
+ QuickShapes qs_;
+};
+
+#endif